diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/JointSampledComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/JointSampledComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..934c282434033a8da755aeca4a947e4265db736d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/JointSampledComparison.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SampledPrimeCoincidence + +namespace OAI + +/-! # Joint signed replacement with actual internal-prime coordinates + +Different tests can use different sampled primes and can depend on the other +prime coordinates. Each test only excludes its own prime coordinate. +-/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem joint_sampled_polynomial_comparison_le {A I : Type*} + [Fintype A] [Nonempty A] [Fintype I] {n : ℕ} + (value : A → ℤ) (hinj : Function.Injective value) + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (F : I → MvPolynomial (Fin (n + 1)) ℤ) (coordinate : I → Fin (n + 1)) + (habsent : ∀ i, coordinate i ∉ (F i).vars) + (μ : Fin (n + 1) → A → ℝ) (hμ : ∀ j a, 0 ≤ μ j a) + (hmass : ∀ j, ∑ a, μ j a = 1) + (α β V H : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) (hH : 1 ≤ H) + (hmax : ∀ j a, μ j a ≤ α) (hpmax : ∀ i a, μ (coordinate i) a ≤ β) + (hsize : ∀ i a, μ (coordinate i) a ≠ 0 → V ≤ Real.log (prime a : ℝ)) + (hvalue : ∀ i x, |(integerTestValue value (F i) x : ℝ)| ≤ H) + (Ψ : (Fin (n + 1) → A) → (I → Bool) → ℂ) + (B : ℝ) (hB : 0 ≤ B) (hΨ : ∀ x flags, ‖Ψ x flags‖ ≤ B) : + ‖∑ x, (productPrior μ x : ℂ) * + (Ψ x (fun i => arithmeticTestFlag + (prime (x (coordinate i)) ∣ (integerTestValue value (F i) x).natAbs)) - + Ψ x (fun i => arithmeticTestFlag (F i = 0)))‖ ≤ + 2 * B * ∑ i, (((F i).totalDegree : ℝ) * α + (Real.log H / V) * β) := by + let bad := fun i x => F i ≠ 0 ∧ prime (x (coordinate i)) ∣ (integerTestValue value (F i) x).natAbs + have hprob (i : I) : (∑ x, productPrior μ x * if bad i x then (1 : ℝ) else 0) ≤ + ((F i).totalDegree : ℝ) * α + (Real.log H / V) * β := by + by_cases hi : F i = 0 + · simp only [bad, hi, ne_eq, not_true_eq_false, false_and, ite_false, mul_zero, + Finset.sum_const_zero] + exact add_nonneg (mul_nonneg (Nat.cast_nonneg _) hα) + (mul_nonneg (div_nonneg (Real.log_nonneg hH) hV.le) hβ) + · simp only [bad, hi, ne_eq, not_false_eq_true, true_and] + exact sampled_coordinate_prime_coincidence_le value hinj prime hpInj hprime (F i) hi + (coordinate i) (habsent i) μ hμ hmass α β V H hα hβ hV hH hmax (hpmax i) (hsize i) (hvalue i) + have heq (x : Fin (n + 1) → A) (hx : ∀ i, ¬bad i x) : + (fun i => arithmeticTestFlag + (prime (x (coordinate i)) ∣ (integerTestValue value (F i) x).natAbs)) = + (fun i => arithmeticTestFlag (F i = 0)) := by + funext i + by_cases hi : F i = 0 + · simp [hi, integerTestValue] + · have hnd : ¬prime (x (coordinate i)) ∣ (integerTestValue value (F i) x).natAbs := + fun h => hx i ⟨hi, h⟩ + simp [hi, hnd] + have h := @weighted_flag_comparison_le (Fin (n + 1) → A) I inferInstance inferInstance + (productPrior μ) (productPrior_nonneg μ hμ) + (fun x i => arithmeticTestFlag + (prime (x (coordinate i)) ∣ (integerTestValue value (F i) x).natAbs)) + (fun _ i => arithmeticTestFlag (F i = 0)) bad (fun _ _ => inferInstance) + heq Ψ B hB hΨ + exact h.trans (mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun i _ => hprob i) (by positivity)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/JointSplitProbability.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/JointSplitProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..acb0265e2a7728aa9a1138fbd2394d8d101efd08 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/JointSplitProbability.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SplitSquareSupport + +namespace OAI + +/-! # The joint support bound for two genuine arithmetic history splits -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem reduced_modulus_pos {s v : ℕ} (hs : s ≠ 0) : 0 < s / v.gcd s := + Nat.div_pos (Nat.le_of_dvd (Nat.pos_of_ne_zero hs) (Nat.gcd_dvd_right v s)) + (Nat.gcd_pos_of_pos_right v (Nat.pos_of_ne_zero hs)) + +/-- The two histories share the random child product but may have different +parent products, pivots, and frequencies. No complete-history validity event +has been conditioned on in this average. -/ +theorem joint_split_probability_le {s t Q : ℕ} [NeZero s] [NeZero t] [NeZero Q] + (hs : s ∣ Q) (ht : t ∣ Q) (v w v' w' : ℕ) + (hgcd : v.gcd s = w.gcd s) (hgcd' : v'.gcd t = w'.gcd t) + (A B P : (ZMod s)ˣ) (A' B' P' : (ZMod t)ˣ) : + (Fintype.card (ZMod Q)ˣ : ℝ)⁻¹ * (∑ x : (ZMod Q)ˣ, + if (v : ZMod s) * (A * (P / ZMod.unitsMap hs x) : (ZMod s)ˣ) = + (w : ZMod s) * (B * ZMod.unitsMap hs x : (ZMod s)ˣ) ∧ + (v' : ZMod t) * (A' * (P' / ZMod.unitsMap ht x) : (ZMod t)ˣ) = + (w' : ZMod t) * (B' * ZMod.unitsMap ht x : (ZMod t)ˣ) + then (1 : ℝ) else 0) ≤ + 2 * (((s / v.gcd s).lcm (t / v'.gcd t)).divisors.card : ℝ) ^ 2 / + (s / v.gcd s).lcm (t / v'.gcd t) := by + let a := s / v.gcd s + let b := t / v'.gcd t + let _ : NeZero a := ⟨Nat.ne_of_gt (reduced_modulus_pos (v := v) (NeZero.ne s))⟩ + let _ : NeZero b := ⟨Nat.ne_of_gt (reduced_modulus_pos (v := v') (NeZero.ne t))⟩ + have ha : a ∣ s := Nat.div_dvd_of_dvd (Nat.gcd_dvd_right v s) + have hb : b ∣ t := Nat.div_dvd_of_dvd (Nat.gcd_dvd_right v' t) + have hleft (x : (ZMod Q)ˣ) : + ZMod.unitsMap ha (ZMod.unitsMap hs x) = ZMod.unitsMap (ha.trans hs) x := + DFunLike.congr_fun (ZMod.unitsMap_comp ha hs) x + have hright (x : (ZMod Q)ˣ) : + ZMod.unitsMap hb (ZMod.unitsMap ht x) = ZMod.unitsMap (hb.trans ht) x := + DFunLike.congr_fun (ZMod.unitsMap_comp hb ht) x + simp_rw [unit_split_iff_square v w hgcd, unit_split_iff_square v' w' hgcd', + hleft, hright] + exact reduced_simultaneous_square_probability_le (ha.trans hs) (hb.trans ht) + (splitSquareTarget v w hgcd A B P) (splitSquareTarget v' w' hgcd' A' B' P') + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/JointSquareLiftExclusions.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/JointSquareLiftExclusions.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9ef11ebeb48a06e1ac48ac2bbc12ab6ceab42e3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/JointSquareLiftExclusions.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Tree.UniformCoordinateAverage +import OAI.NumberTheory.Ostmann.Arithmetic.SquareLiftExclusions +import OAI.NumberTheory.Ostmann.Arithmetic.WeightedFlagComparison + +namespace OAI + +/-! # Dropping all prime-square exclusions in the uniform CRT fibers -/ + +namespace Ostmann +open scoped BigOperators Classical + +theorem squareLiftPairs_card (p : ℕ) [Fact p.Prime] (x₀ y₀ : ZMod p) : + Fintype.card (SquareLiftPairs p x₀ y₀) = p ^ 2 := by + rw [Fintype.card_prod, card_squareReduction_fiber, card_squareReduction_fiber, pow_two] + +theorem squareLiftPairs_nonempty (p : ℕ) [Fact p.Prime] (x₀ y₀ : ZMod p) : + Nonempty (SquareLiftPairs p x₀ y₀) := by + exact ⟨⟨⟨(x₀.val : ZMod (p ^ 2)), by simp only [squareReduction_natCast, ZMod.natCast_zmod_val]⟩, ⟨(y₀.val : ZMod (p ^ 2)), by simp only [squareReduction_natCast, ZMod.natCast_zmod_val]⟩⟩⟩ + +/-- A simultaneous lift comparison for a signed integrand. The remaining +arithmetic conditions can be included in `F`; they are never conditioned away. -/ +theorem joint_square_lift_removed_mass_le {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (J : I → Type*) [∀ i, Fintype (J i)] + (a b : ∀ i, J i → ZMod (p i ^ 2)) (x₀ y₀ : ∀ i, ZMod (p i)) + (hy : ∀ i, y₀ i ≠ 0) + (hrow : ∀ i j, squareReduction (p i) (a i j) ≠ 0 ∨ squareReduction (p i) (b i j) ≠ 0) + (hbase : ∀ i j, squareReduction (p i) (a i j) * x₀ i + + squareReduction (p i) (b i j) * y₀ i = 0) + (F : (∀ i, SquareLiftPairs (p i) (x₀ i) (y₀ i)) → ℂ) + (B : ℝ) (hB : 0 ≤ B) (hF : ∀ x, ‖F x‖ ≤ B) : + (Fintype.card (∀ i, SquareLiftPairs (p i) (x₀ i) (y₀ i)) : ℝ)⁻¹ * + ‖(∑ x, if ∀ i j, a i j * (x i).1.1 + b i j * (x i).2.1 ≠ 0 then F x else 0) - + ∑ x, F x‖ ≤ 2 * B * ∑ i, (Fintype.card (J i) : ℝ) / p i := by + let X := fun i => SquareLiftPairs (p i) (x₀ i) (y₀ i) + let : ∀ i, Nonempty (X i) := fun i => squareLiftPairs_nonempty _ _ _ + let bad := fun i (x : X i) => ∃ j, a i j * x.1.1 + b i j * x.2.1 = 0 + let w : ℝ := (Fintype.card (∀ i, X i) : ℝ)⁻¹ + have hw : 0 ≤ w := inv_nonneg.mpr (Nat.cast_nonneg _) + have hlocal (i : I) : (Fintype.card (X i) : ℝ)⁻¹ * + (∑ x : X i, if bad i x then (1 : ℝ) else 0) ≤ + (Fintype.card (J i) : ℝ) / p i := by + have h := square_lift_nonzero_rows_removed_mass_le (a i) (b i) (x₀ i) (y₀ i) + (hy i) (hrow i) (hbase i) (fun _ => (1 : ℂ)) 1 (by norm_num) (by simp) + rw [squareLiftPairs_card] + simpa only [bad, X, ← Finset.sum_filter, Finset.sum_const, Finset.card_univ, + nsmul_eq_mul, mul_one, Nat.cast_pow, norm_natCast, one_mul, div_eq_mul_inv, mul_comm] using h + have hprob (i : I) : ∑ x : ∀ i, X i, w * (if bad i (x i) then (1 : ℝ) else 0) ≤ + (Fintype.card (J i) : ℝ) / p i := by + rw [← Finset.mul_sum] + exact (uniform_pi_coordinate_average X i (fun x => if bad i x then 1 else 0)).trans_le (hlocal i) + let Ψ := fun (x : ∀ i, X i) (flags : I → Bool) => if ∀ i, flags i = true then F x else 0 + have h := weighted_flag_comparison_le (fun _ : ∀ i, X i => w) (fun _ => hw) + (fun x i => decide (¬bad i (x i))) (fun _ _ => true) + (fun i x => bad i (x i)) + (by intro x hx; funext i; simp [hx i]) Ψ B hB (by + intro x flags + dsimp only [Ψ] + split_ifs + · exact hF x + · simpa using hB) + have he (x : ∀ i, X i) : Ψ x (fun i => decide (¬bad i (x i))) = + if ∀ i j, a i j * (x i).1.1 + b i j * (x i).2.1 ≠ 0 then F x else 0 := by + simp only [Ψ, decide_eq_true_eq, bad, not_exists] + simp only [he, Ψ, implies_true, ite_true] at h + have hn : ‖∑ x : ∀ i, X i, (w : ℂ) * + ((if ∀ i j, a i j * (x i).1.1 + b i j * (x i).2.1 ≠ 0 then F x else 0) - F x)‖ = + w * ‖(∑ x, if ∀ i j, a i j * (x i).1.1 + b i j * (x i).2.1 ≠ 0 then F x else 0) - + ∑ x, F x‖ := by + rw [← Finset.mul_sum, Finset.sum_sub_distrib, norm_mul, Complex.norm_real, + Real.norm_of_nonneg hw] + rw [hn] at h + exact h.trans (mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun i _ => hprob i) (by positivity)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LcmFrequencySum.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LcmFrequencySum.lean new file mode 100644 index 0000000000000000000000000000000000000000..37bff52ece2127bf1968a292531caed1b35ee082 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LcmFrequencySum.lean @@ -0,0 +1,117 @@ +import Mathlib.NumberTheory.Harmonic.Bounds +import Mathlib.Data.Nat.GCD.Basic +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Positivity + +namespace OAI + +/-! # The reciprocal-lcm sum in the frequency budget + +The gcd coordinates embed each frequency pair into three independent +positive harmonic sums. No asymptotic divisor estimate is used here. +-/ + +namespace Ostmann + +open scoped BigOperators + +def gcdFrequencyCoordinates (x : ℕ × ℕ) : ℕ × ℕ × ℕ := + (x.1.gcd x.2, x.1 / x.1.gcd x.2, x.2 / x.1.gcd x.2) + +theorem gcdFrequencyCoordinates_recover (x : ℕ × ℕ) : + (gcdFrequencyCoordinates x).1 * (gcdFrequencyCoordinates x).2.1 = x.1 ∧ + (gcdFrequencyCoordinates x).1 * (gcdFrequencyCoordinates x).2.2 = x.2 := by + exact ⟨Nat.mul_div_cancel' (Nat.gcd_dvd_left _ _), + Nat.mul_div_cancel' (Nat.gcd_dvd_right _ _)⟩ + +theorem gcdFrequencyCoordinates_injective : Function.Injective gcdFrequencyCoordinates := by + intro x y h + obtain ⟨hx₁, hx₂⟩ := gcdFrequencyCoordinates_recover x + obtain ⟨hy₁, hy₂⟩ := gcdFrequencyCoordinates_recover y + apply Prod.ext + · exact hx₁.symm.trans ((congrArg (fun z : ℕ × ℕ × ℕ => z.1 * z.2.1) h).trans hy₁) + · exact hx₂.symm.trans ((congrArg (fun z : ℕ × ℕ × ℕ => z.1 * z.2.2) h).trans hy₂) + +theorem gcdFrequencyCoordinates_lcm (a b : ℕ) (ha : 0 < a) : + (gcdFrequencyCoordinates (a, b)).1 * (gcdFrequencyCoordinates (a, b)).2.1 * + (gcdFrequencyCoordinates (a, b)).2.2 = a.lcm b := by + have hg := Nat.gcd_pos_of_pos_left b ha + obtain ⟨ha', hb'⟩ := gcdFrequencyCoordinates_recover (a, b) + apply Nat.eq_of_mul_eq_mul_left hg + calc + _ = ((gcdFrequencyCoordinates (a, b)).1 * (gcdFrequencyCoordinates (a, b)).2.1) * + ((gcdFrequencyCoordinates (a, b)).1 * (gcdFrequencyCoordinates (a, b)).2.2) := by + dsimp [gcdFrequencyCoordinates] + ring + _ = a * b := by rw [ha', hb'] + _ = _ := (Nat.gcd_mul_lcm a b).symm + +theorem gcdFrequencyCoordinates_mem {N a b : ℕ} + (ha : a ∈ Finset.Icc 1 N) (hb : b ∈ Finset.Icc 1 N) : + gcdFrequencyCoordinates (a, b) ∈ + (Finset.Icc 1 N).product ((Finset.Icc 1 N).product (Finset.Icc 1 N)) := by + obtain ⟨ha₀, haN⟩ := Finset.mem_Icc.mp ha + obtain ⟨hb₀, hbN⟩ := Finset.mem_Icc.mp hb + have hap : 0 < a := ha₀ + have hbp : 0 < b := hb₀ + have hg := Nat.gcd_pos_of_pos_left b hap + have hga := Nat.le_of_dvd hap (Nat.gcd_dvd_left a b) + have hgb := Nat.le_of_dvd hbp (Nat.gcd_dvd_right a b) + apply Finset.mem_product.mpr + refine ⟨Finset.mem_Icc.mpr ⟨hg, hga.trans haN⟩, Finset.mem_product.mpr ⟨?_, ?_⟩⟩ + · exact Finset.mem_Icc.mpr ⟨Nat.div_pos hga hg, (Nat.div_le_self _ _).trans haN⟩ + · exact Finset.mem_Icc.mpr ⟨Nat.div_pos hgb hg, (Nat.div_le_self _ _).trans hbN⟩ + +/-- Exact finite bound before estimating the harmonic sum. -/ +theorem reciprocal_lcm_sum_le_harmonic_cube (N : ℕ) : + (∑ a ∈ Finset.Icc 1 N, ∑ b ∈ Finset.Icc 1 N, ((a.lcm b : ℕ) : ℝ)⁻¹) ≤ + (∑ n ∈ Finset.Icc 1 N, (n : ℝ)⁻¹) ^ 3 := by + let S := Finset.Icc 1 N + let w : ℕ × ℕ × ℕ → ℝ := fun z => (z.1 : ℝ)⁻¹ * (z.2.1 : ℝ)⁻¹ * (z.2.2 : ℝ)⁻¹ + have hw (x : ℕ × ℕ) (hx : x ∈ S.product S) : + ((x.1.lcm x.2 : ℕ) : ℝ)⁻¹ = w (gcdFrequencyCoordinates x) := by + have ha : 0 < x.1 := (Finset.mem_Icc.mp (Finset.mem_product.mp hx).1).1 + rw [← gcdFrequencyCoordinates_lcm x.1 x.2 ha] + simp only [w, Nat.cast_mul, mul_inv_rev] + ring + have hsub : (S.product S).image gcdFrequencyCoordinates ⊆ S.product (S.product S) := by + intro z hz + obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hz + exact gcdFrequencyCoordinates_mem (Finset.mem_product.mp hx).1 (Finset.mem_product.mp hx).2 + calc + _ = ∑ x ∈ S.product S, w (gcdFrequencyCoordinates x) := by + simp only [Finset.product_eq_sprod] + rw [Finset.sum_product S S (fun x => w (gcdFrequencyCoordinates x))] + apply Finset.sum_congr rfl + intro a ha + apply Finset.sum_congr rfl + intro b hb + exact hw (a, b) (Finset.mem_product.mpr ⟨ha, hb⟩) + _ = ∑ z ∈ (S.product S).image gcdFrequencyCoordinates, w z := by + exact (Finset.sum_image (fun _ _ _ _ h => gcdFrequencyCoordinates_injective h)).symm + _ ≤ ∑ z ∈ S.product (S.product S), w z := + Finset.sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => by dsimp [w]; positivity) + _ = ∑ a ∈ S, ∑ b ∈ S, ∑ c ∈ S, (a : ℝ)⁻¹ * (b : ℝ)⁻¹ * (c : ℝ)⁻¹ := by + simp only [Finset.product_eq_sprod] + rw [Finset.sum_product S (S ×ˢ S) w] + apply Finset.sum_congr rfl + intro a _ + exact Finset.sum_product S S (fun z => w (a, z)) + _ = _ := by + simp only [← Finset.mul_sum, ← Finset.sum_mul] + dsimp [S] + ring + +/-- The quantitative frequency-pair estimate used by the norm comparison. -/ +theorem reciprocal_lcm_sum_le_log_cube (N : ℕ) : + (∑ a ∈ Finset.Icc 1 N, ∑ b ∈ Finset.Icc 1 N, ((a.lcm b : ℕ) : ℝ)⁻¹) ≤ + (1 + Real.log N) ^ 3 := by + have hH : (∑ n ∈ Finset.Icc 1 N, (n : ℝ)⁻¹) ≤ 1 + Real.log N := by + simpa only [harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_natCast] + using harmonic_le_one_add_log N + exact (reciprocal_lcm_sum_le_harmonic_cube N).trans + (pow_le_pow_left₀ (Finset.sum_nonneg fun _ _ => by positivity) hH 3) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LeafFrequencyBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LeafFrequencyBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..ccda644485defb4335be23f5a07dd9b0be72d02c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LeafFrequencyBudget.lean @@ -0,0 +1,62 @@ +import Mathlib.Analysis.SpecialFunctions.Log.Basic +import Mathlib.Analysis.Real.Sqrt +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.Ring +import Mathlib.Tactic.Positivity + +namespace OAI + +/-! # The remaining leaf-frequency budget in the norm comparison -/ + +namespace Ostmann + +theorem sqrt_cost_sublinear (A B ε : ℝ) (_hA : 0 ≤ A) (hε : 0 < ε) : + ∃ M : ℝ, ∀ m : ℝ, M ≤ m → A * Real.sqrt m + B ≤ ε * m := by + refine ⟨max ((2 * A / ε) ^ 2) (2 * max B 0 / ε), fun m hm => ?_⟩ + have hmA : (2 * A / ε) ^ 2 ≤ m := (le_max_left _ _).trans hm + have hmB : 2 * max B 0 / ε ≤ m := (le_max_right _ _).trans hm + have hm0 : 0 ≤ m := (sq_nonneg _).trans hmA + have hr := Real.le_sqrt_of_sq_le hmA + have hA' : A ≤ ε / 2 * Real.sqrt m := by + have h := (div_le_iff₀ hε).mp hr + nlinarith + have hprod := mul_le_mul_of_nonneg_right hA' (Real.sqrt_nonneg m) + have hsq := Real.sq_sqrt hm0 + have hB' : B ≤ ε / 2 * m := by + have h := (div_le_iff₀ hε).mp hmB + have hmax := le_max_left B 0 + nlinarith + nlinarith + +theorem leaf_frequency_budget (r V : ℕ) (Δ m K : ℝ) + (hV : (V : ℝ) ≤ Real.exp (Δ + Real.sqrt m)) : + (2 * (V : ℝ)) ^ (2 * r) * Real.exp (-(r : ℝ) * Δ + K) ≤ + Real.exp ((r : ℝ) * Δ + 2 * r * Real.sqrt m + 2 * r * Real.log 2 + K) := by + calc + _ ≤ (2 * Real.exp (Δ + Real.sqrt m)) ^ (2 * r) * Real.exp (-(r : ℝ) * Δ + K) := + mul_le_mul_of_nonneg_right + (pow_le_pow_left₀ (by positivity) (by linarith) _) (Real.exp_pos _).le + _ = _ := by + nth_rw 1 [show (2 : ℝ) = Real.exp (Real.log 2) by rw [Real.exp_log (by norm_num)]] + rw [← Real.exp_add, ← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + simp only [Nat.cast_mul, Nat.cast_ofNat] + ring + +/-- After the smooth factor `exp(-r*Delta)`, summing the two histories' +leaf frequencies costs `exp(r*Delta + o(m))`. -/ +theorem leaf_frequency_budget_sublinear (r : ℕ) (K ε : ℝ) (hε : 0 < ε) : + ∃ M : ℝ, ∀ m : ℝ, M ≤ m → ∀ Δ : ℝ, ∀ V : ℕ, + (V : ℝ) ≤ Real.exp (Δ + Real.sqrt m) → + (2 * (V : ℝ)) ^ (2 * r) * Real.exp (-(r : ℝ) * Δ + K) ≤ + Real.exp ((r : ℝ) * Δ + ε * m) := by + obtain ⟨M, hM⟩ := sqrt_cost_sublinear (2 * r) (2 * r * Real.log 2 + K) ε + (by positivity) hε + refine ⟨M, fun m hm Δ V hV => (leaf_frequency_budget r V Δ m K hV).trans ?_⟩ + apply Real.exp_le_exp.mpr + have h := hM m hm + linarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LeafFrequencySupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LeafFrequencySupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..6def86c0696b06316899fa6074e76c37b96b1940 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LeafFrequencySupport.lean @@ -0,0 +1,50 @@ +import Mathlib.Analysis.SpecialFunctions.ExpDeriv +import OAI.NumberTheory.Ostmann.Construction.HistorySmoothFactor + +namespace OAI + +/-! # Frequency support forced by the actual leaf Fourier factor -/ + +namespace Ostmann + +open Filter + +theorem archimedeanLeaf_frequency_le (X M s cutoff Δ C K : ℝ) (ψhat : ℝ → ℂ) + (hX : 0 < X) (hM : 0 < M) (hupper : M ≤ X * Real.exp (Δ + C)) + (hsupport : ∀ t, ψhat t ≠ 0 → |t| ≤ Real.exp K) + (hne : archimedeanLeafFactor X M s cutoff ψhat ≠ 0) : + |s| ≤ Real.exp (Δ + C + K) := by + have hψ : ψhat (-s * X / M) ≠ 0 := by + intro hz + apply hne + simp only [archimedeanLeafFactor, hz, mul_zero] + have harg := hsupport _ hψ + rw [abs_div, abs_mul, abs_neg, abs_of_pos hX, abs_of_pos hM] at harg + have harg' := (div_le_iff₀ hM).mp harg + apply (mul_le_mul_iff_left₀ hX).mp + calc + |s| * X ≤ Real.exp K * M := harg' + _ ≤ Real.exp K * (X * Real.exp (Δ + C)) := + mul_le_mul_of_nonneg_left hupper (Real.exp_pos _).le + _ = Real.exp (Δ + C + K) * X := by + simp only [Real.exp_add] + ring + +/-- The square-root margin in E_0 eventually covers the fixed Fourier +support radius and all bounded errors in the leaf modulus. -/ +theorem archimedeanLeaf_frequency_window (C K : ℝ) : + ∀ᶠ m : ℝ in atTop, ∀ X M s cutoff Δ : ℝ, ∀ ψhat : ℝ → ℂ, + 0 < X → 0 < M → M ≤ X * Real.exp (Δ + C) → + (∀ t, ψhat t ≠ 0 → |t| ≤ Real.exp K) → + archimedeanLeafFactor X M s cutoff ψhat ≠ 0 → + |s| ≤ Real.exp (Δ + Real.sqrt m) := by + filter_upwards [eventually_ge_atTop ((C + K) ^ 2)] with m hm + intro X M s cutoff Δ ψhat hX hM hupper hsupport hne + have hsqrt : C + K ≤ Real.sqrt m := Real.le_sqrt_of_sq_le hm + apply (archimedeanLeaf_frequency_le X M s cutoff Δ C K ψhat hX hM hupper hsupport hne).trans + apply Real.exp_le_exp.mpr + linarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LeafModulusRanges.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LeafModulusRanges.lean new file mode 100644 index 0000000000000000000000000000000000000000..b04028c0ba7dddf35df3a230754815fcf1b93105 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LeafModulusRanges.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.Ostmann.Construction.HistorySmoothBound + +namespace OAI + +/-! # The leaf modulus from the giant, protected and compensation ranges -/ + +namespace Ostmann + +/-- `P`, `U`, and `D` are the products of protected, compensation, and +outside spectator slots. The center identity is equation (45). -/ +theorem leaf_modulus_lower_from_ranges + (X x₁ x₂ P U D G tD J W Δ cG cP cU cD : ℝ) + (hX : 0 < X) (hx₁ : 0 < x₁) (hx₂ : 0 < x₂) + (hP : 0 < P) (hU : 0 < U) (hD : 0 < D) + (hcenter : 2 * G + 2 * tD + J + W = Real.log X + Δ) + (hg₁ : G - cG ≤ Real.log x₁) (hg₂ : G - cG ≤ Real.log x₂) + (hp : J - cP ≤ Real.log P) (hu : W - cU ≤ Real.log U) + (hd : 2 * tD - cD ≤ Real.log D) : + X * Real.exp (Δ - (2 * cG + cP + cU + cD)) ≤ x₁ * x₂ * P * U * D := by + have hM : 0 < x₁ * x₂ * P * U * D := by positivity + have hlog : Real.log (x₁ * x₂ * P * U * D) = + Real.log x₁ + Real.log x₂ + Real.log P + Real.log U + Real.log D := by + rw [Real.log_mul (by positivity) (ne_of_gt hD), + Real.log_mul (by positivity) (ne_of_gt hU), + Real.log_mul (by positivity) (ne_of_gt hP), + Real.log_mul (ne_of_gt hx₁) (ne_of_gt hx₂)] + have hlow : Real.log X + (Δ - (2 * cG + cP + cU + cD)) ≤ + Real.log (x₁ * x₂ * P * U * D) := by rw [hlog]; linarith + calc + _ = Real.exp (Real.log X + (Δ - (2 * cG + cP + cU + cD))) := by + rw [Real.exp_add, Real.exp_log hX] + _ ≤ Real.exp (Real.log (x₁ * x₂ * P * U * D)) := Real.exp_le_exp.mpr hlow + _ = _ := Real.exp_log hM + +/-- The corresponding size of the square-root prefactor in a leaf of +equation (50); the error in the exponent is independent of frequency. -/ +theorem leaf_sqrt_ratio_from_ranges + (X x₁ x₂ P U D G tD J W Δ cG cP cU cD : ℝ) + (hX : 0 < X) (hx₁ : 0 < x₁) (hx₂ : 0 < x₂) + (hP : 0 < P) (hU : 0 < U) (hD : 0 < D) + (hcenter : 2 * G + 2 * tD + J + W = Real.log X + Δ) + (hg₁ : G - cG ≤ Real.log x₁) (hg₂ : G - cG ≤ Real.log x₂) + (hp : J - cP ≤ Real.log P) (hu : W - cU ≤ Real.log U) + (hd : 2 * tD - cD ≤ Real.log D) : + Real.sqrt (X / (x₁ * x₂ * P * U * D)) ≤ + Real.exp (((2 * cG + cP + cU + cD) - Δ) / 2) := + sqrt_ratio_le_exp X _ Δ _ (by positivity) + (leaf_modulus_lower_from_ranges X x₁ x₂ P U D G tD J W Δ cG cP cU cD + hX hx₁ hx₂ hP hU hD hcenter hg₁ hg₂ hp hu hd) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LinearReversal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LinearReversal.lean new file mode 100644 index 0000000000000000000000000000000000000000..982a12cf05201d23cb343c19ff7e6f166b43a98b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LinearReversal.lean @@ -0,0 +1,72 @@ +import Mathlib + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.LinearReversal + +variable {K : Type*} [Field K] + +def leftStep (a b : K) (hb : b ≠ 0) : (K × K) ≃ₗ[K] (K × K) where + toFun z := (a*z.1+b*z.2,z.1) + invFun z := (z.2,(z.1-a*z.2)/b) + left_inv z := by + apply Prod.ext + · rfl + · dsimp + field_simp + ring + right_inv z := by + apply Prod.ext + · dsimp + field_simp + ring + · rfl + map_add' z w := by ext <;> dsimp; ring + map_smul' c z := by ext <;> dsimp; ring + +def rightStep (a b : K) (ha : a ≠ 0) : (K × K) ≃ₗ[K] (K × K) where + toFun z := (a*z.1+b*z.2,z.2) + invFun z := ((z.1-b*z.2)/a,z.2) + left_inv z := by + apply Prod.ext + · dsimp + field_simp + ring + · rfl + right_inv z := by + apply Prod.ext + · dsimp + field_simp + ring + · rfl + map_add' z w := by ext <;> dsimp; ring + map_smul' c z := by ext <;> dsimp; ring + +theorem pivot_linear {v w Cp Cm s u p Xp Xm : K} + (hs : s ≠ 0) (hu : u ≠ 0) + (h : v*(Xm*Cm)-w*(Xp*Cp)=s*u*p) : + p = (-w*Cp/(s*u))*Xp+(v*Cm/(s*u))*Xm := by + field_simp + linear_combination -h + +theorem nonzero_form_comp (e : (K × K) ≃ₗ[K] (K × K)) (a b : K) + (h : a ≠ 0 ∨ b ≠ 0) : + ¬ ∀ z : K × K, a*(e z).1+b*(e z).2=0 := by + intro hz + have h₁ := hz (e.symm (1,0)) + have h₂ := hz (e.symm (0,1)) + simp only [e.apply_symm_apply,mul_one,mul_zero,add_zero,zero_add] at h₁ h₂ + exact h.elim (fun ha => ha h₁) (fun hb => hb h₂) + +theorem left_row_coefficients (a b c d x y : K) : + c*(a*x+b*y)+d*x=(c*a+d)*x+(c*b)*y := by ring + +theorem right_row_coefficients (a b c d x y : K) : + c*(a*x+b*y)+d*y=(c*a)*x+(c*b+d)*y := by ring + +end Ostmann.Arithmetic.LinearReversal + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionBoundary.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..1067764a3d74e32b217c6daf5d84665169bdd7fd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionBoundary.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionPrimes +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellReplacementUniform + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open PrimeProgression PrimeCellReplacement Classical + +theorem log_eq_left_of_closed_not_assigned (N : ℕ) (lo hi η : ℝ) + (j : Fin (gridCount lo hi η)) {p : ℕ} + (hp : p ∈ logPrimeSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))) + (hpnot : p ∉ assignedPrimeSupport N lo hi η j) : + Real.log (p:ℝ) = gridPoint lo hi η j.val := by + have hclosed := (mem_logPrimeSupport _ _ _ _).mp hp + have hnot : ¬(j.val=0 ∨ gridPoint lo hi η j.val < Real.log (p:ℝ)) := by + intro h + exact hpnot (Finset.mem_filter.mpr ⟨hp,h⟩) + push Not at hnot + exact le_antisymm hnot.2 hclosed.2.2.1 + +theorem closed_assigned_difference_card_le (N : ℕ) (lo hi η : ℝ) + (j : Fin (gridCount lo hi η)) : + ((logPrimeSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))) \ + assignedPrimeSupport N lo hi η j).card ≤ 1 := by + apply Finset.card_le_one.mpr + intro p hp q hq + have hp' := Finset.mem_sdiff.mp hp + have hq' := Finset.mem_sdiff.mp hq + have hpl := log_eq_left_of_closed_not_assigned N lo hi η j hp'.1 hp'.2 + have hql := log_eq_left_of_closed_not_assigned N lo hi η j hq'.1 hq'.2 + have hpp := ((mem_logPrimeSupport _ _ _ _).mp hp'.1).2.1.pos + have hqp := ((mem_logPrimeSupport _ _ _ _).mp hq'.1).2.1.pos + have he : (p:ℝ)=(q:ℝ) := Real.log_injOn_pos + (by change (0:ℝ) hf p (Finset.mem_sdiff.mp hp).1 (Finset.mem_sdiff.mp hp).2) + _ = (((logPrimeSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))) \ + assignedPrimeSupport N lo hi η j).card:ℝ)*A := by simp + _ ≤ A := by + have hc : (((logPrimeSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))) \ + assignedPrimeSupport N lo hi η j).card:ℝ) ≤ 1 := by + exact_mod_cast closed_assigned_difference_card_le N lo hi η j + simpa using mul_le_mul_of_nonneg_right hc hA + +def assignedResidueMass (N M : ℕ) (a : ZMod M) (lo hi η Z : ℝ) + (j : Fin (gridCount lo hi η)) : ℝ := + ∑ p ∈ (assignedPrimeSupport N lo hi η j).filter (fun p : ℕ => (p:ZMod M)=a), + (Z*(p:ℝ))⁻¹ + +theorem residueMass_assigned_error (N M : ℕ) (a : ZMod M) (lo hi η : ℝ) + (j : Fin (gridCount lo hi η)) {Z : ℝ} (hZ : 0 < Z) : + |residueMass N M a (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) Z - + assignedResidueMass N M a lo hi η Z j| ≤ (Z*Real.exp (gridPoint lo hi η j.val))⁻¹ := by + unfold residueMass assignedResidueMass + simp only [Finset.sum_filter] + change ‖(∑ p ∈ logPrimeSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)), + if (p:ZMod M)=a then (Z*(p:ℝ))⁻¹ else 0) - + (∑ p ∈ assignedPrimeSupport N lo hi η j, if (p:ZMod M)=a then (Z*(p:ℝ))⁻¹ else 0)‖ ≤ _ + apply norm_closed_assigned_test_error N lo hi η j _ (by positivity) + intro p hp hpnot + have hpl := log_eq_left_of_closed_not_assigned N lo hi η j hp hpnot + have hpp : (0:ℝ) < p := by exact_mod_cast ((mem_logPrimeSupport _ _ _ _).mp hp).2.1.pos + have he : (p:ℝ)=Real.exp (gridPoint lo hi η j.val) := by rw [← hpl,Real.exp_log hpp] + split_ifs + · rw [he,Real.norm_eq_abs,abs_of_nonneg (by positivity)] + · simp + positivity + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionBoxes.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionBoxes.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e95012818c9a16f38835f2602ea1e092b8f8adf --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionBoxes.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionGrid +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellIntegralFreezing + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open MeasureTheory PrimeCellFreezing +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +abbrev GridBoxIndex (lo hi η : ι → ℝ) := ∀ i, Fin (gridCount (lo i) (hi i) (η i)) + +def boxLower (lo hi η : ι → ℝ) (j : GridBoxIndex lo hi η) (i : ι) : ℝ := + gridPoint (lo i) (hi i) (η i) (j i).val + +def boxUpper (lo hi η : ι → ℝ) (j : GridBoxIndex lo hi η) (i : ι) : ℝ := + gridPoint (lo i) (hi i) (η i) ((j i).val+1) + +def assignedBox (lo hi η : ι → ℝ) (j : GridBoxIndex lo hi η) : Set (ι → ℝ) := + Set.univ.pi fun i => assignedCell (lo i) (hi i) (η i) (j i) + +omit [Fintype ι] [DecidableEq ι] in +theorem assignedBox_subset_rectangle {lo hi η : ι → ℝ} (h : ∀ i, lo i ≤ hi i) + (j : GridBoxIndex lo hi η) : assignedBox lo hi η j ⊆ logRectangle lo hi := by + intro t ht i hi' + exact assignedCell_subset_interval (h i) (j i) (ht i hi') + +omit [Fintype ι] [DecidableEq ι] in +theorem iUnion_assignedBox {lo hi η : ι → ℝ} (h : ∀ i, lo i ≤ hi i) : + (⋃ j : GridBoxIndex lo hi η, assignedBox lo hi η j) = logRectangle lo hi := by + ext t + constructor + · intro ht + obtain ⟨j,hj⟩ := Set.mem_iUnion.mp ht + exact assignedBox_subset_rectangle h j hj + · intro ht + have hc : ∀ i, ∃ j : Fin (gridCount (lo i) (hi i) (η i)), + t i ∈ assignedCell (lo i) (hi i) (η i) j := + fun i => exists_assignedCell (h i) (ht i (Set.mem_univ i)) + choose j hj using hc + exact Set.mem_iUnion.mpr ⟨j,fun i _ => hj i⟩ + +omit [Fintype ι] [DecidableEq ι] in +theorem assignedBox_pairwiseDisjoint {lo hi η : ι → ℝ} (h : ∀ i, lo i ≤ hi i) : + Pairwise (fun j k : GridBoxIndex lo hi η => Disjoint (assignedBox lo hi η j) (assignedBox lo hi η k)) := by + intro j k hjk + obtain ⟨i,hi⟩ := Function.ne_iff.mp hjk + apply Set.disjoint_left.mpr + intro t htj htk + exact Set.disjoint_left.mp (assignedCell_pairwiseDisjoint (h i) hi) + (htj i (Set.mem_univ i)) (htk i (Set.mem_univ i)) + +omit [DecidableEq ι] in +theorem measurableSet_assignedBox (lo hi η : ι → ℝ) (j : GridBoxIndex lo hi η) : + MeasurableSet (assignedBox lo hi η j) := + MeasurableSet.univ_pi fun i => measurableSet_assignedCell (lo i) (hi i) (η i) (j i) + +omit [DecidableEq ι] in +theorem assignedBox_ae_eq_closed (lo hi η : ι → ℝ) (j : GridBoxIndex lo hi η) : + assignedBox lo hi η j =ᵐ[volume] logRectangle (boxLower lo hi η j) (boxUpper lo hi η j) := by + change (Set.univ.pi fun i => assignedCell (lo i) (hi i) (η i) (j i)) =ᵐ[Measure.pi (fun _ : ι => (volume : Measure ℝ))] + (Set.univ.pi fun i => Set.Icc (boxLower lo hi η j i) (boxUpper lo hi η j i)) + exact Measure.ae_eq_set_pi fun i _ => assignedCell_ae_eq_closed (lo i) (hi i) (η i) (j i) + +theorem integral_rectangle_eq_sum_boxes {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (lo hi η : ι → ℝ) (h : ∀ i, lo i ≤ hi i) (f : (ι → ℝ) → E) + (hf : IntegrableOn f (logRectangle lo hi)) : + (∫ t in logRectangle lo hi, f t) = + ∑ j : GridBoxIndex lo hi η, ∫ t in logRectangle (boxLower lo hi η j) (boxUpper lo hi η j), f t := by + rw [← iUnion_assignedBox (η:=η) h] + rw [integral_iUnion_fintype (measurableSet_assignedBox lo hi η) + (assignedBox_pairwiseDisjoint h) (fun j => hf.mono_set (assignedBox_subset_rectangle h j))] + apply Finset.sum_congr rfl + intro j hj + exact setIntegral_congr_set (assignedBox_ae_eq_closed lo hi η j) + +theorem logCellMass_eq_sum_boxes (w lo hi η : ι → ℝ) + (h : ∀ i, lo i ≤ hi i) (hlo : ∀ i, 0 < lo i) : + logCellMass w lo hi = ∑ j : GridBoxIndex lo hi η, + logCellMass w (boxLower lo hi η j) (boxUpper lo hi η j) := + integral_rectangle_eq_sum_boxes lo hi η h (logCellDensity w) + (integrableOn_logCellDensity w lo hi hlo) + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionGrid.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionGrid.lean new file mode 100644 index 0000000000000000000000000000000000000000..93555e55ebf55a53dfef848dd4df372889fcedee --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionGrid.lean @@ -0,0 +1,144 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeProgression + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open MeasureTheory + +def gridCount (lo hi η : ℝ) : ℕ := ⌈(hi-lo)/η⌉₊+1 + +def gridStep (lo hi η : ℝ) : ℝ := (hi-lo)/(gridCount lo hi η:ℝ) + +def gridPoint (lo hi η : ℝ) (j : ℕ) : ℝ := lo+(j:ℝ)*gridStep lo hi η + +def assignedCell (lo hi η : ℝ) (j : Fin (gridCount lo hi η)) : Set ℝ := + if j.val=0 then Set.Icc (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) + else Set.Ioc (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) + +theorem gridCount_pos (lo hi η : ℝ) : 0 < gridCount lo hi η := by unfold gridCount; omega + +theorem gridStep_nonneg {lo hi η : ℝ} (h : lo ≤ hi) : 0 ≤ gridStep lo hi η := by + unfold gridStep + exact div_nonneg (sub_nonneg.mpr h) (Nat.cast_nonneg _) + +@[simp] theorem gridPoint_zero (lo hi η : ℝ) : gridPoint lo hi η 0 = lo := by simp [gridPoint] + +@[simp] theorem gridPoint_last (lo hi η : ℝ) : + gridPoint lo hi η (gridCount lo hi η) = hi := by + have hn : (gridCount lo hi η:ℝ) ≠ 0 := by exact_mod_cast (gridCount_pos lo hi η).ne' + unfold gridPoint gridStep + field_simp + ring + +theorem gridPoint_mono {lo hi η : ℝ} (h : lo ≤ hi) : Monotone (gridPoint lo hi η) := by + intro i j hij + unfold gridPoint + have hs := gridStep_nonneg (η:=η) h + gcongr + +theorem gridPoint_mem {lo hi η : ℝ} (h : lo ≤ hi) {j : ℕ} (hj : j ≤ gridCount lo hi η) : + gridPoint lo hi η j ∈ Set.Icc lo hi := by + have hm := gridPoint_mono (η:=η) h + exact ⟨by simpa using hm (Nat.zero_le j),by simpa using hm hj⟩ + +theorem gridPoint_width (lo hi η : ℝ) (j : ℕ) : + gridPoint lo hi η (j+1)-gridPoint lo hi η j = gridStep lo hi η := by + unfold gridPoint + push_cast + ring + +theorem gridStep_le {lo hi η : ℝ} (_h : lo ≤ hi) (hη : 0 < η) : gridStep lo hi η ≤ η := by + have hn : (0:ℝ) < gridCount lo hi η := by exact_mod_cast gridCount_pos lo hi η + have hc := Nat.le_ceil ((hi-lo)/η) + have hc' : (hi-lo)/η ≤ (gridCount lo hi η:ℝ) := by + unfold gridCount + push_cast + linarith + apply (div_le_iff₀ hn).mpr + have hh := (div_le_iff₀ hη).mp hc' + nlinarith + +theorem gridCount_le_ceiling {lo hi η U : ℝ} (hη : 0 < η) (hU : hi-lo ≤ U) : + gridCount lo hi η ≤ ⌈U/η⌉₊+1 := by + unfold gridCount + exact Nat.add_le_add_right (Nat.ceil_mono (div_le_div_of_nonneg_right hU hη.le)) 1 + +theorem assignedCell_subset_closed (lo hi η : ℝ) (j : Fin (gridCount lo hi η)) : + assignedCell lo hi η j ⊆ Set.Icc (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) := by + unfold assignedCell + split_ifs + · exact Set.Subset.rfl + · exact Set.Ioc_subset_Icc_self + +theorem assignedCell_subset_interval {lo hi η : ℝ} (h : lo ≤ hi) + (j : Fin (gridCount lo hi η)) : assignedCell lo hi η j ⊆ Set.Icc lo hi := by + intro x hx + have hc := assignedCell_subset_closed lo hi η j hx + have hl := gridPoint_mem (η:=η) h j.isLt.le + have hu := gridPoint_mem (η:=η) h (show j.val+1 ≤ gridCount lo hi η by omega) + exact ⟨hl.1.trans hc.1,hc.2.trans hu.2⟩ + +theorem assignedCell_disjoint_of_lt {lo hi η : ℝ} (h : lo ≤ hi) + {i j : Fin (gridCount lo hi η)} (hij : i < j) : + Disjoint (assignedCell lo hi η i) (assignedCell lo hi η j) := by + apply Set.disjoint_left.mpr + intro x hxi hxj + have hi' := (assignedCell_subset_closed lo hi η i hxi).2 + have hj0 : j.val ≠ 0 := by + have hh : i.val < j.val := hij + omega + have hjc : x ∈ Set.Ioc (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) := by + simpa only [assignedCell,ite_eq_right hj0] using hxj + have hj' := hjc.1 + have hm := gridPoint_mono (η:=η) h (show i.val+1 ≤ j.val by exact hij) + linarith + +theorem assignedCell_pairwiseDisjoint {lo hi η : ℝ} (h : lo ≤ hi) : + Pairwise (fun i j : Fin (gridCount lo hi η) => Disjoint (assignedCell lo hi η i) (assignedCell lo hi η j)) := by + intro i j hne + rcases lt_or_gt_of_ne hne with hij | hji + · exact assignedCell_disjoint_of_lt h hij + · exact (assignedCell_disjoint_of_lt h hji).symm + +theorem exists_assignedCell {lo hi η x : ℝ} (h : lo ≤ hi) (hx : x ∈ Set.Icc lo hi) : + ∃ j : Fin (gridCount lo hi η), x ∈ assignedCell lo hi η j := by + by_cases hx0 : x=lo + · refine ⟨⟨0,gridCount_pos lo hi η⟩,?_⟩ + have hu := gridPoint_mem (η:=η) h (gridCount_pos lo hi η) + simp only [assignedCell,ite_true,gridPoint_zero,Set.mem_Icc] + exact ⟨by linarith,by simpa only [hx0,Nat.zero_add] using hu.1⟩ + · have hx' : x ∈ Set.Ioc (gridPoint lo hi η 0) (gridPoint lo hi η (gridCount lo hi η)) := by + simp only [gridPoint_zero,gridPoint_last,Set.mem_Ioc] + exact ⟨lt_of_le_of_ne hx.1 (Ne.symm hx0),hx.2⟩ + obtain ⟨j,hj,hxj⟩ := Set.mem_iUnion₂.mp (Ioc_subset_biUnion_Ioc (gridCount lo hi η) + (gridPoint lo hi η) hx') + refine ⟨⟨j,Finset.mem_range.mp hj⟩,?_⟩ + unfold assignedCell + split_ifs + · exact ⟨hxj.1.le,hxj.2⟩ + · exact hxj + +theorem iUnion_assignedCell {lo hi η : ℝ} (h : lo ≤ hi) : + (⋃ j : Fin (gridCount lo hi η), assignedCell lo hi η j) = Set.Icc lo hi := by + ext x + simp only [Set.mem_iUnion] + exact ⟨fun ⟨j,hj⟩ => assignedCell_subset_interval h j hj,exists_assignedCell h⟩ + +theorem measurableSet_assignedCell (lo hi η : ℝ) (j : Fin (gridCount lo hi η)) : + MeasurableSet (assignedCell lo hi η j) := by + unfold assignedCell + split_ifs <;> measurability + +theorem assignedCell_ae_eq_closed (lo hi η : ℝ) (j : Fin (gridCount lo hi η)) : + assignedCell lo hi η j =ᵐ[volume] Set.Icc (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) := by + unfold assignedCell + split_ifs + · rfl + · exact Ioc_ae_eq_Icc + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionIntegerBoundary.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionIntegerBoundary.lean new file mode 100644 index 0000000000000000000000000000000000000000..d7b47877a3a2f2de3a8da2d76ff80ada2ed4ef15 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionIntegerBoundary.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionIntegers + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open IntegerCell Classical + +theorem integer_log_eq_left_of_closed_not_assigned (N : ℕ) (lo hi η : ℝ) + (j : Fin (gridCount lo hi η)) {p : ℕ} + (hp : p ∈ cellSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))) + (hpnot : p ∉ assignedIntegerSupport N lo hi η j) : + Real.log (p:ℝ) = gridPoint lo hi η j.val := by + have hclosed := (mem_cellSupport _ _ _ _).mp hp + have hnot : ¬(j.val=0 ∨ gridPoint lo hi η j.val < Real.log (p:ℝ)) := by + intro h + exact hpnot (Finset.mem_filter.mpr ⟨hp,h⟩) + push Not at hnot + exact le_antisymm hnot.2 hclosed.2.2.1 + +theorem integer_closed_assigned_difference_card_le (N : ℕ) (lo hi η : ℝ) + (j : Fin (gridCount lo hi η)) : + ((cellSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))) \ + assignedIntegerSupport N lo hi η j).card ≤ 1 := by + apply Finset.card_le_one.mpr + intro p hp q hq + have hp' := Finset.mem_sdiff.mp hp + have hq' := Finset.mem_sdiff.mp hq + have hpl := integer_log_eq_left_of_closed_not_assigned N lo hi η j hp'.1 hp'.2 + have hql := integer_log_eq_left_of_closed_not_assigned N lo hi η j hq'.1 hq'.2 + have hpp := ((mem_cellSupport _ _ _ _).mp hp'.1).2.1 + have hqp := ((mem_cellSupport _ _ _ _).mp hq'.1).2.1 + have he : (p:ℝ)=(q:ℝ) := Real.log_injOn_pos + (by change (0:ℝ) hf p (Finset.mem_sdiff.mp hp).1 (Finset.mem_sdiff.mp hp).2) + _ = (((cellSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))) \ + assignedIntegerSupport N lo hi η j).card:ℝ)*A := by simp + _ ≤ A := by + have hc : (((cellSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))) \ + assignedIntegerSupport N lo hi η j).card:ℝ) ≤ 1 := by + exact_mod_cast integer_closed_assigned_difference_card_le N lo hi η j + simpa using mul_le_mul_of_nonneg_right hc hA + +def assignedIntegerResidueMass (N M : ℕ) (a : ZMod M) (lo hi η G : ℝ) (φ : ℝ → ℝ) + (j : Fin (gridCount lo hi η)) : ℝ := + ∑ n ∈ (assignedIntegerSupport N lo hi η j).filter (fun n : ℕ => (n:ZMod M)=a), + Real.exp (-G)*φ (Real.log n-G) + +theorem integerResidueMass_assigned_error (N M : ℕ) (a : ZMod M) (lo hi η G : ℝ) + (φ : ℝ → ℝ) (j : Fin (gridCount lo hi η)) {B : ℝ} (hB : 0 ≤ B) + (hφ : ∀ t ∈ Set.Icc (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)), + |φ (t-G)| ≤ B) : + |integerResidueMass N M a (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) G φ - + assignedIntegerResidueMass N M a lo hi η G φ j| ≤ Real.exp (-G)*B := by + unfold integerResidueMass assignedIntegerResidueMass + rw [integerSupport_eq_filter] + simp only [Finset.sum_filter] + change ‖(∑ n ∈ cellSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)), + if (n:ZMod M)=a then Real.exp (-G)*φ (Real.log n-G) else 0) - + (∑ n ∈ assignedIntegerSupport N lo hi η j, + if (n:ZMod M)=a then Real.exp (-G)*φ (Real.log n-G) else 0)‖ ≤ _ + apply norm_integer_closed_assigned_test_error N lo hi η j _ (mul_nonneg (Real.exp_pos _).le hB) + intro n hn hnnot + split_ifs + · rw [Real.norm_eq_abs,abs_mul,abs_of_pos (Real.exp_pos _)] + exact mul_le_mul_of_nonneg_left (hφ _ ((mem_cellSupport _ _ _ _).mp hn).2.2) + (Real.exp_pos _).le + · simpa using mul_nonneg (Real.exp_pos (-G)).le hB + +theorem assignedIntegerResidueMass_error (N M : ℕ) [NeZero M] (a : ZMod M) + (lo hi η G : ℝ) (φ ψ : ℝ → ℝ) (j : Fin (gridCount lo hi η)) (B D : ℝ) + (h : lo ≤ hi) (hB : 0 ≤ B) + (hN : ⌊Real.exp (gridPoint lo hi η (j.val+1))⌋₊ ≤ N) + (hφ : ∀ t, HasDerivAt φ (ψ t) t) (hψ : Continuous ψ) + (hφB : ∀ t ∈ Set.Icc (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)), |φ (t-G)| ≤ B) + (hψD : ∀ t ∈ Set.Icc (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)), |ψ (t-G)| ≤ D) : + |assignedIntegerResidueMass N M a lo hi η G φ j - + integerDensityMass M (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) G φ| ≤ + Real.exp (-G)*(6*B+2*D*(gridPoint lo hi η (j.val+1)-gridPoint lo hi η j.val)) := by + have hb := integerResidueMass_assigned_error N M a lo hi η G φ j hB hφB + have he := integerResidueMass_error N M a φ ψ G + (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) B D + (gridPoint_mono h (Nat.le_succ _)) hN hφ hψ hφB hψD + have ht := abs_sub_le (assignedIntegerResidueMass N M a lo hi η G φ j) + (integerResidueMass N M a (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) G φ) + (integerDensityMass M (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) G φ) + rw [abs_sub_comm] at hb + nlinarith + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionIntegers.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionIntegers.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fe1b23e63c53ae2cd16bb755aadbf37d1d56284 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionIntegers.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.IntegerCellTests +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionGrid + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open IntegerCell Classical + +theorem mem_cellSupport (N p : ℕ) (lo hi : ℝ) : + p ∈ cellSupport N lo hi ↔ p ≤ N ∧ 0 < p ∧ lo ≤ Real.log (p:ℝ) ∧ Real.log (p:ℝ) ≤ hi := by + simp only [cellSupport, Finset.mem_filter, Finset.mem_range, Nat.lt_succ_iff] + +def assignedIntegerSupport (N : ℕ) (lo hi η : ℝ) (j : Fin (gridCount lo hi η)) : Finset ℕ := + (cellSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))).filter + (fun p => j.val=0 ∨ gridPoint lo hi η j.val < Real.log (p:ℝ)) + +theorem mem_assignedIntegerSupport (N p : ℕ) (lo hi η : ℝ) (j : Fin (gridCount lo hi η)) : + p ∈ assignedIntegerSupport N lo hi η j ↔ p ≤ N ∧ 0 < p ∧ Real.log (p:ℝ) ∈ assignedCell lo hi η j := by + classical + simp only [assignedIntegerSupport,Finset.mem_filter,mem_cellSupport] + unfold assignedCell + split_ifs with hj + · simp [hj,Set.mem_Icc] + · simp [hj,Set.mem_Ioc] + constructor + · rintro ⟨⟨hpN,hp,hlo,hhi⟩,hlo'⟩ + exact ⟨hpN,hp,hlo',hhi⟩ + · rintro ⟨hpN,hp,hlo,hhi⟩ + exact ⟨⟨hpN,hp,hlo.le,hhi⟩,hlo⟩ + +theorem assignedIntegerSupport_subset {N : ℕ} {lo hi η : ℝ} (h : lo ≤ hi) + (j : Fin (gridCount lo hi η)) : assignedIntegerSupport N lo hi η j ⊆ cellSupport N lo hi := by + intro p hp + obtain ⟨hpN,hpp,hcell⟩ := (mem_assignedIntegerSupport N p lo hi η j).mp hp + have hb := assignedCell_subset_interval h j hcell + exact (mem_cellSupport N p lo hi).mpr ⟨hpN,hpp,hb.1,hb.2⟩ + +theorem assignedIntegerSupport_eq_filter {N : ℕ} {lo hi η : ℝ} (h : lo ≤ hi) + (j : Fin (gridCount lo hi η)) : + assignedIntegerSupport N lo hi η j = (cellSupport N lo hi).filter + (fun p : ℕ => Real.log (p:ℝ) ∈ assignedCell lo hi η j) := by + classical + ext p + simp only [Finset.mem_filter] + constructor + · intro hp + exact ⟨assignedIntegerSupport_subset h j hp,(mem_assignedIntegerSupport N p lo hi η j).mp hp |>.2.2⟩ + · rintro ⟨hp,hcell⟩ + have hp' := (mem_cellSupport N p lo hi).mp hp + exact (mem_assignedIntegerSupport N p lo hi η j).mpr ⟨hp'.1,hp'.2.1,hcell⟩ + +theorem exists_unique_assignedInteger {N p : ℕ} {lo hi η : ℝ} (h : lo ≤ hi) + (hp : p ∈ cellSupport N lo hi) : + ∃! j : Fin (gridCount lo hi η), p ∈ assignedIntegerSupport N lo hi η j := by + have hp' := (mem_cellSupport N p lo hi).mp hp + obtain ⟨j,hj⟩ := exists_assignedCell (η:=η) h hp'.2.2 + refine ⟨j,(mem_assignedIntegerSupport N p lo hi η j).mpr ⟨hp'.1,hp'.2.1,hj⟩,?_⟩ + intro k hk + by_contra hkj + exact Set.disjoint_left.mp (assignedCell_pairwiseDisjoint h hkj) + ((mem_assignedIntegerSupport N p lo hi η k).mp hk).2.2 hj + +theorem sum_assignedIntegerSupport {A : Type*} [AddCommMonoid A] + (N : ℕ) (lo hi η : ℝ) (h : lo ≤ hi) (f : ℕ → A) : + (∑ j : Fin (gridCount lo hi η), ∑ p ∈ assignedIntegerSupport N lo hi η j, f p) = + ∑ p ∈ cellSupport N lo hi, f p := by + classical + simp_rw [assignedIntegerSupport_eq_filter h,Finset.sum_filter] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro p hp + have hp' := (mem_cellSupport N p lo hi).mp hp + obtain ⟨j,hj⟩ := exists_assignedCell (η:=η) h hp'.2.2 + rw [Finset.sum_eq_single j] + · simp [hj] + · intro k hk hkj + have hnot : Real.log (p:ℝ) ∉ assignedCell lo hi η k := fun hkp => + Set.disjoint_left.mp (assignedCell_pairwiseDisjoint h hkj) hkp hj + simp [hnot] + · simp + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMesh.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMesh.lean new file mode 100644 index 0000000000000000000000000000000000000000..839ae12f1d541d86f2dc1ac0007f696c64997088 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMesh.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionBoxes +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellMeshCounts + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open PrimeCellMeshBudget +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +omit [Fintype ι] [DecidableEq ι] in +theorem boxLower_le_boxUpper {lo hi η : ι → ℝ} (h : ∀ i, lo i ≤ hi i) + (j : GridBoxIndex lo hi η) (i : ι) : boxLower lo hi η j i ≤ boxUpper lo hi η j i := + gridPoint_mono (h i) (Nat.le_succ _) + +omit [Fintype ι] [DecidableEq ι] in +theorem boxLower_mem_interval {lo hi η : ι → ℝ} (h : ∀ i, lo i ≤ hi i) + (j : GridBoxIndex lo hi η) (i : ι) : boxLower lo hi η j i ∈ Set.Icc (lo i) (hi i) := + gridPoint_mem (h i) (j i).isLt.le + +omit [Fintype ι] [DecidableEq ι] in +theorem boxUpper_mem_interval {lo hi η : ι → ℝ} (h : ∀ i, lo i ≤ hi i) + (j : GridBoxIndex lo hi η) (i : ι) : boxUpper lo hi η j i ∈ Set.Icc (lo i) (hi i) := + gridPoint_mem (h i) (show (j i).val+1 ≤ gridCount (lo i) (hi i) (η i) by omega) + +omit [Fintype ι] [DecidableEq ι] in +theorem box_width_le {lo hi η : ι → ℝ} (h : ∀ i, lo i ≤ hi i) (hη : ∀ i, 0 < η i) + (j : GridBoxIndex lo hi η) (i : ι) : boxUpper lo hi η j i-boxLower lo hi η j i ≤ η i := by + rw [boxUpper,boxLower,gridPoint_width] + exact gridStep_le (h i) (hη i) + +theorem gridCount_le_meshIntervals (r : ScaleBudget.Row) (L lo hi : ℝ) + (hlen : hi-lo ≤ Real.exp (r.a₁*L)) : + gridCount lo hi (meshWidth r L) ≤ meshIntervals r L := by + exact gridCount_le_ceiling (by unfold meshWidth; positivity) hlen + +theorem gridBoxIndex_card (lo hi η : ι → ℝ) : + Fintype.card (GridBoxIndex lo hi η) = ∏ i, gridCount (lo i) (hi i) (η i) := by + rw [Fintype.card_pi] + simp + +theorem gridBoxIndex_card_le_mesh_power (r : ScaleBudget.Row) (L : ℝ) (lo hi : ι → ℝ) + (hlen : ∀ i, hi i-lo i ≤ Real.exp (r.a₁*L)) : + Fintype.card (GridBoxIndex lo hi (fun _ => meshWidth r L)) ≤ + (meshIntervals r L)^(Fintype.card ι) := by + rw [gridBoxIndex_card] + calc + _ ≤ ∏ _i : ι, meshIntervals r L := + Finset.prod_le_prod (fun i hi' => gridCount_le_meshIntervals r L (lo i) (hi i) (hlen i)) + _ = _ := by simp + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMixed.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMixed.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f7182fb1fac10994b6fd6b00883bd6d91353ade --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMixed.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionBoxes +import OAI.NumberTheory.Ostmann.Arithmetic.MixedCellIntegralFreezingMass + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open MeasureTheory PrimeCellFreezing MixedCellIntegralFreezing +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +abbrev MixedGridIndex (loI hiI ηI : ℝ) (lo hi η : ι → ℝ) := + Fin (gridCount loI hiI ηI) × GridBoxIndex lo hi η + +def assignedMixedBox (loI hiI ηI : ℝ) (lo hi η : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) : Set (ℝ × (ι → ℝ)) := + assignedCell loI hiI ηI j.1 ×ˢ assignedBox lo hi η j.2 + +omit [Fintype ι] [DecidableEq ι] in +theorem assignedMixedBox_subset {loI hiI ηI : ℝ} {lo hi η : ι → ℝ} + (hI : loI ≤ hiI) (h : ∀ i, lo i ≤ hi i) (j : MixedGridIndex loI hiI ηI lo hi η) : + assignedMixedBox loI hiI ηI lo hi η j ⊆ mixedLogRectangle loI hiI lo hi := by + intro t ht + exact ⟨assignedCell_subset_interval hI j.1 ht.1,assignedBox_subset_rectangle h j.2 ht.2⟩ + +omit [Fintype ι] [DecidableEq ι] in +theorem iUnion_assignedMixedBox {loI hiI ηI : ℝ} {lo hi η : ι → ℝ} + (hI : loI ≤ hiI) (h : ∀ i, lo i ≤ hi i) : + (⋃ j : MixedGridIndex loI hiI ηI lo hi η, assignedMixedBox loI hiI ηI lo hi η j) = + mixedLogRectangle loI hiI lo hi := by + ext t + constructor + · rintro ht + obtain ⟨j,hj⟩ := Set.mem_iUnion.mp ht + exact assignedMixedBox_subset hI h j hj + · intro ht + obtain ⟨j,hj⟩ := exists_assignedCell (η:=ηI) hI ht.1 + have hp : t.2 ∈ ⋃ k : GridBoxIndex lo hi η, assignedBox lo hi η k := by + rw [iUnion_assignedBox h] + exact ht.2 + obtain ⟨k,hk⟩ := Set.mem_iUnion.mp hp + exact Set.mem_iUnion.mpr ⟨(j,k),hj,hk⟩ + +omit [Fintype ι] [DecidableEq ι] in +theorem assignedMixedBox_pairwiseDisjoint {loI hiI ηI : ℝ} {lo hi η : ι → ℝ} + (hI : loI ≤ hiI) (h : ∀ i, lo i ≤ hi i) : + Pairwise (fun j k : MixedGridIndex loI hiI ηI lo hi η => + Disjoint (assignedMixedBox loI hiI ηI lo hi η j) (assignedMixedBox loI hiI ηI lo hi η k)) := by + intro j k hjk + apply Set.disjoint_left.mpr + intro t htj htk + by_cases hfirst : j.1=k.1 + · have hsecond : j.2≠k.2 := fun hh => hjk (Prod.ext hfirst hh) + exact Set.disjoint_left.mp (assignedBox_pairwiseDisjoint h hsecond) htj.2 htk.2 + · exact Set.disjoint_left.mp (assignedCell_pairwiseDisjoint hI hfirst) htj.1 htk.1 + +omit [DecidableEq ι] in +theorem assignedMixedBox_ae_eq_closed (loI hiI ηI : ℝ) (lo hi η : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) : + assignedMixedBox loI hiI ηI lo hi η j =ᵐ[volume] + mixedLogRectangle (gridPoint loI hiI ηI j.1.val) (gridPoint loI hiI ηI (j.1.val+1)) + (boxLower lo hi η j.2) (boxUpper lo hi η j.2) := by + exact Measure.set_prod_ae_eq (assignedCell_ae_eq_closed loI hiI ηI j.1) + (assignedBox_ae_eq_closed lo hi η j.2) + +theorem integral_mixedRectangle_eq_sum_boxes {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (loI hiI ηI : ℝ) (lo hi η : ι → ℝ) (hI : loI ≤ hiI) (h : ∀ i, lo i ≤ hi i) + (f : (ℝ × (ι → ℝ)) → E) (hf : IntegrableOn f (mixedLogRectangle loI hiI lo hi)) : + (∫ t in mixedLogRectangle loI hiI lo hi, f t) = + ∑ j : MixedGridIndex loI hiI ηI lo hi η, + ∫ t in mixedLogRectangle (gridPoint loI hiI ηI j.1.val) (gridPoint loI hiI ηI (j.1.val+1)) + (boxLower lo hi η j.2) (boxUpper lo hi η j.2), f t := by + have hm (j : MixedGridIndex loI hiI ηI lo hi η) : + MeasurableSet (assignedMixedBox loI hiI ηI lo hi η j) := + (measurableSet_assignedCell loI hiI ηI j.1).prod (measurableSet_assignedBox lo hi η j.2) + have hint (j : MixedGridIndex loI hiI ηI lo hi η) : + IntegrableOn f (assignedMixedBox loI hiI ηI lo hi η j) := + hf.mono_set (assignedMixedBox_subset hI h j) + rw [← iUnion_assignedMixedBox (ηI:=ηI) (η:=η) hI h] + rw [integral_iUnion_fintype hm (assignedMixedBox_pairwiseDisjoint hI h) hint] + apply Finset.sum_congr rfl + intro j hj + exact setIntegral_congr_set (assignedMixedBox_ae_eq_closed loI hiI ηI lo hi η j) + +theorem mixedLogMass_eq_sum_boxes (M : ℕ) (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) + (w lo hi η : ι → ℝ) (hI : loI ≤ hiI) (h : ∀ i, lo i ≤ hi i) + (hφ : Continuous φ) (hlo : ∀ i, 0 < lo i) : + mixedLogMass M loI hiI G φ w lo hi = + ∑ j : MixedGridIndex loI hiI ηI lo hi η, + mixedLogMass M (gridPoint loI hiI ηI j.1.val) (gridPoint loI hiI ηI (j.1.val+1)) G φ w + (boxLower lo hi η j.2) (boxUpper lo hi η j.2) := + integral_mixedRectangle_eq_sum_boxes loI hiI ηI lo hi η hI h _ + (integrableOn_mixedLogDensity M loI hiI G φ w lo hi hφ hlo) + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMixedMesh.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMixedMesh.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc544f64794680ef24c982ac69dd091c4f5e89e5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMixedMesh.lean @@ -0,0 +1,32 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionMesh +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionMixed + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open PrimeCellMeshBudget +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem mixedGridIndex_card (loI hiI ηI : ℝ) (lo hi η : ι → ℝ) : + Fintype.card (MixedGridIndex loI hiI ηI lo hi η) = + gridCount loI hiI ηI * ∏ i, gridCount (lo i) (hi i) (η i) := by + rw [Fintype.card_prod, Fintype.card_fin, gridBoxIndex_card] + +theorem mixedGridIndex_card_le_mesh_power (r : ScaleBudget.Row) (L loI hiI : ℝ) + (lo hi : ι → ℝ) (hI : hiI-loI ≤ Real.exp (r.a₁*L)) + (hlen : ∀ i, hi i-lo i ≤ Real.exp (r.a₁*L)) : + Fintype.card (MixedGridIndex loI hiI (meshWidth r L) lo hi (fun _ => meshWidth r L)) ≤ + (meshIntervals r L)^(Fintype.card ι+1) := by + rw [Fintype.card_prod, Fintype.card_fin] + calc + _ ≤ meshIntervals r L * (meshIntervals r L)^(Fintype.card ι) := + Nat.mul_le_mul (gridCount_le_meshIntervals r L loI hiI hI) + (gridBoxIndex_card_le_mesh_power r L lo hi hlen) + _ = _ := by rw [pow_succ, Nat.mul_comm] + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMixedTuples.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMixedTuples.lean new file mode 100644 index 0000000000000000000000000000000000000000..1cda76f64c67d4782173b4db22db80b02731e578 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionMixedTuples.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionIntegers +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionMixed +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionTuples + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open IntegerCell PrimeCellReplacement +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem sum_mixedTuples_eq_sum_assigned {A : Type*} [AddCommMonoid A] + (NI : ℕ) (N : ι → ℕ) (loI hiI ηI : ℝ) (lo hi η : ι → ℝ) + (hI : loI ≤ hiI) (h : ∀ i, lo i ≤ hi i) (F : ℕ → (ι → ℕ) → A) : + (∑ n ∈ cellSupport NI loI hiI, ∑ p : PrimeCellTuple N lo hi, F n (fun i => (p i).val)) = + ∑ j : MixedGridIndex loI hiI ηI lo hi η, + ∑ n ∈ assignedIntegerSupport NI loI hiI ηI j.1, + ∑ p : AssignedPrimeTuple N lo hi η j.2, F n (fun i => (p i).val) := by + classical + rw [← sum_assignedIntegerSupport NI loI hiI ηI hI] + rw [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro j hj + simp_rw [sum_primeTuples_eq_sum_assigned N lo hi η h] + exact Finset.sum_comm + +theorem sum_mixed_prior_eq_sum_assigned + (NI : ℕ) (N : ι → ℕ) (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) + (hI : loI ≤ hiI) (h : ∀ i, lo i ≤ hi i) (F : ℕ → (ι → ℕ) → ℂ) : + (∑ n ∈ cellSupport NI loI hiI, ∑ p : PrimeCellTuple N lo hi, + ((Real.exp (-G)*φ (Real.log n-G):ℝ):ℂ) * + (∏ i, (((Z i*(p i).val)⁻¹:ℝ):ℂ)) * F n (fun i => (p i).val)) = + ∑ j : MixedGridIndex loI hiI ηI lo hi η, + ∑ n ∈ assignedIntegerSupport NI loI hiI ηI j.1, + ∑ p : AssignedPrimeTuple N lo hi η j.2, + ((Real.exp (-G)*φ (Real.log n-G):ℝ):ℂ) * + (∏ i, (((Z i*(p i).val)⁻¹:ℝ):ℂ)) * F n (fun i => (p i).val) := + sum_mixedTuples_eq_sum_assigned NI N loI hiI ηI lo hi η hI h + (fun n p => ((Real.exp (-G)*φ (Real.log n-G):ℝ):ℂ) * + (∏ i, (((Z i*p i)⁻¹:ℝ):ℂ)) * F n p) + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionPrimes.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionPrimes.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e5133370f11b035db8f83ea65af42347d7db3fa --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionPrimes.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionGrid + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open PrimeProgression Classical + +def assignedPrimeSupport (N : ℕ) (lo hi η : ℝ) (j : Fin (gridCount lo hi η)) : Finset ℕ := + (logPrimeSupport N (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))).filter + (fun p => j.val=0 ∨ gridPoint lo hi η j.val < Real.log (p:ℝ)) + +theorem mem_assignedPrimeSupport (N p : ℕ) (lo hi η : ℝ) (j : Fin (gridCount lo hi η)) : + p ∈ assignedPrimeSupport N lo hi η j ↔ p ≤ N ∧ p.Prime ∧ Real.log (p:ℝ) ∈ assignedCell lo hi η j := by + classical + simp only [assignedPrimeSupport,Finset.mem_filter,mem_logPrimeSupport] + unfold assignedCell + split_ifs with hj + · simp [hj,Set.mem_Icc] + · simp [hj,Set.mem_Ioc] + constructor + · rintro ⟨⟨hpN,hp,hlo,hhi⟩,hlo'⟩ + exact ⟨hpN,hp,hlo',hhi⟩ + · rintro ⟨hpN,hp,hlo,hhi⟩ + exact ⟨⟨hpN,hp,hlo.le,hhi⟩,hlo⟩ + +theorem assignedPrimeSupport_subset {N : ℕ} {lo hi η : ℝ} (h : lo ≤ hi) + (j : Fin (gridCount lo hi η)) : assignedPrimeSupport N lo hi η j ⊆ logPrimeSupport N lo hi := by + intro p hp + obtain ⟨hpN,hpp,hcell⟩ := (mem_assignedPrimeSupport N p lo hi η j).mp hp + have hb := assignedCell_subset_interval h j hcell + exact (mem_logPrimeSupport N p lo hi).mpr ⟨hpN,hpp,hb.1,hb.2⟩ + +theorem assignedPrimeSupport_eq_filter {N : ℕ} {lo hi η : ℝ} (h : lo ≤ hi) + (j : Fin (gridCount lo hi η)) : + assignedPrimeSupport N lo hi η j = (logPrimeSupport N lo hi).filter + (fun p : ℕ => Real.log (p:ℝ) ∈ assignedCell lo hi η j) := by + classical + ext p + simp only [Finset.mem_filter] + constructor + · intro hp + exact ⟨assignedPrimeSupport_subset h j hp,(mem_assignedPrimeSupport N p lo hi η j).mp hp |>.2.2⟩ + · rintro ⟨hp,hcell⟩ + have hp' := (mem_logPrimeSupport N p lo hi).mp hp + exact (mem_assignedPrimeSupport N p lo hi η j).mpr ⟨hp'.1,hp'.2.1,hcell⟩ + +theorem exists_unique_assignedPrime {N p : ℕ} {lo hi η : ℝ} (h : lo ≤ hi) + (hp : p ∈ logPrimeSupport N lo hi) : + ∃! j : Fin (gridCount lo hi η), p ∈ assignedPrimeSupport N lo hi η j := by + have hp' := (mem_logPrimeSupport N p lo hi).mp hp + obtain ⟨j,hj⟩ := exists_assignedCell (η:=η) h hp'.2.2 + refine ⟨j,(mem_assignedPrimeSupport N p lo hi η j).mpr ⟨hp'.1,hp'.2.1,hj⟩,?_⟩ + intro k hk + by_contra hkj + exact Set.disjoint_left.mp (assignedCell_pairwiseDisjoint h hkj) + ((mem_assignedPrimeSupport N p lo hi η k).mp hk).2.2 hj + +theorem sum_assignedPrimeSupport {A : Type*} [AddCommMonoid A] + (N : ℕ) (lo hi η : ℝ) (h : lo ≤ hi) (f : ℕ → A) : + (∑ j : Fin (gridCount lo hi η), ∑ p ∈ assignedPrimeSupport N lo hi η j, f p) = + ∑ p ∈ logPrimeSupport N lo hi, f p := by + classical + simp_rw [assignedPrimeSupport_eq_filter h,Finset.sum_filter] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro p hp + have hp' := (mem_logPrimeSupport N p lo hi).mp hp + obtain ⟨j,hj⟩ := exists_assignedCell (η:=η) h hp'.2.2 + rw [Finset.sum_eq_single j] + · simp [hj] + · intro k hk hkj + have hnot : Real.log (p:ℝ) ∉ assignedCell lo hi η k := fun hkp => + Set.disjoint_left.mp (assignedCell_pairwiseDisjoint h hkj) hkp hj + simp [hnot] + · simp + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionReplacement.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..194dae33cfd871cef0dc7b174d1fc650c281a050 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionReplacement.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionBoundary + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open PrimeProgression PrimeCellReplacement + +theorem exists_assigned_residueMass_error_constants : + ∃ d K L₀ : ℝ, 0 < d ∧ 0 < K ∧ 1 ≤ L₀ ∧ ∀ lo hi η : ℝ, + L₀ ≤ lo → lo ≤ hi → 0 < η → η ≤ 1 → ∀ (N M : ℕ) [NeZero M] (Z : ℝ), + ⌊Real.exp hi⌋₊ ≤ N → 0 < Z → (M:ℝ) ≤ Real.exp (d*lo^(1/3:ℝ)) → + ∀ j : Fin (gridCount lo hi η), ∀ a : ZMod M, IsUnit a → + |assignedResidueMass N M a lo hi η Z j - + harmonicIntegral M (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))/Z| ≤ + (K/Z)*Real.exp (-d*(gridPoint lo hi η j.val)^(1/3:ℝ)) + + (Z*Real.exp (gridPoint lo hi η j.val))⁻¹ := by + obtain ⟨d,K,L₀,hd,hK,hL₀,hAP⟩ := exists_residueMass_error_constants + refine ⟨d,K,L₀,hd,hK,hL₀,?_⟩ + intro lo hi η hlo horder hη hη1 N M _ Z hN hZ hmod j a ha + have hl := gridPoint_mem (η:=η) horder j.isLt.le + have hu := gridPoint_mem (η:=η) horder (show j.val+1≤gridCount lo hi η by omega) + have hcell : gridPoint lo hi η j.val ≤ gridPoint lo hi η (j.val+1) := + gridPoint_mono horder (Nat.le_succ _) + have hlen : gridPoint lo hi η (j.val+1)-gridPoint lo hi η j.val ≤ 1 := by + rw [gridPoint_width] + exact (gridStep_le horder hη).trans hη1 + have hcut : ⌊Real.exp (gridPoint lo hi η (j.val+1))⌋₊ ≤ N := + (Nat.floor_mono (Real.exp_le_exp.mpr hu.2)).trans hN + have hmod' : (M:ℝ) ≤ Real.exp (d*(gridPoint lo hi η j.val)^(1/3:ℝ)) := by + apply hmod.trans + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonneg_left + (Real.rpow_le_rpow (by linarith : 0≤lo) hl.1 (by norm_num)) hd.le + have hc := hAP (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) + (hlo.trans hl.1) hcell hlen N M a Z hcut (NeZero.pos M) ha hZ hmod' + have hb := residueMass_assigned_error N M a lo hi η j hZ + calc + _ ≤ |assignedResidueMass N M a lo hi η Z j - + residueMass N M a (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) Z| + + |residueMass N M a (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1)) Z - + harmonicIntegral M (gridPoint lo hi η j.val) (gridPoint lo hi η (j.val+1))/Z| := + abs_sub_le _ _ _ + _ ≤ (Z*Real.exp (gridPoint lo hi η j.val))⁻¹ + + (K/Z)*Real.exp (-d*(gridPoint lo hi η j.val)^(1/3:ℝ)) := + add_le_add (by simpa only [abs_sub_comm] using hb) hc + _ = _ := by ring + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionTuples.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionTuples.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac5ffbc4cfaccd2c047a25ec1b8f0b46525e528b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/LogCellPartitionTuples.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionBoxes +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionPrimes +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellJointReplacementPrior + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open PrimeProgression PrimeCellReplacement +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +abbrev AssignedPrimeTuple (N : ι → ℕ) (lo hi η : ι → ℝ) (j : GridBoxIndex lo hi η) := + ∀ i, {p : ℕ // p ∈ assignedPrimeSupport (N i) (lo i) (hi i) (η i) (j i)} + +def assignedTupleEquiv (N : ι → ℕ) (lo hi η : ι → ℝ) (h : ∀ i, lo i ≤ hi i) : + (Σ j : GridBoxIndex lo hi η, AssignedPrimeTuple N lo hi η j) ≃ PrimeCellTuple N lo hi := + Equiv.ofBijective + (fun x i => ⟨(x.2 i).val,assignedPrimeSupport_subset (h i) (x.1 i) (x.2 i).property⟩) (by + constructor + · rintro ⟨j,p⟩ ⟨k,q⟩ he + have hv (i : ι) : (p i).val=(q i).val := congrArg Subtype.val (congrFun he i) + have hjk : j=k := by + funext i + have hu := exists_unique_assignedPrime (η:=η i) (h i) + (assignedPrimeSupport_subset (h i) (j i) (p i).property) + exact hu.unique (p i).property (by rw [hv i]; exact (q i).property) + cases hjk + apply congrArg (Sigma.mk j) + funext i + exact Subtype.ext (hv i) + · intro p + have hc : ∀ i, ∃ j : Fin (gridCount (lo i) (hi i) (η i)), + (p i).val ∈ assignedPrimeSupport (N i) (lo i) (hi i) (η i) j := + fun i => (exists_unique_assignedPrime (η:=η i) (h i) (p i).property).exists + choose j hj using hc + refine ⟨⟨j,fun i => ⟨(p i).val,hj i⟩⟩,?_⟩ + funext i + rfl) + +theorem sum_primeTuples_eq_sum_assigned {A : Type*} [AddCommMonoid A] + (N : ι → ℕ) (lo hi η : ι → ℝ) (h : ∀ i, lo i ≤ hi i) (F : (ι → ℕ) → A) : + (∑ p : PrimeCellTuple N lo hi, F (fun i => (p i).val)) = + ∑ j : GridBoxIndex lo hi η, ∑ p : AssignedPrimeTuple N lo hi η j, F (fun i => (p i).val) := by + classical + have hh := Fintype.sum_equiv (assignedTupleEquiv N lo hi η h) + (fun x => F (fun i => (x.2 i).val)) (fun p => F (fun i => (p i).val)) (fun x => rfl) + simpa only [Fintype.sum_sigma] using hh.symm + +theorem sum_product_prime_prior_eq_sum_assigned + (N : ι → ℕ) (lo hi η Z : ι → ℝ) (h : ∀ i, lo i ≤ hi i) (F : (ι → ℕ) → ℂ) : + (∑ p : PrimeCellTuple N lo hi, + (∏ i, (((Z i*(p i).val)⁻¹:ℝ):ℂ))*F (fun i => (p i).val)) = + ∑ j : GridBoxIndex lo hi η, ∑ p : AssignedPrimeTuple N lo hi η j, + (∏ i, (((Z i*(p i).val)⁻¹:ℝ):ℂ))*F (fun i => (p i).val) := + sum_primeTuples_eq_sum_assigned N lo hi η h (fun p => (∏ i, (((Z i*p i)⁻¹:ℝ):ℂ))*F p) + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MatchedHistoryEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MatchedHistoryEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f891a38890a60c771bbc2ac5bc9b7a10c210550 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MatchedHistoryEnergy.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.Ostmann.Construction.MatchedDiagonalEnergy +import OAI.NumberTheory.Ostmann.Construction.ConstituentUniqueRootEnergy + +namespace OAI + +/-! # Matched diagonal energy without a frequency-history multiplicity loss -/ + +namespace Ostmann +open scoped BigOperators Classical ComplexConjugate + +theorem permuted_root_energy_le {A R : Type*} [Fintype A] [Fintype R] + (e : Equiv.Perm A) (μ : A → ℝ) (F : R → A → ℂ) (A₀ : ℝ) + (hA₀ : 0 ≤ A₀) (hμ : ∀ a, 0 ≤ μ a) (hbound : ∀ a, μ a ≤ A₀) : + ‖∑ s, ∑ a, ((μ a * μ (e a) : ℝ) : ℂ) * F s a * conj (F s (e a))‖ ≤ + A₀ * ∑ s, ∑ a, μ a * ‖F s a‖ ^ 2 := by + have hs (s : R) := matched_diagonal_energy e μ μ (F s) (F s) (fun _ => 1) A₀ + hA₀ hμ hμ (fun _ => by simp) (fun a _ _ => ⟨hbound a, hbound (e a)⟩) + simp only [mul_one] at hs + calc + _ ≤ ∑ s, ‖∑ a, ((μ a * μ (e a) : ℝ) : ℂ) * F s a * conj (F s (e a))‖ := norm_sum_le _ _ + _ ≤ ∑ s, A₀ / 2 * ((∑ a, μ a * ‖F s a‖ ^ 2) + ∑ a, μ a * ‖F s a‖ ^ 2) := + Finset.sum_le_sum fun s _ => hs s + _ = _ := by rw [← Finset.mul_sum, Finset.sum_add_distrib]; ring + +/-- Root equality is retained in the diagonal. Uniqueness removes the entire +frequency-history multiplicity from its square-energy estimate. -/ +theorem permuted_history_energy_le {A D R : Type*} + [Fintype A] [Fintype D] [Fintype R] + (e : Equiv.Perm A) (μ : A → ℝ) (root : D → R) (F : D → A → ℂ) (A₀ : ℝ) + (hA₀ : 0 ≤ A₀) (hμ : ∀ a, 0 ≤ μ a) (hbound : ∀ a, μ a ≤ A₀) + (hunique : ∀ a d d', F d a ≠ 0 → F d' a ≠ 0 → root d = root d' → d = d') : + ‖∑ d, ∑ d', if root d = root d' then + ∑ a, ((μ a * μ (e a) : ℝ) : ℂ) * (F d a * conj (F d' (e a))) else 0‖ ≤ + A₀ * ∑ d, ∑ a, μ a * ‖F d a‖ ^ 2 := by + rw [← rootFibreSum_weighted_pair root root (fun a => μ a * μ (e a)) F + (fun d a => F d (e a))] + have h := permuted_root_energy_le e μ (fun s a => rootFibreSum root s (fun d => F d a)) + A₀ hA₀ hμ hbound + simp only [mul_assoc] at h + apply h.trans_eq + congr 1 + rw [Finset.sum_comm] + simp_rw [← Finset.mul_sum, rootFibreSum_energy_of_unique root _ (hunique _), Finset.mul_sum] + exact Finset.sum_comm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MatchedPriorCorrelation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MatchedPriorCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..52b8e4d03b47e8ac0d5708ca0d4d8e739d0d94ae --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MatchedPriorCorrelation.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Construction.MatchedHarmonicPrior +import OAI.NumberTheory.Ostmann.Construction.MatchedGraphQuotient + +namespace OAI + +/-! # Exact counterpart-prior extraction before the external-pivot sum -/ + +namespace Ostmann + +open scoped BigOperators Classical + +noncomputable def counterpartRoleUnary {n : ℕ} (Q : Fin n → Finset ℕ) + (e : Equiv.Perm (Fin n)) (ν : Fin n → ℕ → ℂ) (i : Fin n) (p : ℕ) : ℂ := + (if p ∈ Q (e.symm i) then 1 else 0) * ν i p + +theorem counterpartRoleUnary_norm {n : ℕ} (Q : Fin n → Finset ℕ) + (e : Equiv.Perm (Fin n)) (ν : Fin n → ℕ → ℂ) + (hν : ∀ i p, ‖ν i p‖ ≤ 1) (i : Fin n) (p : ℕ) : + ‖counterpartRoleUnary Q e ν i p‖ ≤ 1 := by + unfold counterpartRoleUnary + split_ifs + · simpa only [one_mul] using hν i p + · simp only [zero_mul, norm_zero, zero_le_one] + +theorem counterpartRole_finiteEdgeWeight {n : ℕ} (P : Finset ℕ) + (Q : Fin n → Finset ℕ) (e : Equiv.Perm (Fin n)) + (E : Fin n → Fin n → ℕ → ℕ → ℂ) (ν : Fin n → ℕ → ℂ) (x : Fin n → P) : + ((∏ i, counterpartRoleFactor P Q e i (x i) : ℝ) : ℂ) * + finiteEdgeWeight E ν (fun i => (x i : ℕ)) = + finiteEdgeWeight E (counterpartRoleUnary Q e ν) (fun i => (x i : ℕ)) := by + simp only [Complex.ofReal_prod, finiteEdgeWeight, ← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro i _ + simp only [counterpartRoleFactor, counterpartRoleUnary] + split_ifs <;> simp only [Complex.ofReal_one, Complex.ofReal_zero, one_mul, zero_mul] + +/-- This equality factors out the harmonic normalizer and the reciprocal +product scale before any external integer is summed. -/ +theorem matched_harmonic_correlation_eq {n : ℕ} (P : Finset ℕ) + (Q : Fin n → Finset ℕ) (e : Equiv.Perm (Fin n)) + (μ : (Fin n → P) → ℝ) (G : (Fin n → P) → ℂ) + (X : ℝ) (hX : X ≠ 0) : + (∑ x, (μ x : ℂ) * + (productPrior (fun i => primeSubsetPrior P (Q i)) (fun i => x (e i)) : ℂ) * G x) = + (((∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * X⁻¹ : ℝ) : ℂ) * + ∑ x, (μ x : ℂ) * ((X / (∏ i, (x i : ℝ)) : ℝ) : ℂ) * + ((∏ i, counterpartRoleFactor P Q e i (x i) : ℝ) : ℂ) * G x := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + rw [matched_harmonic_prior] + have he (C H R : ℝ) : C * H⁻¹ * R = (C * X⁻¹) * (X / H) * R := by + rw [div_eq_mul_inv] + calc + _ = C * (X⁻¹ * X) * H⁻¹ * R := by rw [inv_mul_cancel₀ hX]; ring + _ = _ := by ring + rw [he] + push_cast + ring + +/-- The actual two-prior correlation has the already-extracted small factor. +Its hypothesis is the normalized ratio bound supplied by FullPrimeRatioPair. -/ +theorem matched_harmonic_correlation_bound {n : ℕ} (P : Finset ℕ) + (Q : Fin n → Finset ℕ) (e : Equiv.Perm (Fin n)) + (μ : (Fin n → P) → ℝ) (G : (Fin n → P) → ℂ) + (X δ : ℝ) (hX : 0 < X) + (hbound : ‖∑ x, (μ x : ℂ) * ((X / (∏ i, (x i : ℝ)) : ℝ) : ℂ) * + ((∏ i, counterpartRoleFactor P Q e i (x i) : ℝ) : ℂ) * G x‖ ≤ δ) : + ‖∑ x, (μ x : ℂ) * + (productPrior (fun i => primeSubsetPrior P (Q i)) (fun i => x (e i)) : ℂ) * G x‖ ≤ + (∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * X⁻¹ * δ := by + rw [matched_harmonic_correlation_eq P Q e μ G X hX.ne', norm_mul, + Complex.norm_real, Real.norm_of_nonneg (by positivity)] + exact mul_le_mul_of_nonneg_left hbound (by positivity) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacement.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..89b4249a04f91f8419d9b561b32a406e465804d1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacement.lean @@ -0,0 +1,142 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MixedCellGridReplacementAssigned +import OAI.NumberTheory.Ostmann.Arithmetic.MixedCellGridReplacementSmooth + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open scoped BigOperators +open PrimeProgression PrimeCellReplacement PrimeCellFreezing MixedCellIntegralFreezing Characters.RationalHistory + +theorem exists_mixed_grid_smooth_replacement_constants : + ∃ d K L₀ : ℝ, 0 < d ∧ 0 < K ∧ 1 ≤ L₀ ∧ + ∀ (ι : Type*) [Fintype ι] [DecidableEq ι] + (NI : ℕ) (N : ι → ℕ) (M : ℕ) [NeZero M] + (loI hiI ηI G Bφ Dφ : ℝ) (φ ψ : ℝ → ℝ) (lo hi η Z : ι → ℝ), + loI ≤ hiI → 0 < ηI → ⌊Real.exp hiI⌋₊ ≤ NI → + (∀ t, HasDerivAt φ (ψ t) t) → Continuous ψ → + (∀ t ∈ Set.Icc loI hiI, 0 ≤ φ (t-G)) → + (∀ t ∈ Set.Icc loI hiI, |φ (t-G)| ≤ Bφ) → + (∀ t ∈ Set.Icc loI hiI, |ψ (t-G)| ≤ Dφ) → + (∀ i, L₀ ≤ lo i ∧ lo i ≤ hi i ∧ 0 < η i ∧ η i ≤ 1 ∧ + ⌊Real.exp (hi i)⌋₊ ≤ N i ∧ 0 < Z i ∧ + (M:ℝ) ≤ Real.exp (d*(lo i)^(1/3:ℝ))) → + ∀ ε B error : ℝ, 0 ≤ ε → 1 ≤ B → 0 ≤ error → + (∀ (j : MixedGridIndex loI hiI ηI lo hi η) i, + (K/Z i)*Real.exp (-d*(boxLower lo hi η j.2 i)^(1/3:ℝ))+ + (Z i*Real.exp (boxLower lo hi η j.2 i))⁻¹ ≤ ε) → + (∀ (j : MixedGridIndex loI hiI ηI lo hi η) i, + |harmonicIntegral M (boxLower lo hi η j.2 i) (boxUpper lo hi η j.2 i)/Z i|+ + ((K/Z i)*Real.exp (-d*(boxLower lo hi η j.2 i)^(1/3:ℝ))+ + (Z i*Real.exp (boxLower lo hi η j.2 i))⁻¹) ≤ B) → + (∀ j : MixedGridIndex loI hiI ηI lo hi η, + mixedGridError (ι:=ι) M loI hiI ηI G Bφ Dφ φ ε B j.1 ≤ error) → + ∀ (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) (f : (Option ι → ℝ) → ℂ) (D mesh A : ℝ), + 0 ≤ D → 0 ≤ mesh → ηI ≤ mesh → (∀ i, η i ≤ mesh) → + (∀ z∈logRectangle (Option.elim' loI lo) (Option.elim' hiI hi), + DifferentiableAt ℝ (fun y => f (fun i => Real.exp (y i))) z) → + (∀ z∈logRectangle (Option.elim' loI lo) (Option.elim' hiI hi),∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun i => Real.exp (z i)) i t)) 0‖ ≤ D) → + (∀ z∈logRectangle (Option.elim' loI lo) (Option.elim' hiI hi), + ‖f (fun i => Real.exp (z i))‖ ≤ A) → + ‖mixedSmoothTestSum NI N M loI hiI G φ lo hi Z F f- + mixedPrincipalIntegral M loI hiI G φ lo hi Z f* + ∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,F r u‖ ≤ + (2*(((Fintype.card ι:ℝ)+1)*D*mesh)*mixedPrincipalMass M loI hiI G φ lo hi Z+ + (((Fintype.card ι:ℝ)+1)*D*mesh+A)* + (Fintype.card (MixedGridIndex loI hiI ηI lo hi η)*error))* + ∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,‖F r u‖ := by + obtain ⟨d,K,L₀,hd,hK,hL₀,hAP⟩ := exists_assigned_mixedCell_replacement_constants + refine ⟨d,K,L₀,hd,hK,hL₀,?_⟩ + intro ι _ _ NI N M _ loI hiI ηI G Bφ Dφ φ ψ lo hi η Z + hI hηI hNI hφ hψ hφ0 hBφ hDφ hcell ε B error hε hB herror hE hbound herrorBound + F f D mesh A hD hm hmeshI hmesh hf hderiv hA + classical + have hφc : Continuous φ := continuous_iff_continuousAt.mpr fun t => (hφ t).continuousAt + have horder : ∀ i, lo i ≤ hi i := fun i => (hcell i).2.1 + have hlo : ∀ i, 0 < lo i := fun i => lt_of_lt_of_le (by linarith) (hcell i).1 + have hη : ∀ i, 0 < η i := fun i => (hcell i).2.2.1 + have hZ : ∀ i, 0 < Z i := fun i => (hcell i).2.2.2.2.2.1 + let v : ℝ := ((Fintype.card ι:ℝ)+1)*D*mesh + let T : ℝ := ∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,‖F r u‖ + let mass : MixedGridIndex loI hiI ηI lo hi η → ℝ := fun j => + mixedPrincipalMass M (gridPoint loI hiI ηI j.1.val) (gridPoint loI hiI ηI (j.1.val+1)) + G φ (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z + have hT0 : 0 ≤ T := Finset.sum_nonneg fun _ _ => Finset.sum_nonneg fun _ _ => norm_nonneg _ + have hlocal (j : MixedGridIndex loI hiI ηI lo hi η) : + ‖mixedSmoothAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F f- + mixedPrincipalIntegral M (gridPoint loI hiI ηI j.1.val) (gridPoint loI hiI ηI (j.1.val+1)) + G φ (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z f* + ∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,F r u‖ ≤ (v*(2*mass j+error)+A*error)*T := by + have hl := gridPoint_mem (η:=ηI) hI j.1.isLt.le + have hu := gridPoint_mem (η:=ηI) hI (show j.1.val+1 ≤ gridCount loI hiI ηI by omega) + have hsubI : Set.Icc (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) ⊆ Set.Icc loI hiI := + fun _ ht => ⟨hl.1.trans ht.1,ht.2.trans hu.2⟩ + have hsub : logRectangle + (Option.elim' (gridPoint loI hiI ηI j.1.val) (boxLower lo hi η j.2)) + (Option.elim' (gridPoint loI hiI ηI (j.1.val+1)) (boxUpper lo hi η j.2)) ⊆ + logRectangle (Option.elim' loI lo) (Option.elim' hiI hi) := by + intro z hz i hi' + cases i with + | none => exact hsubI (hz none (Set.mem_univ _)) + | some i => + exact ⟨(boxLower_ge lo hi η horder j.2 i).trans (hz (some i) (Set.mem_univ _)).1, + (hz (some i) (Set.mem_univ _)).2.trans (boxUpper_le lo hi η horder j.2 i)⟩ + let base : ℝ × (ι → ℝ) := (gridPoint loI hiI ηI j.1.val,boxLower lo hi η j.2) + have hbase : base∈mixedLogRectangle + (gridPoint loI hiI ηI j.1.val) (gridPoint loI hiI ηI (j.1.val+1)) + (boxLower lo hi η j.2) (boxUpper lo hi η j.2) := + ⟨⟨le_rfl,gridPoint_mono hI (Nat.le_succ _)⟩, + fun i _ => ⟨le_rfl,box_order lo hi η horder j.2 i⟩⟩ + have hb := mixed_assigned_smooth_replacement_of_errors (error:=error) + NI N loI hiI ηI G φ lo hi η Z j hφc (fun t ht => hφ0 t (hsubI ht)) hZ + (fun i => (hlo i).trans_le (boxLower_ge lo hi η horder j.2 i)) F f hD hm + ((gridPoint_width loI hiI ηI j.1.val).trans_le ((gridStep_le hI hηI).trans hmeshI)) + (fun i => (box_width_le lo hi η horder hη j.2 i).trans (hmesh i)) + (fun z hz => hf z (hsub hz)) (fun z hz => hderiv z (hsub hz)) hbase + have he := hAP ι NI N M loI hiI ηI G Bφ Dφ φ ψ lo hi η Z + hI hNI hφ hψ hBφ hDφ hcell j ε B hε hB (hE j) (hbound j) F + have heAbs := hAP ι NI N M loI hiI ηI G Bφ Dφ φ ψ lo hi η Z + hI hNI hφ hψ hBφ hDφ hcell j ε B hε hB (hE j) (hbound j) (fun r u => (‖F r u‖:ℂ)) + have he' := he.trans (mul_le_mul_of_nonneg_right (herrorBound j) hT0) + have heAbs' : ‖mixedAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j (fun r u => (‖F r u‖:ℂ))- + (mass j:ℂ)*∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,(‖F r u‖:ℂ)‖ ≤ error*T := by + simp only [Complex.norm_real,Real.norm_eq_abs,abs_norm] at heAbs + exact heAbs.trans (mul_le_mul_of_nonneg_right (herrorBound j) hT0) + have hAbase : ‖f (optionCoordinates (mixedExp base))‖ ≤ A := by + simpa only [optionCoordinates_mixedExp] using + hA _ (hsub ((optionCoordinates_mem_logRectangle _ _ _ _).mpr hbase)) + exact (hb he' heAbs').trans (mul_le_mul_of_nonneg_right + (add_le_add le_rfl (mul_le_mul_of_nonneg_right hAbase herror)) hT0) + have hsum : (∑ j : MixedGridIndex loI hiI ηI lo hi η,(v*(2*mass j+error)+A*error)) = + 2*v*mixedPrincipalMass M loI hiI G φ lo hi Z+ + (v+A)*(Fintype.card (MixedGridIndex loI hiI ηI lo hi η)*error) := by + simp_rw [mul_add] + rw [Finset.sum_add_distrib,Finset.sum_add_distrib] + simp only [← mul_assoc,← Finset.mul_sum,Finset.sum_const,Finset.card_univ,nsmul_eq_mul] + rw [show (∑ j : MixedGridIndex loI hiI ηI lo hi η,mass j)=mixedPrincipalMass M loI hiI G φ lo hi Z from + (mixedPrincipalMass_eq_sum_boxes M loI hiI ηI G φ lo hi η Z hI horder hφc hlo).symm] + ring + rw [mixedSmoothTestSum_eq_sum_assigned NI N loI hiI ηI G φ lo hi η Z hI horder F f, + mixedPrincipalIntegral_eq_sum_boxes M loI hiI ηI G φ lo hi η Z hI horder hφc hlo f + (fun z hz => (hf z hz).continuousAt.continuousWithinAt),Finset.sum_mul,← Finset.sum_sub_distrib] + calc + _ ≤ ∑ j : MixedGridIndex loI hiI ηI lo hi η, + ‖mixedSmoothAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F f- + mixedPrincipalIntegral M (gridPoint loI hiI ηI j.1.val) (gridPoint loI hiI ηI (j.1.val+1)) + G φ (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z f* + ∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,F r u‖ := norm_sum_le _ _ + _ ≤ ∑ j : MixedGridIndex loI hiI ηI lo hi η,(v*(2*mass j+error)+A*error)*T := + Finset.sum_le_sum fun j _ => hlocal j + _ = _ := by rw [← Finset.sum_mul,hsum] + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementAssigned.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementAssigned.lean new file mode 100644 index 0000000000000000000000000000000000000000..caaa7149296375519c3b60e62a072dcec80d5519 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementAssigned.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MixedCellGridReplacementBasic + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open scoped BigOperators +open PrimeProgression PrimeCellReplacement PrimeCellFreezing MixedCellJointReplacement +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def mixedGridIntegerError (loI hiI ηI G Bφ Dφ : ℝ) + (j : Fin (gridCount loI hiI ηI)) : ℝ := + Real.exp (-G)*(6*Bφ+2*Dφ*(gridPoint loI hiI ηI (j.val+1)-gridPoint loI hiI ηI j.val)) + +def mixedGridError (M : ℕ) (loI hiI ηI G Bφ Dφ : ℝ) (φ : ℝ → ℝ) + (ε B : ℝ) (j : Fin (gridCount loI hiI ηI)) : ℝ := + (mixedGridIntegerError loI hiI ηI G Bφ Dφ j + + (|IntegerCell.integerDensityMass M (gridPoint loI hiI ηI j.val) + (gridPoint loI hiI ηI (j.val+1)) G φ|+ + mixedGridIntegerError loI hiI ηI G Bφ Dφ j)*(Fintype.card ι:ℝ)*ε)*B^Fintype.card ι + +theorem exists_assigned_mixedCell_replacement_constants : + ∃ d K L₀ : ℝ, 0 < d ∧ 0 < K ∧ 1 ≤ L₀ ∧ + ∀ (ι : Type*) [Fintype ι] [DecidableEq ι] + (NI : ℕ) (N : ι → ℕ) (M : ℕ) [NeZero M] + (loI hiI ηI G Bφ Dφ : ℝ) (φ ψ : ℝ → ℝ) (lo hi η Z : ι → ℝ), + loI ≤ hiI → ⌊Real.exp hiI⌋₊ ≤ NI → + (∀ t, HasDerivAt φ (ψ t) t) → Continuous ψ → + (∀ t ∈ Set.Icc loI hiI, |φ (t-G)| ≤ Bφ) → + (∀ t ∈ Set.Icc loI hiI, |ψ (t-G)| ≤ Dφ) → + (∀ i, L₀ ≤ lo i ∧ lo i ≤ hi i ∧ 0 < η i ∧ η i ≤ 1 ∧ + ⌊Real.exp (hi i)⌋₊ ≤ N i ∧ 0 < Z i ∧ + (M:ℝ) ≤ Real.exp (d*(lo i)^(1/3:ℝ))) → + ∀ (j : MixedGridIndex loI hiI ηI lo hi η) (ε B : ℝ), 0 ≤ ε → 1 ≤ B → + (∀ i, (K/Z i)*Real.exp (-d*(boxLower lo hi η j.2 i)^(1/3:ℝ))+ + (Z i*Real.exp (boxLower lo hi η j.2 i))⁻¹ ≤ ε) → + (∀ i, |harmonicIntegral M (boxLower lo hi η j.2 i) (boxUpper lo hi η j.2 i)/Z i|+ + ((K/Z i)*Real.exp (-d*(boxLower lo hi η j.2 i)^(1/3:ℝ))+ + (Z i*Real.exp (boxLower lo hi η j.2 i))⁻¹) ≤ B) → + ∀ F : ZMod M → (ι → (ZMod M)ˣ) → ℂ, + ‖mixedAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F- + (mixedPrincipalMass M (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) G φ + (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z:ℂ)* + (∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ, F r u)‖ ≤ + mixedGridError (ι:=ι) M loI hiI ηI G Bφ Dφ φ ε B j.1* + (∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ, ‖F r u‖) := by + obtain ⟨d,K,L₀,hd,hK,hL₀,hprime⟩ := exists_assigned_joint_primeCell_replacement_constants + refine ⟨d,K,L₀,hd,hK,hL₀,?_⟩ + intro ι _ _ NI N M _ loI hiI ηI G Bφ Dφ φ ψ lo hi η Z + hI hNI hφ hψ hBφ hDφ hcell j ε B hε hB hE hbound F + classical + have hBφ0 : 0 ≤ Bφ := (abs_nonneg _).trans (hBφ loI ⟨le_rfl,hI⟩) + have hDφ0 : 0 ≤ Dφ := (abs_nonneg _).trans (hDφ loI ⟨le_rfl,hI⟩) + have hl := gridPoint_mem (η:=ηI) hI j.1.isLt.le + have hu := gridPoint_mem (η:=ηI) hI (show j.1.val+1 ≤ gridCount loI hiI ηI by omega) + have horderI := gridPoint_mono (η:=ηI) hI (Nat.le_succ j.1.val) + have hsub : Set.Icc (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) ⊆ Set.Icc loI hiI := + fun _ ht => ⟨hl.1.trans ht.1,ht.2.trans hu.2⟩ + have hEI : 0 ≤ mixedGridIntegerError loI hiI ηI G Bφ Dφ j.1 := by + unfold mixedGridIntegerError + exact mul_nonneg (Real.exp_pos _).le + (add_nonneg (mul_nonneg (by norm_num) hBφ0) + (mul_nonneg (mul_nonneg (by norm_num) hDφ0) (sub_nonneg.mpr horderI))) + have hInteger (r : ZMod M) := assignedIntegerResidueMass_error NI M r loI hiI ηI G φ ψ j.1 Bφ Dφ + hI hBφ0 ((Nat.floor_mono (Real.exp_le_exp.mpr hu.2)).trans hNI) hφ hψ + (fun t ht => hBφ t (hsub ht)) (fun t ht => hDφ t (hsub ht)) + have hProd : ‖∏ i, ((harmonicIntegral M (boxLower lo hi η j.2 i) + (boxUpper lo hi η j.2 i)/Z i:ℝ):ℂ)‖ ≤ B^Fintype.card ι := by + rw [norm_prod] + calc + _ ≤ ∏ _i : ι, B := by + apply Finset.prod_le_prod₀ (fun i _ => norm_nonneg _) + intro i _ + have hZi := (hcell i).2.2.2.2.2.1 + have hEi : 0 ≤ (K/Z i)*Real.exp (-d*(boxLower lo hi η j.2 i)^(1/3:ℝ))+ + (Z i*Real.exp (boxLower lo hi η j.2 i))⁻¹ := by positivity + simp only [Complex.norm_real,Real.norm_eq_abs] + linarith [hbound i] + _ = _ := by simp + have hJoint (r : ZMod M) := hprime ι N M lo hi η Z hcell j.2 ε B hε hB hE hbound (F r) + have hh := mixed_sum_error + (fun r : ZMod M => assignedIntegerResidueMass NI M r loI hiI ηI G φ j.1) + (IntegerCell.integerDensityMass M (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) G φ) + (fun r => assignedJointComplexTestSum N M lo hi η Z j.2 (F r)) + (∏ i, ((harmonicIntegral M (boxLower lo hi η j.2 i) (boxUpper lo hi η j.2 i)/Z i:ℝ):ℂ)) F + hEI (show 0 ≤ (Fintype.card ι:ℝ)*ε*B^Fintype.card ι by positivity) + (show 0 ≤ B^Fintype.card ι by positivity) hInteger hProd hJoint + rw [← mixedAssignedTestSum_eq_integer] at hh + rw [mixedPrincipalMass,MixedCellIntegralFreezing.residue_mixedLogMass_eq M _ _ _ _ _ _ _ + horderI (box_order lo hi η (fun i => (hcell i).2.1) j.2)] + simp only [Complex.ofReal_mul,Complex.ofReal_prod] + convert hh using 1 + dsimp [mixedGridError] + ring + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementBasic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ae246f3d68f898dcaeddb456435fd9d994e3eb9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementBasic.lean @@ -0,0 +1,125 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionIntegerBoundary +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionMixedTuples +import OAI.NumberTheory.Ostmann.Arithmetic.MixedCellIntegralFreezingLog +import OAI.NumberTheory.Ostmann.Arithmetic.MixedCellJointReplacementAlgebra +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellAssignedReplacement + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open scoped BigOperators +open MeasureTheory PrimeProgression PrimeCellReplacement PrimeCellFreezing MixedCellIntegralFreezing +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + +def mixedSmoothTestSum (NI : ℕ) (N : ι → ℕ) (M : ℕ) [NeZero M] + (loI hiI G : ℝ) (φ : ℝ → ℝ) (lo hi Z : ι → ℝ) + (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) (f : (Option ι → ℝ) → ℂ) : ℂ := + ∑ n ∈ IntegerCell.cellSupport NI loI hiI, ∑ p : PrimeCellTuple N lo hi, + ((Real.exp (-G)*φ (Real.log n-G):ℝ):ℂ)* + (∏ i, (((Z i*(p i).val)⁻¹:ℝ):ℂ))* + jointUnitTest (F (n:ZMod M)) (fun i => ((p i).val:ZMod M))* + f (Option.elim' (n:ℝ) (fun i => ((p i).val:ℝ))) + +def mixedAssignedTestSum (NI : ℕ) (N : ι → ℕ) (M : ℕ) [NeZero M] + (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) : ℂ := + ∑ n ∈ assignedIntegerSupport NI loI hiI ηI j.1, + ((Real.exp (-G)*φ (Real.log n-G):ℝ):ℂ)* + assignedJointComplexTestSum N M lo hi η Z j.2 (F (n:ZMod M)) + +def mixedSmoothAssignedTestSum (NI : ℕ) (N : ι → ℕ) (M : ℕ) [NeZero M] + (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) + (f : (Option ι → ℝ) → ℂ) : ℂ := + ∑ n ∈ assignedIntegerSupport NI loI hiI ηI j.1, + ∑ p : AssignedPrimeTuple N lo hi η j.2, + ((Real.exp (-G)*φ (Real.log n-G):ℝ):ℂ)* + (assignedTupleWeight N lo hi η Z j.2 p:ℂ)* + jointUnitTest (F (n:ZMod M)) (fun i => ((p i).val:ZMod M))* + f (Option.elim' (n:ℝ) (fun i => ((p i).val:ℝ))) + +def mixedAssignedAbsMass (NI : ℕ) (N : ι → ℕ) (M : ℕ) [NeZero M] + (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) : ℝ := + ∑ n ∈ assignedIntegerSupport NI loI hiI ηI j.1, + (Real.exp (-G)*φ (Real.log n-G))*assignedAbsMass N M lo hi η Z j.2 (F (n:ZMod M)) + +def mixedPrincipalMass (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) (lo hi Z : ι → ℝ) : ℝ := + mixedLogMass M loI hiI G φ (fun i => ((Nat.totient M:ℝ)*Z i)⁻¹) lo hi + +def mixedPrincipalIntegral (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) (lo hi Z : ι → ℝ) + (f : (Option ι → ℝ) → ℂ) : ℂ := + mixedLogIntegral M loI hiI G φ (fun i => ((Nat.totient M:ℝ)*Z i)⁻¹) lo hi + (fun x => f (optionCoordinates x)) + +theorem mixedAssignedTestSum_eq_integer (NI : ℕ) (N : ι → ℕ) + (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) : + mixedAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F = + ∑ r : ZMod M, (assignedIntegerResidueMass NI M r loI hiI ηI G φ j.1:ℂ)* + assignedJointComplexTestSum N M lo hi η Z j.2 (F r) := by + unfold mixedAssignedTestSum + rw [IntegerCell.sum_weighted_residueTest (assignedIntegerSupport NI loI hiI ηI j.1) + (fun n : ℕ => ((Real.exp (-G)*φ (Real.log n-G):ℝ):ℂ)) + (fun r : ZMod M => assignedJointComplexTestSum N M lo hi η Z j.2 (F r))] + simp only [assignedIntegerResidueMass,Complex.ofReal_sum] + +theorem mixedAssignedAbsMass_cast (NI : ℕ) (N : ι → ℕ) + (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) : + (mixedAssignedAbsMass NI N M loI hiI ηI G φ lo hi η Z j F:ℂ) = + mixedAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j (fun r u => (‖F r u‖:ℂ)) := by + simp only [mixedAssignedAbsMass,mixedAssignedTestSum,Complex.ofReal_sum, + Complex.ofReal_mul,assignedAbsMass_cast] + +theorem mixedSmoothTestSum_eq_sum_assigned (NI : ℕ) (N : ι → ℕ) + (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) + (hI : loI ≤ hiI) (horder : ∀ i, lo i ≤ hi i) + (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) (f : (Option ι → ℝ) → ℂ) : + mixedSmoothTestSum NI N M loI hiI G φ lo hi Z F f = + ∑ j : MixedGridIndex loI hiI ηI lo hi η, + mixedSmoothAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F f := by + simpa only [mixedSmoothTestSum,mixedSmoothAssignedTestSum,assignedTupleWeight, + Complex.ofReal_prod,mul_assoc] using + sum_mixed_prior_eq_sum_assigned NI N loI hiI ηI G φ lo hi η Z hI horder + (fun n p => jointUnitTest (F (n:ZMod M)) (fun i => (p i:ZMod M))* + f (Option.elim' (n:ℝ) (fun i => (p i:ℝ)))) + +theorem mixedPrincipalMass_eq_sum_boxes (M : ℕ) (loI hiI ηI G : ℝ) + (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) (hI : loI ≤ hiI) + (horder : ∀ i, lo i ≤ hi i) (hφ : Continuous φ) (hlo : ∀ i, 0 < lo i) : + mixedPrincipalMass M loI hiI G φ lo hi Z = + ∑ j : MixedGridIndex loI hiI ηI lo hi η, + mixedPrincipalMass M (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) G φ (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z := + mixedLogMass_eq_sum_boxes M loI hiI ηI G φ _ lo hi η hI horder hφ hlo + +theorem mixedPrincipalIntegral_eq_sum_boxes (M : ℕ) (loI hiI ηI G : ℝ) + (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) (hI : loI ≤ hiI) + (horder : ∀ i, lo i ≤ hi i) (hφ : Continuous φ) (hlo : ∀ i, 0 < lo i) + (f : (Option ι → ℝ) → ℂ) + (hf : ContinuousOn (fun z => f (fun i => Real.exp (z i))) + (logRectangle (Option.elim' loI lo) (Option.elim' hiI hi))) : + mixedPrincipalIntegral M loI hiI G φ lo hi Z f = + ∑ j : MixedGridIndex loI hiI ηI lo hi η, + mixedPrincipalIntegral M (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) G φ (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z f := by + apply integral_mixedRectangle_eq_sum_boxes loI hiI ηI lo hi η hI horder + have hh : ContinuousOn (fun z => f (optionCoordinates (mixedExp z))) + (mixedLogRectangle loI hiI lo hi) := by + simp only [optionCoordinates_mixedExp] + exact hf.comp continuous_optionCoordinates.continuousOn + (fun z hz => (optionCoordinates_mem_logRectangle loI hiI lo hi).mpr hz) + exact ((continuousOn_mixedLogDensity M loI hiI G φ _ lo hi hφ hlo).smul hh).integrableOn_compact + (isCompact_mixedLogRectangle loI hiI lo hi) + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementDiscrete.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementDiscrete.lean new file mode 100644 index 0000000000000000000000000000000000000000..782e9044d9cffa1730ada78c5670351136da4fa4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementDiscrete.lean @@ -0,0 +1,144 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MixedCellGridReplacementBasic + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open scoped BigOperators +open PrimeCellReplacement PrimeCellFreezing MixedCellIntegralFreezing Characters.RationalHistory +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + +def mixedAssignedLog (N : ι → ℕ) (lo hi η : ι → ℝ) (j : GridBoxIndex lo hi η) + (n : ℕ) (p : AssignedPrimeTuple N lo hi η j) : Option ι → ℝ := + Option.elim' (Real.log (n:ℝ)) (assignedTupleLog N lo hi η j p) + +theorem mixedAssignedLog_mem (NI : ℕ) (N : ι → ℕ) (loI hiI ηI : ℝ) (lo hi η : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) {n : ℕ} + (hn : n ∈ assignedIntegerSupport NI loI hiI ηI j.1) (p : AssignedPrimeTuple N lo hi η j.2) : + mixedAssignedLog N lo hi η j.2 n p ∈ + logRectangle (Option.elim' (gridPoint loI hiI ηI j.1.val) (boxLower lo hi η j.2)) + (Option.elim' (gridPoint loI hiI ηI (j.1.val+1)) (boxUpper lo hi η j.2)) := by + intro i _ + cases i with + | none => exact ((mem_cellSupport _ _ _ _).mp (Finset.mem_filter.mp hn).1).2.2 + | some i => exact assignedTupleLog_mem N lo hi η j.2 p i (Set.mem_univ _) + +theorem exp_mixedAssignedLog (NI : ℕ) (N : ι → ℕ) (loI hiI ηI : ℝ) (lo hi η : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) {n : ℕ} + (hn : n ∈ assignedIntegerSupport NI loI hiI ηI j.1) (p : AssignedPrimeTuple N lo hi η j.2) : + (fun i => Real.exp (mixedAssignedLog N lo hi η j.2 n p i)) = + Option.elim' (n:ℝ) (fun i => ((p i).val:ℝ)) := by + funext i + cases i with + | none => + apply Real.exp_log + exact_mod_cast ((mem_cellSupport _ _ _ _).mp (Finset.mem_filter.mp hn).1).2.1 + | some i => exact congrFun (exp_assignedTupleLog N lo hi η j.2 p) i + +theorem mixed_assigned_freezing_of_variation (NI : ℕ) (N : ι → ℕ) + (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) (hZ : ∀ i, 0 ≤ Z i) + (hφ0 : ∀ t ∈ Set.Icc (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)), 0 ≤ φ (t-G)) + (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) (f : (Option ι → ℝ) → ℂ) + (f₀ : ℂ) {v : ℝ} + (hvar : ∀ n ∈ assignedIntegerSupport NI loI hiI ηI j.1, + ∀ p : AssignedPrimeTuple N lo hi η j.2, + ‖f (Option.elim' (n:ℝ) (fun i => ((p i).val:ℝ)))-f₀‖ ≤ v) : + ‖mixedSmoothAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F f- + f₀*mixedAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F‖ ≤ + v*mixedAssignedAbsMass NI N M loI hiI ηI G φ lo hi η Z j F := by + classical + have heq : mixedSmoothAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F f- + f₀*mixedAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F = + ∑ n ∈ assignedIntegerSupport NI loI hiI ηI j.1, + ∑ p : AssignedPrimeTuple N lo hi η j.2, + (((Real.exp (-G)*φ (Real.log n-G):ℝ):ℂ)*(assignedTupleWeight N lo hi η Z j.2 p:ℂ)* + jointUnitTest (F (n:ZMod M)) (fun i => ((p i).val:ZMod M)))* + (f (Option.elim' (n:ℝ) (fun i => ((p i).val:ℝ)))-f₀) := by + simp only [mixedSmoothAssignedTestSum,mixedAssignedTestSum,assignedJointTestSum_tupleWeight, + Finset.mul_sum,← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro n hn + apply Finset.sum_congr rfl + intro p hp + ring + rw [heq] + calc + _ ≤ ∑ n ∈ assignedIntegerSupport NI loI hiI ηI j.1, + ∑ p : AssignedPrimeTuple N lo hi η j.2, + ‖(((Real.exp (-G)*φ (Real.log n-G):ℝ):ℂ)*(assignedTupleWeight N lo hi η Z j.2 p:ℂ)* + jointUnitTest (F (n:ZMod M)) (fun i => ((p i).val:ZMod M)))* + (f (Option.elim' (n:ℝ) (fun i => ((p i).val:ℝ)))-f₀)‖ := + (norm_sum_le _ _).trans (Finset.sum_le_sum fun n _ => norm_sum_le _ _) + _ ≤ ∑ n ∈ assignedIntegerSupport NI loI hiI ηI j.1, + ∑ p : AssignedPrimeTuple N lo hi η j.2, + v*((Real.exp (-G)*φ (Real.log n-G))* + (assignedTupleWeight N lo hi η Z j.2 p* + jointAbsTest (F (n:ZMod M)) (fun i => ((p i).val:ZMod M)))) := by + apply Finset.sum_le_sum + intro n hn + have hwI : 0 ≤ Real.exp (-G)*φ (Real.log n-G) := + mul_nonneg (Real.exp_pos _).le + (hφ0 _ ((mem_cellSupport _ _ _ _).mp (Finset.mem_filter.mp hn).1).2.2) + apply Finset.sum_le_sum + intro p hp + have hwP := assignedTupleWeight_nonneg N lo hi η Z hZ j.2 p + rw [norm_mul,norm_mul,norm_mul,Complex.norm_real,Real.norm_eq_abs, + abs_of_nonneg hwI,Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg hwP] + calc + _ ≤ ((Real.exp (-G)*φ (Real.log n-G))*assignedTupleWeight N lo hi η Z j.2 p* + jointAbsTest (F (n:ZMod M)) (fun i => ((p i).val:ZMod M)))*v := + mul_le_mul (mul_le_mul_of_nonneg_left (jointUnitTest_norm_le _ _) (mul_nonneg hwI hwP)) + (hvar n hn p) (norm_nonneg _) (mul_nonneg (mul_nonneg hwI hwP) (jointAbsTest_nonneg _ _)) + _ = _ := by ring + _ = _ := by + simp only [mixedAssignedAbsMass,assignedAbsMass,Finset.mul_sum] + +theorem smooth_mixed_assigned_freezing_bound (NI : ℕ) (N : ι → ℕ) + (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) (hZ : ∀ i, 0 ≤ Z i) + (hφ0 : ∀ t ∈ Set.Icc (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)), 0 ≤ φ (t-G)) + (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) (f : (Option ι → ℝ) → ℂ) + {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hwidthI : gridPoint loI hiI ηI (j.1.val+1)-gridPoint loI hiI ηI j.1.val ≤ mesh) + (hwidth : ∀ i, boxUpper lo hi η j.2 i-boxLower lo hi η j.2 i ≤ mesh) + (hf : ∀ z∈logRectangle + (Option.elim' (gridPoint loI hiI ηI j.1.val) (boxLower lo hi η j.2)) + (Option.elim' (gridPoint loI hiI ηI (j.1.val+1)) (boxUpper lo hi η j.2)), + DifferentiableAt ℝ (fun y => f (fun i => Real.exp (y i))) z) + (hd : ∀ z∈logRectangle + (Option.elim' (gridPoint loI hiI ηI j.1.val) (boxLower lo hi η j.2)) + (Option.elim' (gridPoint loI hiI ηI (j.1.val+1)) (boxUpper lo hi η j.2)), ∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun i => Real.exp (z i)) i t)) 0‖ ≤ D) + {base : Option ι → ℝ} (hbase : base∈logRectangle + (Option.elim' (gridPoint loI hiI ηI j.1.val) (boxLower lo hi η j.2)) + (Option.elim' (gridPoint loI hiI ηI (j.1.val+1)) (boxUpper lo hi η j.2))) : + ‖mixedSmoothAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F f- + f (fun i => Real.exp (base i))*mixedAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F‖ ≤ + ((Fintype.card ι:ℝ)+1)*D*mesh*mixedAssignedAbsMass NI N M loI hiI ηI G φ lo hi η Z j F := by + apply mixed_assigned_freezing_of_variation NI N loI hiI ηI G φ lo hi η Z j hZ hφ0 F f + intro n hn p + have hp := mixedAssignedLog_mem NI N loI hiI ηI lo hi η j hn p + have hwidth' : ∀ i : Option ι, + Option.elim' (gridPoint loI hiI ηI (j.1.val+1)) (boxUpper lo hi η j.2) i - + Option.elim' (gridPoint loI hiI ηI j.1.val) (boxLower lo hi η j.2) i ≤ mesh := by + intro i + cases i with + | none => exact hwidthI + | some i => exact hwidth i + have hh := positive_norm_sub_le f _ _ hD hm hf hd hp hbase + (logRectangle_coordinate_dist_le _ _ hwidth' hp hbase) + simpa only [exp_mixedAssignedLog NI N loI hiI ηI lo hi η j hn p, + Fintype.card_option,Nat.cast_add,Nat.cast_one] using hh + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementSmooth.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementSmooth.lean new file mode 100644 index 0000000000000000000000000000000000000000..6689a56f85bef03e41737f5c005c8d8c792f2f4f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellGridReplacementSmooth.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MixedCellGridReplacementDiscrete + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open scoped BigOperators +open PrimeCellFreezing MixedCellIntegralFreezing Characters.RationalHistory +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + +theorem mixedAssignedAbsMass_le_of_error (NI : ℕ) (N : ι → ℕ) + (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) + (main error : ℝ) + (he : ‖mixedAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j (fun r u => (‖F r u‖:ℂ))- + (main:ℂ)*∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,(‖F r u‖:ℂ)‖ ≤ + error*∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,‖F r u‖) : + mixedAssignedAbsMass NI N M loI hiI ηI G φ lo hi η Z j F ≤ + (main+error)*∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,‖F r u‖ := by + rw [← mixedAssignedAbsMass_cast] at he + simp only [← Complex.ofReal_sum,← Complex.ofReal_mul,← Complex.ofReal_sub, + Complex.norm_real,Real.norm_eq_abs] at he + have hh := (le_abs_self _).trans he + linarith + +theorem mixed_assigned_smooth_replacement_of_errors (NI : ℕ) (N : ι → ℕ) + (loI hiI ηI G : ℝ) (φ : ℝ → ℝ) (lo hi η Z : ι → ℝ) + (j : MixedGridIndex loI hiI ηI lo hi η) + (hφ : Continuous φ) + (hφ0 : ∀ t ∈ Set.Icc (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)), 0 ≤ φ (t-G)) + (hZ : ∀ i, 0 < Z i) (hlo : ∀ i, 0 < boxLower lo hi η j.2 i) + (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) (f : (Option ι → ℝ) → ℂ) + {D mesh error : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hwidthI : gridPoint loI hiI ηI (j.1.val+1)-gridPoint loI hiI ηI j.1.val ≤ mesh) + (hwidth : ∀ i, boxUpper lo hi η j.2 i-boxLower lo hi η j.2 i ≤ mesh) + (hf : ∀ z∈logRectangle + (Option.elim' (gridPoint loI hiI ηI j.1.val) (boxLower lo hi η j.2)) + (Option.elim' (gridPoint loI hiI ηI (j.1.val+1)) (boxUpper lo hi η j.2)), + DifferentiableAt ℝ (fun y => f (fun i => Real.exp (y i))) z) + (hd : ∀ z∈logRectangle + (Option.elim' (gridPoint loI hiI ηI j.1.val) (boxLower lo hi η j.2)) + (Option.elim' (gridPoint loI hiI ηI (j.1.val+1)) (boxUpper lo hi η j.2)), ∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun i => Real.exp (z i)) i t)) 0‖ ≤ D) + {base : ℝ × (ι → ℝ)} (hbase : base∈mixedLogRectangle + (gridPoint loI hiI ηI j.1.val) (gridPoint loI hiI ηI (j.1.val+1)) + (boxLower lo hi η j.2) (boxUpper lo hi η j.2)) + (he : ‖mixedAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F- + (mixedPrincipalMass M (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) G φ (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z:ℂ)* + ∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,F r u‖ ≤ error*∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,‖F r u‖) + (heAbs : ‖mixedAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j (fun r u => (‖F r u‖:ℂ))- + (mixedPrincipalMass M (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) G φ (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z:ℂ)* + ∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,(‖F r u‖:ℂ)‖ ≤ error*∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,‖F r u‖) : + ‖mixedSmoothAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F f- + mixedPrincipalIntegral M (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) G φ (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z f* + ∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,F r u‖ ≤ + (((Fintype.card ι:ℝ)+1)*D*mesh* + (2*mixedPrincipalMass M (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) G φ (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z+error)+ + ‖f (optionCoordinates (mixedExp base))‖*error)*∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,‖F r u‖ := by + classical + let v : ℝ := ((Fintype.card ι:ℝ)+1)*D*mesh + let f₀ := f (optionCoordinates (mixedExp base)) + let S := ∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,F r u + let T := ∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ,‖F r u‖ + let mass := mixedPrincipalMass M (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) G φ (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z + let integral := mixedPrincipalIntegral M (gridPoint loI hiI ηI j.1.val) + (gridPoint loI hiI ηI (j.1.val+1)) G φ (boxLower lo hi η j.2) (boxUpper lo hi η j.2) Z f + let actual := mixedAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F + have hv : 0 ≤ v := by dsimp [v]; positivity + have hmass := mixedAssignedAbsMass_le_of_error NI N loI hiI ηI G φ lo hi η Z j F mass error heAbs + have hdisc := smooth_mixed_assigned_freezing_bound NI N loI hiI ηI G φ lo hi η Z j + (fun i => (hZ i).le) hφ0 F f hD hm hwidthI hwidth hf hd + ((optionCoordinates_mem_logRectangle _ _ _ _).mpr hbase) + have hdisc' : ‖mixedSmoothAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F f-f₀*actual‖ ≤ + v*((mass+error)*T) := by + simpa only [f₀,optionCoordinates_mixedExp] using + hdisc.trans (mul_le_mul_of_nonneg_left hmass hv) + have hap : ‖f₀*actual-f₀*((mass:ℂ)*S)‖ ≤ ‖f₀‖*(error*T) := by + rw [← mul_sub,norm_mul] + exact mul_le_mul_of_nonneg_left he (norm_nonneg _) + have hint := mixed_integral_freezing_of_log_partials M + (gridPoint loI hiI ηI j.1.val) (gridPoint loI hiI ηI (j.1.val+1)) G φ + (fun i => ((Nat.totient M:ℝ)*Z i)⁻¹) (boxLower lo hi η j.2) (boxUpper lo hi η j.2) + hφ hφ0 (fun i => inv_nonneg.mpr (mul_nonneg (Nat.cast_nonneg _) (hZ i).le)) hlo + f hD hm hwidthI hwidth hf hd hbase + have hint' : ‖(mass:ℂ)*f₀-integral‖ ≤ v*mass := by + rw [norm_sub_rev] + simpa only [integral,mass,mixedPrincipalIntegral,mixedPrincipalMass,Complex.real_smul] using hint + have hS : ‖S‖ ≤ T := (norm_sum_le _ _).trans (Finset.sum_le_sum fun r _ => norm_sum_le _ _) + have hmain : ‖f₀*((mass:ℂ)*S)-integral*S‖ ≤ (v*mass)*T := by + have heq : f₀*((mass:ℂ)*S)-integral*S = ((mass:ℂ)*f₀-integral)*S := by ring + rw [heq,norm_mul] + exact mul_le_mul hint' hS (norm_nonneg _) ((norm_nonneg _).trans hint') + calc + _ ≤ ‖mixedSmoothAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F f-f₀*actual‖+ + ‖f₀*actual-f₀*((mass:ℂ)*S)‖+‖f₀*((mass:ℂ)*S)-integral*S‖ := by + have h₁ := norm_sub_le_norm_sub_add_norm_sub + (mixedSmoothAssignedTestSum NI N M loI hiI ηI G φ lo hi η Z j F f) (f₀*actual) (integral*S) + have h₂ := norm_sub_le_norm_sub_add_norm_sub (f₀*actual) (f₀*((mass:ℂ)*S)) (integral*S) + simpa only [add_assoc] using h₁.trans (add_le_add le_rfl h₂) + _ ≤ v*((mass+error)*T)+‖f₀‖*(error*T)+(v*mass)*T := add_le_add (add_le_add hdisc' hap) hmain + _ = _ := by dsimp only [v,f₀,T,mass]; ring + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellIntegralFreezing.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellIntegralFreezing.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa04db32ca3281a7068862964fe85b79a761f639 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellIntegralFreezing.lean @@ -0,0 +1,131 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MixedCellIntegralFreezingMass + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.MixedCellIntegralFreezing +open MeasureTheory PrimeCellFreezing +open scoped BigOperators +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def mixedExp (t : ℝ × (ι → ℝ)) : ℝ × (ι → ℝ) := + (Real.exp t.1, fun i => Real.exp (t.2 i)) + +def mixedLogIntegral (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) + (w lo hi : ι → ℝ) (f : (ℝ × (ι → ℝ)) → ℂ) : ℂ := + ∫ t in mixedLogRectangle loI hiI lo hi, mixedLogDensity M G φ w t • f (mixedExp t) + +omit [DecidableEq ι] in +theorem mixed_freezing_of_variation (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) + (w lo hi : ι → ℝ) (hφ : Continuous φ) + (hφ0 : ∀ t ∈ Set.Icc loI hiI, 0 ≤ φ (t-G)) + (hw : ∀ i, 0 ≤ w i) (hlo : ∀ i, 0 < lo i) + (F : (ℝ × (ι → ℝ)) → ℂ) + (hF : ContinuousOn F (mixedLogRectangle loI hiI lo hi)) + (base : ℝ × (ι → ℝ)) {C : ℝ} + (hvar : ∀ t ∈ mixedLogRectangle loI hiI lo hi, ‖F t - F base‖ ≤ C) : + ‖(∫ t in mixedLogRectangle loI hiI lo hi, mixedLogDensity M G φ w t • F t) - + mixedLogMass M loI hiI G φ w lo hi • F base‖ ≤ + C * mixedLogMass M loI hiI G φ w lo hi := by + have hc := isCompact_mixedLogRectangle loI hiI lo hi + have hdc := continuousOn_mixedLogDensity M loI hiI G φ w lo hi hφ hlo + have hdi := integrableOn_mixedLogDensity M loI hiI G φ w lo hi hφ hlo + have hFi : IntegrableOn (fun t => mixedLogDensity M G φ w t • F t) + (mixedLogRectangle loI hiI lo hi) := + (hdc.smul hF).integrableOn_compact hc + have hbi : IntegrableOn (fun t => mixedLogDensity M G φ w t • F base) + (mixedLogRectangle loI hiI lo hi) := + (hdc.smul continuousOn_const).integrableOn_compact hc + have heq : (∫ t in mixedLogRectangle loI hiI lo hi, mixedLogDensity M G φ w t • F t) - + mixedLogMass M loI hiI G φ w lo hi • F base = + ∫ t in mixedLogRectangle loI hiI lo hi, mixedLogDensity M G φ w t • (F t-F base) := by + unfold mixedLogMass + rw [← integral_smul_const, ← integral_sub hFi hbi] + congr 1 + funext t + exact (smul_sub _ _ _).symm + rw [heq] + calc + _ ≤ ∫ t in mixedLogRectangle loI hiI lo hi, mixedLogDensity M G φ w t * C := by + apply norm_integral_le_of_norm_le (hdi.mul_const C) + filter_upwards [ae_restrict_mem hc.measurableSet] with t ht + have hn := mixedLogDensity_nonneg M loI hiI G φ w lo hi hφ0 hw hlo ht + rw [norm_smul, Real.norm_eq_abs, abs_of_nonneg hn] + exact mul_le_mul_of_nonneg_left (hvar t ht) hn + _ = C * mixedLogMass M loI hiI G φ w lo hi := by + rw [integral_mul_const] + exact mul_comm _ _ + +omit [Fintype ι] [DecidableEq ι] in +theorem mixedLogRectangle_convex (loI hiI : ℝ) (lo hi : ι → ℝ) : + Convex ℝ (mixedLogRectangle loI hiI lo hi) := + (convex_Icc loI hiI).prod (logRectangle_convex lo hi) + +omit [DecidableEq ι] in +theorem mixedLogRectangle_dist_le (loI hiI : ℝ) (lo hi : ι → ℝ) + {mesh : ℝ} (hm : 0 ≤ mesh) (hwidthI : hiI-loI ≤ mesh) + (hwidth : ∀ i, hi i-lo i ≤ mesh) + {x y : ℝ × (ι → ℝ)} + (hx : x ∈ mixedLogRectangle loI hiI lo hi) + (hy : y ∈ mixedLogRectangle loI hiI lo hi) : ‖x-y‖ ≤ mesh := by + rw [Prod.norm_def, max_le_iff] + constructor + · simp only [Prod.fst_sub, Real.norm_eq_abs] + exact abs_le.mpr ⟨by linarith [hx.1.1, hy.1.2], by linarith [hy.1.1, hx.1.2]⟩ + · apply (pi_norm_le_iff_of_nonneg hm).mpr + intro i + simpa only [Prod.snd_sub, Pi.sub_apply, Real.norm_eq_abs] using + logRectangle_coordinate_dist_le lo hi hwidth hx.2 hy.2 i + +omit [DecidableEq ι] in +theorem mixed_positive_integral_freezing_bound (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) + (w lo hi : ι → ℝ) (hφ : Continuous φ) + (hφ0 : ∀ t ∈ Set.Icc loI hiI, 0 ≤ φ (t-G)) + (hw : ∀ i, 0 ≤ w i) (hlo : ∀ i, 0 < lo i) + (f : (ℝ × (ι → ℝ)) → ℂ) {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hwidthI : hiI-loI ≤ mesh) (hwidth : ∀ i, hi i-lo i ≤ mesh) + (hf : ∀ z ∈ mixedLogRectangle loI hiI lo hi, + DifferentiableAt ℝ (fun y => f (mixedExp y)) z) + (hd : ∀ z ∈ mixedLogRectangle loI hiI lo hi, + ‖fderiv ℝ (fun y => f (mixedExp y)) z‖ ≤ D) + {base : ℝ × (ι → ℝ)} (hbase : base ∈ mixedLogRectangle loI hiI lo hi) : + ‖mixedLogIntegral M loI hiI G φ w lo hi f - + mixedLogMass M loI hiI G φ w lo hi • f (mixedExp base)‖ ≤ + D * mesh * mixedLogMass M loI hiI G φ w lo hi := by + apply mixed_freezing_of_variation M loI hiI G φ w lo hi hφ hφ0 hw hlo + (fun y => f (mixedExp y)) + (fun z hz => (hf z hz).continuousAt.continuousWithinAt) base + intro z hz + have h := (mixedLogRectangle_convex loI hiI lo hi).norm_image_sub_le_of_norm_fderiv_le + hf hd hbase hz + exact h.trans (mul_le_mul_of_nonneg_left + (mixedLogRectangle_dist_le loI hiI lo hi hm hwidthI hwidth hz hbase) hD) + +omit [DecidableEq ι] in +theorem residue_mixed_integral_freezing_bound (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) + (Z lo hi : ι → ℝ) (hφ : Continuous φ) + (hφ0 : ∀ t ∈ Set.Icc loI hiI, 0 ≤ φ (t-G)) + (hZ : ∀ i, 0 < Z i) (hlo : ∀ i, 0 < lo i) + (hI : loI ≤ hiI) (horder : ∀ i, lo i ≤ hi i) + (f : (ℝ × (ι → ℝ)) → ℂ) {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hwidthI : hiI-loI ≤ mesh) (hwidth : ∀ i, hi i-lo i ≤ mesh) + (hf : ∀ z ∈ mixedLogRectangle loI hiI lo hi, + DifferentiableAt ℝ (fun y => f (mixedExp y)) z) + (hd : ∀ z ∈ mixedLogRectangle loI hiI lo hi, + ‖fderiv ℝ (fun y => f (mixedExp y)) z‖ ≤ D) + {base : ℝ × (ι → ℝ)} (hbase : base ∈ mixedLogRectangle loI hiI lo hi) : + ‖mixedLogIntegral M loI hiI G φ (fun i => ((Nat.totient M : ℝ) * Z i)⁻¹) lo hi f - + (IntegerCell.integerDensityMass M loI hiI G φ * + ∏ i, PrimeProgression.harmonicIntegral M (lo i) (hi i) / Z i) • f (mixedExp base)‖ ≤ + D * mesh * (IntegerCell.integerDensityMass M loI hiI G φ * + ∏ i, PrimeProgression.harmonicIntegral M (lo i) (hi i) / Z i) := by + rw [← residue_mixedLogMass_eq M loI hiI G φ Z lo hi hI horder] + exact mixed_positive_integral_freezing_bound M loI hiI G φ _ lo hi hφ hφ0 + (fun i => inv_nonneg.mpr (mul_nonneg (Nat.cast_nonneg _) (hZ i).le)) + hlo f hD hm hwidthI hwidth hf hd hbase + +end Ostmann.Arithmetic.MixedCellIntegralFreezing + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellIntegralFreezingLog.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellIntegralFreezingLog.lean new file mode 100644 index 0000000000000000000000000000000000000000..b978ab4b22119aebfbbf9c12ab355bf663405a04 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellIntegralFreezingLog.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MixedCellIntegralFreezing + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.MixedCellIntegralFreezing +open MeasureTheory PrimeCellFreezing Characters.RationalHistory +open scoped BigOperators +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def optionCoordinates (t : ℝ × (ι → ℝ)) : Option ι → ℝ := Option.elim' t.1 t.2 + +omit [Fintype ι] [DecidableEq ι] in +theorem continuous_optionCoordinates : Continuous (optionCoordinates (ι := ι)) := by + apply continuous_pi + intro i + cases i with + | none => exact continuous_fst + | some i => exact (continuous_apply i).comp continuous_snd + +omit [Fintype ι] [DecidableEq ι] in +theorem optionCoordinates_mem_logRectangle (loI hiI : ℝ) (lo hi : ι → ℝ) + {t : ℝ × (ι → ℝ)} : + optionCoordinates t ∈ logRectangle (Option.elim' loI lo) (Option.elim' hiI hi) ↔ + t ∈ mixedLogRectangle loI hiI lo hi := by + constructor + · intro h + exact ⟨h none (Set.mem_univ _), fun i _ => h (some i) (Set.mem_univ _)⟩ + · intro h i _ + cases i with + | none => exact h.1 + | some i => exact h.2 i (Set.mem_univ i) + +omit [Fintype ι] [DecidableEq ι] in +@[simp] theorem optionCoordinates_mixedExp (t : ℝ × (ι → ℝ)) : + optionCoordinates (mixedExp t) = fun j => Real.exp (optionCoordinates t j) := by + funext j + cases j <;> rfl + +theorem mixed_integral_freezing_of_log_partials + (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) (w lo hi : ι → ℝ) + (hφ : Continuous φ) (hφ0 : ∀ t ∈ Set.Icc loI hiI, 0 ≤ φ (t-G)) + (hw : ∀ i, 0 ≤ w i) (hlo : ∀ i, 0 < lo i) + (f : (Option ι → ℝ) → ℂ) {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hwidthI : hiI-loI ≤ mesh) (hwidth : ∀ i, hi i-lo i ≤ mesh) + (hf : ∀ z ∈ logRectangle (Option.elim' loI lo) (Option.elim' hiI hi), + DifferentiableAt ℝ (fun y => f (fun j => Real.exp (y j))) z) + (hd : ∀ z ∈ logRectangle (Option.elim' loI lo) (Option.elim' hiI hi), ∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun j => Real.exp (z j)) i t)) 0‖ ≤ D) + {base : ℝ × (ι → ℝ)} (hbase : base ∈ mixedLogRectangle loI hiI lo hi) : + ‖mixedLogIntegral M loI hiI G φ w lo hi (fun x => f (optionCoordinates x)) - + mixedLogMass M loI hiI G φ w lo hi • f (optionCoordinates (mixedExp base))‖ ≤ + ((Fintype.card ι : ℝ)+1)*D*mesh * mixedLogMass M loI hiI G φ w lo hi := by + have hF : ContinuousOn (fun z => f (optionCoordinates (mixedExp z))) + (mixedLogRectangle loI hiI lo hi) := by + intro z hz + have hh := (hf (optionCoordinates z) + ((optionCoordinates_mem_logRectangle loI hiI lo hi).mpr hz)).continuousAt.comp + continuous_optionCoordinates.continuousAt + simpa only [Function.comp_def, optionCoordinates_mixedExp] using hh.continuousWithinAt + (s := mixedLogRectangle loI hiI lo hi) + apply mixed_freezing_of_variation M loI hiI G φ w lo hi hφ hφ0 hw hlo + (fun z => f (optionCoordinates (mixedExp z))) hF base + intro z hz + have hwidth' : ∀ i : Option ι, + Option.elim' hiI hi i - Option.elim' loI lo i ≤ mesh := by + intro i + cases i with + | none => exact hwidthI + | some i => exact hwidth i + have hz' := (optionCoordinates_mem_logRectangle loI hiI lo hi).mpr hz + have hb' := (optionCoordinates_mem_logRectangle loI hiI lo hi).mpr hbase + have h := positive_norm_sub_le f (Option.elim' loI lo) (Option.elim' hiI hi) + hD hm hf hd hz' hb' + (logRectangle_coordinate_dist_le _ _ hwidth' hz' hb') + simpa only [Fintype.card_option, Nat.cast_add, Nat.cast_one, optionCoordinates_mixedExp] using h + +theorem residue_mixed_integral_freezing_of_log_partials + (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) (Z lo hi : ι → ℝ) + (hφ : Continuous φ) (hφ0 : ∀ t ∈ Set.Icc loI hiI, 0 ≤ φ (t-G)) + (hZ : ∀ i, 0 < Z i) (hlo : ∀ i, 0 < lo i) + (hI : loI ≤ hiI) (horder : ∀ i, lo i ≤ hi i) + (f : (Option ι → ℝ) → ℂ) {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hwidthI : hiI-loI ≤ mesh) (hwidth : ∀ i, hi i-lo i ≤ mesh) + (hf : ∀ z ∈ logRectangle (Option.elim' loI lo) (Option.elim' hiI hi), + DifferentiableAt ℝ (fun y => f (fun j => Real.exp (y j))) z) + (hd : ∀ z ∈ logRectangle (Option.elim' loI lo) (Option.elim' hiI hi), ∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun j => Real.exp (z j)) i t)) 0‖ ≤ D) + {base : ℝ × (ι → ℝ)} (hbase : base ∈ mixedLogRectangle loI hiI lo hi) : + ‖mixedLogIntegral M loI hiI G φ (fun i => ((Nat.totient M : ℝ)*Z i)⁻¹) lo hi + (fun x => f (optionCoordinates x)) - + (IntegerCell.integerDensityMass M loI hiI G φ * + ∏ i, PrimeProgression.harmonicIntegral M (lo i) (hi i)/Z i) • + f (optionCoordinates (mixedExp base))‖ ≤ + ((Fintype.card ι : ℝ)+1)*D*mesh * (IntegerCell.integerDensityMass M loI hiI G φ * + ∏ i, PrimeProgression.harmonicIntegral M (lo i) (hi i)/Z i) := by + rw [← residue_mixedLogMass_eq M loI hiI G φ Z lo hi hI horder] + exact mixed_integral_freezing_of_log_partials M loI hiI G φ _ lo hi hφ hφ0 + (fun i => inv_nonneg.mpr (mul_nonneg (Nat.cast_nonneg _) (hZ i).le)) + hlo f hD hm hwidthI hwidth hf hd hbase + +end Ostmann.Arithmetic.MixedCellIntegralFreezing + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellIntegralFreezingMass.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellIntegralFreezingMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..649ad11e2ea208e35eb3cfe4fb7bfeb7a47a418d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellIntegralFreezingMass.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.IntegerCell +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellIntegralFreezing + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.MixedCellIntegralFreezing +open MeasureTheory PrimeCellFreezing +open scoped BigOperators +variable {ι : Type*} [Fintype ι] + +def mixedLogRectangle (loI hiI : ℝ) (lo hi : ι → ℝ) : Set (ℝ × (ι → ℝ)) := + Set.Icc loI hiI ×ˢ logRectangle lo hi + +def mixedLogDensity (M : ℕ) (G : ℝ) (φ : ℝ → ℝ) (w : ι → ℝ) + (t : ℝ × (ι → ℝ)) : ℝ := + (Real.exp (t.1-G) * φ (t.1-G) / (M : ℝ)) * logCellDensity w t.2 + +def mixedLogMass (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) (w lo hi : ι → ℝ) : ℝ := + ∫ t in mixedLogRectangle loI hiI lo hi, mixedLogDensity M G φ w t + +theorem mixedLogMass_eq (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) (w lo hi : ι → ℝ) + (hI : loI ≤ hiI) : + mixedLogMass M loI hiI G φ w lo hi = + IntegerCell.integerDensityMass M loI hiI G φ * logCellMass w lo hi := by + unfold mixedLogMass mixedLogDensity mixedLogRectangle + change (∫ t in Set.Icc loI hiI ×ˢ logRectangle lo hi, + (Real.exp (t.1-G) * φ (t.1-G) / (M : ℝ)) * logCellDensity w t.2 + ∂(volume.prod volume)) = _ + rw [setIntegral_prod_mul (fun t : ℝ => Real.exp (t-G) * φ (t-G) / (M : ℝ)) + (logCellDensity w) (Set.Icc loI hiI) (logRectangle lo hi)] + congr 1 + simp_rw [div_eq_mul_inv] + rw [integral_mul_const, integral_Icc_eq_integral_Ioc, + ← intervalIntegral.integral_of_le hI] + rfl + +theorem residue_mixedLogMass_eq (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) (Z lo hi : ι → ℝ) + (hI : loI ≤ hiI) (horder : ∀ i, lo i ≤ hi i) : + mixedLogMass M loI hiI G φ (fun i => ((Nat.totient M : ℝ) * Z i)⁻¹) lo hi = + IntegerCell.integerDensityMass M loI hiI G φ * + ∏ i, PrimeProgression.harmonicIntegral M (lo i) (hi i) / Z i := by + rw [mixedLogMass_eq M loI hiI G φ _ lo hi hI, + residue_logCellMass_eq_prod M Z lo hi horder] + +omit [Fintype ι] in +theorem isCompact_mixedLogRectangle (loI hiI : ℝ) (lo hi : ι → ℝ) : + IsCompact (mixedLogRectangle loI hiI lo hi) := + isCompact_Icc.prod (isCompact_logRectangle lo hi) + +theorem continuousOn_mixedLogDensity (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) + (w lo hi : ι → ℝ) (hφ : Continuous φ) (hlo : ∀ i, 0 < lo i) : + ContinuousOn (mixedLogDensity M G φ w) (mixedLogRectangle loI hiI lo hi) := by + have hI : Continuous (fun t : ℝ × (ι → ℝ) => + Real.exp (t.1-G) * φ (t.1-G) / (M : ℝ)) := by fun_prop + exact hI.continuousOn.mul ((continuousOn_logCellDensity w lo hi hlo).comp + continuous_snd.continuousOn (fun _ ht => ht.2)) + +theorem integrableOn_mixedLogDensity (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) + (w lo hi : ι → ℝ) (hφ : Continuous φ) (hlo : ∀ i, 0 < lo i) : + IntegrableOn (mixedLogDensity M G φ w) (mixedLogRectangle loI hiI lo hi) := + (continuousOn_mixedLogDensity M loI hiI G φ w lo hi hφ hlo).integrableOn_compact + (isCompact_mixedLogRectangle loI hiI lo hi) + +theorem mixedLogDensity_nonneg (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) + (w lo hi : ι → ℝ) (hφ : ∀ t ∈ Set.Icc loI hiI, 0 ≤ φ (t-G)) + (hw : ∀ i, 0 ≤ w i) (hlo : ∀ i, 0 < lo i) + {t : ℝ × (ι → ℝ)} (ht : t ∈ mixedLogRectangle loI hiI lo hi) : + 0 ≤ mixedLogDensity M G φ w t := + mul_nonneg (div_nonneg (mul_nonneg (Real.exp_pos _).le (hφ t.1 ht.1)) (Nat.cast_nonneg M)) + (logCellDensity_nonneg w lo hi hw hlo ht.2) + +theorem mixedLogMass_nonneg (M : ℕ) (loI hiI G : ℝ) (φ : ℝ → ℝ) + (w lo hi : ι → ℝ) (hφ : ∀ t ∈ Set.Icc loI hiI, 0 ≤ φ (t-G)) + (hw : ∀ i, 0 ≤ w i) (hlo : ∀ i, 0 < lo i) : + 0 ≤ mixedLogMass M loI hiI G φ w lo hi := by + apply setIntegral_nonneg (isCompact_mixedLogRectangle loI hiI lo hi).measurableSet + intro t ht + exact mixedLogDensity_nonneg M loI hiI G φ w lo hi hφ hw hlo ht + +end Ostmann.Arithmetic.MixedCellIntegralFreezing + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellJointReplacementAlgebra.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellJointReplacementAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1dfd69e7cb1260e1a5b2b8dcb2a8c7469ff4da3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellJointReplacementAlgebra.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MixedCellJointReplacementPrior + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.MixedCellJointReplacement +open scoped BigOperators + +theorem mixed_sum_error {α β : Type*} [Fintype α] [Fintype β] + (μ : α → ℝ) (J : ℝ) (X : α → ℂ) (P : ℂ) (F : α → β → ℂ) + {E Q B : ℝ} (hE : 0 ≤ E) (_hQ : 0 ≤ Q) (hB : 0 ≤ B) + (hμ : ∀ r, |μ r-J| ≤ E) (hP : ‖P‖ ≤ B) + (hX : ∀ r, ‖X r-P*(∑ u, F r u)‖ ≤ Q*(∑ u, ‖F r u‖)) : + ‖(∑ r, (μ r : ℂ)*X r)-(J : ℂ)*P*(∑ r, ∑ u, F r u)‖ ≤ + (E*B+(|J|+E)*Q)*(∑ r, ∑ u, ‖F r u‖) := by + have hm (r : α) : ‖(μ r : ℂ)‖ ≤ |J|+E := by + have h := abs_add_le (μ r-J) J + rw [sub_add_cancel] at h + simp only [Complex.norm_real, Real.norm_eq_abs] + linarith [hμ r] + have hd (r : α) : ‖(μ r : ℂ)-(J : ℂ)‖ ≤ E := by + simpa only [← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] using hμ r + have hp (r : α) : ‖(μ r : ℂ)*X r-(J : ℂ)*P*(∑ u, F r u)‖ ≤ + (E*B+(|J|+E)*Q)*(∑ u, ‖F r u‖) := by + have he : (μ r : ℂ)*X r-(J : ℂ)*P*(∑ u, F r u) = + (μ r : ℂ)*(X r-P*(∑ u, F r u))+ + ((μ r : ℂ)-(J : ℂ))*P*(∑ u, F r u) := by ring + rw [he] + calc + _ ≤ ‖(μ r : ℂ)*(X r-P*(∑ u, F r u))‖+ + ‖((μ r : ℂ)-(J : ℂ))*P*(∑ u, F r u)‖ := norm_add_le _ _ + _ = ‖(μ r : ℂ)‖*‖X r-P*(∑ u, F r u)‖+ + ‖(μ r : ℂ)-(J : ℂ)‖*‖P‖*‖∑ u, F r u‖ := by simp only [norm_mul] + _ ≤ (|J|+E)*(Q*(∑ u, ‖F r u‖))+E*B*(∑ u, ‖F r u‖) := by + apply add_le_add + · exact mul_le_mul (hm r) (hX r) (norm_nonneg _) (by positivity) + · exact mul_le_mul (mul_le_mul (hd r) hP (norm_nonneg _) hE) + (norm_sum_le _ _) (norm_nonneg _) (mul_nonneg hE hB) + _ = _ := by ring + rw [Finset.mul_sum, ← Finset.sum_sub_distrib] + calc + _ ≤ ∑ r, ‖(μ r : ℂ)*X r-(J : ℂ)*P*(∑ u, F r u)‖ := norm_sum_le _ _ + _ ≤ ∑ r, (E*B+(|J|+E)*Q)*(∑ u, ‖F r u‖) := Finset.sum_le_sum (fun r _ => hp r) + _ = _ := (Finset.mul_sum _ _ _).symm + +end Ostmann.Arithmetic.MixedCellJointReplacement +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellJointReplacementPrior.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellJointReplacementPrior.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0ff4543bd197d850247be7949428c8a971882dd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MixedCellJointReplacementPrior.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.IntegerCell +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellJointReplacement + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.MixedCellJointReplacement +open scoped BigOperators +open PrimeCellReplacement +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def mixedComplexTestSum (NI : ℕ) (N : ι → ℕ) (M : ℕ) [NeZero M] + (loI hiI G : ℝ) (φ : ℝ → ℝ) (lo hi Z : ι → ℝ) + (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) : ℂ := + ∑ n ∈ IntegerCell.cellSupport NI loI hiI, + ((Real.exp (-G)*φ (Real.log n-G) : ℝ) : ℂ)* + jointComplexTestSum N M lo hi Z (F (n : ZMod M)) + +theorem mixedComplexTestSum_expanded (NI : ℕ) (N : ι → ℕ) (M : ℕ) [NeZero M] + (loI hiI G : ℝ) (φ : ℝ → ℝ) (lo hi Z : ι → ℝ) + (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) : + mixedComplexTestSum NI N M loI hiI G φ lo hi Z F = + ∑ n ∈ IntegerCell.cellSupport NI loI hiI, ∑ p : PrimeCellTuple N lo hi, + ((Real.exp (-G)*φ (Real.log n-G) : ℝ) : ℂ)* + (∏ i, (((Z i*((p i).val : ℝ))⁻¹ : ℝ) : ℂ))* + jointUnitTest (F (n : ZMod M)) (fun i => ((p i).val : ZMod M)) := by + simp only [mixedComplexTestSum, jointComplexTestSum, Finset.mul_sum, mul_assoc] + +theorem mixedComplexTestSum_eq_integer (NI : ℕ) (N : ι → ℕ) (M : ℕ) [NeZero M] + (loI hiI G : ℝ) (φ : ℝ → ℝ) (lo hi Z : ι → ℝ) + (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) : + mixedComplexTestSum NI N M loI hiI G φ lo hi Z F = + ∑ r : ZMod M, (IntegerCell.integerResidueMass NI M r loI hiI G φ : ℂ)* + jointComplexTestSum N M lo hi Z (F r) := by + exact IntegerCell.complexTestSum_eq NI M loI hiI G φ + (fun r => jointComplexTestSum N M lo hi Z (F r)) + +theorem mixedComplexTestSum_eq (NI : ℕ) (N : ι → ℕ) (M : ℕ) [NeZero M] + (loI hiI G : ℝ) (φ : ℝ → ℝ) (lo hi Z : ι → ℝ) + (F : ZMod M → (ι → (ZMod M)ˣ) → ℂ) : + mixedComplexTestSum NI N M loI hiI G φ lo hi Z F = + ∑ r : ZMod M, ∑ u : ι → (ZMod M)ˣ, + (IntegerCell.integerResidueMass NI M r loI hiI G φ : ℂ)* + (∏ i, (residueMass (N i) M (u i) (lo i) (hi i) (Z i) : ℂ))*F r u := by + rw [mixedComplexTestSum_eq_integer] + simp only [jointComplexTestSum_eq, Finset.mul_sum, mul_assoc] + +end Ostmann.Arithmetic.MixedCellJointReplacement +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MonomialDenominators.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MonomialDenominators.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b32187b7ddec8f34b7839eeaf83d7db9b5fe5df --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MonomialDenominators.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.HistoryFieldEvaluation +import OAI.NumberTheory.Ostmann.Characters.RationalHistoryVariables + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.MonomialDenominators +open MvPolynomial + +variable {ι : Type*} + +inductive Generated (S : Set ℤ) : MvPolynomial ι ℤ → Prop + | one : Generated S 1 + | constant (c : ℤ) (hc : c ∈ S) : Generated S (C c) + | var (i : ι) : Generated S (X i) + | mul {P Q : MvPolynomial ι ℤ} : Generated S P → Generated S Q → Generated S (P*Q) + +theorem Generated.exists_monomial {S : Set ℤ} {P : MvPolynomial ι ℤ} + (hP : Generated S P) {K : Type*} [Field K] + (hS : ∀ c ∈ S, (c:K) ≠ 0) : + ∃ (d : ι →₀ ℕ) (c : ℤ), P = monomial d c ∧ (c:K) ≠ 0 := by + classical + induction hP with + | one => exact ⟨0,1,by simp,by simp⟩ + | constant c hc => exact ⟨0,c,rfl,hS c hc⟩ + | var i => exact ⟨Finsupp.single i 1,1,rfl,by simp⟩ + | @mul P Q hP hQ ihP ihQ => + obtain ⟨d,c,rfl,hc⟩ := ihP + obtain ⟨e,b,rfl,hb⟩ := ihQ + exact ⟨d+e,c*b,by rw [monomial_mul_monomial],by simpa only [Int.cast_mul] using mul_ne_zero hc hb⟩ + +theorem Generated.eval₂_ne_zero {S : Set ℤ} {P : MvPolynomial ι ℤ} + (hP : Generated S P) {K : Type*} [Field K] [DecidableEq ι] + (hS : ∀ c ∈ S, (c:K) ≠ 0) (x : ι → K) + (hx : ∀ i ∈ P.vars, x i ≠ 0) : eval₂ (Int.castRingHom K) x P ≠ 0 := by + obtain ⟨d,c,rfl,hc⟩ := hP.exists_monomial hS + have hcZ : c ≠ 0 := by intro h; exact hc (by simp [h]) + rw [vars_monomial hcZ] at hx + rw [eval₂_monomial] + apply mul_ne_zero hc + change (∏ i ∈ d.support, x i ^ d i) ≠ 0 + exact Finset.prod_ne_zero_iff.mpr (fun i hi => pow_ne_zero _ (hx i hi)) + +end Ostmann.Arithmetic.MonomialDenominators + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingActualLineComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingActualLineComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..882df45dcfb0d19c4ba4a16dbc36a5620df40758 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingActualLineComparison.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampledIndexedProbability +import OAI.NumberTheory.Ostmann.Arithmetic.MovingLineProductComparison + +namespace OAI + +/-! # Symbolic replacement for the actual two-history internal line factors -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem moving_actual_line_product_comparison {A J : Type*} + [Fintype A] [Nonempty A] [Fintype J] {N n : ℕ} + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (T : Bool → MovingSlotData (Fin (N + 1)) n) (tier : Fin (N + 1) → ℕ) + (hlevels : ∀ side, (T side).Levels tier) + (rep : J → Fin (N + 1)) (base : ∀ j, MovingPairRepresentativeOccurrences T (rep j)) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ side, (T side).SizeLE d) + (hfreq : ∀ side, (T side).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : Fin (N + 1) → A → ℝ) (hμ : ∀ i a, 0 ≤ μ i a) + (hmass : ∀ i, ∑ a, μ i a = 1) + (α β V : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hmax : ∀ i a, μ i a ≤ α) (hpmax : ∀ j a, μ (rep j) a ≤ β) + (hprimeSize : ∀ j a, μ (rep j) a ≠ 0 → V ≤ Real.log (prime a : ℝ)) + (weight : (Fin (N + 1) → A) → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hweight : ∀ x, ‖weight x‖ * ∏ j, internalLineScalar true (prime (x (rep j))) ≤ B) + (hdisjoint : ∀ x, weight x ≠ 0 → ∀ i j, + tier i ≠ tier j → prime (x i) ≠ prime (x j)) + (hunique : ∀ x, weight x ≠ 0 → ∀ j i, prime (x i) = prime (x (rep j)) → i = rep j) + (hfmod : ∀ x, weight x ≠ 0 → ∀ j side, + (T side).Frequencies (fun s => (s : ZMod (prime (x (rep j)))) ≠ 0)) : + ‖∑ x, (productPrior μ x : ℂ) * weight x * + ((∏ j, (movingSampledInternalProbability prime hprime T x (rep j) : ℂ)) - + ∏ j, (internalLineFlagWeight true (prime (x (rep j))) + (fun s => arithmeticTestFlag (lineTestPolynomials + (movingIndexedLine T (rep j) (base j)) ⟨(base j).1, (base j).2.val⟩ s = 0)) : ℂ))‖ ≤ + 2 * B * (Fintype.card J * (2 + Fintype.card (MovingPairOccurrenceIndex T))) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β) := by + let path := fun j o => (movingIndexedOccurrence T (rep j) (base j) o).path + let current := fun j o => (movingIndexedOccurrence T (rep j) (base j) o).current + let b : J → MovingPairOccurrenceIndex T := fun j => ⟨(base j).1, (base j).2.val⟩ + have hi : Function.Injective (fun a => (prime a : ℤ)) := by + intro a b h + apply hpInj + exact Int.ofNat.inj h + have hu (x : Fin (N + 1) → A) (hx : weight x ≠ 0) (j : J) (o : MovingPairOccurrenceIndex T) := + movingIndexedOccurrence_units T tier (fun i => prime (x i)) (fun i => hprime (x i)) + (hdisjoint x hx) hlevels (rep j) (base j) (hfmod x hx j) o + have h := moving_slot_line_product_comparison (fun a => (prime a : ℤ)) hi prime hpInj hprime + path current b rep (fun _ => true) n d F U hF hU + (fun j o => movingIndexedOccurrence_path_length T tier hlevels (rep j) (base j) o) + (fun j o => movingIndexedOccurrence_size T d F hsize hfreq (rep j) (base j) o) + (fun j o => movingIndexedOccurrence_absent T tier hlevels (rep j) (base j) o) + hvalues μ hμ hmass α β V hα hβ hV hmax hpmax hprimeSize weight B hB hweight + (by + intro x hx j o s hs + simpa only [integerLineReduction, MovingSlotReversal.naturalReduction, Int.cast_natCast] using + (hu x hx j o).1 s hs) + (by + intro x hx j + simpa only [integerLineReduction, MovingSlotReversal.naturalReduction, Int.cast_natCast] using + (hu x hx j (b j)).2) + have he (x : Fin (N + 1) → A) : + weight x * (∏ j, (movingSampledInternalProbability prime hprime T x (rep j) : ℂ)) = + weight x * ∏ j, (movingSlotLineProbability (fun a => (prime a : ℤ)) prime hprime + (path j) (current j) true x (x (rep j)) : ℂ) := by + by_cases hx : weight x = 0 + · simp only [hx, zero_mul] + · congr 1 + apply Finset.prod_congr rfl + intro j _ + exact congrArg (fun r : ℝ => (r : ℂ)) + (movingSampledIndexedProbability prime hprime x T tier (hdisjoint x hx) hlevels + (rep j) (base j) (hunique x hx j) (hfmod x hx j)) + convert h using 1 + congr 1 + apply Finset.sum_congr rfl + intro x _ + rw [mul_assoc, mul_sub, he, ← mul_sub, ← mul_assoc] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAdaptiveSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAdaptiveSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f8c8693fe4478f9a2112191d0bc1f2604f5842d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAdaptiveSupport.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNodeUnits +import OAI.NumberTheory.Ostmann.Construction.CompensatedAdaptiveSupport +import OAI.NumberTheory.Ostmann.Arithmetic.ForwardHistorySupport + +namespace OAI + +/-! # Constructed adaptive support for the original moving-giant sampler -/ + +namespace Ostmann +open scoped Classical + +noncomputable def movingSampledPivotHistory {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (n Q : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) (XL XR : ℕ) + (y : TreeLeafTuple (ZMod Q)ˣ n) + (hy : treeIntegerResidues Q n + (treeLeafMap (fun q : ℕ => (q : ℤ)) n (movingSlotValues value n bulk)) y) : + SampledPivotHistory n Q where + bulk := treeLeafMap (fun q : ℕ => (q : ℤ)) n (movingSlotValues value n bulk) + residue := y + pivots := movingGiantArray value childBound pivotBound n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ t + compatible := hy + +theorem movingSampledPivotHistory_valid {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (S : Finset ℤ) (n Q : ℕ) (t : FrequencyTree S n) + (small bulk : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) (XL XR : ℕ) + (y : TreeLeafTuple (ZMod Q)ˣ n) + (hy : treeIntegerResidues Q n + (treeLeafMap (fun q : ℕ => (q : ℤ)) n (movingSlotValues value n bulk)) y) + (hsmall : ∀ i s, s ∈ S → IsCoprime (value i : ℤ) s) + (hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingGuardedExtra value outside E)) n + ⟨n, buildMovingSlotData n (frequencyTreeMap Subtype.val n t) small bulk a, XL, XR⟩ + (frequencyTreeMap Subtype.val n t) ≠ 0) : + (movingSampledPivotHistory value childBound pivotBound n Q + (frequencyTreeMap Subtype.val n t) small bulk a XL XR y hy).compensatedValid + (movingSampleAncestorScheme value S n t small a XL XR) + (movingSampleCompensation value n small a) := by + exact ⟨movingSample_compensatedEquations value childBound pivotBound F + (movingGuardedExtra value outside E) S n t small bulk a XL XR hw, + movingSample_coefficient_units value outside childBound pivotBound F E S n t + small bulk a XL XR hsmall hw⟩ + +theorem movingFrameConstants_compensation_coprime {σ : Type*} (value : σ → ℕ) + (R : ℤ) (hsmall : ∀ i, IsCoprime (value i : ℤ) R) (n : ℕ) + (small : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) (path : List Bool) : + IsCoprime ((movingFrameConstants value n small a path).compensation : ℤ) R := by + induction n generalizing path with + | zero => + cases a + change IsCoprime (1 : ℤ) R + exact isCoprime_one_left + | succ n ih => + cases a with + | node a l r => + cases path with + | nil => exact movingNaturalProduct_coprime value _ R (fun i _ => hsmall i) + | cons b path => cases b <;> apply ih + +/-- The prefix tests are built from actual samples and are passed by every +nonzero original history. There is no assumed adaptive-support event. -/ +theorem movingSample_adaptive_support {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (S : Finset ℤ) (n R : ℕ) [NeZero (R ^ (n + 2))] (t : FrequencyTree S n) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ∣ R) + (small bulk : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) (XL XR : ℕ) + (hsmall : ∀ i, IsCoprime (value i : ℤ) (R : ℤ)) + (y : TreeLeafTuple (ZMod (R ^ (n + 2)))ˣ n) + (hy : treeIntegerResidues (R ^ (n + 2)) n + (treeLeafMap (fun q : ℕ => (q : ℤ)) n (movingSlotValues value n bulk)) y) + (hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingGuardedExtra value outside E)) n + ⟨n, buildMovingSlotData n (frequencyTreeMap Subtype.val n t) small bulk a, XL, XR⟩ + (frequencyTreeMap Subtype.val n t) ≠ 0) : + let D := movingSampleAncestorScheme value S n t small a XL XR + let hs : ∀ i, (D.frequencies i).root ≠ 0 := + fun i => (hS _ (singleTreeNodeFrequencies_root_mem S n t i.val i.isLt)).1 + let hsR : ∀ i, (D.frequencies i).root.natAbs ∣ R := + fun i => (hS _ (singleTreeNodeFrequencies_root_mem S n t i.val i.isLt)).2 + singleArithmeticLeafSupport n + (compensatedAdaptiveData n R n D (movingSampleCompensation value n small a) hs hsR) y = 1 := by + dsimp only + let hist := movingSampledPivotHistory value childBound pivotBound n (R ^ (n + 2)) + (frequencyTreeMap Subtype.val n t) small bulk a XL XR y hy + have hs : ∀ i s, s ∈ S → IsCoprime (value i : ℤ) s := by + intro i s hmem + exact (hsmall i).of_isCoprime_of_dvd_right + (Int.natAbs_dvd.mp (Int.natCast_dvd_natCast.mpr (hS s hmem).2)) + apply compensatedAdaptiveData_actual_support n R n + (movingSampleAncestorScheme value S n t small a XL XR) + (movingSampleCompensation value n small a) + (fun i => movingFrameConstants_compensation_coprime value R hsmall n small a _) + (fun i => (preorderNodePath_length n i).le) + (fun i => (hS _ (singleTreeNodeFrequencies_root_mem S n t i.val i.isLt)).1) + (fun i => (hS _ (singleTreeNodeFrequencies_root_mem S n t i.val i.isLt)).2) + hist + exact movingSampledPivotHistory_valid value outside childBound pivotBound F E S n _ t + small bulk a XL XR y hy hs hw + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAlphabetRestriction.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAlphabetRestriction.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae37048a069692a4ae0a9e0d4ac632c5c10382fc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAlphabetRestriction.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Construction.SupportedAlphabetSum +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalWeightRelabel +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTree + +namespace OAI + +/-! # The original moving sampler on a smaller live alphabet -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingCompensationExtra_map {A B : Type*} (e : B → A) (value : A → ℕ) + {n : ℕ} (T : MovingSlotData B n) (s v w : ℤ) : + movingCompensationExtra value (T.map e) s v w = + movingCompensationExtra (value ∘ e) T s v w := by + cases T <;> simp only [MovingSlotData.map, movingCompensationExtra, + MovingSlotReversal.naturalProduct_map] + +theorem movingOriginalSampleAverage_alphabet {A B I : Type} [Fintype A] [Fintype B] + (e : B ↪ A) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : A → ℕ) (outside : List ℕ) (μ : ℕ → A → ℝ) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData A n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (XL XR : ℕ) (hμ : ∀ j a, j < n → μ j a ≠ 0 → a ∈ Set.range e) : + movingOriginalSampleAverage q value outside μ childBound pivotBound F g Dq S ψ X lo hi φ G + n t (treeLeafMap (List.map e) n small) (treeLeafMap (List.map e) n bulk) XL XR = + movingOriginalSampleAverage q (value ∘ e) outside (fun j b => μ j (e b)) childBound pivotBound + (fun T => F (T.map e)) g Dq S ψ X lo hi φ G n t small bulk XL XR := by + unfold movingOriginalSampleAverage + rw [movingSamplesPrior_alphabet_sum e μ n _ hμ] + apply Finset.sum_congr rfl + intro a _ + congr 1 + rw [← buildMovingSlotData_map, movingOriginalGiantWeight_map, movingSupportedWeight_map] + congr 2 + funext d T s v w + exact movingCompensationExtra_map e value T s v w + +theorem movingFrequencyCoefficient_original_alphabet {A B I : Type} [Fintype A] [Fintype B] + (e : B ↪ A) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : A → ℕ) (outside : List ℕ) (μ : ℕ → A → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData A n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (s : ℤ) (small bulk : TreeLeafTuple (List B) n) + (XL XR : ℕ) (hμ : ∀ j a, j < n → μ j a ≠ 0 → a ∈ Set.range e) : + movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map e) n small) (treeLeafMap (List.map e) n bulk) XL XR = + movingFrequencyCoefficient (value ∘ e) outside (fun j b => μ j (e b)) childBound pivotBound V + (movingOriginalLeaf (value ∘ e) q (fun T => F (T.map e)) g Dq S ψ X lo hi) + φ G n s small bulk XL XR := by + simp only [movingFrequencyCoefficient_original] + apply Finset.sum_congr rfl + intro t _ + exact movingOriginalSampleAverage_alphabet e q value outside μ childBound pivotBound F g Dq S + ψ X lo hi φ G n _ small bulk XL XR hμ + +theorem movingTemplateCoefficient_original_alphabet {A B I : Type} [Fintype A] [Fintype B] + (e : B ↪ A) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : A → ℕ) (outside : List ℕ) (μ : ℕ → A → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData A n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n r m : ℕ) (s : ℤ) (y : MovingRegularSlot n r m → B) + (XL XR : ℕ) (hμ : ∀ j a, j < n → μ j a ≠ 0 → a ∈ Set.range e) : + movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n r m s (e ∘ y) XL XR = + movingTemplateCoefficient (value ∘ e) outside (fun j b => μ j (e b)) childBound pivotBound V + (movingOriginalLeaf (value ∘ e) q (fun T => F (T.map e)) g Dq S ψ X lo hi) + φ G n r m s y XL XR := by + unfold movingTemplateCoefficient + rw [← treeLeafMap_list_comp, ← treeLeafMap_list_comp] + exact movingFrequencyCoefficient_original_alphabet e q value outside μ childBound pivotBound V F + g Dq S ψ X lo hi φ G n s _ _ XL XR hμ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeAlphabet.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeAlphabet.lean new file mode 100644 index 0000000000000000000000000000000000000000..e88c55beab6715360e103b100add51b5fc5578c1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeAlphabet.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAlphabetRestriction +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateAmplitude + +namespace OAI + +/-! # The literal prime amplitude is unchanged by restricting live regular primes -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplatePrimeAmplitude_original_alphabet {A B I : Type} + [Fintype A] [Fintype B] + (e : B ↪ A) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : A → ℕ) (outside : List ℕ) (μ : ℕ → A → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData A n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n r m : ℕ) (Pg : Finset ℕ) (ρ : Pg → ℝ) + (ν : MovingRegularSlot n r m → A → ℝ) + (hμ : ∀ j a, j < n → μ j a ≠ 0 → a ∈ Set.range e) + (hν : ∀ i a, ν i a ≠ 0 → a ∈ Set.range e) + (greg ggiant : ∀ p : ℕ, ZMod p → ℂ) (favorable : ℕ → Bool) : + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n r m Pg ρ ν greg ggiant favorable = + movingTemplatePrimeAmplitude (value ∘ e) outside (fun j b => μ j (e b)) childBound pivotBound V + (movingOriginalLeaf (value ∘ e) q (fun T => F (T.map e)) g Dq S ψ X lo hi) + φ G n r m Pg ρ (fun i b => ν i (e b)) greg ggiant favorable := by + unfold movingTemplatePrimeAmplitude + apply Finset.sum_congr rfl + intro XL _ + congr 1 + apply Finset.sum_congr rfl + intro XR _ + congr 1 + apply Finset.sum_congr rfl + intro s _ + have he := productPrior_alphabet_sum e ν (fun y => + movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n r m s.val y XL XR * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then (XL : ℕ) else (XR : ℕ)) (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s.val) hν + simp only [finite_univ_canonical] at he ⊢ + rw [he] + apply Finset.sum_congr rfl + intro y _ + rw [movingTemplateCoefficient_original_alphabet e q value outside μ childBound pivotBound V + F g Dq S ψ X lo hi φ G n r m s.val y XL XR hμ] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeCoefficientSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeCoefficientSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..accd01cf42029acf63be95d549f66c8401b6f2d7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeCoefficientSupport.lean @@ -0,0 +1,339 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNodeCoefficientSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingConstructedLiveProductStep + +namespace OAI + +/-! # The full moving transfer with separation on its actual coefficient support -/ +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +private theorem coefficient_amplitude_pair_sum {A B C : Type} [Fintype A] [Fintype B] [Fintype C] + (ρ : A → ℝ) (ν : B → ℝ) (F : A → A → B → B → C → C → ℂ) : + (∑ a : A × (B × C), ∑ b : A × (B × C), + ((ρ a.1 * ν a.2.1 : ℝ) : ℂ) * ((ρ b.1 * ν b.2.1 : ℝ) : ℂ) * + F a.1 b.1 a.2.1 b.2.1 a.2.2 b.2.2) = + ∑ x, (ρ x : ℂ) * ∑ z, (ρ z : ℂ) * + ∑ y, (ν y : ℂ) * ∑ t, (ν t : ℂ) * ∑ v, ∑ w, F x z y t v w := by + simp only [Fintype.sum_prod_type, Finset.mul_sum, Complex.ofReal_mul] + conv_lhs => + arg 2 + ext x + arg 2 + ext y + rw [Finset.sum_comm] + conv_lhs => + arg 2 + ext x + rw [Finset.sum_comm] + conv_lhs => + arg 2 + ext x + arg 2 + ext z + arg 2 + ext y + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro z _ + apply Finset.sum_congr rfl + intro y _ + apply Finset.sum_congr rfl + intro t _ + apply Finset.sum_congr rfl + intro v _ + apply Finset.sum_congr rfl + intro w _ + ring + +private theorem coefficient_amplitude_full_sum {U S A B C : Type} + [Fintype U] [Fintype S] [Fintype A] [Fintype B] [Fintype C] + (M : U → ℂ) (ρ : A → ℝ) (ν : B → ℝ) + (F : U → S → A → A → B → B → C → C → ℂ) : + (∑ u, M u * ∑ s, ∑ a : A × (B × C), ∑ b : A × (B × C), + ((ρ a.1 * ν a.2.1 : ℝ) : ℂ) * ((ρ b.1 * ν b.2.1 : ℝ) : ℂ) * + F u s a.1 b.1 a.2.1 b.2.1 a.2.2 b.2.2) = + ∑ XL, (ρ XL : ℂ) * ∑ XR, (ρ XR : ℂ) * ∑ s, ∑ u, M u * + ∑ left, (ν left : ℂ) * ∑ right, (ν right : ℂ) * ∑ v, ∑ w, + F u s XL XR left right v w := by + simp_rw [coefficient_amplitude_pair_sum] + simp only [Finset.mul_sum] + conv_lhs => + arg 2 + ext u + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro XL _ + conv_lhs => + arg 2 + ext u + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro XR _ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro u _ + apply Finset.sum_congr rfl + intro left _ + apply Finset.sum_congr rfl + intro right _ + apply Finset.sum_congr rfl + intro v _ + apply Finset.sum_congr rfl + intro w _ + ring + +theorem movingAmplitudeOffDiagonal_eq_next_on_coefficients {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg : Finset ℕ) (hPg : ∀ q ∈ Pg, q.Prime) (ρ : Pg → ℝ) + (ν : MovingRegularSlot n r m → σ → ℝ) + (hlarge : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ) (w : ℤ), + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w + (movingRestoreSample n r m u right) p XR ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hRH : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + ∀ q, q.Prime → q ∣ (XR : ℕ) * (∏ i, value (right i)) → V (n + 1) < q) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + movingAmplitudeOffDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable = + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable := by + rw [movingTemplatePrimeAmplitude_next_on_coefficients value hvalue outside μ childBound pivotBound V hV + F hF φ G n r m Pg hPg ρ (movingTemplateDoubledPrior n r m ν) hlarge I hI hφ hchild + (by simpa only [movingTemplateDoubledPrior_side] using hgap) + (by simpa only [movingTemplateDoubledPrior_side] using hRH) hcomp] + simp only [movingTemplateDoubledPrior_side] + unfold movingAmplitudeOffDiagonal + dsimp only [movingAmplitudePrior] + have hr := coefficient_amplitude_full_sum + (U := TreeLeafIndex n × Fin 4 → σ) (S := transferFrequencyRange (V (n + 1))) + (A := Pg) (B := MovingRegularSlot n r m → σ) (C := transferFrequencyRange (V n)) + (fun u => (((∏ i, μ n (u i)) * (∏ i, value (u i) : ℕ) : ℝ) : ℂ)) + ρ (fun y => ∏ i, ν i (y i)) + (fun u s XL XR left right v w => movingTemplateIntegerFourierTerm value outside μ + childBound pivotBound V F φ G n r m I XL XR s.val left right greg ggiant favorable + u v.val w.val) + convert hr using 1 + simp only [Nat.cast_prod] + +theorem movingTemplatePrimeAmplitude_step_on_coefficients {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hH : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ), p ∈ I → + ∀ (q : Pg) (y : MovingRegularSlot n r m → σ) (s : transferFrequencyRange (V n)), + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m s.val (movingRestoreSample n r m u y) p q ≠ 0 → + (q : ℕ) * (∏ i, value (y i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p ∈ I, + 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i))) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ), + (∏ i, ν i (y i)) ≠ 0 → ∀ ℓ, ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) + (hvg : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (hφsupport : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ) (w : ℤ), + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w + (movingRestoreSample n r m u right) p XR ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable‖ := by + intro ρ greg + have he := movingAmplitudeOffDiagonal_eq_next_on_coefficients value hvalue outside μ childBound pivotBound V + hV F hF φ G n r m Pg hPg ρ ν hvg I hI hφsupport hchild hgap + (fun XR right hr => hlarge XR right hr) hcomp greg ggiant favorable + rw [← he] + exact movingTemplatePrimeAmplitude_transfer_on_live value hvalue outside μ childBound pivotBound V F + φ G n r m Pg I hPg hPI hI hφ hpos hμ hμmass ν sets hsets hcard ggiant favorable + hgiant H hH hscale hlarge + +theorem movingTemplatePrimeAmplitude_step_of_live_coefficients {σ J : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (q : J → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (hF : ∀ {n} (T : MovingSlotData σ n), F T 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset J) + (ψ : SchwartzMap ℝ ℂ) (X lo hi W : ℝ) (hX : 0 < X) + (hwindow : X * hi ≤ Real.exp W) + (φ : ℝ → ℝ) (G c : ℕ → ℝ) (hout : ∀ t, 1 ≤ |t| → φ t = 0) + (hμlower : ∀ j x, μ j x ≠ 0 → Real.exp (c j - 1) ≤ (value x : ℝ)) + (n r m : ℕ) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hcap : ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊ ≤ H) + (hIlower : ∀ p ∈ I, Real.exp (G (n + 1) - 1) ≤ (p : ℝ)) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p ∈ I, + 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i))) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ), + (∏ i, ν i (y i)) ≠ 0 → ∀ ℓ, ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) + (hvg : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (hφsupport : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ) (w : ℤ), + movingTemplateCoefficient value outside μ childBound pivotBound V (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n (4 + r) m w + (movingRestoreSample n r m u right) p XR ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable‖ := by + let F₀ := movingOriginalLeaf value q F g Dq S ψ X lo hi + have hzero : ∀ x, F₀ x 0 = 0 := + movingOriginalLeaf_zero value q F hF g Dq S ψ X lo hi + have hH (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (p : ℕ) (hp : p ∈ I) (q' : Pg) (y : MovingRegularSlot n r m → σ) + (s : transferFrequencyRange (V n)) + (hc : movingTemplateCoefficient value outside μ childBound pivotBound V F₀ φ G + n (4 + r) m s.val (movingRestoreSample n r m u y) p q' ≠ 0) : + (q' : ℕ) * (∏ i, value (y i)) ≤ H := + (movingTemplateCoefficient_recursive_cell_cap value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi W hX hwindow φ G c hout hμlower n r m u hu + s.val y p q' (hIlower p hp) hc).trans hcap + exact movingTemplatePrimeAmplitude_step_on_coefficients value hvalue outside μ childBound pivotBound V + hV F₀ hzero φ G n r m Pg I hPg hPI hI hφ hpos hμ hμmass ν sets hsets hcard + ggiant favorable hgiant H hH hscale hlarge hvg hφsupport hchild hgap hcomp + +theorem movingTemplatePrimeAmplitude_step_constructed_coefficients {σ J : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : J → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (hF : ∀ {n} (T : MovingSlotData σ n), F T 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset J) + (ψ : SchwartzMap ℝ ℂ) (X lo hi W : ℝ) (hX : 0 < X) + (hwindow : X * hi ≤ Real.exp W) + (φ : ℝ → ℝ) (G c : ℕ → ℝ) (hout : ∀ t, 1 ≤ |t| → φ t = 0) + (hμlower : ∀ j x, μ j x ≠ 0 → Real.exp (c j - 1) ≤ (value x : ℝ)) + (n r m : ℕ) (Y reserveMass : ℝ) (hm : 64 ≤ reserveMass) (hY : Y ≤ W) + (hVeq : V = movingProductNaturalCutoff (movingCellPivotExponent G c) W Y reserveMass) + (hbudget : ∀ j, 2 * movingCellPivotExponent G c j ≤ + movingProductExponent (movingCellPivotExponent G c) W j) + (hpositive : 0 ≤ movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hHeq : H = ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊) + (hIlower : ∀ p ∈ I, Real.exp (G (n + 1) - 1) ≤ (p : ℝ)) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ), + (∏ i, ν i (y i)) ≠ 0 → ∀ ℓ, ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) + (hvg : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (hφsupport : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ) (w : ℤ), + movingTemplateCoefficient value outside μ childBound pivotBound V (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n (4 + r) m w + (movingRestoreSample n r m u right) p XR ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable‖ := by + have hV : Monotone V := by + rw [hVeq] + exact movingProductNaturalCutoff_monotone (movingCellPivotExponent G c) W Y reserveMass hbudget + have hcap : ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊ ≤ H := by rw [hHeq] + have hscale (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (p : ℕ) (hp : p ∈ I) : 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i)) := by + rw [hVeq, hHeq] + exact movingProductNaturalCutoff_compensation_scale value μ G c hμlower W Y reserveMass + hm hY hbudget n hpositive u hu p (hIlower p hp) + exact movingTemplatePrimeAmplitude_step_of_live_coefficients value hvalue outside μ childBound pivotBound V hV + q F hF g Dq S ψ X lo hi W hX hwindow φ G c hout hμlower n r m Pg I hPg hPI hI hφ + hpos hμ hμmass ν sets hsets hcard ggiant favorable hgiant H hcap hIlower hscale + hlarge hvg hφsupport hchild hgap hcomp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeEnergyLogNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeEnergyLogNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f56ca90c5a96655b3a48129dfbc3bc02191439c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeEnergyLogNorm.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeHarmonicCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogNorm + +namespace OAI + +/-! # The retained bulk cutoff in the one-branch diagonal energy -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- This comparison is applied after the harmonic diagonal reduction. +The signed two-branch comparison keeps the log weights throughout. -/ +theorem movingAmplitudeRegularEnergy_bulk_log_le + (P Pg I : Finset ℕ) (tier : P → ℕ) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) (μ : ℕ → P → ℝ) + (hμ0 : ∀ j a, 0 ≤ μ j a) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) (G : ℕ → ℝ) + (n r m : ℕ) (hn : n < k) (Q : MovingRegularSlot n r m → Finset ℕ) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → tier q ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inr j.2)) q ≠ 0 → tier q = k) + (greg : ∀ q : ℕ, ZMod q → ℂ) : + movingAmplitudeRegularEnergy P Pg I outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s) + φ G n r m Q greg ≤ + movingAmplitudeRegularEnergy P Pg I outside μ childBound pivotBound V F φ G n r m Q greg := by + unfold movingAmplitudeRegularEnergy + dsimp only + apply Finset.sum_le_sum + intro u _ + by_cases hu : (∏ i, μ n (u i)) = 0 + · simp only [hu, zero_mul, le_refl] + apply mul_le_mul_of_nonneg_left _ + (mul_nonneg (Finset.prod_nonneg (fun i _ => hμ0 n (u i))) (Nat.cast_nonneg _)) + apply Finset.sum_le_sum + intro p _ + apply mul_le_mul_of_nonneg_left _ (hφ _) + apply Finset.sum_le_sum + intro a _ + let α := movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a + have hα : 0 ≤ α := mul_nonneg (smoothGiantPrior_nonneg Pg φ (G (n + 1)) hφ a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (a.2.1 i))) + by_cases ha : α = 0 + · simp only [show movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a = 0 from ha, zero_mul, le_refl] + have hν i : primeSubsetPrior P (Q i) (a.2.1 i) ≠ 0 := + Finset.prod_ne_zero_iff.mp (right_ne_zero_of_mul ha) i (Finset.mem_univ i) + apply mul_le_mul_of_nonneg_left _ hα + apply pow_le_pow_left₀ (norm_nonneg _) _ 2 + rw [norm_mul, norm_mul] + apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) + exact movingTemplateCoefficient_restored_bulk_log_norm_le Subtype.val tier k outside cb cd + μ hμ childBound pivotBound V F φ G n r m a.2.2.val u hu a.2.1 hn + (fun j => hsmall j _ (hν _)) (fun j => hbulk j _ (hν _)) p a.1 + +/-- The full diagonal reduces to the original one-branch energy with its explicit counterpart cost. -/ +theorem movingAmplitude_harmonic_unweighted_cost_le + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (tier : P → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → P → ℝ) (hμ0 : ∀ j a, 0 ≤ μ j a) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (hn : n < k) (Q : MovingRegularSlot n r m → Finset ℕ) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → tier q ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inr j.2)) q ≠ 0 → tier q = k) + (hvg : ∀ q : Pg, V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (Gmin : ℝ) (hX : ∀ q : Pg, Real.exp Gmin ≤ (q : ℝ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let Fw := fun x s => + (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s + let K := Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1)) - Gmin - + (2 ^ n : ℕ) * (cb - 1)) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V Fw φ G n r m Pg I + (smoothGiantPrior Pg φ (G (n + 1))) (fun i => primeSubsetPrior P (Q i)) greg ggiant favorable ≤ + K * movingAmplitudeRegularEnergy P Pg I outside μ childBound pivotBound V F φ G n r m Q greg := by + intro Fw K + have hcost := movingAmplitude_harmonic_cost_le P Pg I hP hPg tier k outside cb cd μ hμ0 hμ + childBound pivotBound V F hF φ hφ0 hφ1 G n r m hn Q hsmall hbulk hvg hvr hsep + Gmin hX greg ggiant favorable + have hK : 0 ≤ K := by + dsimp only [K] + apply mul_nonneg + · exact mul_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + · exact Finset.prod_nonneg (fun i _ => inv_nonneg.mpr + (Finset.sum_nonneg (fun q _ => inv_nonneg.mpr (Nat.cast_nonneg q)))) + exact hcost.trans (mul_le_mul_of_nonneg_left + (movingAmplitudeRegularEnergy_bulk_log_le P Pg I tier k outside cb cd μ hμ0 hμ + childBound pivotBound V F φ hφ0 G n r m hn Q hsmall hbulk greg) hK) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeFullHarmonicCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeFullHarmonicCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9d6e6a76044481fc11a25350be5dbad209067ca --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeFullHarmonicCost.lean @@ -0,0 +1,132 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeEnergyLogNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullHarmonicCost + +namespace OAI + +/-! # The complete small and bulk denominator in the original diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingAmplitude_full_harmonic_cost_le + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (tier : P → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → P → ℝ) (hμ0 : ∀ j a, 0 ≤ μ j a) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (hn : n < k) (Q : MovingRegularSlot n r m → Finset ℕ) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → tier q ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inr j.2)) q ≠ 0 → tier q = k) + (lower : TreeLeafIndex n × Fin r → ℝ) + (hlower : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → Real.exp (lower j) ≤ (q : ℝ)) + (hvg : ∀ q : Pg, V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (Gmin : ℝ) (hX : ∀ q : Pg, Real.exp Gmin ≤ (q : ℝ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let Fw := fun x s => + (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s + let K := Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1)) - Gmin - + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1))) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V Fw φ G n r m Pg I + (smoothGiantPrior Pg φ (G (n + 1))) (fun i => primeSubsetPrior P (Q i)) greg ggiant favorable ≤ + K * movingAmplitudeRegularEnergy P Pg I outside μ childBound pivotBound V Fw φ G n r m Q greg := by + intro Fw K + have hFw x : Fw x 0 = 0 := by simp only [Fw, hF, mul_zero] + have hdiag := movingAmplitude_harmonic_diagonal_le P Pg I hP hPg outside μ hμ0 + childBound pivotBound V Fw hFw φ hφ0 hφ1 G n r m Q hvg hvr hsep greg ggiant favorable + apply hdiag.trans + dsimp only at hdiag ⊢ + unfold movingAmplitudeRegularEnergy + simp only [Finset.mul_sum] + apply Finset.sum_le_sum + intro u _ + by_cases hu : (∏ i, μ n (u i)) = 0 + · simp only [hu, zero_mul, mul_zero, Finset.sum_const_zero, le_refl] + have hU : 0 ≤ (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) := + mul_nonneg (Finset.prod_nonneg (fun i _ => hμ0 n (u i))) (Nat.cast_nonneg _) + apply Finset.sum_le_sum + intro p hp + apply Finset.sum_le_sum + intro a _ + let α := movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a + have hα : 0 ≤ α := mul_nonneg (smoothGiantPrior_nonneg Pg φ (G (n + 1)) hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (a.2.1 i))) + by_cases ha : α = 0 + · simp only [show movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a = 0 from ha, zero_mul, mul_zero, le_refl] + have hν i : primeSubsetPrior P (Q i) (a.2.1 i) ≠ 0 := + Finset.prod_ne_zero_iff.mp (right_ne_zero_of_mul ha) i (Finset.mem_univ i) + by_cases hc : movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V Fw φ G + n (4 + r) m a.2.2.val (movingRestoreSample n r m u a.2.1) p a.1 = 0 + · simp only [hc, zero_mul, norm_zero, zero_pow (by norm_num : 2 ≠ 0), mul_zero, le_refl] + have hcost := movingTemplate_restored_full_harmonic_cost_le Subtype.val tier + (fun q => (hP q q.property).pos) k outside cb cd μ hμ childBound pivotBound V F φ G + n r m a.2.2.val u hu a.2.1 hn (fun j => hsmall j _ (hν _)) + (fun j => hbulk j _ (hν _)) lower (fun j => hlower j _ (hν _)) p a.1 Q (smoothGiantLogNormalizer Pg φ (G (n + 1))) + Gmin (hX a.1) hc + have hpos := mul_nonneg hU (hφ0 (Real.log p - G (n + 1))) + have hcost' := mul_le_mul_of_nonneg_left hcost + (mul_nonneg (mul_nonneg hpos hα) (sq_nonneg + ‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V Fw φ G + n (4 + r) m a.2.2.val (movingRestoreSample n r m u a.2.1) p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖)) + dsimp only [α] at hcost' + simp only [Nat.cast_prod] at hcost' + dsimp only [K] + simp only [Nat.cast_prod] + convert hcost' using 1 <;> ring + +/-- The full diagonal reduces to the original one-branch energy with its explicit counterpart cost. -/ +theorem movingAmplitude_full_harmonic_unweighted_cost_le + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (tier : P → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → P → ℝ) (hμ0 : ∀ j a, 0 ≤ μ j a) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (hn : n < k) (Q : MovingRegularSlot n r m → Finset ℕ) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → tier q ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inr j.2)) q ≠ 0 → tier q = k) + (lower : TreeLeafIndex n × Fin r → ℝ) + (hlower : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → Real.exp (lower j) ≤ (q : ℝ)) + (hvg : ∀ q : Pg, V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (Gmin : ℝ) (hX : ∀ q : Pg, Real.exp Gmin ≤ (q : ℝ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let Fw := fun x s => + (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s + let K := Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1)) - Gmin - + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1))) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V Fw φ G n r m Pg I + (smoothGiantPrior Pg φ (G (n + 1))) (fun i => primeSubsetPrior P (Q i)) greg ggiant favorable ≤ + K * movingAmplitudeRegularEnergy P Pg I outside μ childBound pivotBound V F φ G n r m Q greg := by + intro Fw K + have hcost := movingAmplitude_full_harmonic_cost_le P Pg I hP hPg tier k outside cb cd μ hμ0 hμ + childBound pivotBound V F hF φ hφ0 hφ1 G n r m hn Q hsmall hbulk lower hlower hvg hvr hsep + Gmin hX greg ggiant favorable + have hK : 0 ≤ K := by + dsimp only [K] + apply mul_nonneg + · exact mul_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + · exact Finset.prod_nonneg (fun i _ => inv_nonneg.mpr + (Finset.sum_nonneg (fun q _ => inv_nonneg.mpr (Nat.cast_nonneg q)))) + exact hcost.trans (mul_le_mul_of_nonneg_left + (movingAmplitudeRegularEnergy_bulk_log_le P Pg I tier k outside cb cd μ hμ0 hμ + childBound pivotBound V F φ hφ0 G n r m hn Q hsmall hbulk greg) hK) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeHarmonicCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeHarmonicCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..5196c4d2bb717ab7d09f42bfff307bd49c9f15d5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeHarmonicCost.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeHarmonicDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredHarmonicCost + +namespace OAI + +/-! # A uniform counterpart cost for the complete original-prior diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingAmplitudeRegularEnergy + (P Pg I : Finset ℕ) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) : ℝ := + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let ν := fun i => primeSubsetPrior P (Q i) + ∑ u : TreeLeafIndex n × Fin 4 → P, (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + ∑ a : MovingAmplitudeIndex P Pg n r m V, + movingAmplitudePrior Pg n r m V ρ ν a * + ‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n (4 + r) m a.2.2.val (movingRestoreSample n r m u a.2.1) p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖ ^ 2 + +theorem movingAmplitude_harmonic_cost_le + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (tier : P → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → P → ℝ) (hμ0 : ∀ j a, 0 ≤ μ j a) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (hn : n < k) (Q : MovingRegularSlot n r m → Finset ℕ) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → tier q ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inr j.2)) q ≠ 0 → tier q = k) + (hvg : ∀ q : Pg, V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (Gmin : ℝ) (hX : ∀ q : Pg, Real.exp Gmin ≤ (q : ℝ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let Fw := fun x s => + (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s + let K := Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1)) - Gmin - + (2 ^ n : ℕ) * (cb - 1)) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V Fw φ G n r m Pg I + (smoothGiantPrior Pg φ (G (n + 1))) (fun i => primeSubsetPrior P (Q i)) greg ggiant favorable ≤ + K * movingAmplitudeRegularEnergy P Pg I outside μ childBound pivotBound V Fw φ G n r m Q greg := by + intro Fw K + have hFw x : Fw x 0 = 0 := by simp only [Fw, hF, mul_zero] + have hdiag := movingAmplitude_harmonic_diagonal_le P Pg I hP hPg outside μ hμ0 + childBound pivotBound V Fw hFw φ hφ0 hφ1 G n r m Q hvg hvr hsep greg ggiant favorable + apply hdiag.trans + dsimp only at hdiag ⊢ + unfold movingAmplitudeRegularEnergy + simp only [Finset.mul_sum] + apply Finset.sum_le_sum + intro u _ + by_cases hu : (∏ i, μ n (u i)) = 0 + · simp only [hu, zero_mul, mul_zero, Finset.sum_const_zero, le_refl] + have hU : 0 ≤ (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) := + mul_nonneg (Finset.prod_nonneg (fun i _ => hμ0 n (u i))) (Nat.cast_nonneg _) + apply Finset.sum_le_sum + intro p hp + apply Finset.sum_le_sum + intro a _ + let α := movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a + have hα : 0 ≤ α := mul_nonneg (smoothGiantPrior_nonneg Pg φ (G (n + 1)) hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (a.2.1 i))) + by_cases ha : α = 0 + · simp only [show movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a = 0 from ha, zero_mul, mul_zero, le_refl] + have hν i : primeSubsetPrior P (Q i) (a.2.1 i) ≠ 0 := + Finset.prod_ne_zero_iff.mp (right_ne_zero_of_mul ha) i (Finset.mem_univ i) + by_cases hc : movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V Fw φ G + n (4 + r) m a.2.2.val (movingRestoreSample n r m u a.2.1) p a.1 = 0 + · simp only [hc, zero_mul, norm_zero, zero_pow (by norm_num : 2 ≠ 0), mul_zero, le_refl] + have hcost := movingTemplate_restored_harmonic_cost_le Subtype.val tier + (fun q => (hP q q.property).pos) k outside cb cd μ hμ childBound pivotBound V F φ G + n r m a.2.2.val u hu a.2.1 hn (fun j => hsmall j _ (hν _)) + (fun j => hbulk j _ (hν _)) p a.1 Q (smoothGiantLogNormalizer Pg φ (G (n + 1))) + Gmin (hX a.1) hc + have hpos := mul_nonneg hU (hφ0 (Real.log p - G (n + 1))) + have hcost' := mul_le_mul_of_nonneg_left hcost + (mul_nonneg (mul_nonneg hpos hα) (sq_nonneg + ‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V Fw φ G + n (4 + r) m a.2.2.val (movingRestoreSample n r m u a.2.1) p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖)) + dsimp only [α] at hcost' + simp only [Nat.cast_prod] at hcost' + dsimp only [K] + simp only [Nat.cast_prod] + convert hcost' using 1 <;> ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeHarmonicDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeHarmonicDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..a388d00efa6aed42797cbeeaf8ffb2ea956f9470 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeHarmonicDiagonal.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateHarmonicDiagonal + +namespace OAI + +/-! # Harmonic product-fibre control of the whole prime amplitude diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingAmplitude_harmonic_diagonal_le + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (hμ : ∀ j a, 0 ≤ μ j a) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (hvg : ∀ q : Pg, V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let ν := fun i => primeSubsetPrior P (Q i) + let A := MovingAmplitudeIndex P Pg n r m V + let α := fun a : A => movingAmplitudePrior Pg n r m V ρ ν a + let θ := fun a : A => + (Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1))) / (a.1 : ℕ)) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (a.2.1 i : ℕ)) : ℝ)⁻¹ + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable ≤ + ∑ u : TreeLeafIndex n × Fin 4 → P, (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * ∑ a : A, α a * θ a * + ‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n (4 + r) m a.2.2.val (movingRestoreSample n r m u a.2.1) p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖ ^ 2 := by + intro ρ ν A α θ + unfold movingAmplitudeDiagonal + dsimp only + apply Finset.sum_le_sum + intro u _ + apply mul_le_mul_of_nonneg_left _ + (mul_nonneg (Finset.prod_nonneg (fun i _ => hμ n (u i))) (Nat.cast_nonneg _)) + apply Finset.sum_le_sum + intro p _ + apply mul_le_mul_of_nonneg_left _ (hφ0 _) + have hd := movingTemplate_harmonic_diagonal_le P Pg hP hPg outside μ childBound pivotBound V + F hF φ hφ0 hφ1 G (G (n + 1)) n r m Q u p hvg hvr hsep greg ggiant favorable + dsimp only at hd + let : ∀ a : A, Fact (a.1 : ℕ).Prime := fun a => ⟨hPg _ a.1.property⟩ + let : ∀ a : A, ∀ i, Fact (a.2.1 i : ℕ).Prime := fun a i => ⟨hP _ (a.2.1 i).property⟩ + simpa only [movingTemplateTransferWeight, movingAmplitudePrior, movingOneGiant_transform_tagged, + ρ, ν, α, θ, Nat.cast_prod, Function.comp_def] + using hd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeIndex.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeIndex.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf143b6bf6b297ab83338b8429fa9f22b03f8fc3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeIndex.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateAmplitudeRestore +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateWeightedSupport + +namespace OAI + +/-! # The surviving giant, regular tuple and frequency as one transfer index -/ + +namespace Ostmann +open scoped Classical BigOperators + +abbrev MovingAmplitudeIndex (σ : Type) (Pg : Finset ℕ) (n r m : ℕ) (V : ℕ → ℕ) := + Pg × ((MovingRegularSlot n r m → σ) × transferFrequencyRange (V n)) + +noncomputable def movingAmplitudePrior {σ : Type} (Pg : Finset ℕ) (n r m : ℕ) + (V : ℕ → ℕ) (ρ : Pg → ℝ) (ν : MovingRegularSlot n r m → σ → ℝ) + (a : MovingAmplitudeIndex σ Pg n r m V) : ℝ := + ρ a.1 * ∏ i, ν i (a.2.1 i) + +/-- The frequency is part of the transfer index and has counting measure. +Only the giant and regular prime coordinates carry probability weights. -/ +theorem movingTemplatePrimeAmplitude_index {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg : Finset ℕ) (ρ : Pg → ℝ) (ν : MovingRegularSlot n r m → σ → ℝ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable = + ∑ u : TreeLeafIndex n × Fin 4 → σ, ((∏ i, μ n (u i) : ℝ) : ℂ) * + ∑ p : Pg, (ρ p : ℂ) * ∑ a : MovingAmplitudeIndex σ Pg n r m V, + movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m + (fun a => a.2.2.val) (fun a => (movingAmplitudePrior Pg n r m V ρ ν a : ℂ)) + (fun a => (a.1 : ℕ)) (fun a => a.2.1) u p a * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then (p : ℕ) else (a.1 : ℕ)) + (value ∘ movingRestoreSample n r m u a.2.1)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod a.2.2.val := by + rw [movingTemplatePrimeAmplitude_restore] + apply Finset.sum_congr rfl + intro u _ + congr 1 + apply Finset.sum_congr rfl + intro p _ + congr 1 + simp only [MovingAmplitudeIndex, Fintype.sum_prod_type, movingTemplateTransferWeight, + movingAmplitudePrior, Complex.ofReal_mul, Finset.mul_sum] + apply Finset.sum_congr rfl + intro X _ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro y _ + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..1146d649415fe9391246de939374895bff244767 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveCost.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSymmetrizedCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeLiveSymmetrization + +namespace OAI + +/-! # Harmonic cost for live priors and the literal coefficient support -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingAmplitude_symmetrized_full_harmonic_cost_live + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) + (μ : ℕ → P → ℝ) (hμ0 : ∀ j a, 0 ≤ μ j a) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (hidentical : ∀ j k : TreeLeafIndex n × Fin m, + primeSubsetPrior P (Q (movingTemplateBulk n r m j)) = + primeSubsetPrior P (Q (movingTemplateBulk n r m k))) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ i (q : P), primeSubsetPrior P (Q i) q ≠ 0 → V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → + ∀ i (a : P), primeSubsetPrior P (Q i) a ≠ 0 → (q : ℕ) ≠ (a : ℕ)) + (Gmin : ℝ) (hX : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → Real.exp Gmin ≤ (q : ℝ)) + (totalLower : ℝ) + (hproduct : ∀ (u : TreeLeafIndex n × Fin 4 → P), (∏ i, μ n (u i)) ≠ 0 → + ∀ (a : MovingAmplitudeIndex P Pg n r m V), + (∀ i, primeSubsetPrior P (Q i) (a.2.1 i) ≠ 0) → + ∀ p : ℕ, movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m a.2.2.val u a.2.1 p a.1 ≠ 0 → + Real.exp totalLower ≤ ((∏ i, (a.2.1 i : ℕ) : ℕ) : ℝ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let K := Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1)) - Gmin - + totalLower) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V F φ G n r m Pg I + (smoothGiantPrior Pg φ (G (n + 1))) (fun i => primeSubsetPrior P (Q i)) greg ggiant favorable ≤ + K * movingAmplitudeSymmetrizedRegularEnergy P Pg I outside μ childBound pivotBound V F φ G n r m Q greg := by + intro K + have hdiag := movingAmplitude_symmetrized_harmonic_diagonal_live P Pg I hP hPg outside μ hμ0 + childBound pivotBound V F hF φ hφ0 hφ1 G n r m Q hidentical hvg hvr hsep greg ggiant favorable + apply hdiag.trans + dsimp only at hdiag ⊢ + unfold movingAmplitudeSymmetrizedRegularEnergy + simp only [Finset.mul_sum] + apply Finset.sum_le_sum + intro u _ + by_cases hu : (∏ i, μ n (u i)) = 0 + · simp only [hu, zero_mul, mul_zero, Finset.sum_const_zero, le_refl] + have hU : 0 ≤ (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) := + mul_nonneg (Finset.prod_nonneg (fun i _ => hμ0 n (u i))) (Nat.cast_nonneg _) + apply Finset.sum_le_sum + intro p hp + apply Finset.sum_le_sum + intro a _ + let α := movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a + have hα : 0 ≤ α := mul_nonneg (smoothGiantPrior_nonneg Pg φ (G (n + 1)) hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (a.2.1 i))) + by_cases ha : α = 0 + · simp only [show movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a = 0 from ha, zero_mul, mul_zero, le_refl] + have hν i : primeSubsetPrior P (Q i) (a.2.1 i) ≠ 0 := + Finset.prod_ne_zero_iff.mp (right_ne_zero_of_mul ha) i (Finset.mem_univ i) + by_cases hc : movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m a.2.2.val u a.2.1 p a.1 = 0 + · simp only [hc, zero_mul, norm_zero, zero_pow (by norm_num : 2 ≠ 0), mul_zero, le_refl] + have hcost := moving_harmonic_full_counterpart_le n r m Q + (smoothGiantLogNormalizer Pg φ (G (n + 1))) Gmin totalLower + (a.1 : ℕ) (fun i => (a.2.1 i : ℕ)) (hX a.1 (left_ne_zero_of_mul ha)) + (hproduct u hu a hν p hc) + have hpos := mul_nonneg hU (hφ0 (Real.log p - G (n + 1))) + have hcost' := mul_le_mul_of_nonneg_left hcost + (mul_nonneg (mul_nonneg hpos hα) (sq_nonneg + ‖movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m a.2.2.val u a.2.1 p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖)) + dsimp only [α] at hcost' + simp only [Nat.cast_prod] at hcost' + dsimp only [K] + simp only [Nat.cast_prod] + convert hcost' using 1 <;> ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveHarmonic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveHarmonic.lean new file mode 100644 index 0000000000000000000000000000000000000000..12b559585fc3c93a6d27775f9abc5fc1ca80ae98 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveHarmonic.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLiveHarmonic + +namespace OAI + +/-! # Harmonic product-fibre control of the whole prime amplitude diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingAmplitude_harmonic_diagonal_live + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (hμ : ∀ j a, 0 ≤ μ j a) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ i (q : P), primeSubsetPrior P (Q i) q ≠ 0 → V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → + ∀ i (a : P), primeSubsetPrior P (Q i) a ≠ 0 → (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let ν := fun i => primeSubsetPrior P (Q i) + let A := MovingAmplitudeIndex P Pg n r m V + let α := fun a : A => movingAmplitudePrior Pg n r m V ρ ν a + let θ := fun a : A => + (Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1))) / (a.1 : ℕ)) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (a.2.1 i : ℕ)) : ℝ)⁻¹ + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable ≤ + ∑ u : TreeLeafIndex n × Fin 4 → P, (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * ∑ a : A, α a * θ a * + ‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n (4 + r) m a.2.2.val (movingRestoreSample n r m u a.2.1) p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖ ^ 2 := by + intro ρ ν A α θ + unfold movingAmplitudeDiagonal + dsimp only + apply Finset.sum_le_sum + intro u _ + apply mul_le_mul_of_nonneg_left _ + (mul_nonneg (Finset.prod_nonneg (fun i _ => hμ n (u i))) (Nat.cast_nonneg _)) + apply Finset.sum_le_sum + intro p _ + apply mul_le_mul_of_nonneg_left _ (hφ0 _) + have hd := movingTemplate_harmonic_diagonal_live P Pg hP hPg outside μ childBound pivotBound V + F hF φ hφ0 hφ1 G (G (n + 1)) n r m Q u p hvg hvr hsep greg ggiant favorable + dsimp only at hd + let : ∀ a : A, Fact (a.1 : ℕ).Prime := fun a => ⟨hPg _ a.1.property⟩ + let : ∀ a : A, ∀ i, Fact (a.2.1 i : ℕ).Prime := fun a i => ⟨hP _ (a.2.1 i).property⟩ + simpa only [movingTemplateTransferWeight, movingAmplitudePrior, movingOneGiant_transform_tagged, + ρ, ν, α, θ, Nat.cast_prod, Function.comp_def] + using hd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveStep.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..eaf352a65a5509998ce883b165fc5bffa6524500 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveStep.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeLiveTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeNext + +namespace OAI + +/-! # Consecutive original amplitudes with their supported product windows -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- The next term is the actual doubled-prior amplitude. The transfer +inequality is derived rather than imposed as a recurrence hypothesis. -/ +theorem movingTemplatePrimeAmplitude_step_on_live {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hH : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ), p ∈ I → + ∀ (q : Pg) (y : MovingRegularSlot n r m → σ) (s : transferFrequencyRange (V n)), + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m s.val (movingRestoreSample n r m u y) p q ≠ 0 → + (q : ℕ) * (∏ i, value (y i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p ∈ I, + 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i))) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ), + (∏ i, ν i (y i)) ≠ 0 → ∀ ℓ, ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) + (hvg : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (hφsupport : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable‖ := by + intro ρ greg + have he := movingAmplitudeOffDiagonal_eq_next value hvalue outside μ childBound pivotBound V + hV F hF φ G n r m Pg hPg ρ ν hvg I hI hφsupport hchild hgap + (fun XR right hr => hlarge XR right hr) hcomp greg ggiant favorable + rw [← he] + exact movingTemplatePrimeAmplitude_transfer_on_live value hvalue outside μ childBound pivotBound V F + φ G n r m Pg I hPg hPI hI hφ hpos hμ hμmass ν sets hsets hcard ggiant favorable + hgiant H hH hscale hlarge + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..20eb8b95d24bc1d15ecbc083fcf049ad1cef40eb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveSupport.lean @@ -0,0 +1,33 @@ +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantLiveSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateAmplitude + +namespace OAI + +/-! # The exact full giant amplitude on its nonzero finite support -/ +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTemplatePrimeAmplitude_live {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (P : Finset ℕ) (H : ℝ) (ν : MovingRegularSlot n r m → σ → ℝ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n r m + P (smoothGiantPrior P φ H) ν greg ggiant favorable = + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n r m + (smoothGiantLivePrimes P φ H) (smoothGiantPrior (smoothGiantLivePrimes P φ H) φ H) + ν greg ggiant favorable := by + unfold movingTemplatePrimeAmplitude + exact smoothGiantPrior_double_sum_live P φ H (fun XL XR => + ∑ s : transferFrequencyRange (V n), + ∑ y : MovingRegularSlot n r m → σ, ((∏ i, ν i (y i) : ℝ) : ℂ) * + (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n r m + s.val y XL XR * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then XL else XR) (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s.val)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveSymmetrization.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveSymmetrization.lean new file mode 100644 index 0000000000000000000000000000000000000000..efdaaed3e9d956c8d92ec1d73218dd05889726e2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveSymmetrization.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLiveSymmetrization +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSymmetrizedProductLower + +namespace OAI + +/-! # Harmonic product-fibre control of the whole prime amplitude diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingAmplitude_symmetrized_harmonic_diagonal_live + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (hμ : ∀ j a, 0 ≤ μ j a) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (hν : ∀ j k : TreeLeafIndex n × Fin m, + primeSubsetPrior P (Q (movingTemplateBulk n r m j)) = + primeSubsetPrior P (Q (movingTemplateBulk n r m k))) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ i (q : P), primeSubsetPrior P (Q i) q ≠ 0 → V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → + ∀ i (a : P), primeSubsetPrior P (Q i) a ≠ 0 → (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let ν := fun i => primeSubsetPrior P (Q i) + let A := MovingAmplitudeIndex P Pg n r m V + let α := fun a : A => movingAmplitudePrior Pg n r m V ρ ν a + let θ := fun a : A => + (Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1))) / (a.1 : ℕ)) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (a.2.1 i : ℕ)) : ℝ)⁻¹ + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable ≤ + ∑ u : TreeLeafIndex n × Fin 4 → P, (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * ∑ a : A, α a * θ a * + ‖movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m a.2.2.val u a.2.1 p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖ ^ 2 := by + intro ρ ν A α θ + unfold movingAmplitudeDiagonal + dsimp only + apply Finset.sum_le_sum + intro u _ + apply mul_le_mul_of_nonneg_left _ + (mul_nonneg (Finset.prod_nonneg (fun i _ => hμ n (u i))) (Nat.cast_nonneg _)) + apply Finset.sum_le_sum + intro p _ + apply mul_le_mul_of_nonneg_left _ (hφ0 _) + have hd := movingTemplate_symmetrized_harmonic_diagonal_live P Pg hP hPg outside μ childBound pivotBound V + F hF φ hφ0 hφ1 G (G (n + 1)) n r m Q hν u p hvg hvr hsep greg ggiant favorable + dsimp only at hd + let : ∀ a : A, Fact (a.1 : ℕ).Prime := fun a => ⟨hPg _ a.1.property⟩ + let : ∀ a : A, ∀ i, Fact (a.2.1 i : ℕ).Prime := fun a i => ⟨hP _ (a.2.1 i).property⟩ + simpa only [movingSymmetrizedTemplateCoefficient, movingTemplateTransferWeight, movingAmplitudePrior, movingOneGiant_transform_tagged, + ρ, ν, α, θ, Nat.cast_prod, Function.comp_def] + using hd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..f41926059fe4971f9e73ee1f6b7ed5d242e7f5e2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeLiveTransfer.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLiveTransfer + +namespace OAI + +/-! # Transfer of the original amplitude with its supported product window -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- Specialization to the actual surviving giant, regular tuple and frequency. +The compensation draw and the giant harmonic normalization are unchanged. -/ +theorem movingTemplatePrimeAmplitude_transfer_on_live {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hH : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ), p ∈ I → + ∀ (q : Pg) (y : MovingRegularSlot n r m → σ) (s : transferFrequencyRange (V n)), + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m s.val (movingRestoreSample n r m u y) p q ≠ 0 → + (q : ℕ) * (∏ i, value (y i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p ∈ I, + 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i))) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ), + (∏ i, ν i (y i)) ≠ 0 → ∀ ℓ, ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingAmplitudeOffDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable‖ := by + intro ρ greg + let A := MovingAmplitudeIndex σ Pg n r m V + let X := fun a : A => (a.1 : ℕ) + let y := fun a : A => a.2.1 + let v := fun a : A => a.2.2.val + let α := fun a : A => (movingAmplitudePrior Pg n r m V ρ ν a : ℂ) + let : ∀ a : A, Fact (X a).Prime := fun a => ⟨hPg _ a.1.property⟩ + let : ∀ a : A, ∀ i, Fact (value (y a i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let : ∀ a : A, ∀ i, NeZero ((value ∘ y a) i) := + fun a i => ⟨(hvalue (y a i)).ne_zero⟩ + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G + n r m v α X y + have ht := movingTemplate_prior_transfer_on_live value hvalue outside μ childBound pivotBound V F + φ G n r m Pg I hPg hPI hI hφ hpos hμ hμmass X (fun a => hPg _ a.1.property) + y v α sets hsets hcard ggiant favorable (fun a => hgiant a.1) + (V n) H (V (n + 1)) (fun a => (mem_transferFrequencyRange _ _).mp a.2.2.property) + (fun u hu p hp a ha => hH u hu p hp a.1 (y a) a.2.2 (right_ne_zero_of_mul ha)) hscale (fun a ha => by + have hprior : movingAmplitudePrior Pg n r m V ρ ν a ≠ 0 := + Complex.ofReal_ne_zero.mp ha + exact hlarge a.1 (y a) (right_ne_zero_of_mul hprior)) + dsimp only at ht + rw [← movingTemplatePrimeAmplitude_index] at ht + have hC u p : movingRegularCoefficient L + (fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable) + outside.prod (∏ i, value (u i)) v (W u) p = + fun a => W u p a * movingTaggedTransform (L a) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable + (p * (∏ i, value (u i)) * outside.prod) (v a) := by + funext a + exact congrArg (fun z => W u p a * z) + (movingOneGiant_transform_tagged (X a) (value ∘ y a) greg ggiant favorable + (p * (∏ i, value (u i)) * outside.prod) (v a)) + convert ht using 1 + congr 1 + · unfold movingAmplitudeDiagonal + apply Finset.sum_congr rfl + intro u _ + congr 1 + apply Finset.sum_congr rfl + intro p _ + congr 1 + simp only [movingOneGiantModuli_product, Function.comp_apply] + exact congrArg (fun c : A → ℂ => + (pivotDiagonal (fun a => X a * ∏ i, value (y a i)) v c).re) (hC u p).symm + · congr 1 + unfold movingAmplitudeOffDiagonal + apply Finset.sum_congr rfl + intro u _ + congr 1 + conv_rhs => rw [← Finset.sum_coe_sort] + apply Finset.sum_congr rfl + intro s hs + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + simp only [movingOneGiantModuli_product, Function.comp_apply, + movingOneGiant_pair_transform_tagged] + dsimp only [movingTemplateIntegerFourierTerm, movingTemplateTransferWeight, A, X, y, v, α, W] + split_ifs + · simp only [map_mul, Complex.conj_ofReal] + simp only [starRingEnd_apply] + dsimp only [greg] + ring + · simp only [mul_zero] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeMaskedEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeMaskedEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..81d2bc487dac4198592fde922f6f5c8574c7ddf1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeMaskedEnergy.lean @@ -0,0 +1,120 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeHarmonicCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMaskedTemplateEnergy + +namespace OAI + +/-! # The actual one-branch amplitude energy in restored arithmetic coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators + +private theorem amplitude_energy_fubini {U T X Y S : Type} + [Fintype U] [Fintype X] [Fintype Y] [Fintype S] + (I : Finset T) (M : U → ℝ) (w : T → ℝ) (ρ : X → ℝ) (ν : Y → ℝ) + (F : U → T → X → Y → S → ℝ) : + (∑ u, M u * ∑ p ∈ I, w p * ∑ a : X × (Y × S), + (ρ a.1 * ν a.2.1) * F u p a.1 a.2.1 a.2.2) = + ∑ u, M u * ∑ y, ν y * ∑ p ∈ I, w p * ∑ x, ρ x * ∑ s, F u p x y s := by + simp only [Fintype.sum_prod_type, Finset.mul_sum] + apply Finset.sum_congr rfl + intro u _ + conv_lhs => + arg 2 + ext p + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro y _ + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro s _ + ring + +/-- The compensation draw and the surviving draw are independent original +priors; this reordering introduces no frequency probability factor. -/ +theorem movingAmplitudeRegularEnergy_fubini + (P Pg I : Finset ℕ) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (greg : ∀ q : ℕ, ZMod q → ℂ) : + movingAmplitudeRegularEnergy P Pg I outside μ childBound pivotBound V F φ G n r m Q greg = + ∑ u : TreeLeafIndex n × Fin 4 → P, (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) * + ∑ y : MovingRegularSlot n r m → P, (∏ i, primeSubsetPrior P (Q i) (y i)) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + ∑ X : Pg, smoothGiantPrior Pg φ (G (n + 1)) X * + ∑ s : transferFrequencyRange (V n), + ‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n (4 + r) m s.val (movingRestoreSample n r m u y) p X * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (X : ℕ)) + (∏ i, (y i : ℕ)) s.val‖ ^ 2 := by + unfold movingAmplitudeRegularEnergy + dsimp only + have h := amplitude_energy_fubini + (U := TreeLeafIndex n × Fin 4 → P) (X := Pg) + (Y := MovingRegularSlot n r m → P) (S := transferFrequencyRange (V n)) I + (fun u => (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ)) + (fun p => φ (Real.log p - G (n + 1))) + (smoothGiantPrior Pg φ (G (n + 1))) + (fun y => ∏ i, primeSubsetPrior P (Q i) (y i)) + (fun u p X y s => + ‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n (4 + r) m s.val (movingRestoreSample n r m u y) p X * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (X : ℕ)) + (∏ i, (y i : ℕ)) s.val‖ ^ 2) + convert h using 1 + simp only [movingAmplitudePrior, Nat.cast_prod] + +/-- This is the literal arithmetic energy under the original restored prior. +The extracted compensation product is a weight, not a change of measure. -/ +theorem movingAmplitudeRegularEnergy_eq_masked + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (greg : ∀ q : ℕ, ZMod q → ℂ) : + movingAmplitudeRegularEnergy P Pg I outside μ childBound pivotBound V F φ G n r m Q greg = + movingMaskedTemplateEnergy P Pg I hP outside μ childBound pivotBound V F φ G n r m Q greg + (fun x => (movingRestoredCompensationProduct Subtype.val n r m x : ℝ)) := by + rw [movingAmplitudeRegularEnergy_fubini] + unfold movingMaskedTemplateEnergy + rw [movingTemplateRestoredPrior_average_real] + simp only [movingRestoredCompensationProduct_restore, Finset.mul_sum] + apply Finset.sum_congr rfl + intro u _ + apply Finset.sum_congr rfl + intro y _ + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro X _ + apply Finset.sum_congr rfl + intro s _ + rw [movingMaskedTemplateKernel_restore] + ring + +/-- The compensation cost is now explicit, with the same original prior in +both energies. The bound is used only after the nonnegative diagonal reduction. -/ +theorem movingAmplitudeRegularEnergy_le_masked + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hφ : ∀ t, 0 ≤ φ t) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (greg : ∀ q : ℕ, ZMod q → ℂ) + (b : ℝ) (hb : ∀ a, μ n a ≠ 0 → (a : ℝ) ≤ Real.exp b) : + movingAmplitudeRegularEnergy P Pg I outside μ childBound pivotBound V F φ G n r m Q greg ≤ + Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * b) * + movingMaskedTemplateEnergy P Pg I hP outside μ childBound pivotBound V F φ G n r m Q greg + (fun _ => 1) := by + rw [movingAmplitudeRegularEnergy_eq_masked P Pg I hP] + apply movingMaskedTemplateEnergy_weight_le P Pg I hP outside μ hμ + childBound pivotBound V F φ hφ G n r m Q greg + intro x hx + exact movingRestoredCompensationProduct_le_exp P (μ n) n r m + (fun i => primeSubsetPrior P (Q i)) b hb x hx + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeNext.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeNext.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e4fc4c7580efcc32f50bbdd2111f99eb5b8e93a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeNext.lean @@ -0,0 +1,148 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms + +namespace OAI + +/-! # Identifying the transferred off-diagonal with the next prime amplitude -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingTemplateDoubledPrior {σ : Type} (n r m : ℕ) + (ν : MovingRegularSlot n r m → σ → ℝ) : + MovingRegularSlot (n + 1) r m → σ → ℝ := + fun i => ν (Sum.elim id id i.1, i.2) + +@[simp] theorem movingTemplateDoubledPrior_side {σ : Type} (n r m : ℕ) + (ν : MovingRegularSlot n r m → σ → ℝ) (b : Bool) + (y : MovingRegularSlot n r m → σ) : + movingTemplateSidePrior n r m (movingTemplateDoubledPrior n r m ν) b y = + ∏ i, ν i (y i) := by + cases b <;> rfl + +private theorem amplitude_pair_sum {A B C : Type} [Fintype A] [Fintype B] [Fintype C] + (ρ : A → ℝ) (ν : B → ℝ) (F : A → A → B → B → C → C → ℂ) : + (∑ a : A × (B × C), ∑ b : A × (B × C), + ((ρ a.1 * ν a.2.1 : ℝ) : ℂ) * ((ρ b.1 * ν b.2.1 : ℝ) : ℂ) * + F a.1 b.1 a.2.1 b.2.1 a.2.2 b.2.2) = + ∑ x, (ρ x : ℂ) * ∑ z, (ρ z : ℂ) * + ∑ y, (ν y : ℂ) * ∑ t, (ν t : ℂ) * ∑ v, ∑ w, F x z y t v w := by + simp only [Fintype.sum_prod_type, Finset.mul_sum, Complex.ofReal_mul] + conv_lhs => + arg 2 + ext x + arg 2 + ext y + rw [Finset.sum_comm] + conv_lhs => + arg 2 + ext x + rw [Finset.sum_comm] + conv_lhs => + arg 2 + ext x + arg 2 + ext z + arg 2 + ext y + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro z _ + apply Finset.sum_congr rfl + intro y _ + apply Finset.sum_congr rfl + intro t _ + apply Finset.sum_congr rfl + intro v _ + apply Finset.sum_congr rfl + intro w _ + ring + +private theorem amplitude_full_sum {U S A B C : Type} + [Fintype U] [Fintype S] [Fintype A] [Fintype B] [Fintype C] + (M : U → ℂ) (ρ : A → ℝ) (ν : B → ℝ) + (F : U → S → A → A → B → B → C → C → ℂ) : + (∑ u, M u * ∑ s, ∑ a : A × (B × C), ∑ b : A × (B × C), + ((ρ a.1 * ν a.2.1 : ℝ) : ℂ) * ((ρ b.1 * ν b.2.1 : ℝ) : ℂ) * + F u s a.1 b.1 a.2.1 b.2.1 a.2.2 b.2.2) = + ∑ XL, (ρ XL : ℂ) * ∑ XR, (ρ XR : ℂ) * ∑ s, ∑ u, M u * + ∑ left, (ν left : ℂ) * ∑ right, (ν right : ℂ) * ∑ v, ∑ w, + F u s XL XR left right v w := by + simp_rw [amplitude_pair_sum] + simp only [Finset.mul_sum] + conv_lhs => + arg 2 + ext u + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro XL _ + conv_lhs => + arg 2 + ext u + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro XR _ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro u _ + apply Finset.sum_congr rfl + intro left _ + apply Finset.sum_congr rfl + intro right _ + apply Finset.sum_congr rfl + intro v _ + apply Finset.sum_congr rfl + intro w _ + ring + +/-- The off-diagonal is the next amplitude under the independent doubled +regular law. Both surviving giants retain their common original prior. -/ +theorem movingAmplitudeOffDiagonal_eq_next {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg : Finset ℕ) (hPg : ∀ q ∈ Pg, q.Prime) (ρ : Pg → ℝ) + (ν : MovingRegularSlot n r m → σ → ℝ) + (hlarge : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hRH : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + ∀ q, q.Prime → q ∣ (XR : ℕ) * (∏ i, value (right i)) → V (n + 1) < q) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + movingAmplitudeOffDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable = + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable := by + rw [movingTemplatePrimeAmplitude_next value hvalue outside μ childBound pivotBound V hV + F hF φ G n r m Pg hPg ρ (movingTemplateDoubledPrior n r m ν) hlarge I hI hφ hchild + (by simpa only [movingTemplateDoubledPrior_side] using hgap) + (by simpa only [movingTemplateDoubledPrior_side] using hRH) hcomp] + simp only [movingTemplateDoubledPrior_side] + unfold movingAmplitudeOffDiagonal + dsimp only [movingAmplitudePrior] + have hr := amplitude_full_sum + (U := TreeLeafIndex n × Fin 4 → σ) (S := transferFrequencyRange (V (n + 1))) + (A := Pg) (B := MovingRegularSlot n r m → σ) (C := transferFrequencyRange (V n)) + (fun u => (((∏ i, μ n (u i)) * (∏ i, value (u i) : ℕ) : ℝ) : ℂ)) + ρ (fun y => ∏ i, ν i (y i)) + (fun u s XL XR left right v w => movingTemplateIntegerFourierTerm value outside μ + childBound pivotBound V F φ G n r m I XL XR s.val left right greg ggiant favorable + u v.val w.val) + convert hr using 1 + simp only [Nat.cast_prod] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeOriginalEnergyNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeOriginalEnergyNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..7879eb923be4ba19df8eca703ebbd171963d7369 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeOriginalEnergyNorm.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNormalizedMaskedEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeMaskedEnergy + +namespace OAI + +/-! # The original one-branch energy controlled by its exact mixed integral -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingAmplitudeRegularEnergy_original_norm_le {J : Type} + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (q : J → ℕ) [∀ i, Fact (q i).Prime] + (outside : List ℕ) (μ : ℕ → P → ℝ) (hμ : ∀ j a, 0 ≤ μ j a) (n r m : ℕ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset J) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) + (hφ : ∀ x, 0 ≤ φ x) (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (Q : MovingRegularSlot n r m → Finset ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (center b : ℝ) + (hb : ∀ a, μ n a ≠ 0 → (a : ℝ) ≤ Real.exp b) : + let H := G (n + 1) + let Pg := smoothGiantPrimeRange H + let Pivots := Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊ + let ν := movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i)) + movingAmplitudeRegularEnergy P Pg Pivots outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val q (fun _ => f) g Dq S ψ X lo hi) φ G n r m Q greg ≤ + Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * b + smoothGiantLogNormalizer Pg φ H + center) * + ‖movingWeightedDiagonalEnergy q Subtype.val outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n (movingTemplateSmall n (4 + r) m) + (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m)) + (fun s => movingTemplateExternalMultiplier P hP n (4 + r) m + (movingRestoredActive n r m) outside greg s φ H H false) + (H - 1) (H + 1) (H - 1) (H + 1) center‖ := by + intro H Pg Pivots ν + have hid := movingMaskedTemplateEnergy_original_interval P hP q outside μ n r m + childBound pivotBound V f g Dq S ψ X lo hi φ hout G Q greg center + dsimp only at hid + have hn := congrArg norm hid + simp only [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] at hn + have hm := (le_abs_self _).trans_eq hn + have he := movingAmplitudeRegularEnergy_le_masked P Pg Pivots hP outside μ hμ + childBound pivotBound V (movingOriginalLeaf Subtype.val q (fun _ => f) g Dq S ψ X lo hi) + φ hφ G n r m Q greg b hb + apply he.trans + apply (mul_le_mul_of_nonneg_left hm (Real.exp_nonneg _)).trans_eq + rw [← mul_assoc, ← Real.exp_add] + congr 2 + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeStep.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5436aafc777d6b22f399ba9294565c3833d9a90 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeStep.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeNext + +namespace OAI + +/-! # The exact consecutive-amplitude step under the original prime laws -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- The next term is the actual doubled-prior amplitude. The transfer +inequality is derived rather than imposed as a recurrence hypothesis. -/ +theorem movingTemplatePrimeAmplitude_step {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hH : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ), + (q : ℕ) * (∏ i, value (y i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p ∈ I, + 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i))) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ) ℓ, + ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) + (hvg : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (hφsupport : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable‖ := by + intro ρ greg + have he := movingAmplitudeOffDiagonal_eq_next value hvalue outside μ childBound pivotBound V + hV F hF φ G n r m Pg hPg ρ ν hvg I hI hφsupport hchild hgap + (fun XR right _ => hlarge XR right) hcomp greg ggiant favorable + rw [← he] + exact movingTemplatePrimeAmplitude_transfer value hvalue outside μ childBound pivotBound V F + φ G n r m Pg I hPg hPI hI hφ hpos hμ hμmass ν sets hsets hcard ggiant favorable + hgiant H hH hscale hlarge + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..125300c056a6a3d8a8cebf02a3184f37bf71562e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedCost.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSymmetrizedCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSupportedSymmetrization + +namespace OAI + +/-! # Harmonic cost on the actual smooth-prime support -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingAmplitude_symmetrized_full_harmonic_cost_supported + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (tier : P → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → P → ℝ) (hμ0 : ∀ j a, 0 ≤ μ j a) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (hn : n < k) (Q : MovingRegularSlot n r m → Finset ℕ) + (hidentical : ∀ j k : TreeLeafIndex n × Fin m, + primeSubsetPrior P (Q (movingTemplateBulk n r m j)) = + primeSubsetPrior P (Q (movingTemplateBulk n r m k))) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → tier q ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inr j.2)) q ≠ 0 → tier q = k) + (lower : TreeLeafIndex n × Fin r → ℝ) + (hlower : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → Real.exp (lower j) ≤ (q : ℝ)) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (Gmin : ℝ) (hX : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → Real.exp Gmin ≤ (q : ℝ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let Fw := fun x s => + (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s + let K := Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1)) - Gmin - + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1))) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V Fw φ G n r m Pg I + (smoothGiantPrior Pg φ (G (n + 1))) (fun i => primeSubsetPrior P (Q i)) greg ggiant favorable ≤ + K * movingAmplitudeSymmetrizedRegularEnergy P Pg I outside μ childBound pivotBound V Fw φ G n r m Q greg := by + intro Fw K + have hFw x : Fw x 0 = 0 := by simp only [Fw, hF, mul_zero] + have hdiag := movingAmplitude_symmetrized_harmonic_diagonal_supported P Pg I hP hPg outside μ hμ0 + childBound pivotBound V Fw hFw φ hφ0 hφ1 G n r m Q hidentical hvg hvr hsep greg ggiant favorable + apply hdiag.trans + dsimp only at hdiag ⊢ + unfold movingAmplitudeSymmetrizedRegularEnergy + simp only [Finset.mul_sum] + apply Finset.sum_le_sum + intro u _ + by_cases hu : (∏ i, μ n (u i)) = 0 + · simp only [hu, zero_mul, mul_zero, Finset.sum_const_zero, le_refl] + have hU : 0 ≤ (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) := + mul_nonneg (Finset.prod_nonneg (fun i _ => hμ0 n (u i))) (Nat.cast_nonneg _) + apply Finset.sum_le_sum + intro p hp + apply Finset.sum_le_sum + intro a _ + let α := movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a + have hα : 0 ≤ α := mul_nonneg (smoothGiantPrior_nonneg Pg φ (G (n + 1)) hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (a.2.1 i))) + by_cases ha : α = 0 + · simp only [show movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a = 0 from ha, zero_mul, mul_zero, le_refl] + have hν i : primeSubsetPrior P (Q i) (a.2.1 i) ≠ 0 := + Finset.prod_ne_zero_iff.mp (right_ne_zero_of_mul ha) i (Finset.mem_univ i) + by_cases hc : movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V Fw φ G + n r m a.2.2.val u a.2.1 p a.1 = 0 + · simp only [hc, zero_mul, norm_zero, zero_pow (by norm_num : 2 ≠ 0), mul_zero, le_refl] + have hcost := movingSymmetrizedTemplateCoefficient_full_harmonic_cost_le Subtype.val tier + (fun q => (hP q q.property).pos) k outside cb cd μ hμ childBound pivotBound V F φ G + n r m a.2.2.val u hu a.2.1 hn (fun j => hsmall j _ (hν _)) + (fun j => hbulk j _ (hν _)) lower (fun j => hlower j _ (hν _)) p a.1 Q (smoothGiantLogNormalizer Pg φ (G (n + 1))) + Gmin (hX a.1 (left_ne_zero_of_mul ha)) hc + have hpos := mul_nonneg hU (hφ0 (Real.log p - G (n + 1))) + have hcost' := mul_le_mul_of_nonneg_left hcost + (mul_nonneg (mul_nonneg hpos hα) (sq_nonneg + ‖movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V Fw φ G + n r m a.2.2.val u a.2.1 p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖)) + dsimp only [α] at hcost' + simp only [Nat.cast_prod] at hcost' + dsimp only [K] + simp only [Nat.cast_prod] + convert hcost' using 1 <;> ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedFullCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedFullCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc0c673c28f62d731789d87e13141f557964f8c3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedFullCost.lean @@ -0,0 +1,133 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeEnergyLogNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullHarmonicCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSupportedHarmonic + +namespace OAI + +/-! # The complete small and bulk denominator in the original diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingAmplitude_full_harmonic_cost_supported + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (tier : P → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → P → ℝ) (hμ0 : ∀ j a, 0 ≤ μ j a) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (hn : n < k) (Q : MovingRegularSlot n r m → Finset ℕ) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → tier q ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inr j.2)) q ≠ 0 → tier q = k) + (lower : TreeLeafIndex n × Fin r → ℝ) + (hlower : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → Real.exp (lower j) ≤ (q : ℝ)) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (Gmin : ℝ) (hX : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → Real.exp Gmin ≤ (q : ℝ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let Fw := fun x s => + (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s + let K := Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1)) - Gmin - + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1))) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V Fw φ G n r m Pg I + (smoothGiantPrior Pg φ (G (n + 1))) (fun i => primeSubsetPrior P (Q i)) greg ggiant favorable ≤ + K * movingAmplitudeRegularEnergy P Pg I outside μ childBound pivotBound V Fw φ G n r m Q greg := by + intro Fw K + have hFw x : Fw x 0 = 0 := by simp only [Fw, hF, mul_zero] + have hdiag := movingAmplitude_harmonic_diagonal_supported P Pg I hP hPg outside μ hμ0 + childBound pivotBound V Fw hFw φ hφ0 hφ1 G n r m Q hvg hvr hsep greg ggiant favorable + apply hdiag.trans + dsimp only at hdiag ⊢ + unfold movingAmplitudeRegularEnergy + simp only [Finset.mul_sum] + apply Finset.sum_le_sum + intro u _ + by_cases hu : (∏ i, μ n (u i)) = 0 + · simp only [hu, zero_mul, mul_zero, Finset.sum_const_zero, le_refl] + have hU : 0 ≤ (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) := + mul_nonneg (Finset.prod_nonneg (fun i _ => hμ0 n (u i))) (Nat.cast_nonneg _) + apply Finset.sum_le_sum + intro p hp + apply Finset.sum_le_sum + intro a _ + let α := movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a + have hα : 0 ≤ α := mul_nonneg (smoothGiantPrior_nonneg Pg φ (G (n + 1)) hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (a.2.1 i))) + by_cases ha : α = 0 + · simp only [show movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a = 0 from ha, zero_mul, mul_zero, le_refl] + have hν i : primeSubsetPrior P (Q i) (a.2.1 i) ≠ 0 := + Finset.prod_ne_zero_iff.mp (right_ne_zero_of_mul ha) i (Finset.mem_univ i) + by_cases hc : movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V Fw φ G + n (4 + r) m a.2.2.val (movingRestoreSample n r m u a.2.1) p a.1 = 0 + · simp only [hc, zero_mul, norm_zero, zero_pow (by norm_num : 2 ≠ 0), mul_zero, le_refl] + have hcost := movingTemplate_restored_full_harmonic_cost_le Subtype.val tier + (fun q => (hP q q.property).pos) k outside cb cd μ hμ childBound pivotBound V F φ G + n r m a.2.2.val u hu a.2.1 hn (fun j => hsmall j _ (hν _)) + (fun j => hbulk j _ (hν _)) lower (fun j => hlower j _ (hν _)) p a.1 Q (smoothGiantLogNormalizer Pg φ (G (n + 1))) + Gmin (hX a.1 (left_ne_zero_of_mul ha)) hc + have hpos := mul_nonneg hU (hφ0 (Real.log p - G (n + 1))) + have hcost' := mul_le_mul_of_nonneg_left hcost + (mul_nonneg (mul_nonneg hpos hα) (sq_nonneg + ‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V Fw φ G + n (4 + r) m a.2.2.val (movingRestoreSample n r m u a.2.1) p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖)) + dsimp only [α] at hcost' + simp only [Nat.cast_prod] at hcost' + dsimp only [K] + simp only [Nat.cast_prod] + convert hcost' using 1 <;> ring + +/-- The full diagonal reduces to the original one-branch energy with its explicit counterpart cost. -/ +theorem movingAmplitude_full_harmonic_unweighted_cost_supported + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (tier : P → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → P → ℝ) (hμ0 : ∀ j a, 0 ≤ μ j a) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (hn : n < k) (Q : MovingRegularSlot n r m → Finset ℕ) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → tier q ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inr j.2)) q ≠ 0 → tier q = k) + (lower : TreeLeafIndex n × Fin r → ℝ) + (hlower : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → Real.exp (lower j) ≤ (q : ℝ)) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (Gmin : ℝ) (hX : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → Real.exp Gmin ≤ (q : ℝ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let Fw := fun x s => + (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s + let K := Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1)) - Gmin - + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1))) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V Fw φ G n r m Pg I + (smoothGiantPrior Pg φ (G (n + 1))) (fun i => primeSubsetPrior P (Q i)) greg ggiant favorable ≤ + K * movingAmplitudeRegularEnergy P Pg I outside μ childBound pivotBound V F φ G n r m Q greg := by + intro Fw K + have hcost := movingAmplitude_full_harmonic_cost_supported P Pg I hP hPg tier k outside cb cd μ hμ0 hμ + childBound pivotBound V F hF φ hφ0 hφ1 G n r m hn Q hsmall hbulk lower hlower hvg hvr hsep + Gmin hX greg ggiant favorable + have hK : 0 ≤ K := by + dsimp only [K] + apply mul_nonneg + · exact mul_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + · exact Finset.prod_nonneg (fun i _ => inv_nonneg.mpr + (Finset.sum_nonneg (fun q _ => inv_nonneg.mpr (Nat.cast_nonneg q)))) + exact hcost.trans (mul_le_mul_of_nonneg_left + (movingAmplitudeRegularEnergy_bulk_log_le P Pg I tier k outside cb cd μ hμ0 hμ + childBound pivotBound V F φ hφ0 G n r m hn Q hsmall hbulk greg) hK) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedHarmonic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedHarmonic.lean new file mode 100644 index 0000000000000000000000000000000000000000..82fcb9ab50e89ae541c5ad95d9aef96c8cfcd927 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedHarmonic.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateSupportedHarmonic + +namespace OAI + +/-! # Harmonic product-fibre control of the whole prime amplitude diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingAmplitude_harmonic_diagonal_supported + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (hμ : ∀ j a, 0 ≤ μ j a) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let ν := fun i => primeSubsetPrior P (Q i) + let A := MovingAmplitudeIndex P Pg n r m V + let α := fun a : A => movingAmplitudePrior Pg n r m V ρ ν a + let θ := fun a : A => + (Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1))) / (a.1 : ℕ)) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (a.2.1 i : ℕ)) : ℝ)⁻¹ + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable ≤ + ∑ u : TreeLeafIndex n × Fin 4 → P, (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * ∑ a : A, α a * θ a * + ‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n (4 + r) m a.2.2.val (movingRestoreSample n r m u a.2.1) p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖ ^ 2 := by + intro ρ ν A α θ + unfold movingAmplitudeDiagonal + dsimp only + apply Finset.sum_le_sum + intro u _ + apply mul_le_mul_of_nonneg_left _ + (mul_nonneg (Finset.prod_nonneg (fun i _ => hμ n (u i))) (Nat.cast_nonneg _)) + apply Finset.sum_le_sum + intro p _ + apply mul_le_mul_of_nonneg_left _ (hφ0 _) + have hd := movingTemplate_harmonic_diagonal_supported P Pg hP hPg outside μ childBound pivotBound V + F hF φ hφ0 hφ1 G (G (n + 1)) n r m Q u p hvg hvr hsep greg ggiant favorable + dsimp only at hd + let : ∀ a : A, Fact (a.1 : ℕ).Prime := fun a => ⟨hPg _ a.1.property⟩ + let : ∀ a : A, ∀ i, Fact (a.2.1 i : ℕ).Prime := fun a i => ⟨hP _ (a.2.1 i).property⟩ + simpa only [movingTemplateTransferWeight, movingAmplitudePrior, movingOneGiant_transform_tagged, + ρ, ν, α, θ, Nat.cast_prod, Function.comp_def] + using hd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedStep.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..b291514441506c3ee8c1d70c131bbf6fdc4493ff --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedStep.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSupportedTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeNext + +namespace OAI + +/-! # Consecutive original amplitudes with their supported product windows -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- The next term is the actual doubled-prior amplitude. The transfer +inequality is derived rather than imposed as a recurrence hypothesis. -/ +theorem movingTemplatePrimeAmplitude_step_on_support {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hH : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ), p ∈ I → + ∀ (q : Pg) (y : MovingRegularSlot n r m → σ) (s : transferFrequencyRange (V n)), + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m s.val (movingRestoreSample n r m u y) p q ≠ 0 → + (q : ℕ) * (∏ i, value (y i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p ∈ I, + 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i))) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ) ℓ, + ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) + (hvg : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (hφsupport : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable‖ := by + intro ρ greg + have he := movingAmplitudeOffDiagonal_eq_next value hvalue outside μ childBound pivotBound V + hV F hF φ G n r m Pg hPg ρ ν hvg I hI hφsupport hchild hgap + (fun XR right _ => hlarge XR right) hcomp greg ggiant favorable + rw [← he] + exact movingTemplatePrimeAmplitude_transfer_on_support value hvalue outside μ childBound pivotBound V F + φ G n r m Pg I hPg hPI hI hφ hpos hμ hμmass ν sets hsets hcard ggiant favorable + hgiant H hH hscale hlarge + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedSymmetrization.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedSymmetrization.lean new file mode 100644 index 0000000000000000000000000000000000000000..073d4675fdd4a05ca82c2804aa4c7ec3a8b8bc40 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedSymmetrization.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateSupportedSymmetrization +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSymmetrizedProductLower + +namespace OAI + +/-! # Harmonic product-fibre control of the whole prime amplitude diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingAmplitude_symmetrized_harmonic_diagonal_supported + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (hμ : ∀ j a, 0 ≤ μ j a) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (hν : ∀ j k : TreeLeafIndex n × Fin m, + primeSubsetPrior P (Q (movingTemplateBulk n r m j)) = + primeSubsetPrior P (Q (movingTemplateBulk n r m k))) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ (G (n + 1)) q ≠ 0 → ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let ν := fun i => primeSubsetPrior P (Q i) + let A := MovingAmplitudeIndex P Pg n r m V + let α := fun a : A => movingAmplitudePrior Pg n r m V ρ ν a + let θ := fun a : A => + (Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1))) / (a.1 : ℕ)) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (a.2.1 i : ℕ)) : ℝ)⁻¹ + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable ≤ + ∑ u : TreeLeafIndex n × Fin 4 → P, (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * ∑ a : A, α a * θ a * + ‖movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m a.2.2.val u a.2.1 p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖ ^ 2 := by + intro ρ ν A α θ + unfold movingAmplitudeDiagonal + dsimp only + apply Finset.sum_le_sum + intro u _ + apply mul_le_mul_of_nonneg_left _ + (mul_nonneg (Finset.prod_nonneg (fun i _ => hμ n (u i))) (Nat.cast_nonneg _)) + apply Finset.sum_le_sum + intro p _ + apply mul_le_mul_of_nonneg_left _ (hφ0 _) + have hd := movingTemplate_symmetrized_harmonic_diagonal_supported P Pg hP hPg outside μ childBound pivotBound V + F hF φ hφ0 hφ1 G (G (n + 1)) n r m Q hν u p hvg hvr hsep greg ggiant favorable + dsimp only at hd + let : ∀ a : A, Fact (a.1 : ℕ).Prime := fun a => ⟨hPg _ a.1.property⟩ + let : ∀ a : A, ∀ i, Fact (a.2.1 i : ℕ).Prime := fun a i => ⟨hP _ (a.2.1 i).property⟩ + simpa only [movingSymmetrizedTemplateCoefficient, movingTemplateTransferWeight, movingAmplitudePrior, movingOneGiant_transform_tagged, + ρ, ν, α, θ, Nat.cast_prod, Function.comp_def] + using hd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..973a41850fc1a32ca27d484042218f305f9e4dc5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSupportedTransfer.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateSupportedTransfer + +namespace OAI + +/-! # Transfer of the original amplitude with its supported product window -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- Specialization to the actual surviving giant, regular tuple and frequency. +The compensation draw and the giant harmonic normalization are unchanged. -/ +theorem movingTemplatePrimeAmplitude_transfer_on_support {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hH : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ), p ∈ I → + ∀ (q : Pg) (y : MovingRegularSlot n r m → σ) (s : transferFrequencyRange (V n)), + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m s.val (movingRestoreSample n r m u y) p q ≠ 0 → + (q : ℕ) * (∏ i, value (y i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p ∈ I, + 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i))) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ) ℓ, + ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingAmplitudeOffDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable‖ := by + intro ρ greg + let A := MovingAmplitudeIndex σ Pg n r m V + let X := fun a : A => (a.1 : ℕ) + let y := fun a : A => a.2.1 + let v := fun a : A => a.2.2.val + let α := fun a : A => (movingAmplitudePrior Pg n r m V ρ ν a : ℂ) + let : ∀ a : A, Fact (X a).Prime := fun a => ⟨hPg _ a.1.property⟩ + let : ∀ a : A, ∀ i, Fact (value (y a i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let : ∀ a : A, ∀ i, NeZero ((value ∘ y a) i) := + fun a i => ⟨(hvalue (y a i)).ne_zero⟩ + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G + n r m v α X y + have ht := movingTemplate_prior_transfer_on_support value hvalue outside μ childBound pivotBound V F + φ G n r m Pg I hPg hPI hI hφ hpos hμ hμmass X (fun a => hPg _ a.1.property) + y v α sets hsets hcard ggiant favorable (fun a => hgiant a.1) + (V n) H (V (n + 1)) (fun a => (mem_transferFrequencyRange _ _).mp a.2.2.property) + (fun u hu p hp a ha => hH u hu p hp a.1 (y a) a.2.2 (right_ne_zero_of_mul ha)) hscale (fun a => hlarge a.1 (y a)) + dsimp only at ht + rw [← movingTemplatePrimeAmplitude_index] at ht + have hC u p : movingRegularCoefficient L + (fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable) + outside.prod (∏ i, value (u i)) v (W u) p = + fun a => W u p a * movingTaggedTransform (L a) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable + (p * (∏ i, value (u i)) * outside.prod) (v a) := by + funext a + exact congrArg (fun z => W u p a * z) + (movingOneGiant_transform_tagged (X a) (value ∘ y a) greg ggiant favorable + (p * (∏ i, value (u i)) * outside.prod) (v a)) + convert ht using 1 + congr 1 + · unfold movingAmplitudeDiagonal + apply Finset.sum_congr rfl + intro u _ + congr 1 + apply Finset.sum_congr rfl + intro p _ + congr 1 + simp only [movingOneGiantModuli_product, Function.comp_apply] + exact congrArg (fun c : A → ℂ => + (pivotDiagonal (fun a => X a * ∏ i, value (y a i)) v c).re) (hC u p).symm + · congr 1 + unfold movingAmplitudeOffDiagonal + apply Finset.sum_congr rfl + intro u _ + congr 1 + conv_rhs => rw [← Finset.sum_coe_sort] + apply Finset.sum_congr rfl + intro s hs + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + simp only [movingOneGiantModuli_product, Function.comp_apply, + movingOneGiant_pair_transform_tagged] + dsimp only [movingTemplateIntegerFourierTerm, movingTemplateTransferWeight, A, X, y, v, α, W] + split_ifs + · simp only [map_mul, Complex.conj_ofReal] + simp only [starRingEnd_apply] + dsimp only [greg] + ring + · simp only [mul_zero] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..259b06608a7ddd1ed2e488cd0d4f4ed81b45c07b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedCost.lean @@ -0,0 +1,108 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSymmetrizedDiagonal + +namespace OAI + +/-! # The original diagonal with the full symmetrized harmonic cost -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingAmplitudeSymmetrizedRegularEnergy + (P Pg I : Finset ℕ) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) : ℝ := + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let ν := fun i => primeSubsetPrior P (Q i) + ∑ u : TreeLeafIndex n × Fin 4 → P, (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + ∑ a : MovingAmplitudeIndex P Pg n r m V, + movingAmplitudePrior Pg n r m V ρ ν a * + ‖movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m a.2.2.val u a.2.1 p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖ ^ 2 + +theorem movingAmplitude_symmetrized_full_harmonic_cost_le + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (tier : P → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → P → ℝ) (hμ0 : ∀ j a, 0 ≤ μ j a) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (hn : n < k) (Q : MovingRegularSlot n r m → Finset ℕ) + (hidentical : ∀ j k : TreeLeafIndex n × Fin m, + primeSubsetPrior P (Q (movingTemplateBulk n r m j)) = + primeSubsetPrior P (Q (movingTemplateBulk n r m k))) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → tier q ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inr j.2)) q ≠ 0 → tier q = k) + (lower : TreeLeafIndex n × Fin r → ℝ) + (hlower : ∀ j : TreeLeafIndex n × Fin r, ∀ q : P, + primeSubsetPrior P (Q (j.1, .inl j.2)) q ≠ 0 → Real.exp (lower j) ≤ (q : ℝ)) + (hvg : ∀ q : Pg, V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (Gmin : ℝ) (hX : ∀ q : Pg, Real.exp Gmin ≤ (q : ℝ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let Fw := fun x s => + (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s + let K := Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1)) - Gmin - + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1))) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V Fw φ G n r m Pg I + (smoothGiantPrior Pg φ (G (n + 1))) (fun i => primeSubsetPrior P (Q i)) greg ggiant favorable ≤ + K * movingAmplitudeSymmetrizedRegularEnergy P Pg I outside μ childBound pivotBound V Fw φ G n r m Q greg := by + intro Fw K + have hFw x : Fw x 0 = 0 := by simp only [Fw, hF, mul_zero] + have hdiag := movingAmplitude_symmetrized_harmonic_diagonal_le P Pg I hP hPg outside μ hμ0 + childBound pivotBound V Fw hFw φ hφ0 hφ1 G n r m Q hidentical hvg hvr hsep greg ggiant favorable + apply hdiag.trans + dsimp only at hdiag ⊢ + unfold movingAmplitudeSymmetrizedRegularEnergy + simp only [Finset.mul_sum] + apply Finset.sum_le_sum + intro u _ + by_cases hu : (∏ i, μ n (u i)) = 0 + · simp only [hu, zero_mul, mul_zero, Finset.sum_const_zero, le_refl] + have hU : 0 ≤ (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) := + mul_nonneg (Finset.prod_nonneg (fun i _ => hμ0 n (u i))) (Nat.cast_nonneg _) + apply Finset.sum_le_sum + intro p hp + apply Finset.sum_le_sum + intro a _ + let α := movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a + have hα : 0 ≤ α := mul_nonneg (smoothGiantPrior_nonneg Pg φ (G (n + 1)) hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (a.2.1 i))) + by_cases ha : α = 0 + · simp only [show movingAmplitudePrior Pg n r m V (smoothGiantPrior Pg φ (G (n + 1))) + (fun i => primeSubsetPrior P (Q i)) a = 0 from ha, zero_mul, mul_zero, le_refl] + have hν i : primeSubsetPrior P (Q i) (a.2.1 i) ≠ 0 := + Finset.prod_ne_zero_iff.mp (right_ne_zero_of_mul ha) i (Finset.mem_univ i) + by_cases hc : movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V Fw φ G + n r m a.2.2.val u a.2.1 p a.1 = 0 + · simp only [hc, zero_mul, norm_zero, zero_pow (by norm_num : 2 ≠ 0), mul_zero, le_refl] + have hcost := movingSymmetrizedTemplateCoefficient_full_harmonic_cost_le Subtype.val tier + (fun q => (hP q q.property).pos) k outside cb cd μ hμ childBound pivotBound V F φ G + n r m a.2.2.val u hu a.2.1 hn (fun j => hsmall j _ (hν _)) + (fun j => hbulk j _ (hν _)) lower (fun j => hlower j _ (hν _)) p a.1 Q (smoothGiantLogNormalizer Pg φ (G (n + 1))) + Gmin (hX a.1) hc + have hpos := mul_nonneg hU (hφ0 (Real.log p - G (n + 1))) + have hcost' := mul_le_mul_of_nonneg_left hcost + (mul_nonneg (mul_nonneg hpos hα) (sq_nonneg + ‖movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V Fw φ G + n r m a.2.2.val u a.2.1 p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖)) + dsimp only [α] at hcost' + simp only [Nat.cast_prod] at hcost' + dsimp only [K] + simp only [Nat.cast_prod] + convert hcost' using 1 <;> ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..c823e3d36efd22acdd6df7efd1eeef7a4bb30df9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedDiagonal.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateSymmetrizedDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSymmetrizedProductLower + +namespace OAI + +/-! # Harmonic product-fibre control of the whole prime amplitude diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingAmplitude_symmetrized_harmonic_diagonal_le + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (hμ : ∀ j a, 0 ≤ μ j a) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (hν : ∀ j k : TreeLeafIndex n × Fin m, + primeSubsetPrior P (Q (movingTemplateBulk n r m j)) = + primeSubsetPrior P (Q (movingTemplateBulk n r m k))) + (hvg : ∀ q : Pg, V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let ν := fun i => primeSubsetPrior P (Q i) + let A := MovingAmplitudeIndex P Pg n r m V + let α := fun a : A => movingAmplitudePrior Pg n r m V ρ ν a + let θ := fun a : A => + (Real.exp (smoothGiantLogNormalizer Pg φ (G (n + 1))) / (a.1 : ℕ)) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (a.2.1 i : ℕ)) : ℝ)⁻¹ + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable ≤ + ∑ u : TreeLeafIndex n × Fin 4 → P, (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * ∑ a : A, α a * θ a * + ‖movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m a.2.2.val u a.2.1 p a.1 * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (a.1 : ℕ)) + (∏ i, (a.2.1 i : ℕ)) a.2.2.val‖ ^ 2 := by + intro ρ ν A α θ + unfold movingAmplitudeDiagonal + dsimp only + apply Finset.sum_le_sum + intro u _ + apply mul_le_mul_of_nonneg_left _ + (mul_nonneg (Finset.prod_nonneg (fun i _ => hμ n (u i))) (Nat.cast_nonneg _)) + apply Finset.sum_le_sum + intro p _ + apply mul_le_mul_of_nonneg_left _ (hφ0 _) + have hd := movingTemplate_symmetrized_harmonic_diagonal_le P Pg hP hPg outside μ childBound pivotBound V + F hF φ hφ0 hφ1 G (G (n + 1)) n r m Q hν u p hvg hvr hsep greg ggiant favorable + dsimp only at hd + let : ∀ a : A, Fact (a.1 : ℕ).Prime := fun a => ⟨hPg _ a.1.property⟩ + let : ∀ a : A, ∀ i, Fact (a.2.1 i : ℕ).Prime := fun a i => ⟨hP _ (a.2.1 i).property⟩ + simpa only [movingSymmetrizedTemplateCoefficient, movingTemplateTransferWeight, movingAmplitudePrior, movingOneGiant_transform_tagged, + ρ, ν, α, θ, Nat.cast_prod, Function.comp_def] + using hd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedMasked.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedMasked.lean new file mode 100644 index 0000000000000000000000000000000000000000..8bfbfb6fd7be3e67e695c489c7721bc6dde2a1bf --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedMasked.lean @@ -0,0 +1,120 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSymmetrizedCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSymmetrizedMaskedEnergy + +namespace OAI + +/-! # The actual one-branch amplitude energy in restored arithmetic coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators + +private theorem amplitude_energy_fubini {U T X Y S : Type} + [Fintype U] [Fintype X] [Fintype Y] [Fintype S] + (I : Finset T) (M : U → ℝ) (w : T → ℝ) (ρ : X → ℝ) (ν : Y → ℝ) + (F : U → T → X → Y → S → ℝ) : + (∑ u, M u * ∑ p ∈ I, w p * ∑ a : X × (Y × S), + (ρ a.1 * ν a.2.1) * F u p a.1 a.2.1 a.2.2) = + ∑ u, M u * ∑ y, ν y * ∑ p ∈ I, w p * ∑ x, ρ x * ∑ s, F u p x y s := by + simp only [Fintype.sum_prod_type, Finset.mul_sum] + apply Finset.sum_congr rfl + intro u _ + conv_lhs => + arg 2 + ext p + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro y _ + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro s _ + ring + +/-- The compensation draw and the surviving draw are independent original +priors; this reordering introduces no frequency probability factor. -/ +theorem movingAmplitudeSymmetrizedRegularEnergy_fubini + (P Pg I : Finset ℕ) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (greg : ∀ q : ℕ, ZMod q → ℂ) : + movingAmplitudeSymmetrizedRegularEnergy P Pg I outside μ childBound pivotBound V F φ G n r m Q greg = + ∑ u : TreeLeafIndex n × Fin 4 → P, (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ) * + ∑ y : MovingRegularSlot n r m → P, (∏ i, primeSubsetPrior P (Q i) (y i)) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + ∑ X : Pg, smoothGiantPrior Pg φ (G (n + 1)) X * + ∑ s : transferFrequencyRange (V n), + ‖movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m s.val u y p X * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (X : ℕ)) + (∏ i, (y i : ℕ)) s.val‖ ^ 2 := by + unfold movingAmplitudeSymmetrizedRegularEnergy + dsimp only + have h := amplitude_energy_fubini + (U := TreeLeafIndex n × Fin 4 → P) (X := Pg) + (Y := MovingRegularSlot n r m → P) (S := transferFrequencyRange (V n)) I + (fun u => (∏ i, μ n (u i)) * (∏ i, (u i : ℕ) : ℕ)) + (fun p => φ (Real.log p - G (n + 1))) + (smoothGiantPrior Pg φ (G (n + 1))) + (fun y => ∏ i, primeSubsetPrior P (Q i) (y i)) + (fun u p X y s => + ‖movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m s.val u y p X * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * (X : ℕ)) + (∏ i, (y i : ℕ)) s.val‖ ^ 2) + convert h using 1 + simp only [movingAmplitudePrior, Nat.cast_prod] + +/-- This is the literal arithmetic energy under the original restored prior. +The extracted compensation product is a weight, not a change of measure. -/ +theorem movingAmplitudeSymmetrizedRegularEnergy_eq_masked + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (greg : ∀ q : ℕ, ZMod q → ℂ) : + movingAmplitudeSymmetrizedRegularEnergy P Pg I outside μ childBound pivotBound V F φ G n r m Q greg = + movingSymmetrizedMaskedTemplateEnergy P Pg I hP outside μ childBound pivotBound V F φ G n r m Q greg + (fun x => (movingRestoredCompensationProduct Subtype.val n r m x : ℝ)) := by + rw [movingAmplitudeSymmetrizedRegularEnergy_fubini] + unfold movingSymmetrizedMaskedTemplateEnergy + rw [movingTemplateRestoredPrior_average_real] + simp only [movingRestoredCompensationProduct_restore, Finset.mul_sum] + apply Finset.sum_congr rfl + intro u _ + apply Finset.sum_congr rfl + intro y _ + apply Finset.sum_congr rfl + intro p _ + apply Finset.sum_congr rfl + intro X _ + apply Finset.sum_congr rfl + intro s _ + rw [movingSymmetrizedMaskedTemplateKernel_restore] + ring + +/-- The compensation cost is now explicit, with the same original prior in +both energies. The bound is used only after the nonnegative diagonal reduction. -/ +theorem movingAmplitudeSymmetrizedRegularEnergy_le_masked + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hφ : ∀ t, 0 ≤ φ t) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (greg : ∀ q : ℕ, ZMod q → ℂ) + (b : ℝ) (hb : ∀ a, μ n a ≠ 0 → (a : ℝ) ≤ Real.exp b) : + movingAmplitudeSymmetrizedRegularEnergy P Pg I outside μ childBound pivotBound V F φ G n r m Q greg ≤ + Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * b) * + movingSymmetrizedMaskedTemplateEnergy P Pg I hP outside μ childBound pivotBound V F φ G n r m Q greg + (fun _ => 1) := by + rw [movingAmplitudeSymmetrizedRegularEnergy_eq_masked P Pg I hP] + apply movingSymmetrizedMaskedTemplateEnergy_weight_le P Pg I hP outside μ hμ + childBound pivotBound V F φ hφ G n r m Q greg + intro x hx + exact movingRestoredCompensationProduct_le_exp P (μ n) n r m + (fun i => primeSubsetPrior P (Q i)) b hb x hx + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8f0e89f9be5cbab851a218d83c0bf033c5ebf00 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeSymmetrizedNorm.lean @@ -0,0 +1,47 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNormalizedSymmetrizedEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSymmetrizedMasked + +namespace OAI + +/-! # The full original diagonal reduces to its masked symmetrized integral -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingAmplitudeSymmetrizedRegularEnergy_norm_le + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (hμ : ∀ j a, 0 ≤ μ j a) (n r m : ℕ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (Q : MovingRegularSlot n r m → Finset ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (center b : ℝ) + (hb : ∀ a, μ n a ≠ 0 → (a : ℝ) ≤ Real.exp b) : + let H := G (n + 1) + let Pg := smoothGiantPrimeRange H + let Pivots := Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊ + let ν := movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i)) + movingAmplitudeSymmetrizedRegularEnergy P Pg Pivots outside μ childBound pivotBound V + F φ G n r m Q greg ≤ + Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * b + smoothGiantLogNormalizer Pg φ H + center) * + ‖movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G + n (4 + r) m ν (movingRestoredActive n r m) greg H H false + (H - 1) (H + 1) (H - 1) (H + 1) center‖ := by + intro H Pg Pivots ν + have hid := movingSymmetrizedMaskedTemplateEnergy_original_interval P hP outside μ + childBound pivotBound V F φ hout G n r m Q greg center + dsimp only at hid + have hn := congrArg norm hid + simp only [norm_mul, Complex.norm_real, Real.norm_eq_abs, abs_of_pos (Real.exp_pos _)] at hn + have hm := (le_abs_self _).trans_eq hn + have he := movingAmplitudeSymmetrizedRegularEnergy_le_masked P Pg Pivots hP outside μ hμ + childBound pivotBound V F φ hφ G n r m Q greg b hb + apply he.trans + apply (mul_le_mul_of_nonneg_left hm (Real.exp_nonneg _)).trans_eq + rw [← mul_assoc, ← Real.exp_add] + congr 2 + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeTerms.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeTerms.lean new file mode 100644 index 0000000000000000000000000000000000000000..7cf544b186328815737a37d5953e3416bfecf817 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeTerms.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeIndex +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateTransfer + +namespace OAI + +/-! # The actual diagonal and integer off-diagonal of a prime amplitude -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +theorem movingOneGiant_transform_tagged {I : Type*} [Fintype I] + (X : ℕ) (p : I → ℕ) [NeZero X] [∀ i, NeZero (p i)] + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (D : ℕ) (s : ℤ) : + movingRegularTransform (movingOneGiantModuli X p) + (movingOneGiantFactors X p greg ggiant favorable) D s = + movingTaggedTransform (movingOneGiantModuli X p) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable D s := by + unfold movingRegularTransform movingTaggedTransform + apply Finset.prod_congr rfl + intro i _ + cases i <;> rfl + +local instance amplitudeSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +theorem movingOneGiant_pair_transform_tagged {I : Type*} [Fintype I] + (X Y : ℕ) (p q : I → ℕ) [NeZero X] [NeZero Y] + [∀ i, NeZero (p i)] [∀ i, NeZero (q i)] + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (D : ℕ) (s : ℤ) : + movingRegularTransform (Sum.elim (movingOneGiantModuli X p) (movingOneGiantModuli Y q)) + (movingSumFactors (movingOneGiantModuli X p) (movingOneGiantModuli Y q) + (movingOneGiantFactors X p greg ggiant favorable) + (movingOneGiantFactors Y q greg ggiant favorable)) D s = + movingTaggedTransform (Sum.elim (movingOneGiantModuli X p) (movingOneGiantModuli Y q)) + (Sum.elim (Sum.elim (fun _ : Unit => true) (fun _ => false)) + (Sum.elim (fun _ : Unit => true) (fun _ => false))) greg ggiant favorable D s := by + unfold movingRegularTransform movingTaggedTransform + apply Finset.prod_congr rfl + intro i _ + rcases i with (i | i) <;> cases i <;> rfl + +noncomputable def movingAmplitudeDiagonal {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (Pg I : Finset ℕ) + (ρ : Pg → ℝ) (ν : MovingRegularSlot n r m → σ → ℝ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : ℝ := + let A := MovingAmplitudeIndex σ Pg n r m V + let X := fun a : A => (a.1 : ℕ) + let y := fun a : A => a.2.1 + let v := fun a : A => a.2.2.val + let α := fun a : A => (movingAmplitudePrior Pg n r m V ρ ν a : ℂ) + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G + n r m v α X y + ∑ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) * (∏ i, value (u i) : ℕ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + (pivotDiagonal (fun a => X a * ∏ i, value (y a i)) v + (fun a => W u p a * movingTaggedTransform (movingOneGiantModuli (X a) (value ∘ y a)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable + (p * (∏ i, value (u i)) * outside.prod) (v a))).re + +noncomputable def movingAmplitudeOffDiagonal {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (Pg I : Finset ℕ) + (ρ : Pg → ℝ) (ν : MovingRegularSlot n r m → σ → ℝ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : ℂ := + ∑ u : TreeLeafIndex n × Fin 4 → σ, + (((∏ i, μ n (u i)) * (∏ i, value (u i) : ℕ) : ℝ) : ℂ) * + ∑ s : transferFrequencyRange (V (n + 1)), + ∑ a : MovingAmplitudeIndex σ Pg n r m V, + ∑ b : MovingAmplitudeIndex σ Pg n r m V, + (movingAmplitudePrior Pg n r m V ρ ν a : ℂ) * + (movingAmplitudePrior Pg n r m V ρ ν b : ℂ) * + movingTemplateIntegerFourierTerm value outside μ childBound pivotBound V F φ G + n r m I a.1 b.1 s.val a.2.1 b.2.1 greg ggiant favorable u a.2.2.val b.2.2.val + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..94293b0b195ef6af6271b1c2d59febce6f3bb0ff --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAmplitudeTransfer.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms + +namespace OAI + +/-! # One transfer inequality for the original prime amplitude -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- Specialization to the actual surviving giant, regular tuple and frequency. +The compensation draw and the giant harmonic normalization are unchanged. -/ +theorem movingTemplatePrimeAmplitude_transfer {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hH : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ), + (q : ℕ) * (∏ i, value (y i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p ∈ I, + 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i))) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ) ℓ, + ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingAmplitudeOffDiagonal value outside μ childBound pivotBound V F φ G n r m Pg I + ρ ν greg ggiant favorable‖ := by + intro ρ greg + let A := MovingAmplitudeIndex σ Pg n r m V + let X := fun a : A => (a.1 : ℕ) + let y := fun a : A => a.2.1 + let v := fun a : A => a.2.2.val + let α := fun a : A => (movingAmplitudePrior Pg n r m V ρ ν a : ℂ) + let : ∀ a : A, Fact (X a).Prime := fun a => ⟨hPg _ a.1.property⟩ + let : ∀ a : A, ∀ i, Fact (value (y a i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let : ∀ a : A, ∀ i, NeZero ((value ∘ y a) i) := + fun a i => ⟨(hvalue (y a i)).ne_zero⟩ + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G + n r m v α X y + have ht := movingTemplate_prior_transfer value hvalue outside μ childBound pivotBound V F + φ G n r m Pg I hPg hPI hI hφ hpos hμ hμmass X (fun a => hPg _ a.1.property) + y v α sets hsets hcard ggiant favorable (fun a => hgiant a.1) + (V n) H (V (n + 1)) (fun a => (mem_transferFrequencyRange _ _).mp a.2.2.property) + (fun a => hH a.1 (y a)) hscale (fun a => hlarge a.1 (y a)) + dsimp only at ht + rw [← movingTemplatePrimeAmplitude_index] at ht + have hC u p : movingRegularCoefficient L + (fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable) + outside.prod (∏ i, value (u i)) v (W u) p = + fun a => W u p a * movingTaggedTransform (L a) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable + (p * (∏ i, value (u i)) * outside.prod) (v a) := by + funext a + exact congrArg (fun z => W u p a * z) + (movingOneGiant_transform_tagged (X a) (value ∘ y a) greg ggiant favorable + (p * (∏ i, value (u i)) * outside.prod) (v a)) + convert ht using 1 + congr 1 + · unfold movingAmplitudeDiagonal + apply Finset.sum_congr rfl + intro u _ + congr 1 + apply Finset.sum_congr rfl + intro p _ + congr 1 + simp only [movingOneGiantModuli_product, Function.comp_apply] + exact congrArg (fun c : A → ℂ => + (pivotDiagonal (fun a => X a * ∏ i, value (y a i)) v c).re) (hC u p).symm + · congr 1 + unfold movingAmplitudeOffDiagonal + apply Finset.sum_congr rfl + intro u _ + congr 1 + conv_rhs => rw [← Finset.sum_coe_sort] + apply Finset.sum_congr rfl + intro s hs + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + simp only [movingOneGiantModuli_product, Function.comp_apply, + movingOneGiant_pair_transform_tagged] + dsimp only [movingTemplateIntegerFourierTerm, movingTemplateTransferWeight, A, X, y, v, α, W] + split_ifs + · simp only [map_mul, Complex.conj_ofReal] + simp only [starRingEnd_apply] + dsimp only [greg] + ring + · simp only [mul_zero] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticBlocks.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticBlocks.lean new file mode 100644 index 0000000000000000000000000000000000000000..5135df8d4d68c8cf3ec56ea6b792be02ce97775f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticBlocks.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedProduct +import OAI.NumberTheory.Ostmann.Arithmetic.CRTLineAverage + +namespace OAI + +/-! # Concrete CRT blocks for the original moving-history coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators + +abbrev MovingArithmeticBlocks {I : Type*} (P : Finset ℕ) (S : Finset I) := + Unit ⊕ (P ⊕ S) + +/-- One frequency block, one square for each distinct internal prime, and +one field for each spectator. -/ +def movingArithmeticModuli {I : Type*} (r : ℕ) (q : I → ℕ) + (P : Finset ℕ) (S : Finset I) : MovingArithmeticBlocks P S → ℕ + | .inl _ => r + | .inr (.inl p) => p.val ^ 2 + | .inr (.inr i) => q i.val + +theorem movingArithmeticModuli_product {I : Type*} (r : ℕ) (q : I → ℕ) + (P : Finset ℕ) (S : Finset I) : + (∏ b, movingArithmeticModuli r q P S b) = + r * ((∏ p ∈ P, p) ^ 2 * ∏ i ∈ S, q i) := by + simp only [Fintype.prod_sum_type, movingArithmeticModuli, Fintype.prod_unique, + Finset.prod_coe_sort, Finset.prod_pow] + have hp : (∏ x : P, (x : ℕ)) = ∏ p ∈ P, p := Finset.prod_coe_sort P (fun p : ℕ => p) + rw [hp] + +theorem movingFrequencyPairFactor_modEq {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (hf : ∀ side, (T side).Frequencies (· ≠ 0)) + (hR : ∀ side, (T side).frequencyProduct ∣ R) (x y a b M : ℤ) + (hM : R ^ (n + 1) ∣ M) (hx : x ≡ a [ZMOD M]) (hy : y ≡ b [ZMOD M]) : + movingFrequencyPairFactor value outside F E T nodes R x y = + movingFrequencyPairFactor value outside F E T nodes R a b := by + have he (side : Bool) := movingFrequencyGate_modEq value R (T side) (hf side) (hR side) + x y a b (hx.of_dvd hM) (hy.of_dvd hM) + have hs : movingFrequencyPairSupport value outside T nodes R x y ↔ + movingFrequencyPairSupport value outside T nodes R a b := by + simp only [movingFrequencyPairSupport, he] + by_cases h : movingFrequencyPairSupport value outside T nodes R a b + · simp only [movingFrequencyPairFactor, ite_eq_left (hs.mpr h), ite_eq_left h] + · simp only [movingFrequencyPairFactor, ite_eq_right (fun hxy => h (hs.mp hxy)), + ite_eq_right h] + +/-- CRT coordinates are the casts of the original two residue representatives. -/ +theorem crtExternalPairEquiv_casts {B : Type*} [Fintype B] (a : B → ℕ) + [NeZero (∏ i, a i)] (hc : Pairwise (fun i j => (a i).Coprime (a j))) + (z : ZMod (∏ i, a i) × (ZMod (∏ i, a i))ˣ) (i : B) : + ((z.1.val : ZMod (a i)), ((z.2 : ZMod (∏ i, a i)).val : ZMod (a i))) = + ((crtExternalPairEquiv a hc z i).1, ((crtExternalPairEquiv a hc z i).2 : ZMod (a i))) := by + rcases z with ⟨x, y⟩ + rw [crtExternalPairEquiv_apply, crtUnitEquiv_apply, ZMod.prodEquivPi_apply] + apply Prod.ext + · have h := congrArg (ZMod.castHom (Finset.dvd_prod_of_mem a (Finset.mem_univ i)) + (ZMod (a i))) (ZMod.natCast_zmod_val x) + simpa only [map_natCast] using h + · have h := congrArg (ZMod.castHom (Finset.dvd_prod_of_mem a (Finset.mem_univ i)) + (ZMod (a i))) (ZMod.natCast_zmod_val (y : ZMod (∏ i, a i))) + change ((y : ZMod (∏ i, a i)).val : ZMod (a i)) = + (ZMod.castHom (Finset.dvd_prod_of_mem a (Finset.mem_univ i)) (ZMod (a i))) + (y : ZMod (∏ i, a i)) + simpa only [map_natCast] using h + +noncomputable def movingArithmeticLocalFactor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : Bool → ∀ i, (ZMod (q i))ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) (P : Finset ℕ) (S : Finset I) : + (b : MovingArithmeticBlocks P S) → + ZMod (movingArithmeticModuli r q P S b) × (ZMod (movingArithmeticModuli r q P S b))ˣ → ℂ + | .inl _, z => movingFrequencyPairFactor value outside F E T nodes R + z.1.val (show (ZMod r)ˣ from z.2).val.val + | .inr (.inl p), z => movingInternalPairFactor value T p.val z.1 (show (ZMod (p.val ^ 2))ˣ from z.2).val + | .inr (.inr i), z => movingSpectatorPairFactor value (q i.val) (g i.val) + (fun side => D side i.val) T z.1 (show (ZMod (q i.val))ˣ from z.2).val + +/-- Complex-valued finite CRT factorization for the actual arithmetic blocks. -/ +theorem movingArithmeticBlocks_average {I : Type*} (r : ℕ) (q : I → ℕ) + (P : Finset ℕ) (S : Finset I) + [∀ b, NeZero (movingArithmeticModuli r q P S b)] + [NeZero (∏ b, movingArithmeticModuli r q P S b)] + (hc : Pairwise (fun b c => (movingArithmeticModuli r q P S b).Coprime + (movingArithmeticModuli r q P S c))) + (f : ∀ b, ZMod (movingArithmeticModuli r q P S b) × + (ZMod (movingArithmeticModuli r q P S b))ˣ → ℂ) : + (Fintype.card (ZMod (∏ b, movingArithmeticModuli r q P S b) × + (ZMod (∏ b, movingArithmeticModuli r q P S b))ˣ) : ℂ)⁻¹ * + (∑ z, ∏ b, f b (crtExternalPairEquiv (movingArithmeticModuli r q P S) hc z b)) = + ∏ b, (Fintype.card (ZMod (movingArithmeticModuli r q P S b) × + (ZMod (movingArithmeticModuli r q P S b))ˣ) : ℂ)⁻¹ * ∑ z, f b z := by + let e := crtExternalPairEquiv (movingArithmeticModuli r q P S) hc + rw [e.sum_comp (fun x => ∏ b, f b (x b)), Fintype.card_congr e, Fintype.card_pi] + rw [← Fintype.prod_sum] + simp only [Nat.cast_prod, Finset.prod_mul_distrib, Finset.prod_inv_distrib] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticCells.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..23a84f1d7d1a45d6ab2e5eba3a54c0a1ffa90858 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticCells.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportWeight +import OAI.NumberTheory.Ostmann.Arithmetic.RootCellPrimeComparison + +namespace OAI + +/-! # Exact root-cell multipliers for the original moving arithmetic support -/ + +namespace Ostmann +open scoped Classical + +theorem rootCellCode_eq_of_subset (S T : Finset ℝ) (hST : S ⊆ T) (x y : ℝ) + (h : rootCellCode T x = rootCellCode T y) : rootCellCode S x = rootCellCode S y := by + funext r + exact congrFun h ⟨r.val, hST r.property⟩ + +/-- A cell is accepted precisely when it contains an original supported +integer in the prescribed progression. Invariance supplies the converse. -/ +noncomputable def movingArithmeticCellValue {σ : Type*} (value : σ → ℕ) + (_hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (_hf : T.Frequencies (· ≠ 0)) (XR a M : ℕ) + (S : Finset ℝ) (code : S → Ordering) : ℂ := + if ∃ XL : ℕ, + (XL : ℤ) ≡ (a : ℤ) [ZMOD M] ∧ + rootCellCode S (XL : ℝ) = code ∧ T.ArithmeticSupport value childBound pivotBound XL XR + then 1 else 0 + +theorem movingArithmeticCellValue_norm {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M : ℕ) + (S : Finset ℝ) (code : S → Ordering) : + ‖movingArithmeticCellValue value hvalue childBound pivotBound T hf XR a M S code‖ ≤ 1 := by + unfold movingArithmeticCellValue + split_ifs <;> norm_num + +/-- Adding derivative roots to the arithmetic cuts does not change the +exact support multiplier on any integer in the progression. -/ +theorem movingArithmeticIndicator_eq_cell {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XL XR a M : ℕ) + (S : Finset ℝ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hS : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ S) + (hres : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) : + movingArithmeticIndicator value childBound pivotBound T XL XR = + movingArithmeticCellValue value hvalue childBound pivotBound T hf XR a M S + (rootCellCode S (XL : ℝ)) := by + unfold movingArithmeticIndicator movingArithmeticCellValue + congr 1 + apply propext + constructor + · intro hx + exact ⟨XL, hres, rfl, hx⟩ + · rintro ⟨YL, hyres, hycode, hysupp⟩ + exact (moving_top_support_cells value hvalue childBound pivotBound T hf YL XL XR + ((hyres.trans hres.symm).of_dvd (by exact_mod_cast hM)) (rootCellCode_eq_of_subset _ S hS _ _ hycode)).mp hysupp + +theorem complexPrimeInterval_congr (q a : ℕ) (u v : ℝ) (w g : ℝ → ℂ) + (h : ∀ p ∈ Finset.Ioc ⌊Real.exp u⌋₊ ⌊Real.exp v⌋₊, + p.Prime → Nat.ModEq q p a → w (Real.log p) = g (Real.log p)) : + complexPrimeInterval q a u v w = complexPrimeInterval q a u v g := by + unfold complexPrimeInterval + apply Finset.sum_congr rfl + intro p hp + by_cases hc : p.Prime ∧ Nat.ModEq q p a + · simp only [ite_eq_left hc, h p hp hc.1 hc.2] + · simp only [ite_eq_right hc] + +/-- The exact original arithmetic indicator becomes the constructed root-cell +multiplier under the actual prime sum, with every boundary prime included. -/ +theorem movingArithmeticPrimeInterval_cells {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M : ℕ) + (S : Finset ℝ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hS : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ S) + (u v : ℝ) (w : ℝ → ℂ) : + complexPrimeInterval M a u v + (fun y => movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * w y) = + complexPrimeInterval M a u v + (fun y => movingArithmeticCellValue value hvalue childBound pivotBound T hf XR a M S + (rootCellCode S (Real.exp y)) * w y) := by + apply complexPrimeInterval_congr + intro p hp hprime hpa + have hp0 : (0 : ℝ) < p := by exact_mod_cast hprime.pos + rw [Real.exp_log hp0, Nat.floor_natCast] + rw [movingArithmeticIndicator_eq_cell value hvalue childBound pivotBound T hf p XR a M S hM hS + (Int.natCast_modEq_iff.mpr hpa)] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticModulus.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4e2ca48c565ff6da4dc6e4eec152dab51b823dc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticModulus.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticBlocks + +namespace OAI + +/-! # Coprimality of the concrete arithmetic blocks -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingArithmeticModuli_ne_zero {I : Type*} (r : ℕ) (q : I → ℕ) + (P : Finset ℕ) (S : Finset I) (hr : r ≠ 0) + (hp : ∀ p ∈ P, p.Prime) (hq : ∀ i ∈ S, (q i).Prime) + (b : MovingArithmeticBlocks P S) : movingArithmeticModuli r q P S b ≠ 0 := by + rcases b with u | (p | i) + · exact hr + · exact pow_ne_zero _ (hp p.val p.property).ne_zero + · exact (hq i.val i.property).ne_zero + +theorem movingArithmeticModuli_coprime {I : Type*} (r : ℕ) (q : I → ℕ) + (P : Finset ℕ) (S : Finset I) + (hp : ∀ p ∈ P, p.Prime) (hq : ∀ i ∈ S, (q i).Prime) + (hinj : Set.InjOn q S) + (hrp : ∀ p ∈ P, r.Coprime p) (hrq : ∀ i ∈ S, r.Coprime (q i)) + (hd : ∀ p ∈ P, ∀ i ∈ S, p ≠ q i) : + Pairwise (fun b c => (movingArithmeticModuli r q P S b).Coprime + (movingArithmeticModuli r q P S c)) := by + rintro (u | (p | i)) (v | (t | j)) hne + · cases u; cases v + exact False.elim (hne rfl) + · exact (hrp t.val t.property).pow_right 2 + · exact hrq j.val j.property + · exact (hrp p.val p.property).symm.pow_left 2 + · have hpt : p.val ≠ t.val := fun h => hne (by rw [Subtype.ext h]) + exact (((Nat.coprime_primes (hp p.val p.property) (hp t.val t.property)).mpr hpt).pow_left 2).pow_right 2 + · exact ((Nat.coprime_primes (hp p.val p.property) (hq j.val j.property)).mpr + (hd p.val p.property j.val j.property)).pow_left 2 + · exact (hrq i.val i.property).symm + · exact ((Nat.coprime_primes (hp t.val t.property) (hq i.val i.property)).mpr + (hd t.val t.property i.val i.property)).symm.pow_right 2 + · have hij : q i.val ≠ q j.val := fun h => + hne (by rw [Subtype.ext (hinj i.property j.property h)]) + exact (Nat.coprime_primes (hq i.val i.property) (hq j.val j.property)).mpr hij + +/-- The three arithmetic periods divide the concrete CRT modulus. -/ +theorem movingArithmeticModuli_periods {I : Type*} (r : ℕ) (q : I → ℕ) + (P : Finset ℕ) (S : Finset I) (R : ℤ) (k : ℕ) (hR : R ^ k ∣ (r : ℤ)) : + (R ^ k ∣ ((∏ b, movingArithmeticModuli r q P S b : ℕ) : ℤ)) ∧ + (∀ p ∈ P, (p ^ 2 : ℤ) ∣ ((∏ b, movingArithmeticModuli r q P S b : ℕ) : ℤ)) ∧ + (∀ i ∈ S, (q i : ℤ) ∣ ((∏ b, movingArithmeticModuli r q P S b : ℕ) : ℤ)) := by + constructor + · apply hR.trans + exact_mod_cast (Finset.dvd_prod_of_mem (movingArithmeticModuli r q P S) + (Finset.mem_univ (Sum.inl ()))) + constructor + · intro p hp + have h : p ^ 2 ∣ ∏ b, movingArithmeticModuli r q P S b := + Finset.dvd_prod_of_mem (movingArithmeticModuli r q P S) + (Finset.mem_univ (Sum.inr (Sum.inl (⟨p, hp⟩ : P)))) + exact_mod_cast h + · intro i hi + have h : q i ∣ ∏ b, movingArithmeticModuli r q P S b := + Finset.dvd_prod_of_mem (movingArithmeticModuli r q P S) + (Finset.mem_univ (Sum.inr (Sum.inr (⟨i, hi⟩ : S)))) + exact_mod_cast h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticPageDeletion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticPageDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..2636c4943d1f55f3470288f9230353323c9787f3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticPageDeletion.lean @@ -0,0 +1,40 @@ +import Mathlib.Algebra.BigOperators.Associated +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedPageCRT + +namespace OAI + +/-! # The prescribed conductor deletion confines Page to the frequency block -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem pageAtModulus_movingArithmeticFactors {I : Type*} + (z : Option PrimitiveRealZero) (r : ℕ) (q : I → ℕ) (P : Finset ℕ) (S : Finset I) + (cutoff : ℕ) (hP : ∀ p ∈ P, p.Prime ∧ cutoff ≤ p) + (hS : ∀ i ∈ S, (q i).Prime ∧ cutoff ≤ q i) + (hexcluded : ∀ e, z = some e → ∀ p, + deletedConductorPrime e.modulus cutoff = some p → + ¬p ∣ ∏ b, movingArithmeticModuli r q P S b) : + pageAtModulus (∏ b, movingArithmeticModuli r q P S b) z = pageAtModulus r z := by + let C := (∏ p ∈ P, p) ^ 2 * ∏ i ∈ S, q i + have hprod : (∏ b, movingArithmeticModuli r q P S b) = C * r := by + rw [movingArithmeticModuli_product] + exact Nat.mul_comm _ _ + have hlarge : ∀ p, p.Prime → p ∣ C → cutoff ≤ p := by + intro p hp hd + rcases hp.dvd_mul.mp hd with hl | hr + · obtain ⟨t, ht, hpt⟩ := (hp.prime.dvd_finsetProd_iff (fun t : ℕ => t)).mp + (hp.dvd_of_dvd_pow hl) + have heq := (Nat.prime_dvd_prime_iff_eq hp (hP t ht).1).mp hpt + simpa only [heq] using (hP t ht).2 + · obtain ⟨i, hi, hpi⟩ := (hp.prime.dvd_finsetProd_iff q).mp hr + have heq := (Nat.prime_dvd_prime_iff_eq hp (hS i hi).1).mp hpi + simpa only [heq] using (hS i hi).2 + rw [hprod] + apply pageAtModulus_regular_factor z C r cutoff hlarge + intro e he p hdel hd + exact hexcluded e he p hdel (hprod.symm ▸ hd) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticPrimeComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticPrimeComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5f637e6346b4904e21273e88b0154448f749e3e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticPrimeComparison.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticCells + +namespace OAI + +/-! # Prime idealization with the literal moving arithmetic support retained -/ + +namespace Ostmann +open scoped BigOperators Classical +open MeasureTheory + +noncomputable def movingPrimeRootCuts {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR : ℕ) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) : Finset ℝ := + movingTopRootCuts value hvalue childBound pivotBound T hf XR ∪ + polynomialRootCuts (fun i => (F i).polynomial.derivative) + +theorem movingPrimeRootCuts_card {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR : ℕ) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) : + (movingPrimeRootCuts value hvalue childBound pivotBound T hf XR F).card ≤ + (movingTopRootCuts value hvalue childBound pivotBound T hf XR).card + + ∑ i, (F i).polynomial.derivative.natDegree := by + exact (Finset.card_union_le _ _).trans + (Nat.add_le_add_left (polynomialRootCuts_card (fun i => (F i).polynomial.derivative)) _) + +/-- The arithmetic gate in this statement is the original recursive gate. +Its idealization is derived on an explicitly bounded number of root cells. -/ +theorem PublishedProgressionInput.moving_arithmetic_prime_comparison + (P : PublishedProgressionInput) {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M Q : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hQ : 2 ≤ Q) (hq : 1 ≤ M) (hqQ : M ≤ Q) (ha : a.Coprime M) + (u v : ℝ) (hu : 1 ≤ u) (huv : u ≤ v) (hshort : v ≤ u + 1) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) : + ∃ (s : ℕ → ℝ) (N : ℕ) (d : ℕ → ℂ), + Monotone s ∧ s 0 = u ∧ s N = v ∧ + N ≤ (movingTopRootCuts value hvalue childBound pivotBound T hf XR).card + + (∑ i, (F i).polynomial.derivative.natDegree) + 1 ∧ (∀ j, ‖d j‖ ≤ 1) ∧ + ‖complexPrimeInterval M a u v + (fun y => movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + smoothPolynomialWeight F (Real.exp y)) - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + d j * smoothPolynomialWeight F (Real.exp y) * + (selectedPrimeLogDensity P Q M a y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, + (‖d j‖ * smoothPolynomialBudget F * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ)))) + + 2 * smoothPolynomialBudget F * Real.exp (-(s j))) := by + let S := movingPrimeRootCuts value hvalue childBound pivotBound T hf XR F + have hS : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ S := + Finset.subset_union_left + have hroot : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S := by + intro i r hr + exact Finset.mem_union_right _ (Finset.mem_biUnion.mpr + ⟨i, Finset.mem_univ _, Multiset.mem_toFinset.mpr hr⟩) + obtain ⟨s, N, d, hs, hs0, hsN, hN, hd, herr⟩ := P.root_cell_prime_comparison hQ hq hqQ ha + u v hu huv hshort F S hroot + (movingArithmeticCellValue value hvalue childBound pivotBound T hf XR a M S) 1 + (by norm_num) (movingArithmeticCellValue_norm value hvalue childBound pivotBound T hf XR a M S) + refine ⟨s, N, d, hs, hs0, hsN, hN.trans ?_, hd, ?_⟩ + · exact Nat.add_le_add_right (movingPrimeRootCuts_card value hvalue childBound pivotBound T hf XR F) 1 + · rw [movingArithmeticPrimeInterval_cells value hvalue childBound pivotBound T hf XR a M S hM hS] + simpa only [mul_one] using herr + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticScale.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..174e55b01e2844de163d5872124b29b1efcf4b56 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticScale.lean @@ -0,0 +1,35 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # The actual degree and frequency scales in the arithmetic comparison -/ + +namespace Ostmann +open Filter + +theorem moving_arithmetic_degree_bound (n r₀ k : ℕ) (L : ℝ) (hL : 1 ≤ L) : + ((2 ^ n * (r₀ + spectatorBulkCount k L + 4 * n + 4) : ℕ) : ℝ) ≤ + ((2 ^ n : ℕ) : ℝ) * ((r₀ : ℝ) + (k : ℝ) ^ 4 + 4 * n + 4) * L := by + have hm := spectatorBulkCount_upper k L (by linarith) + have hc : 0 ≤ (r₀ : ℝ) + 4 * n + 4 := by positivity + have hh := mul_le_mul_of_nonneg_left hL hc + have hsum : (r₀ : ℝ) + spectatorBulkCount k L + 4 * n + 4 ≤ + ((r₀ : ℝ) + (k : ℝ) ^ 4 + 4 * n + 4) * L := by nlinarith + calc + _ = ((2 ^ n : ℕ) : ℝ) * ((r₀ : ℝ) + spectatorBulkCount k L + 4 * n + 4) := by + push_cast + rfl + _ ≤ _ := by + simpa only [mul_assoc] using mul_le_mul_of_nonneg_left hsum + (show (0 : ℝ) ≤ (2 ^ n : ℕ) by positivity) + +theorem moving_arithmetic_frequency_bound (k : ℕ) (A L : ℝ) + (hA : 0 ≤ A) (hL : 0 ≤ L) : + Real.log (Real.exp (A * spectatorBulkCount k L)) ≤ (A * (k : ℝ) ^ 4) * L := by + rw [Real.log_exp] + exact (mul_le_mul_of_nonneg_left (spectatorBulkCount_upper k L hL) hA).trans_eq + (mul_assoc _ _ _).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticSumRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticSumRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..b80e5a36071f40ba6e6b980be4b1986e19a27e27 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticSumRate.lean @@ -0,0 +1,153 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSignedSum +import OAI.NumberTheory.Ostmann.Construction.SpectatorBulkScale + +namespace OAI + +/-! # The original arithmetic error after summing all equality patterns -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +theorem movingInternalArithmeticError_nonneg (n c d : ℕ) (F U α β V : ℝ) + (hF : 1 ≤ F) (hU : 1 ≤ U) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 ≤ V) : + 0 ≤ movingInternalArithmeticError n c d F U α β V := by + have hbase : 1 ≤ 2 * (F * U ^ d) := by + have hh := one_le_mul_of_one_le_of_one_le hF (one_le_pow₀ hU (n := d)) + linarith + have hh := one_le_pow₀ (one_le_pow₀ hbase (n := n + 1)) (n := 2) + have hlog : 0 ≤ Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) := + Real.log_nonneg (by linarith) + unfold movingInternalArithmeticError + positivity + +theorem movingInternalArithmeticError_card (n c d : ℕ) (F U α β V : ℝ) : + movingInternalArithmeticError n c d F U α β V = + c * movingInternalArithmeticError n 1 d F U α β V := by + simp only [movingInternalArithmeticError, Nat.cast_mul, Nat.cast_add, Nat.cast_one] + ring + +theorem movingInternalArithmeticError_mono_card (n c c' d : ℕ) (F U α β V : ℝ) + (hcc : c ≤ c') (hF : 1 ≤ F) (hU : 1 ≤ U) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 ≤ V) : + movingInternalArithmeticError n c d F U α β V ≤ + movingInternalArithmeticError n c' d F U α β V := by + rw [movingInternalArithmeticError_card n c, movingInternalArithmeticError_card n c'] + exact mul_le_mul_of_nonneg_right (Nat.cast_le.mpr hcc) + (movingInternalArithmeticError_nonneg n 1 d F U α β V hF hU hα hβ hV) + +/-- A fixed-depth pattern sum retains any prescribed ordinary exponential +saving in the bulk count, and all arithmetic comparison errors stay negligible. +The antecedent is the explicit per-pattern bound proved for the original +harmonic prime laws, not a new analytic input. -/ +theorem moving_arithmetic_pattern_sum_rate (n k : ℕ) (hk : 0 < k) + (C D E Cprior B G : ℝ) (hC : 0 ≤ C) (hD : 0 ≤ D) (hE : 0 ≤ E) + (hCprior : 1 ≤ Cprior) (hB : 0 ≤ B) : + let J := 4 * n * 2 ^ n + let gain := G + 2 * ((J ^ 2 + J : ℕ) : ℝ) * Cprior + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + ∀ (d : ℕ) (F U α β Eprior cost : ℝ) + (R : Setoid (Bool × MovingSampleIndex n) → ℂ), + 1 ≤ F → 1 ≤ U → 0 ≤ α → + α ≤ Real.exp (E * L - Real.exp ((39 / 10000 : ℝ) * L)) → 0 ≤ β → + Real.log F ≤ C * L → (d : ℝ) ≤ D * L → + Real.log U ≤ Real.exp ((12 / 1000 : ℝ) * L) → + β ≤ Real.exp (E * L - Real.exp ((1 / 100 : ℝ) * L)) → + 0 ≤ Eprior → Eprior ≤ Real.exp (Cprior * L) → + 0 ≤ cost → cost ≤ Real.exp (B * L ^ 2 + B * L * Real.exp ((1 / 1000 : ℝ) * L)) → + (∀ s, ‖R s‖ ≤ + ((2 : ℝ) ^ Fintype.card (Quotient s) * Eprior ^ (J - Fintype.card (Quotient s))) * + (cost * movingInternalArithmeticError n (Fintype.card (Quotient s)) d F U α β + (Real.exp ((1 / 100 : ℝ) * L)) + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))))) → + ‖∑ s, R s‖ ≤ Real.exp (-G * m) + + 4 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + intro J gain + let H : ℝ := ((J ^ 2 + J : ℕ) : ℝ) * Cprior + have hH : 0 ≤ H := mul_nonneg (Nat.cast_nonneg _) (by linarith) + have hrate := arithmetic_error_absorption 0 (125 / 100000) (12 / 10000) H 1 1 + (by norm_num) (by norm_num) (by norm_num) (by norm_num) + filter_upwards [moving_internal_error_with_cost n J C D E Cprior B + hC hD hE hCprior hB, hrate, eventually_ge_atTop (4 : ℝ)] + with L hinternal hrate hL4 + have hL : 1 ≤ L := by linarith + simp only [one_mul, neg_mul] at hrate + dsimp only + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + intro d F U α β Eprior cost R hF hU hα0 hα hβ0 hfreq hdegree hvalue hβ + hEprior hEpriorup hcost hcostup hR + let m := spectatorBulkCount k L + let err := movingInternalArithmeticError n J d F U α β (Real.exp ((1 / 100 : ℝ) * L)) + let small := Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + have hsmall0 : 0 ≤ small := by dsimp only [small]; positivity + let budget := (2 : ℝ) ^ (J ^ 2) * (max 2 (Real.exp (Cprior * L))) ^ J + have herr : 0 ≤ err := movingInternalArithmeticError_nonneg n J d F U α β _ + hF hU hα0 hβ0 (Real.exp_nonneg _) + have hsum : ‖∑ s, R s‖ ≤ budget * (cost * err + small) := by + have hh := movingPattern_error_sum_le n (Real.exp (Cprior * L)) (cost * err + small) + (Real.exp_nonneg _) (add_nonneg (mul_nonneg hcost herr) hsmall0) R ?_ + · exact hh.trans_eq (by dsimp only [budget, J]; ring) + · intro s + have hc := movingPattern_quotient_card_le n s + have he := movingInternalArithmeticError_mono_card n _ J d F U α β (Real.exp ((1 / 100 : ℝ) * L)) + hc hF hU hα0 hβ0 (Real.exp_nonneg _) + have hp : (2 : ℝ) ^ Fintype.card (Quotient s) * Eprior ^ (J - Fintype.card (Quotient s)) ≤ + (2 : ℝ) ^ Fintype.card (Quotient s) * + (Real.exp (Cprior * L)) ^ (J - Fintype.card (Quotient s)) := + mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hEprior hEpriorup _) (by positivity) + apply (hR s).trans + have hminor := add_le_add (mul_le_mul_of_nonneg_left he hcost) (le_refl small) + exact (mul_le_mul_of_nonneg_left hminor (by positivity)).trans + ((mul_le_mul_of_nonneg_right hp (add_nonneg (mul_nonneg hcost herr) hsmall0)).trans_eq + (mul_comm _ _)) + have hbudget : budget ≤ Real.exp (H * L) := + movingPattern_total_cost_le_exp n Cprior L hCprior hL + have hmL : L ≤ 2 * m := by + have hk1 : (1 : ℝ) ≤ k := by exact_mod_cast (Nat.succ_le_iff.mpr hk) + have hk4 : (1 : ℝ) ≤ (k : ℝ) ^ 4 := one_le_pow₀ hk1 (n := 4) + have hh := mul_le_mul_of_nonneg_right hk4 (by linarith : 0 ≤ L) + have hhalf := spectatorBulkCount_half k L (by nlinarith) + dsimp only [m] + nlinarith + have hmain : budget * Real.exp (-gain * m) ≤ Real.exp (-G * m) := by + apply (mul_le_mul_of_nonneg_right hbudget (Real.exp_nonneg _)).trans + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_left hmL hH + dsimp only [gain, H] at hh ⊢ + nlinarith + have hbulk : budget * Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) ≤ + Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + apply (mul_le_mul_of_nonneg_right hbudget (Real.exp_nonneg _)).trans + apply le_trans _ hrate + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg _) + apply Real.exp_le_exp.mpr + simp only [pow_one, zero_mul, Real.exp_zero, mul_one] + nlinarith + have hsmaller : Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) ≤ + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) := by + apply Real.exp_le_exp.mpr + have hh := Real.exp_le_exp.mpr (show (125 / 100000 : ℝ) * L ≤ (2 / 1000 : ℝ) * L by linarith) + linarith + have hmid : Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) ≤ + Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + apply Real.exp_le_exp.mpr + have hh := Real.exp_le_exp.mpr + (show (12 / 10000 : ℝ) * L ≤ (125 / 100000 : ℝ) * L by linarith) + linarith + have hint : budget * cost * err ≤ Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + apply le_trans _ ((hinternal d F U α β hF hU hα0 hα hβ0 hfreq hdegree hvalue hβ).trans (hsmaller.trans hmid)) + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hcostup (by positivity)) herr + have hrest := mul_le_mul_of_nonneg_left hsmaller (show 0 ≤ budget by positivity) + have hall : budget * (cost * err + small) ≤ Real.exp (-G * m) + + 4 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + dsimp only [small] + nlinarith + exact hsum.trans hall + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0a6b19c3e07eb042fb1de7174c57b188464896d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingArithmeticSupport.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFormulaNodes + +namespace OAI + +/-! # Exact arithmetic support of the constructed moving formulas -/ + +namespace Ostmann +open scoped Classical + +theorem MovingSlotReversal.giantFormula_of_composite {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) + (hs : step.rootFrequency ≠ 0) + (hu : MovingSlotReversal.naturalProduct value step.compensationSlots ≠ 0) + (L R : HistoryFormula Bool) (a : Bool → ℤ) (XL XR Q : ℕ) + (hL : L.value (fun b => (a b : ℚ)) = (XL : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (XR : ℚ)) + (hQ : step.leftFrequency * ((XR * MovingSlotReversal.naturalProduct value step.rightSlots : ℕ) : ℤ) - + step.rightFrequency * ((XL * MovingSlotReversal.naturalProduct value step.leftSlots : ℕ) : ℤ) = + step.rootFrequency * (Q : ℤ)) : + (step.giantFormula value hs hu L R).value (fun b => (a b : ℚ)) = + (Q : ℚ) / MovingSlotReversal.naturalProduct value step.compensationSlots := by + have he := congrArg (fun z : ℤ => (z : ℚ)) hQ + simp only [Int.cast_sub, Int.cast_mul, Int.cast_natCast, Nat.cast_mul] at he + simp only [giantFormula, HistoryFormula.value_solve, HistoryFormula.value_product, + HistoryFormula.value_external, hL, hR, Int.cast_mul, Int.cast_natCast] + rw [he] + field_simp + +/-- This support is exactly the original node validity together with the +sampled compensation division. It also specifies the actual child giants. -/ +def MovingSlotData.ArithmeticSupport {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → Prop + | _, .leaf _ _, _, _ => True + | n + 1, .node s CL CR u left right, XL, XR => + ∃ Q : ℕ, ValidTransferNode (movingSlotSystem value childBound pivotBound) + ⟨n + 1, .node s CL CR u left right, XL, XR⟩ s left.frequency right.frequency Q ∧ + MovingSlotReversal.naturalProduct value u ∣ Q ∧ + left.ArithmeticSupport value childBound pivotBound (Q / MovingSlotReversal.naturalProduct value u) XL ∧ + right.ArithmeticSupport value childBound pivotBound (Q / MovingSlotReversal.naturalProduct value u) XR + +/-- The finite list of rational formulas characterizes every original +arithmetic condition. In particular the reverse implication retains the +compensation divisibility; no new support assumption is introduced. -/ +theorem MovingSlotData.formulaNodes_iff {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XL XR : ℕ) + (L R : HistoryFormula Bool) (a : Bool → ℤ) + (hL : L.value (fun b => (a b : ℚ)) = (XL : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (XR : ℚ)) : + (∀ f ∈ T.formulaNodes value hvalue childBound pivotBound hf L R, + f.guard.ValidAt a ∧ f.newGiant.IntegralAt a) ↔ + T.ArithmeticSupport value childBound pivotBound XL XR := by + induction T generalizing XL XR L R with + | leaf s regular => simp [formulaNodes, ArithmeticSupport] + | @node n s CL CR u left right ihL ihR => + let step := MovingSlotData.step s CL CR u left right false + let U := MovingSlotReversal.naturalProduct value u + have hU : U ≠ 0 := MovingSlotReversal.naturalProduct_ne_zero value hvalue u + let G := step.giantFormula value hf.1 hU L R + let g := movingNodeGuard (MovingSlotReversal.naturalProduct value CL) + (MovingSlotReversal.naturalProduct value CR) s left.frequency right.frequency hf.1 + (childBound (n + 1)) (pivotBound (n + 1)) L R + have hg := movingNodeGuard_iff value childBound pivotBound s CL CR u left right hf.1 XL XR L R a hL hR + have hformula (Q : ℕ) + (hQ : ValidTransferNode (movingSlotSystem value childBound pivotBound) + ⟨n + 1, .node s CL CR u left right, XL, XR⟩ s left.frequency right.frequency Q) : + G.value (fun b => (a b : ℚ)) = (Q : ℚ) / U := by + apply step.giantFormula_of_composite value hf.1 hU L R a XL XR Q hL hR + exact hQ.relation + have hGint (Q : ℕ) + (hQ : ValidTransferNode (movingSlotSystem value childBound pivotBound) + ⟨n + 1, .node s CL CR u left right, XL, XR⟩ s left.frequency right.frequency Q) : + G.IntegralAt a ↔ U ∣ Q := by + simp only [HistoryFormula.IntegralAt, hformula Q hQ] + exact rational_nat_div_integral_iff Q U hU + have hGvalue (Q : ℕ) + (hQ : ValidTransferNode (movingSlotSystem value childBound pivotBound) + ⟨n + 1, .node s CL CR u left right, XL, XR⟩ s left.frequency right.frequency Q) + (hdiv : U ∣ Q) : G.value (fun b => (a b : ℚ)) = (Q / U : ℕ) := by + rw [hformula Q hQ] + calc + (Q : ℚ) / U = ((U * (Q / U) : ℕ) : ℚ) / U := + congrArg (fun z : ℕ => (z : ℚ) / U) (Nat.mul_div_cancel' hdiv).symm + _ = _ := by + rw [Nat.cast_mul] + exact mul_div_cancel_left₀ _ (Nat.cast_ne_zero.mpr hU) + change (∀ f ∈ ({ guard := g, newGiant := G } :: + (left.formulaNodes value hvalue childBound pivotBound hf.2.1 G L ++ + right.formulaNodes value hvalue childBound pivotBound hf.2.2 G R) : List MovingFormulaNode), + f.guard.ValidAt a ∧ f.newGiant.IntegralAt a) ↔ _ + constructor + · intro hall + have hroot := hall ⟨g, G⟩ (by simp) + obtain ⟨Q, hQ⟩ := hg.mp hroot.1 + have hd := (hGint Q hQ).mp hroot.2 + have hv := hGvalue Q hQ hd + refine ⟨Q, hQ, hd, ?_, ?_⟩ + · apply (ihL hf.2.1 (Q / U) XL G L hv hL).mp + intro f hmem + exact hall f (List.mem_cons_of_mem _ (List.mem_append_left _ hmem)) + · apply (ihR hf.2.2 (Q / U) XR G R hv hR).mp + intro f hmem + exact hall f (List.mem_cons_of_mem _ (List.mem_append_right _ hmem)) + · rintro ⟨Q, hQ, hd, hl, hr⟩ + have hv := hGvalue Q hQ hd + have hleft := (ihL hf.2.1 (Q / U) XL G L hv hL).mpr hl + have hright := (ihR hf.2.2 (Q / U) XR G R hv hR).mpr hr + intro f hmem + rcases List.mem_cons.mp hmem with h | h + · subst f + exact ⟨hg.mpr ⟨Q, hQ⟩, (hGint Q hQ).mpr hd⟩ + · rcases List.mem_append.mp h with h | h + · exact hleft f h + · exact hright f h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAuxiliaryCoprime.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAuxiliaryCoprime.lean new file mode 100644 index 0000000000000000000000000000000000000000..37e1b51a00d2cb30e9199df00a60d8ae1f9e92fa --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAuxiliaryCoprime.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAuxiliaryPeriod +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSmallFrequencyUnits + +namespace OAI + +/-! # The recursive auxiliary period is coprime to the original regular block -/ + +namespace Ostmann +open scoped Classical + +private theorem product_coprime_right {σ : Type*} (value : σ → ℕ) (p : ℤ) + (L : List σ) (h : ∀ i ∈ L, IsCoprime p (value i : ℤ)) : + IsCoprime p (MovingSlotReversal.naturalProduct value L : ℤ) := by + induction L with + | nil => simpa [MovingSlotReversal.naturalProduct] using (isCoprime_one_right (x := p)) + | cons a L ih => + simpa only [MovingSlotReversal.naturalProduct, List.map_cons, List.prod_cons, Nat.cast_mul] + using (h a List.mem_cons_self).mul_right (ih (fun i hi => h i (List.mem_cons_of_mem a hi))) + +theorem MovingSlotData.regular_level_bound {σ : Type*} (tier : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hT : T.Levels tier) (i : σ) (hi : i ∈ T.regularSlots) : n ≤ tier i := by + cases T with + | leaf => exact Nat.zero_le _ + | node s CL CR U left right => + exact (List.mem_append.mp hi).elim (hT.1 i) (hT.2.1 i) + +theorem movingAuxiliaryUnitPeriod_coprime {σ : Type*} (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) (hT : T.Levels tier) + (i : σ) (hi : n ≤ tier i) + (hf : T.Frequencies (fun s => IsCoprime s (value i : ℤ))) + (ho : IsCoprime (value i : ℤ) (outside.prod : ℤ)) : + IsCoprime (value i : ℤ) (movingAuxiliaryUnitPeriod value outside T) := by + induction T with + | leaf s regular => exact hf.symm.mul_right ho + | @node n s CL CR U left right ihL ihR => + have hcomp : IsCoprime (value i : ℤ) (MovingSlotReversal.naturalProduct value U : ℤ) := by + apply product_coprime_right + intro j hj + have hneq : value i ≠ value j := hdisjoint i j (by have := hT.2.2.1 j hj; omega) + exact ((Nat.coprime_primes (hprime i) (hprime j)).mpr hneq).isCoprime + have hfreq : IsCoprime (value i : ℤ) + (MovingSlotData.node s CL CR U left right).frequencyProduct := + ((MovingSlotData.node s CL CR U left right).frequencies_isCoprime _).mp + (hf.mono (fun _ h => h.symm)) + exact (((hfreq.mul_right ho).mul_right (hf.1.symm.mul_right hcomp)).mul_right + (ihL hT.2.2.2.1 (by omega) hf.2.1)).mul_right (ihR hT.2.2.2.2 (by omega) hf.2.2) + +/-- This is the actual CRT separation: an original regular prime has higher +level than every compensation prime in the subtree, and is coprime to every +frequency and to the fixed outside list. -/ +theorem movingRegularProduct_coprime_auxiliary {σ : Type*} (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) (hT : T.Levels tier) + (hf : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) + (houtside : movingRegularOutsidePairwise value outside T) : + IsCoprime (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) + (movingAuxiliaryUnitPeriod value outside T) := by + have hroot : (T.regularSlots.map value ++ outside).Pairwise Nat.Coprime := by + cases T with + | leaf => exact houtside + | node => exact houtside.1 + have hp : (MovingSlotReversal.naturalProduct value T.regularSlots).Coprime + (movingAuxiliaryUnitPeriod value outside T).natAbs := by + apply Nat.coprime_list_prod_left_iff.mpr + intro a ha + obtain ⟨i, hi, rfl⟩ := List.mem_map.mp ha + have ho : (value i).Coprime outside.prod := by + apply Nat.coprime_list_prod_right_iff.mpr + intro b hb + exact (List.pairwise_append.mp hroot).2.2 _ (List.mem_map.mpr ⟨i, hi, rfl⟩) b hb + have h := movingAuxiliaryUnitPeriod_coprime tier value hprime hdisjoint outside T hT i + (T.regular_level_bound tier hT i hi) (hf i) ho.isCoprime + simpa only [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast] using h + simpa only [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast] using hp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAuxiliaryPeriod.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAuxiliaryPeriod.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc0820bdb1e66e845e6f49720a91a7047c498ebf --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAuxiliaryPeriod.lean @@ -0,0 +1,96 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAuxiliaryUnits + +namespace OAI + +/-! # A residue period that omits inherited regular-slot unit tests -/ + +namespace Ostmann +open scoped Classical + +noncomputable def movingSignedAuxiliaryUnits {σ : Type*} (value : σ → ℕ) (outside : List ℕ) : + {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → Prop + | _, T@(.leaf _ _), XL, XR => movingAuxiliaryLocalUnits outside T XL XR + | _, T@(.node s CL CR U left right), XL, XR => + let p := (MovingSlotData.step s CL CR U left right false).signedPivot value XL XR + movingAuxiliaryLocalUnits outside T XL XR ∧ + movingSignedAuxiliaryUnits value outside left p XL ∧ movingSignedAuxiliaryUnits value outside right p XR + +def movingAuxiliaryUnitPeriod {σ : Type*} (value : σ → ℕ) (outside : List ℕ) : + {n : ℕ} → MovingSlotData σ n → ℤ + | _, T@(.leaf _ _) => T.frequencyProduct * outside.prod + | _, T@(.node s _ _ U left right) => + (T.frequencyProduct * outside.prod) * (s * (MovingSlotReversal.naturalProduct value U : ℤ)) * + movingAuxiliaryUnitPeriod value outside left * movingAuxiliaryUnitPeriod value outside right + +theorem movingSignedAuxiliaryUnits_nat {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (XL XR : ℕ) (hI : T.Integral value XL XR) : + movingSignedAuxiliaryUnits value outside T XL XR ↔ movingAuxiliaryUnits value outside T XL XR := by + induction T generalizing XL XR with + | leaf => rfl + | node s CL CR U left right ihL ihR => + simp only [movingSignedAuxiliaryUnits, movingAuxiliaryUnits, + (MovingSlotData.step s CL CR U left right false).signedPivot_nat value hvalue hf.1 XL XR hI.1, + ihL hf.2.1 _ _ hI.2.1, ihR hf.2.2 _ _ hI.2.2] + +theorem movingAuxiliaryLocalUnits_modEq {σ : Type*} (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR YL YR : ℤ) + (hL : XL ≡ YL [ZMOD T.frequencyProduct * outside.prod]) + (hR : XR ≡ YR [ZMOD T.frequencyProduct * outside.prod]) : + movingAuxiliaryLocalUnits outside T XL XR ↔ movingAuxiliaryLocalUnits outside T YL YR := by + unfold movingAuxiliaryLocalUnits + rw [int_modEq_isCoprime_iff (hL.of_dvd (dvd_mul_right _ _)), + int_modEq_isCoprime_iff (hR.of_dvd (dvd_mul_right _ _)), + int_modEq_isCoprime_iff (hL.of_dvd (dvd_mul_left _ _)), + int_modEq_isCoprime_iff (hR.of_dvd (dvd_mul_left _ _))] + +theorem movingSignedAuxiliaryUnits_modEq {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (XL XR YL YR : ℤ) + (hL : XL ≡ YL [ZMOD movingAuxiliaryUnitPeriod value outside T]) + (hR : XR ≡ YR [ZMOD movingAuxiliaryUnitPeriod value outside T]) : + movingSignedAuxiliaryUnits value outside T XL XR ↔ movingSignedAuxiliaryUnits value outside T YL YR := by + induction T generalizing XL XR YL YR with + | leaf s regular => exact movingAuxiliaryLocalUnits_modEq outside _ _ _ _ _ hL hR + | node s CL CR U left right ihL ihR => + let T := MovingSlotData.node s CL CR U left right + let a := T.frequencyProduct * (outside.prod : ℤ) + let c := s * (MovingSlotReversal.naturalProduct value U : ℤ) + let dl := movingAuxiliaryUnitPeriod value outside left + let dr := movingAuxiliaryUnitPeriod value outside right + have hd : movingAuxiliaryUnitPeriod value outside T = a * c * dl * dr := rfl + have hl : movingAuxiliaryLocalUnits outside T XL XR ↔ movingAuxiliaryLocalUnits outside T YL YR := + movingAuxiliaryLocalUnits_modEq outside T XL XR YL YR + (hL.of_dvd ⟨c * dl * dr, by rw [hd]; ring⟩) + (hR.of_dvd ⟨c * dl * dr, by rw [hd]; ring⟩) + let step := MovingSlotData.step s CL CR U left right false + let p := step.signedPivot value XL XR + let r := step.signedPivot value YL YR + have hp : p ≡ r [ZMOD a * dl * dr] := + step.signedPivot_modEq value hvalue hf.1 XL XR YL YR _ + (hL.of_dvd ⟨1, by change a * c * dl * dr = c * (a * dl * dr) * 1; ring⟩) + (hR.of_dvd ⟨1, by change a * c * dl * dr = c * (a * dl * dr) * 1; ring⟩) + exact and_congr hl (and_congr + (ihL hf.2.1 p XL r YL (hp.of_dvd ⟨a * dr, by ring⟩) + (hL.of_dvd ⟨a * c * dr, by rw [hd]; ring⟩)) + (ihR hf.2.2 p XR r YR (hp.of_dvd ⟨a * dl, by ring⟩) + (hR.of_dvd ⟨a * c * dl, by rw [hd]; ring⟩))) + +theorem movingAuxiliaryUnitPeriod_dvd_full {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) : + movingAuxiliaryUnitPeriod value outside T ∣ movingGiantUnitPeriod value outside T := by + induction T with + | leaf s regular => + refine ⟨MovingSlotReversal.naturalProduct value regular, ?_⟩ + simp only [movingAuxiliaryUnitPeriod, movingGiantUnitPeriod, MovingSlotData.regularSlots] + ring + | node s CL CR U left right ihL ihR => + have hlocal : (MovingSlotData.node s CL CR U left right).frequencyProduct * (outside.prod : ℤ) ∣ + (MovingSlotData.node s CL CR U left right).frequencyProduct * + (MovingSlotReversal.naturalProduct value (CL ++ CR) : ℤ) * outside.prod := + ⟨MovingSlotReversal.naturalProduct value (CL ++ CR), by ring⟩ + exact mul_dvd_mul (mul_dvd_mul (mul_dvd_mul hlocal (dvd_refl _)) ihL) ihR + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAuxiliaryUnits.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAuxiliaryUnits.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d810d2076f77a8fcfd8dcc13a8f4843d46bed6d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAuxiliaryUnits.lean @@ -0,0 +1,139 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedWeight + +namespace OAI + +/-! # Separating inherited regular-slot units from the recursive residue tests -/ + +namespace Ostmann +open scoped Classical + +def movingAuxiliaryLocalUnits {σ : Type*} (outside : List ℕ) {n : ℕ} + (T : MovingSlotData σ n) (XL XR : ℤ) : Prop := + IsCoprime XL T.frequencyProduct ∧ IsCoprime XR T.frequencyProduct ∧ + IsCoprime XL (outside.prod : ℤ) ∧ IsCoprime XR (outside.prod : ℤ) + +def movingAuxiliaryUnits {σ : Type*} (value : σ → ℕ) (outside : List ℕ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → Prop + | _, T@(.leaf _ _), XL, XR => movingAuxiliaryLocalUnits outside T XL XR + | _, T@(.node s CL CR U left right), XL, XR => + let p := (MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR + movingAuxiliaryLocalUnits outside T XL XR ∧ + movingAuxiliaryUnits value outside left p XL ∧ movingAuxiliaryUnits value outside right p XR + +theorem movingNaturalGiantUnits_auxiliary {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) + (h : movingNaturalGiantUnits value outside T XL XR) : movingAuxiliaryUnits value outside T XL XR := by + induction T generalizing XL XR with + | leaf => exact ⟨h.1, h.2.1, h.2.2.2.2.1, h.2.2.2.2.2⟩ + | node s CL CR U left right ihL ihR => + exact ⟨⟨h.1.1, h.1.2.1, h.1.2.2.2.2.1, h.1.2.2.2.2.2⟩, + ihL _ _ h.2.1, ihR _ _ h.2.2⟩ + +private theorem localGiantUnits_of_pairwise {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) + (hp : (T.currentSlots value XL XR ++ outside).Pairwise Nat.Coprime) + (hu : movingAuxiliaryLocalUnits outside T XL XR) : movingLocalGiantUnits value outside T XL XR := by + have hcur : T.CurrentPairwise value XL XR := (List.pairwise_append.mp hp).1 + have h := (T.currentPairwise_iff value XL XR).mp hcur + exact ⟨hu.1, hu.2.1, h.2.2.1.isCoprime, h.2.2.2.isCoprime, hu.2.2.1, hu.2.2.2⟩ + +theorem movingFullOutsidePairwise_giantUnits {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) + (hp : movingFullOutsidePairwise value outside T XL XR) + (hu : movingAuxiliaryUnits value outside T XL XR) : movingNaturalGiantUnits value outside T XL XR := by + induction T generalizing XL XR with + | leaf => exact localGiantUnits_of_pairwise value outside _ _ _ hp hu + | node s CL CR U left right ihL ihR => + exact ⟨localGiantUnits_of_pairwise value outside _ _ _ hp.1 hu.1, + ihL _ _ hp.2.1 hu.2.1, ihR _ _ hp.2.2 hu.2.2⟩ + +theorem movingFullSupport_auxiliary_iff {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : + movingFullSupport value outside T XL XR ↔ + movingFullOutsidePairwise value outside T XL XR ∧ movingAuxiliaryUnits value outside T XL XR := + ⟨fun h => ⟨h.1, movingNaturalGiantUnits_auxiliary value outside T XL XR h.2⟩, + fun h => ⟨h.1, movingFullOutsidePairwise_giantUnits value outside T XL XR h.1 h.2⟩⟩ + +private theorem currentOutsidePairwise_auxiliary_iff {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) + (hu : movingAuxiliaryLocalUnits outside T XL XR) : + (T.currentSlots value XL XR ++ outside).Pairwise Nat.Coprime ↔ + T.CurrentPairwise value XL XR ∧ (T.regularSlots.map value ++ outside).Pairwise Nat.Coprime := by + have hXL := Nat.coprime_list_prod_right_iff.mp hu.2.2.1.natCoprime + have hXR := Nat.coprime_list_prod_right_iff.mp hu.2.2.2.natCoprime + simp only [MovingSlotData.currentSlots, MovingSlotData.CurrentPairwise, + List.cons_append, List.pairwise_cons, List.mem_cons, List.mem_append, forall_eq_or_imp] + constructor + · rintro ⟨⟨hp, hl⟩, hr, hs⟩ + exact ⟨⟨⟨hp, fun a ha => hl a (Or.inl ha)⟩, + (fun a ha => hr a (Or.inl ha)), (List.pairwise_append.mp hs).1⟩, hs⟩ + · rintro ⟨⟨⟨hp, hl⟩, hr, _⟩, hs⟩ + exact ⟨⟨hp, fun a ha => ha.elim (hl a) (hXL a)⟩, + (fun a ha => ha.elim (hr a) (hXR a)), hs⟩ + +theorem movingFullOutsidePairwise_auxiliary_iff {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) + (hu : movingAuxiliaryUnits value outside T XL XR) : + movingFullOutsidePairwise value outside T XL XR ↔ + T.FullPairwise value XL XR ∧ movingRegularOutsidePairwise value outside T := by + induction T generalizing XL XR with + | leaf => exact currentOutsidePairwise_auxiliary_iff value outside _ _ _ hu + | node s CL CR U left right ihL ihR => + simp only [movingFullOutsidePairwise, MovingSlotData.FullPairwise, + movingRegularOutsidePairwise, currentOutsidePairwise_auxiliary_iff value outside _ _ _ hu.1, + ihL _ _ hu.2.1, ihR _ _ hu.2.2] + tauto + +private theorem naturalProduct_coprime_of_members {σ : Type*} (value : σ → ℕ) (s : ℤ) + (L : List σ) (h : ∀ i ∈ L, IsCoprime s (value i : ℤ)) : + IsCoprime s (MovingSlotReversal.naturalProduct value L : ℤ) := by + induction L with + | nil => simpa [MovingSlotReversal.naturalProduct] using (isCoprime_one_right (x := s)) + | cons a L ih => + simpa only [MovingSlotReversal.naturalProduct, List.map_cons, List.prod_cons, Nat.cast_mul] + using (h a List.mem_cons_self).mul_right (ih (fun i hi => h i (List.mem_cons_of_mem a hi))) + +theorem movingAuxiliaryUnits_cross {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) + (hsmall : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) (XL XR : ℕ) + (hu : movingAuxiliaryUnits value outside T XL XR) : T.CrossFrequencyUnits value XL XR := by + induction T generalizing XL XR with + | leaf => trivial + | node s CL CR U left right ihL ihR => + have hXL := (left.frequencies_isCoprime (XL : ℤ)).mpr + (hu.1.1.of_isCoprime_of_dvd_right ⟨s * right.frequencyProduct, by + simp only [MovingSlotData.frequencyProduct]; ring⟩) + have hXR := (right.frequencies_isCoprime (XR : ℤ)).mpr + (hu.1.2.1.of_isCoprime_of_dvd_right ⟨s * left.frequencyProduct, by + simp only [MovingSlotData.frequencyProduct]; ring⟩) + refine ⟨?_, ?_, ihL (fun i => (hsmall i).2.1) _ _ hu.2.1, + ihR (fun i => (hsmall i).2.2) _ _ hu.2.2⟩ + · simpa only [Nat.cast_mul] using hXL.root.symm.mul_right + (naturalProduct_coprime_of_members value left.frequency CL (fun i _ => (hsmall i).2.1.root)) + · simpa only [Nat.cast_mul] using hXR.root.symm.mul_right + (naturalProduct_coprime_of_members value right.frequency CR (fun i _ => (hsmall i).2.2.root)) + +/-- All descendant regular-slot units have disappeared; only the top current +pair, the explicit square tests, and frequency/outside tests remain. -/ +theorem movingFullSupport_auxiliary_square_iff {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (hcoh : T.RegularCoherent) (hc : T.CompensationPrimeData value) + (hsmall : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) (XL XR : ℕ) + (hI : T.Integral value XL XR) : + movingFullSupport value outside T XL XR ↔ + T.CurrentPairwise value XL XR ∧ movingRegularOutsidePairwise value outside T ∧ + T.PrimeSquareTests value XL XR ∧ movingAuxiliaryUnits value outside T XL XR := by + rw [movingFullSupport_auxiliary_iff] + constructor + · rintro ⟨hp, hu⟩ + obtain ⟨hpair, hs⟩ := (movingFullOutsidePairwise_auxiliary_iff value outside T XL XR hu).mp hp + obtain ⟨ht, hsq⟩ := (T.fullPairwise_iff_squareTests value hcoh hc XL XR hI + (movingAuxiliaryUnits_cross value outside T hsmall XL XR hu)).mp hpair + exact ⟨ht, hs, hsq, hu⟩ + · rintro ⟨ht, hs, hsq, hu⟩ + refine ⟨(movingFullOutsidePairwise_auxiliary_iff value outside T XL XR hu).mpr ⟨?_, hs⟩, hu⟩ + exact (T.fullPairwise_iff_squareTests value hcoh hc XL XR hI + (movingAuxiliaryUnits_cross value outside T hsmall XL XR hu)).mpr ⟨ht, hsq⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAveragedIntegerNode.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAveragedIntegerNode.lean new file mode 100644 index 0000000000000000000000000000000000000000..7cb7f3dc071384cfe22324e6d22d0e575a517099 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingAveragedIntegerNode.lean @@ -0,0 +1,128 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTransformedIntegerNode + +namespace OAI + +/-! # Averaging the forced integer node under the surviving regular law -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingTemplateSidePrior {σ : Type} (n r m : ℕ) + (ν : MovingRegularSlot (n + 1) r m → σ → ℝ) (left : Bool) + (y : MovingRegularSlot n r m → σ) : ℝ := + ∏ i, ν (if left then (.inl i.1, i.2) else (.inr i.1, i.2)) (y i) + +noncomputable def movingTemplateIntegerFourierTerm {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (I : Finset ℕ) + (XL XR : ℕ) (s : ℤ) (left right : MovingRegularSlot n r m → σ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (u : TreeLeafIndex n × Fin 4 → σ) (v w : ℤ) : ℂ := + let LH := XL * ∏ i, value (left i) + let RH := XR * ∏ i, value (right i) + let p := reconstructedPivot (v * RH - w * LH) (s * ∏ i, value (u i)) + if validTransferredPivot I (v * RH - w * LH) (s * ∏ i, value (u i)) then + (φ (Real.log p - G (n + 1)) : ℂ) * + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m v + (movingRestoreSample n r m u left) p XL * + star (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w + (movingRestoreSample n r m u right) p XR) * + movingTaggedTransform + (Sum.elim (movingOneGiantModuli XL (value ∘ left)) + (movingOneGiantModuli XR (value ∘ right))) + (Sum.elim (Sum.elim (fun _ : Unit => true) (fun _ => false)) + (Sum.elim (fun _ : Unit => true) (fun _ => false))) + greg ggiant favorable outside.prod s + else 0 + +/-- The next regular template is the independent pair of the two surviving +templates. Compensation remains outside both priors and is sampled once. -/ +theorem movingTemplateCoefficient_averaged_integer_node {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (hsV : s.natAbs ≤ V (n + 1)) + (ν : MovingRegularSlot (n + 1) r m → σ → ℝ) + (XL XR : ℕ) (hXL : XL.Prime) (hXR : XR.Prime) + (hVL : V (n + 1) < XL) (hVR : V (n + 1) < XR) + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ right, movingTemplateSidePrior n r m ν false right ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < XR * ∏ i, value (right i)) + (hRH : ∀ right, movingTemplateSidePrior n r m ν false right ≠ 0 → + ∀ q, q.Prime → q ∣ XR * (∏ i, value (right i)) → V (n + 1) < q) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + (∑ y : MovingRegularSlot (n + 1) r m → σ, ((∏ i, ν i (y i) : ℝ) : ℂ) * + (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G (n + 1) r m s y XL XR * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then XL else XR) (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s)) = + ∑ u : TreeLeafIndex n × Fin 4 → σ, + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * + ∑ left : MovingRegularSlot n r m → σ, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right : MovingRegularSlot n r m → σ, (movingTemplateSidePrior n r m ν false right : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + movingTemplateIntegerFourierTerm value outside μ childBound pivotBound V F φ G n r m I + XL XR s left right greg ggiant favorable u v.val w.val := by + let A := fun y : MovingRegularSlot (n + 1) r m → σ => + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G (n + 1) r m s y XL XR * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then XL else XR) (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s + let M := fun u : TreeLeafIndex n × Fin 4 → σ => + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) + let B := fun left right u => + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + movingTemplateIntegerFourierTerm value outside μ childBound pivotBound V F φ G n r m I + XL XR s left right greg ggiant favorable u v.val w.val + have hn left right (hr : movingTemplateSidePrior n r m ν false right ≠ 0) : + A (movingTemplatePairSample n r m left right) = ∑ u, M u * B left right u := by + exact movingTemplateCoefficient_transformed_integer_node value outside μ childBound pivotBound V hV + F hF φ G n r m s hsV left right XL XR hXL hXR hVL hVR I hI hφ hchild + (hgap right hr) (hRH right hr) hcomp (fun i => (hvalue _).ne_zero) + (fun i => (hvalue _).ne_zero) greg ggiant favorable + change (∑ y, ((∏ i, ν i (y i) : ℝ) : ℂ) * A y) = _ + rw [movingTemplatePair_average] + change (∑ left, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right, (movingTemplateSidePrior n r m ν false right : ℂ) * + A (movingTemplatePairSample n r m left right)) = _ + have he : (∑ left, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right, (movingTemplateSidePrior n r m ν false right : ℂ) * + A (movingTemplatePairSample n r m left right)) = + ∑ left, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right, (movingTemplateSidePrior n r m ν false right : ℂ) * + ∑ u, M u * B left right u := by + apply Finset.sum_congr rfl + intro left _ + congr 1 + apply Finset.sum_congr rfl + intro right _ + by_cases hr : movingTemplateSidePrior n r m ν false right = 0 + · simp only [hr, Complex.ofReal_zero, zero_mul] + · rw [hn left right hr] + rw [he] + change _ = ∑ u, M u * ∑ left, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right, (movingTemplateSidePrior n r m ν false right : ℂ) * B left right u + simp only [Finset.mul_sum] + conv_lhs => + arg 2 + ext left + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro u _ + apply Finset.sum_congr rfl + intro left _ + apply Finset.sum_congr rfl + intro right _ + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBadDiagonalRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBadDiagonalRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..07494036194dbd9da6dfd29f97b45aaa48e9018a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBadDiagonalRate.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBadHarmonicScale +import OAI.NumberTheory.Ostmann.Construction.DiagonalGapBudget + +namespace OAI + +/-! # The bad part of the actual logarithmic diagonal at the chosen gaps -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +theorem eventual_moving_bad_diagonal_rate (n s k : ℕ) (hk : 0 < k) + (Bs BD Bz B C a ε εdiag : ℝ) (ha : 0 < a) (hε : 0 < ε) (hεdiag : 0 ≤ εdiag) + (hbudget : 4 * C * s ≤ ε * (k : ℝ) ^ 4) (hBz : 9 ≤ Bz) + (hBD : Bs + 2 * B + (Real.log 2 - Real.log a + 5 / 4 + ε + Real.log 12 + 1 + εdiag) + 6 ≤ BD) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let z := (k : ℝ) ^ 4 + let r : ℝ := (2 ^ n : ℕ) + let Δ := spectatorBaseGap Bs z m + ∀ mass : MovingRegularSlot n s m → ℝ, + (∀ j : TreeLeafIndex n × Fin s, Real.exp (-C * L) ≤ mass (j.1, .inl j.2)) → + (∀ j : TreeLeafIndex n × Fin m, a * L ≤ mass (j.1, .inr j.2)) → + ∀ arch : ℝ, arch ≤ Real.exp (-spectatorStepGap BD Bz z r m) → + arch * + (((((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) * + Real.exp (r * m * (-(3 / 4 : ℝ) * Real.log r + 5 / 4))) * + (((Fintype.card (MovingRegularSlot n s m)).factorial : ℝ) * (∏ i, (mass i)⁻¹))) * + Real.exp (r * Δ + (Real.log 12 + 1) * r * m + εdiag * m) ≤ + Real.exp (-(2 * B + 6) * r * m) := by + filter_upwards [eventual_moving_bad_harmonic_scale n s k hk C a ε ha hε hbudget, + eventually_gt_atTop (0 : ℝ)] with L hmass hL + dsimp only at hmass ⊢ + intro mass hsmall hbulk arch harch + let m := spectatorBulkCount k L + let z := (k : ℝ) ^ 4 + let r : ℝ := (2 ^ n : ℕ) + have hr : 1 ≤ r := by dsimp [r]; exact_mod_cast (Nat.one_le_two_pow) + have hz : 1 ≤ z := by + dsimp [z] + exact one_le_pow₀ (by exact_mod_cast hk) + have hm : 0 ≤ (m : ℝ) := Nat.cast_nonneg _ + have hlog : Real.log ((k : ℝ) ^ 4 / a) = Real.log z - Real.log a := + Real.log_div (by positivity) ha.ne' + have hnorm := hmass mass hsmall hbulk + rw [hlog] at hnorm + have hp : (2 : ℝ) ^ n = ((2 ^ n : ℕ) : ℝ) := by simp + rw [hp] at hnorm + have hmass0 : 0 ≤ ∏ i, (mass i)⁻¹ := by + apply Finset.prod_nonneg + rintro ⟨j, i | i⟩ _ + · exact inv_nonneg.mpr ((Real.exp_pos _).le.trans (hsmall (j, i))) + · exact inv_nonneg.mpr ((mul_pos ha hL).le.trans (hbulk (j, i))) + have hdiag : r * spectatorBaseGap Bs z m + (Real.log 12 + 1) * r * m + εdiag * m ≤ + r * spectatorBaseGap Bs z m + (Real.log 12 + 1 + εdiag) * r * m := by + nlinarith [mul_le_mul_of_nonneg_right hr (mul_nonneg hεdiag hm)] + have hgap := spectator_diagonal_exponent_bound Bs BD Bz z r m + (Real.log 2 - Real.log a + 5 / 4 + ε + Real.log 12 + 1 + εdiag) B + hz hr hm hBz hBD + apply (mul_le_mul_of_nonneg_right + (mul_le_mul harch hnorm (mul_nonneg (by positivity) + (mul_nonneg (Nat.cast_nonneg _) hmass0)) (Real.exp_nonneg _)) (Real.exp_nonneg _)).trans + rw [← Real.exp_add, ← Real.exp_add] + apply Real.exp_le_exp.mpr + dsimp only [r] at hdiag hgap ⊢ + push_cast at hdiag hgap ⊢ + nlinarith only [hdiag, hgap] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBadHarmonicBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBadHarmonicBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0126e8814b4b631a20b5a817ba75bd6452cc697 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBadHarmonicBudget.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicMassBudget +import OAI.NumberTheory.Ostmann.Construction.SpectatorBulkScale + +namespace OAI + +/-! # The bad-arrangement saving in the complete diagonal normalization -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +noncomputable def movingNonbulkCost (n s : ℕ) : ℝ := + (((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) * + (2 : ℝ) ^ (2 ^ n * s) * ((2 ^ n * s).factorial : ℝ) + +theorem moving_bad_full_harmonic_bound (n s m : ℕ) + (mass : MovingRegularSlot n s m → ℝ) (L z C : ℝ) (hL : 0 < L) (hz : 0 < z) + (hm : (m : ℝ) ≤ z * L) + (hsmall : ∀ j : TreeLeafIndex n × Fin s, Real.exp (-C * L) ≤ mass (j.1, .inl j.2)) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, L ≤ mass (j.1, .inr j.2)) : + ((((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) * + Real.exp ((2 ^ n : ℝ) * m * (-(3 / 4 : ℝ) * Real.log (2 ^ n : ℕ) + 5 / 4))) * + (((Fintype.card (MovingRegularSlot n s m)).factorial : ℝ) * (∏ i, (mass i)⁻¹)) ≤ + movingNonbulkCost n s * Real.exp (C * L * (2 ^ n * s : ℕ)) * + Real.exp ((Real.log 2 + Real.log z + Real.log (2 ^ n : ℕ) / 4 + 5 / 4) * (2 ^ n * m : ℕ)) := by + have h := mul_le_mul_of_nonneg_left + (movingRegular_factorial_harmonic_bound n s m mass L z C hL hz hm hsmall hbulk) + (show 0 ≤ (((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) * + Real.exp ((2 ^ n : ℝ) * m * (-(3 / 4 : ℝ) * Real.log (2 ^ n : ℕ) + 5 / 4)) by positivity) + apply h.trans_eq + unfold movingNonbulkCost + rw [show ((2 ^ n : ℝ) * m * (-(3 / 4 : ℝ) * Real.log (2 ^ n : ℕ) + 5 / 4)) = + ((2 ^ n * m : ℕ) : ℝ) * (-(3 / 4 : ℝ) * Real.log (2 ^ n : ℕ) + 5 / 4) by push_cast; ring] + have he : Real.exp (((2 ^ n * m : ℕ) : ℝ) * (-(3 / 4 : ℝ) * Real.log (2 ^ n : ℕ) + 5 / 4)) * + Real.exp ((Real.log 2 + Real.log z + Real.log (2 ^ n : ℕ)) * (2 ^ n * m : ℕ)) = + Real.exp ((Real.log 2 + Real.log z + Real.log (2 ^ n : ℕ) / 4 + 5 / 4) * (2 ^ n * m : ℕ)) := by + rw [← Real.exp_add] + congr 1 + ring + calc + _ = movingNonbulkCost n s * Real.exp (C * L * (2 ^ n * s : ℕ)) * + (Real.exp (((2 ^ n * m : ℕ) : ℝ) * (-(3 / 4 : ℝ) * Real.log (2 ^ n : ℕ) + 5 / 4)) * + Real.exp ((Real.log 2 + Real.log z + Real.log (2 ^ n : ℕ)) * (2 ^ n * m : ℕ))) := by + unfold movingNonbulkCost + ring + _ = _ := by rw [he]; rfl + +theorem eventual_moving_nonbulk_cost (n s k : ℕ) (hk : 0 < k) (C ε : ℝ) + (hε : 0 < ε) (hbudget : 4 * C * s ≤ ε * (k : ℝ) ^ 4) : + ∀ᶠ L : ℝ in atTop, + movingNonbulkCost n s * Real.exp (C * L * (2 ^ n * s : ℕ)) ≤ + Real.exp (ε * (2 ^ n : ℕ) * (spectatorBulkCount k L : ℝ)) := by + let F := movingNonbulkCost n s + let r : ℝ := (2 ^ n : ℕ) + have hr : 0 < r := by dsimp [r]; positivity + have hF : 0 < F := by dsimp [F, movingNonbulkCost]; positivity + have hk4 : 0 < (k : ℝ) ^ 4 := by positivity + have ht := (spectatorBulkCount_tendsto k hk).eventually + (eventually_ge_atTop (2 * Real.log F / (ε * r))) + filter_upwards [ht, eventually_ge_atTop (4 / (k : ℝ) ^ 4), eventually_ge_atTop (0 : ℝ)] + with L hL hscale hL0 + have hscale' : 4 ≤ (k : ℝ) ^ 4 * L := by + simpa only [mul_comm L] using (div_le_iff₀ hk4).mp hscale + have hhalf := spectatorBulkCount_half k L hscale' + have hc : C * L * (2 ^ n * s : ℕ) ≤ ε / 2 * r * (spectatorBulkCount k L : ℝ) := by + have hb := mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hbudget hL0) hr.le + have hm := mul_le_mul_of_nonneg_left hhalf (mul_nonneg hε.le hr.le) + dsimp only [r] at hm hb ⊢ + push_cast at hm hb ⊢ + nlinarith + have hlog : Real.log F ≤ ε / 2 * r * (spectatorBulkCount k L : ℝ) := by + have hh := (div_le_iff₀ (mul_pos hε hr)).mp hL + nlinarith + change F * _ ≤ _ + rw [← Real.exp_log hF, ← Real.exp_add] + exact Real.exp_le_exp.mpr (by linarith) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBadHarmonicScale.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBadHarmonicScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..51d29d2001551f5d1b8c356125ed23c17525b609 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBadHarmonicScale.lean @@ -0,0 +1,44 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBadHarmonicBudget + +namespace OAI + +/-! # Bad-arrangement normalization at the selected bulk scale -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +theorem eventual_moving_bad_harmonic_scale (n s k : ℕ) (hk : 0 < k) + (C a ε : ℝ) (ha : 0 < a) (hε : 0 < ε) + (hbudget : 4 * C * s ≤ ε * (k : ℝ) ^ 4) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ mass : MovingRegularSlot n s m → ℝ, + (∀ j : TreeLeafIndex n × Fin s, Real.exp (-C * L) ≤ mass (j.1, .inl j.2)) → + (∀ j : TreeLeafIndex n × Fin m, a * L ≤ mass (j.1, .inr j.2)) → + ((((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) * + Real.exp ((2 ^ n : ℝ) * m * (-(3 / 4 : ℝ) * Real.log (2 ^ n : ℕ) + 5 / 4))) * + (((Fintype.card (MovingRegularSlot n s m)).factorial : ℝ) * (∏ i, (mass i)⁻¹)) ≤ + Real.exp ((Real.log 2 + Real.log ((k : ℝ) ^ 4 / a) + + Real.log (2 ^ n : ℕ) / 4 + 5 / 4 + ε) * (2 ^ n * m : ℕ)) := by + filter_upwards [eventual_moving_nonbulk_cost n s k hk C ε hε hbudget, + eventually_gt_atTop (0 : ℝ)] with L hcost hL + dsimp only + intro mass hsmall hbulk + have hscale : (spectatorBulkCount k L : ℝ) ≤ ((k : ℝ) ^ 4 / a) * (a * L) := by + convert spectatorBulkCount_upper k L hL.le using 1; field_simp + have hid : -(C / a) * (a * L) = -C * L := by field_simp + have he := moving_bad_full_harmonic_bound n s (spectatorBulkCount k L) mass + (a * L) ((k : ℝ) ^ 4 / a) (C / a) (mul_pos ha hL) (by positivity) hscale + (by simpa only [hid] using hsmall) hbulk + have hid' : (C / a) * (a * L) = C * L := by field_simp + rw [hid'] at he + apply he.trans + apply (mul_le_mul_of_nonneg_right hcost (Real.exp_nonneg _)).trans_eq + rw [← Real.exp_add] + congr 1 + push_cast + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkCoefficient.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..1fe034416a2d4f9cc8512e12d5c5d4315ec3a9f4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkCoefficient.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkRecursiveWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyCoefficient + +namespace OAI + +/-! # External bulk weights in the exact original coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingSupportedSampleTerm_bulk_log {σ : Type*} + (value tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (XL XR : ℕ) (a : MovingSampleSlots σ n) : + movingSupportedSampleTerm value outside childBound pivotBound + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + E n t small bulk XL XR a = + (movingBulkTreeLogWeight value tier k outside cb cd + (buildMovingSlotData n t small bulk a) : ℂ) * + movingSupportedSampleTerm value outside childBound pivotBound F E n t small bulk XL XR a := by + unfold movingSupportedSampleTerm + rw [movingSlotWeight_bulk_log] + unfold movingSupportedWeight + split_ifs + · rfl + · exact (mul_zero _).symm + +/-- Extracting the logarithmic weights does not restrict the independent +compensation prior. Its zero terms vanish; every remaining draw has the +prescribed tier and therefore gives the same external bulk factor. -/ +theorem movingSupportedSampledWeight_bulk_log {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → σ → ℝ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (hn : n ≤ k) (hsmall : ∀ i ∈ flattenMovingSlots n small, tier i ≠ k) + (hbulk : ∀ i ∈ flattenMovingSlots n bulk, tier i = k) (XL XR : ℕ) : + movingSupportedSampledWeight value outside μ childBound pivotBound + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + E n t small bulk XL XR = + ((treeLeafProduct n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n bulk) : ℝ) : ℂ) * + movingSupportedSampledWeight value outside μ childBound pivotBound F E n t small bulk XL XR := by + rw [movingSupportedSampledWeight_eq, movingSupportedSampledWeight_eq] + unfold movingCompensatedAverage + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + by_cases ha : movingSamplesPrior μ a = 0 + · simp only [ha, mul_zero, Complex.ofReal_zero, zero_mul, mul_zero] + · rw [movingSupportedSampleTerm_bulk_log, + movingBulkTreeLogWeight_sample value tier k outside cb cd n t small bulk a hn + hsmall hbulk (movingSamplesPrior_levels μ tier hμ a ha)] + ring + +theorem movingFrequencyCoefficient_bulk_log {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → σ → ℝ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (small bulk : TreeLeafTuple (List σ) n) + (hn : n ≤ k) (hsmall : ∀ i ∈ flattenMovingSlots n small, tier i ≠ k) + (hbulk : ∀ i ∈ flattenMovingSlots n bulk, tier i = k) (XL XR : ℕ) : + movingFrequencyCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n s small bulk XL XR = + ((treeLeafProduct n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n bulk) : ℝ) : ℂ) * + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n s small bulk XL XR := by + unfold movingFrequencyCoefficient + simp only [movingSupportedSampledWeight_bulk_log value tier k outside cb cd μ hμ + childBound pivotBound F _ n _ small bulk hn hsmall hbulk XL XR, Finset.mul_sum] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkFrames.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkFrames.lean new file mode 100644 index 0000000000000000000000000000000000000000..697e54c994efbae1ccfc9561cbeee9f9899e3451 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkFrames.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantAncestorValues + +namespace OAI + +/-! # Fixed nonbulk factors and literal bulk products at each moving node -/ + +namespace Ostmann +open scoped Classical + +structure MovingFrameConstants where + leftSmall : ℕ + rightSmall : ℕ + compensation : ℕ + +/-- These factors are computed from the fixed small and internal samples; +no bulk coordinate or giant value is used. -/ +def movingFrameConstants {σ : Type*} (value : σ → ℕ) : + (n : ℕ) → TreeLeafTuple (List σ) n → MovingSampleSlots σ n → + List Bool → MovingFrameConstants + | 0, _, .leaf, _ => ⟨1, 1, 1⟩ + | n + 1, small, .node a l r, path => + let u := movingCompensationSlots n a + match path with + | [] => ⟨MovingSlotReversal.naturalProduct value (flattenMovingSlots n small.1), + MovingSlotReversal.naturalProduct value (flattenMovingSlots n small.2), + MovingSlotReversal.naturalProduct value (flattenMovingSlots n u)⟩ + | false :: path => movingFrameConstants value n (appendMovingSlotLeaves n u small.1) l path + | true :: path => movingFrameConstants value n (appendMovingSlotLeaves n u small.2) r path + +/-- The two child bulk products in the same root-to-node order. -/ +def movingBulkProducts {σ : Type*} (value : σ → ℕ) : + (n : ℕ) → TreeLeafTuple (List σ) n → List Bool → ℕ × ℕ + | 0, _, _ => (1, 1) + | n + 1, bulk, [] => + (MovingSlotReversal.naturalProduct value (flattenMovingSlots n bulk.1), + MovingSlotReversal.naturalProduct value (flattenMovingSlots n bulk.2)) + | n + 1, bulk, false :: path => movingBulkProducts value n bulk.1 path + | n + 1, bulk, true :: path => movingBulkProducts value n bulk.2 path + +/-- Every actual transfer node has its fixed small factor, its current giant, +and precisely the bulk product from its own child subtree. -/ +theorem movingNodeAtPath_products {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) + (XL XR : ℕ) (path : List Bool) (hp : path.length < n) : + let z := (transferNodeAtPath (movingSlotSystem value childBound pivotBound) n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ t path).state + let c := movingFrameConstants value n small a path + let b := movingBulkProducts value n bulk path + z.compensation value = c.compensation ∧ + z.leftProduct value = z.leftGiant * c.leftSmall * b.1 ∧ + z.rightProduct value = z.rightGiant * c.rightSmall * b.2 := by + induction n generalizing XL XR path with + | zero => simp at hp + | succ n ih => + cases a with + | node a l r => + cases path with + | nil => + simp only [transferNodeAtPath, buildMovingSlotData, movingFrameConstants, + movingBulkProducts, MovingSlotState.compensation, MovingSlotState.leftProduct, + MovingSlotState.rightProduct, movingNaturalProduct_append, Nat.mul_assoc, and_self] + | cons b path => + have hp' : path.length < n := by simpa using hp + let sys := movingSlotSystem value childBound pivotBound + let u := movingCompensationSlots n a + let x : MovingSlotState σ := + ⟨n + 1, buildMovingSlotData (n + 1) t small bulk (.node a l r), XL, XR⟩ + let p := historyPivot sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) / + MovingSlotReversal.naturalProduct value (flattenMovingSlots n u) + cases b + · exact ih t.2.1 (appendMovingSlotLeaves n u small.1) bulk.1 l p XL path hp' + · exact ih t.2.2 (appendMovingSlotLeaves n u small.2) bulk.2 r p XR path hp' + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogFactors.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogFactors.lean new file mode 100644 index 0000000000000000000000000000000000000000..f68cf7280f1ad39a3b6003a350a33652eee36915 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogFactors.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkLogWeight +import OAI.NumberTheory.Ostmann.Arithmetic.BulkSmoothRootCuts + +namespace OAI + +/-! # The retained bulk logarithmic cutoffs as polynomial factors -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def bulkLogCutoffWeight {σ : Type*} (value : σ → ℝ) + (cb : ℝ) (slots : List σ) : ℝ := + positiveLogCutoff logCellProfile cb (realSlotProduct value slots) + +theorem bulkLogCutoffWeight_bounds {σ : Type*} (value : σ → ℝ) + (cb : ℝ) (slots : List σ) : + 0 ≤ bulkLogCutoffWeight value cb slots ∧ bulkLogCutoffWeight value cb slots ≤ 1 := by + unfold bulkLogCutoffWeight positiveLogCutoff + split_ifs + · exact ⟨logCellProfile_nonneg _, logCellProfile_le_one _⟩ + · exact ⟨le_rfl, zero_le_one⟩ + +/-- At the original positive prime values this is precisely the initial +log-sum cutoff, including its unchanged spectator factor. -/ +theorem movingBulkListLogWeight_eq_cutoff {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ a, 0 < value a) (outside : List ℕ) (cb cd : ℝ) (slots : List σ) : + movingBulkListLogWeight value outside cb cd slots = + bulkLogCutoffWeight (fun a => (value a : ℝ)) cb slots * + logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) := by + have hp : 0 < realSlotProduct (fun a => (value a : ℝ)) slots := by + unfold realSlotProduct + apply List.prod_pos + intro x hx + obtain ⟨a, _, rfl⟩ := List.mem_map.mp hx + exact_mod_cast hvalue a + have hl : Real.log (realSlotProduct (fun a => (value a : ℝ)) slots) = + (slots.map (fun a => Real.log (value a : ℝ))).sum := by + unfold realSlotProduct + rw [Real.log_list_prod] + · simp only [List.map_map, Function.comp_def] + · intro x hx + obtain ⟨a, _, rfl⟩ := List.mem_map.mp hx + exact Nat.cast_ne_zero.mpr (Nat.ne_of_gt (hvalue a)) + simp only [movingBulkListLogWeight, bulkLogCutoffWeight, positiveLogCutoff, + ite_eq_left hp, hl] + +noncomputable def bulkLogCutoffFactors {σ : Type*} {t : ℕ} + (value : σ → ℝ) (i : σ) (cb D : ℝ) (hD : 0 ≤ D) + (hlip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ D * |x - y|) + (slots : Fin t → List σ) : Fin t → ClippedPolynomialFactor := fun j => + logCutoffPolynomialFactor (bulkSlotProduct value i (slots j)) logCellProfile cb 1 D + zero_le_one hD (fun x => by + rw [abs_of_nonneg (logCellProfile_nonneg x)] + exact logCellProfile_le_one x) hlip + +theorem bulkLogCutoffFactors_weight {σ : Type*} {t : ℕ} + (value : σ → ℝ) (i : σ) (cb D : ℝ) (hD : 0 ≤ D) + (hlip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ D * |x - y|) + (slots : Fin t → List σ) (z : ℝ) : + smoothPolynomialWeight (bulkLogCutoffFactors value i cb D hD hlip slots) z = + ((∏ j, bulkLogCutoffWeight (Function.update value i z) cb (slots j) : ℝ) : ℂ) := by + simp only [smoothPolynomialWeight, bulkLogCutoffFactors, bulkLogCutoffWeight, + Complex.ofReal_prod] + apply Finset.prod_congr rfl + intro j _ + rw [logCutoffPolynomialFactor_value (hout := logCellProfile_zero_outside), + bulkSlotProduct_eval] + +theorem bulkLogCutoffFactors_budget {σ : Type*} {t : ℕ} + (value : σ → ℝ) (i : σ) (cb D : ℝ) (hD : 0 ≤ D) + (hlip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ D * |x - y|) + (slots : Fin t → List σ) : + smoothPolynomialBudget (bulkLogCutoffFactors value i cb D hD hlip slots) = + (2 + D * (Real.exp 2 - 1)) ^ t := by + simp only [smoothPolynomialBudget, bulkLogCutoffFactors, logCutoffPolynomialFactor_budget, + mul_one, Finset.prod_const, Finset.card_univ, Fintype.card_fin] + +/-- Repeated occurrences in a leaf group are retained. They contribute their +actual multiplicity to the elementary degree bound. -/ +theorem bulkLogCutoffFactors_roots {σ : Type*} {t : ℕ} + (value : σ → ℝ) (i : σ) (cb D : ℝ) (hD : 0 ≤ D) + (hlip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ D * |x - y|) + (slots : Fin t → List σ) (r : ℕ) (hr : ∀ j, (slots j).length ≤ r) : + ∃ S : Finset ℝ, S.card ≤ t * r ∧ + ∀ j z, z ∈ (bulkLogCutoffFactors value i cb D hD hlip slots j).polynomial.derivative.roots → z ∈ S := by + let F := bulkLogCutoffFactors value i cb D hD hlip slots + let S := polynomialRootCuts (fun j => (F j).polynomial.derivative) + refine ⟨S, ?_, ?_⟩ + · apply (polynomialRootCuts_card _).trans + calc + _ ≤ ∑ _j : Fin t, r := Finset.sum_le_sum (fun j _ => + (Polynomial.natDegree_derivative_le _).trans ((Nat.sub_le _ _).trans + ((bulkSlotProduct_degree value i (slots j)).trans (hr j)))) + _ = _ := by simp + · intro j z hz + exact Finset.mem_biUnion.mpr ⟨j, Finset.mem_univ _, Multiset.mem_toFinset.mpr hz⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogProductLower.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogProductLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..a65af2905221d899de12d43cf31a16b2328b5cb4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogProductLower.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateProducts +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkOriginalCoefficient + +namespace OAI + +/-! # Product lower bounds forced by the original terminal weights -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingBulkListLogWeight_product_lower {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ a, 0 < value a) (outside : List ℕ) (cb cd : ℝ) (bulk : List σ) + (h : movingBulkListLogWeight value outside cb cd bulk ≠ 0) : + Real.exp (cb - 1) ≤ (MovingSlotReversal.naturalProduct value bulk : ℝ) := by + have hw : logCellProfile ((bulk.map (fun a => Real.log (value a : ℝ))).sum - cb) ≠ 0 := + left_ne_zero_of_mul h + have habs : |(bulk.map (fun a => Real.log (value a : ℝ))).sum - cb| < 1 := by + by_contra hn + exact hw (logCellProfile_zero_outside _ (not_lt.mp hn)) + have hp : 0 < (MovingSlotReversal.naturalProduct value bulk : ℝ) := by + exact_mod_cast List.prod_pos (fun p hp => by + obtain ⟨a, _, rfl⟩ := List.mem_map.mp hp + exact hvalue a) + have hl : Real.log (MovingSlotReversal.naturalProduct value bulk : ℝ) = + (bulk.map (fun a => Real.log (value a : ℝ))).sum := by + unfold MovingSlotReversal.naturalProduct + rw [Nat.cast_list_prod, Real.log_list_prod] + · simp only [List.map_map, Function.comp_def] + · intro p hp + obtain ⟨q, hq, rfl⟩ := List.mem_map.mp hp + obtain ⟨a, _, rfl⟩ := List.mem_map.mp hq + exact_mod_cast (hvalue a).ne' + have hlog : cb - 1 ≤ Real.log (MovingSlotReversal.naturalProduct value bulk : ℝ) := by + rw [hl] + linarith [(abs_lt.mp habs).1] + exact (Real.exp_le_exp.mpr hlog).trans_eq (Real.exp_log hp) + +/-- Every original leaf supplies its own product lower bound. Multiplication +therefore gives the full `2^n` exponent, with no distinctness assumption. -/ +theorem movingBulkTreeLogWeight_product_lower {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ a, 0 < value a) (outside : List ℕ) (cb cd : ℝ) + (n m : ℕ) (slot : TreeLeafIndex n × Fin m → σ) + (h : treeLeafProduct n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n + (bulkSlotLeaves n m slot)) ≠ 0) : + Real.exp ((2 ^ n : ℕ) * (cb - 1)) ≤ ((∏ i, value (slot i) : ℕ) : ℝ) := by + have hw : (∏ j : TreeLeafIndex n, + movingBulkListLogWeight value outside cb cd (List.ofFn (fun i => slot (j, i)))) ≠ 0 := by + have he : treeLeafMap (movingBulkListLogWeight value outside cb cd) n + (bulkSlotLeaves n m slot) = (treeLeafTupleEquiv ℝ n).symm + (fun j => movingBulkListLogWeight value outside cb cd (List.ofFn (fun i => slot (j, i)))) := by + apply (treeLeafTupleEquiv ℝ n).injective + funext j + simp only [treeLeafTupleEquiv_map, bulkSlotLeaves, Equiv.apply_symm_apply] + rwa [he, treeLeafProduct_indexed] at h + have hleaf (j : TreeLeafIndex n) : Real.exp (cb - 1) ≤ + ((∏ i : Fin m, value (slot (j, i)) : ℕ) : ℝ) := by + have hh := movingBulkListLogWeight_product_lower value hvalue outside cb cd + (List.ofFn (fun i => slot (j, i))) (Finset.prod_ne_zero_iff.mp hw j (Finset.mem_univ j)) + simpa only [MovingSlotReversal.naturalProduct, List.map_ofFn, List.prod_ofFn, Function.comp_def] using hh + have hp := Finset.prod_le_prod₀ (fun j (_ : j ∈ (Finset.univ : Finset (TreeLeafIndex n))) => + (Real.exp_nonneg (cb - 1))) (fun j _ => hleaf j) + simpa only [Finset.prod_const, Finset.card_univ, card_treeLeafIndex, ← Real.exp_nat_mul, + Fintype.prod_prod_type, Nat.cast_prod, Nat.cast_pow] using hp + +/-- The actual weighted Fourier coefficient can be nonzero only above the +product cutoff. This uses the exact coefficient factorization, not an extra +support hypothesis on a surrogate coefficient. -/ +theorem movingFrequencyCoefficient_log_product_lower {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (hvalue : ∀ a, 0 < value a) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n m : ℕ) (s : ℤ) + (small : TreeLeafTuple (List σ) n) (slot : TreeLeafIndex n × Fin m → σ) + (hn : n ≤ k) (hsmall : ∀ i ∈ flattenMovingSlots n small, tier i ≠ k) + (hbulk : ∀ i ∈ flattenMovingSlots n (bulkSlotLeaves n m slot), tier i = k) + (XL XR : ℕ) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n s small (bulkSlotLeaves n m slot) XL XR ≠ 0) : + Real.exp ((2 ^ n : ℕ) * (cb - 1)) ≤ ((∏ i, value (slot i) : ℕ) : ℝ) := by + rw [movingFrequencyCoefficient_bulk_log value tier k outside cb cd μ hμ childBound + pivotBound V F φ G n s small (bulkSlotLeaves n m slot) hn hsmall hbulk XL XR] at h + apply movingBulkTreeLogWeight_product_lower value hvalue outside cb cd n m slot + exact_mod_cast left_ne_zero_of_mul h + +/-- Pointwise removal is valid for one unsymmetrized coefficient. This is +used only after the harmonic diagonal has reduced to one-branch energy. -/ +theorem movingFrequencyCoefficient_bulk_log_norm_le {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → σ → ℝ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (small bulk : TreeLeafTuple (List σ) n) + (hn : n ≤ k) (hsmall : ∀ i ∈ flattenMovingSlots n small, tier i ≠ k) + (hbulk : ∀ i ∈ flattenMovingSlots n bulk, tier i = k) (XL XR : ℕ) : + ‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n s small bulk XL XR‖ ≤ + ‖movingFrequencyCoefficient value outside μ childBound pivotBound V F + φ G n s small bulk XL XR‖ := by + rw [movingFrequencyCoefficient_bulk_log value tier k outside cb cd μ hμ + childBound pivotBound V F φ G n s small bulk hn hsmall hbulk XL XR, + norm_mul, Complex.norm_real, + Real.norm_of_nonneg (movingBulkLeafProduct_bounds value outside cb cd n bulk).1] + exact mul_le_of_le_one_left (norm_nonneg _) + (movingBulkLeafProduct_bounds value outside cb cd n bulk).2 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogTrees.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogTrees.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5ced8cb19f34bc1e3e2063c226c2eac4f3b0c14 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogTrees.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkLogFactors + +namespace OAI + +/-! # The actual terminal bulk groups in the logarithmic comparison -/ + +namespace Ostmann +open scoped Classical BigOperators + +def bulkLogLeafLists {σ : Type*} (tier : σ → ℕ) (k : ℕ) : + {n : ℕ} → MovingSlotData σ n → List (List σ) + | _, T@(.leaf _ _) => [T.regularSlots.filter (fun a => decide (tier a = k))] + | _, .node _ _ _ _ left right => bulkLogLeafLists tier k left ++ bulkLogLeafLists tier k right + +theorem bulkLogLeafLists_length {σ : Type*} (tier : σ → ℕ) (k : ℕ) + {n : ℕ} (T : MovingSlotData σ n) : (bulkLogLeafLists tier k T).length = 2 ^ n := by + induction T with + | leaf => rfl + | @node n s CL CR u left right ihL ihR => + simp only [bulkLogLeafLists, List.length_append, ihL, ihR, pow_succ] + omega + +theorem bulkLogLeafLists_length_le {σ : Type*} (tier : σ → ℕ) (k : ℕ) + {n : ℕ} (T : MovingSlotData σ n) (r : ℕ) (hT : T.RegularLengthLE r) : + ∀ slots ∈ bulkLogLeafLists tier k T, slots.length ≤ r := by + induction T with + | leaf => + intro slots hs + have he : slots = _ := List.mem_singleton.mp hs + subst slots + exact (List.length_filter_le _ _).trans hT + | node s CL CR u left right ihL ihR => + intro slots hs + rcases List.mem_append.mp hs with hs | hs + · exact ihL hT.2.1 slots hs + · exact ihR hT.2.2 slots hs + +theorem movingBulkTreeLogWeight_eq_lists {σ : Type*} (value tier : σ → ℕ) + (k : ℕ) (outside : List ℕ) (cb cd : ℝ) {n : ℕ} (T : MovingSlotData σ n) : + movingBulkTreeLogWeight value tier k outside cb cd T = + ((bulkLogLeafLists tier k T).map (movingBulkListLogWeight value outside cb cd)).prod := by + induction T with + | leaf => simp only [movingBulkTreeLogWeight, movingBulkLeafLogWeight, + bulkLogLeafLists, List.map_singleton, List.prod_singleton] + | node s CL CR u left right ihL ihR => + simp only [movingBulkTreeLogWeight, bulkLogLeafLists, List.map_append, + List.prod_append, ihL, ihR] + +/-- Every terminal logarithmic factor is retained. The constant spectator +weight factors out once per actual leaf. -/ +theorem movingBulkTreeLogWeight_eq_cutoff_product {σ : Type*} (value tier : σ → ℕ) + (hvalue : ∀ a, 0 < value a) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + {n : ℕ} (T : MovingSlotData σ n) : + movingBulkTreeLogWeight value tier k outside cb cd T = + logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ (2 ^ n) * + ∏ j : Fin (bulkLogLeafLists tier k T).length, + bulkLogCutoffWeight (fun a => (value a : ℝ)) cb ((bulkLogLeafLists tier k T)[j]) := by + rw [movingBulkTreeLogWeight_eq_lists] + let slots := bulkLogLeafLists tier k T + have he : (slots.map (movingBulkListLogWeight value outside cb cd)).prod = + ∏ j : Fin slots.length, movingBulkListLogWeight value outside cb cd slots[j] := + (congrArg List.prod (List.ofFn_getElem_eq_map slots + (movingBulkListLogWeight value outside cb cd))).symm.trans (Fin.prod_ofFn _) + rw [he] + simp only [movingBulkListLogWeight_eq_cutoff value hvalue, Finset.prod_mul_distrib, + Finset.prod_const, Finset.card_univ, Fintype.card_fin] + have hpow : + logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ slots.length = + logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ (2 ^ n) := + congrArg (fun m : ℕ => logCellProfile + ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ m) + (bulkLogLeafLists_length tier k T) + rw [hpow] + exact mul_comm _ _ + +/-- Both branches use their own actual terminal groups. The real logarithmic +weights commute with conjugation, but remain inside the common prime average. -/ +theorem movingBulkPairLogWeight_eq_cutoff_product {σ : Type*} (value tier : σ → ℕ) + (hvalue : ∀ a, 0 < value a) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) : + let L := bulkLogLeafLists tier k (T false) + let R := bulkLogLeafLists tier k (T true) + let slots := Fin.append (fun j : Fin L.length => L[j]) (fun j : Fin R.length => R[j]) + (movingBulkTreeLogWeight value tier k outside cb cd (T false) : ℂ) * + star (movingBulkTreeLogWeight value tier k outside cb cd (T true) : ℂ) = + (logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ + (2 ^ n + 2 ^ n) : ℝ) * + ((∏ j, bulkLogCutoffWeight (fun a => (value a : ℝ)) cb (slots j) : ℝ) : ℂ) := by + dsimp only + simp only [Complex.star_def, Complex.conj_ofReal, ← Complex.ofReal_mul] + congr 1 + rw [movingBulkTreeLogWeight_eq_cutoff_product value tier hvalue k outside cb cd (T false), + movingBulkTreeLogWeight_eq_cutoff_product value tier hvalue k outside cb cd (T true)] + simp only [Fin.prod_univ_add, Fin.append_left, Fin.append_right, pow_add] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogVariation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogVariation.lean new file mode 100644 index 0000000000000000000000000000000000000000..cca7b9a084d0a939eba9d91e93baeb4dc0e16a4e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogVariation.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkLogWeight + +namespace OAI + +/-! # Variation of the retained logarithmic bulk weights -/ + +namespace Ostmann +open scoped Classical + +/-- Freezing each prime in a log cell of diameter `η` changes the retained +bulk cutoff by at most its number of slots times one fixed Lipschitz constant. -/ +theorem movingBulkListLogWeight_variation {σ : Type*} + (value value' : σ → ℕ) (outside : List ℕ) (cb cd D η : ℝ) + (hD : 0 ≤ D) + (hprofile : ∀ x y, |logCellProfile x - logCellProfile y| ≤ D * |x - y|) + (bulk : List σ) + (hclose : ∀ a ∈ bulk, |Real.log (value a : ℝ) - Real.log (value' a : ℝ)| ≤ η) : + |movingBulkListLogWeight value outside cb cd bulk - + movingBulkListLogWeight value' outside cb cd bulk| ≤ D * bulk.length * η := by + have hs : |(bulk.map (fun a => Real.log (value a : ℝ))).sum - + (bulk.map (fun a => Real.log (value' a : ℝ))).sum| ≤ (bulk.length : ℝ) * η := by + induction bulk with + | nil => simp + | cons a bulk ih => + have ha := hclose a List.mem_cons_self + have hb := ih (fun b hb => hclose b (List.mem_cons_of_mem a hb)) + simp only [List.map_cons, List.sum_cons, List.length_cons, Nat.cast_add, Nat.cast_one] + calc + _ = |(Real.log (value a : ℝ) - Real.log (value' a : ℝ)) + + ((bulk.map (fun b => Real.log (value b : ℝ))).sum - + (bulk.map (fun b => Real.log (value' b : ℝ))).sum)| := by congr 1; ring + _ ≤ _ := abs_add_le _ _ + _ ≤ η + (bulk.length : ℝ) * η := add_le_add ha hb + _ = _ := by ring + unfold movingBulkListLogWeight + rw [← sub_mul, abs_mul, abs_of_nonneg (logCellProfile_nonneg _)] + have hl := hprofile + ((bulk.map (fun a => Real.log (value a : ℝ))).sum - cb) + ((bulk.map (fun a => Real.log (value' a : ℝ))).sum - cb) + have hsub : + (bulk.map (fun a => Real.log (value a : ℝ))).sum - cb - + ((bulk.map (fun a => Real.log (value' a : ℝ))).sum - cb) = + (bulk.map (fun a => Real.log (value a : ℝ))).sum - + (bulk.map (fun a => Real.log (value' a : ℝ))).sum := by ring + rw [hsub] at hl + calc + _ ≤ (D * |(bulk.map (fun a => Real.log (value a : ℝ))).sum - + (bulk.map (fun a => Real.log (value' a : ℝ))).sum|) * 1 := + mul_le_mul hl (logCellProfile_le_one _) (logCellProfile_nonneg _) + (mul_nonneg hD (abs_nonneg _)) + _ ≤ D * ((bulk.length : ℝ) * η) := by + rw [mul_one] + exact mul_le_mul_of_nonneg_left hs hD + _ = _ := by ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f1e8e98c5acd6d00f4f4ffd0adbbecc780f83b4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkLogWeight.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.Ostmann.Construction.InitialHalfListWeights +import OAI.NumberTheory.Ostmann.Arithmetic.MovingScalarWindows +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularSlots + +namespace OAI + +/-! # The two initial logarithmic weights as external bulk factors -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingBulkListLogWeight {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (cb cd : ℝ) (bulk : List σ) : ℝ := + logCellProfile ((bulk.map (fun a => Real.log (value a : ℝ))).sum - cb) * + logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) + +noncomputable def movingBulkLeafLogWeight {σ : Type*} (value : σ → ℕ) + (tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + {n : ℕ} (T : MovingSlotData σ n) : ℝ := + movingBulkListLogWeight value outside cb cd + (T.regularSlots.filter (fun a => decide (tier a = k))) + +noncomputable def movingBulkTreeLogWeight {σ : Type*} (value : σ → ℕ) + (tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) : + {n : ℕ} → MovingSlotData σ n → ℝ + | _, T@(.leaf _ _) => movingBulkLeafLogWeight value tier k outside cb cd T + | _, .node _ _ _ _ left right => + movingBulkTreeLogWeight value tier k outside cb cd left * + movingBulkTreeLogWeight value tier k outside cb cd right + +theorem movingBulkListLogWeight_bounds {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (cb cd : ℝ) (bulk : List σ) : + 0 ≤ movingBulkListLogWeight value outside cb cd bulk ∧ + movingBulkListLogWeight value outside cb cd bulk ≤ 1 := by + refine ⟨mul_nonneg (logCellProfile_nonneg _) (logCellProfile_nonneg _), ?_⟩ + exact (mul_le_mul (logCellProfile_le_one _) (logCellProfile_le_one _) + (logCellProfile_nonneg _) zero_le_one).trans_eq (one_mul 1) + +theorem movingBulkTreeLogWeight_bounds {σ : Type*} (value : σ → ℕ) + (tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + {n : ℕ} (T : MovingSlotData σ n) : + 0 ≤ movingBulkTreeLogWeight value tier k outside cb cd T ∧ + movingBulkTreeLogWeight value tier k outside cb cd T ≤ 1 := by + induction T with + | leaf => exact movingBulkListLogWeight_bounds value outside cb cd _ + | node s CL CR U left right ihL ihR => + exact ⟨mul_nonneg ihL.1 ihR.1, + (mul_le_mul ihL.2 ihR.2 ihR.1 zero_le_one).trans_eq (one_mul 1)⟩ + +/-- Real logarithmic weights survive all right-branch conjugations and +factor out as their literal product over the terminal bulk groups. -/ +theorem movingDataWeight_bulk_log {σ : Type*} (value : σ → ℕ) (tier : σ → ℕ) + (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) : + movingDataWeight (fun T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F T s) E T = + (movingBulkTreeLogWeight value tier k outside cb cd T : ℂ) * movingDataWeight F E T := by + induction T with + | leaf => rfl + | node s CL CR U left right ihL ihR => + simp only [movingDataWeight, movingBulkTreeLogWeight, ihL, ihR, Complex.ofReal_mul, + star_mul, Complex.star_def, Complex.conj_ofReal] + ring + +/-- The selected tier is exactly the original bulk. Restored compensation +slots have smaller tiers and cannot enter either logarithmic cutoff. -/ +theorem movingBulkTreeLogWeight_sample {σ : Type*} (value : σ → ℕ) (tier : σ → ℕ) + (k : ℕ) (outside : List ℕ) (cb cd : ℝ) (n : ℕ) + (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (a : MovingSampleSlots σ n) (hn : n ≤ k) + (hsmall : ∀ i ∈ flattenMovingSlots n small, tier i ≠ k) + (hbulk : ∀ i ∈ flattenMovingSlots n bulk, tier i = k) + (ha : a.Levels tier) : + movingBulkTreeLogWeight value tier k outside cb cd (buildMovingSlotData n t small bulk a) = + treeLeafProduct n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n bulk) := by + induction a with + | leaf => + have hs : (small.filter (fun i => decide (tier i = k))) = [] := by + apply List.filter_eq_nil_iff.mpr + intro i hi + simp [hsmall i hi] + have hb : (bulk.filter (fun i => decide (tier i = k))) = bulk := by + apply List.filter_eq_self.mpr + intro i hi + simp [hbulk i hi] + simp only [buildMovingSlotData, movingBulkTreeLogWeight, movingBulkLeafLogWeight, + MovingSlotData.regularSlots, flattenMovingSlots, List.filter_append, hs, hb, List.nil_append, + treeLeafMap, treeLeafProduct] + | @node n u left right ihL ihR => + have happ (b c : TreeLeafTuple (List σ) n) + (hb : ∀ i ∈ flattenMovingSlots n b, tier i ≠ k) + (hc : ∀ i ∈ flattenMovingSlots n c, tier i ≠ k) : + ∀ i ∈ flattenMovingSlots n (appendMovingSlotLeaves n b c), tier i ≠ k := by + intro i hi + have hi' := (flattenMovingSlots_append_perm n b c).mem_iff.mp hi + exact (List.mem_append.mp hi').elim (hb i) (hc i) + have hu : ∀ i ∈ flattenMovingSlots n (movingCompensationSlots n u), tier i ≠ k := by + intro i hi + rw [ha.1 i hi] + omega + simp only [buildMovingSlotData, movingBulkTreeLogWeight, treeLeafMap, treeLeafProduct] + rw [ihL _ _ _ (by omega) (happ _ _ hu (fun i hi => hsmall i (List.mem_append_left _ hi))) + (fun i hi => hbulk i (List.mem_append_left _ hi)) ha.2.1, + ihR _ _ _ (by omega) (happ _ _ hu (fun i hi => hsmall i (List.mem_append_right _ hi))) + (fun i hi => hbulk i (List.mem_append_right _ hi)) ha.2.2] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkNodup.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkNodup.lean new file mode 100644 index 0000000000000000000000000000000000000000..c28cc213527a11e73d36753731956da993f5cf99 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkNodup.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenRegularSupport +import OAI.NumberTheory.Ostmann.Arithmetic.BulkSlotPolynomials + +namespace OAI + +/-! # Bulk labels remain distinct throughout the actual coherent sampled tree -/ + +namespace Ostmann +open scoped Classical + +theorem MovingSlotData.regularLists_bulk_nodup {σ : Type*} (bulk : σ → Bool) + {n : ℕ} (T : MovingSlotData σ n) : + T.RegularCoherent → + (∀ i, bulk i = true → T.CompensationAbsent i) → + (T.regularSlots.filter bulk).Nodup → + ∀ L ∈ T.regularLists, (L.filter bulk).Nodup := by + induction T with + | leaf s regular => + intro _ _ hn L hL + simpa only [MovingSlotData.regularLists, MovingSlotData.regularSlots, + List.mem_singleton.mp hL] using hn + | node s CL CR U left right ihL ihR => + intro hc ha hn + have hu : U.filter bulk = [] := by + apply List.filter_eq_nil_iff.mpr + intro i hi + cases hb : bulk i with + | false => simp + | true => exact False.elim ((ha i hb).1 hi) + have hn' : (CL.filter bulk ++ CR.filter bulk).Nodup := by + simpa only [MovingSlotData.regularSlots, List.filter_append] using hn + have hleft : (left.regularSlots.filter bulk).Nodup := by + have hp := hc.1.filter bulk + rw [List.filter_append, hu, List.nil_append] at hp + exact hp.nodup_iff.mpr (List.nodup_append.mp hn').1 + have hright : (right.regularSlots.filter bulk).Nodup := by + have hp := hc.2.1.filter bulk + rw [List.filter_append, hu, List.nil_append] at hp + exact hp.nodup_iff.mpr (List.nodup_append.mp hn').2.1 + intro L hL + rcases List.mem_cons.mp hL with rfl | hL + · exact hn + · rcases List.mem_append.mp hL with hL | hL + · exact ihL hc.2.2.1 (fun i hi => (ha i hi).2.1) hleft L hL + · exact ihR hc.2.2.2 (fun i hi => (ha i hi).2.2) hright L hL + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkOriginalCoefficient.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkOriginalCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9606258c9fecf2649b99e48d1ada49c89ae8181 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkOriginalCoefficient.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkCoefficient + +namespace OAI + +/-! # The original windowed Fourier coefficient retains its bulk cutoffs -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingBulkLeafProduct_bounds {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (cb cd : ℝ) (n : ℕ) (bulk : TreeLeafTuple (List σ) n) : + 0 ≤ treeLeafProduct n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n bulk) ∧ + treeLeafProduct n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n bulk) ≤ 1 := by + induction n with + | zero => exact movingBulkListLogWeight_bounds value outside cb cd bulk + | succ n ih => + obtain ⟨hL, hL'⟩ := ih bulk.1 + obtain ⟨hR, hR'⟩ := ih bulk.2 + exact ⟨mul_nonneg hL hR, (mul_le_mul hL' hR' hR zero_le_one).trans_eq (one_mul 1)⟩ + +theorem movingOriginalLeaf_bulk_log {σ I : Type*} + (value tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (x : MovingSlotState σ) (s : ℤ) : + movingOriginalLeaf value q + (fun T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F T s) + g Dq S ψ X lo hi x s = + (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * + movingOriginalLeaf value q F g Dq S ψ X lo hi x s := by + unfold movingOriginalLeaf movingWindowLeaf movingDataLeaf + split_ifs <;> ring + +/-- All sharp windows, Fourier factors, spectator factors and support tests +remain in the coefficient after the real bulk weight has been extracted. -/ +theorem movingFrequencyCoefficient_original_bulk_log {σ I : Type} [Fintype σ] + (value tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → σ → ℝ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (childBound pivotBound V : ℕ → ℕ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (s : ℤ) (small bulk : TreeLeafTuple (List σ) n) + (hn : n ≤ k) (hsmall : ∀ i ∈ flattenMovingSlots n small, tier i ≠ k) + (hbulk : ∀ i ∈ flattenMovingSlots n bulk, tier i = k) (XL XR : ℕ) : + movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q + (fun T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F T s) + g Dq S ψ X lo hi) φ G n s small bulk XL XR = + ((treeLeafProduct n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n bulk) : ℝ) : ℂ) * + movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s small bulk XL XR := by + have hF : movingOriginalLeaf value q + (fun T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F T s) + g Dq S ψ X lo hi = + fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * + movingOriginalLeaf value q F g Dq S ψ X lo hi x s := by + funext x s + exact movingOriginalLeaf_bulk_log value tier k outside cb cd q F g Dq S ψ X lo hi x s + rw [hF] + exact movingFrequencyCoefficient_bulk_log value tier k outside cb cd μ hμ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s small bulk hn hsmall hbulk XL XR + +/-- Pointwise domination applies before any external bulk symmetrization. +It supplies the original same-assignment energy bound with the cutoffs retained. -/ +theorem movingFrequencyCoefficient_original_bulk_log_norm_le {σ I : Type} [Fintype σ] + (value tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → σ → ℝ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (childBound pivotBound V : ℕ → ℕ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (s : ℤ) (small bulk : TreeLeafTuple (List σ) n) + (hn : n ≤ k) (hsmall : ∀ i ∈ flattenMovingSlots n small, tier i ≠ k) + (hbulk : ∀ i ∈ flattenMovingSlots n bulk, tier i = k) (XL XR : ℕ) : + ‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q + (fun T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F T s) + g Dq S ψ X lo hi) φ G n s small bulk XL XR‖ ≤ + ‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s small bulk XL XR‖ := by + rw [movingFrequencyCoefficient_original_bulk_log value tier k outside cb cd μ hμ q F + g Dq S ψ X lo hi childBound pivotBound V φ G n s small bulk hn hsmall hbulk XL XR, + norm_mul, Complex.norm_real, + Real.norm_of_nonneg (movingBulkLeafProduct_bounds value outside cb cd n bulk).1] + exact mul_le_of_le_one_left (norm_nonneg _) + (movingBulkLeafProduct_bounds value outside cb cd n bulk).2 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPageBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPageBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..0602c8cee69d7bb0c5dc78f1c4d9d717a5890da3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPageBound.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.BulkSlotFieldBridge +import OAI.NumberTheory.Ostmann.Arithmetic.BulkSpectatorPageBound +import OAI.NumberTheory.Ostmann.ZeroDensity.BulkHaarDensity + +namespace OAI + +/-! # Combining the actual transfer conjugations with the bulk Page density -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +theorem bulk_prime_density_norm {I J : Type*} [Fintype I] [Fintype J] + (r : ℕ) [NeZero r] (p : I → ℕ) [∀ i, NeZero (p i)] + [NeZero (∏ i, bulkResidueModuli r p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (P : PublishedProgressionInput) (Q : ℕ) + (hpage : pageAtModulus (∏ i, bulkResidueModuli r p i) (selectedPageZero P Q) = + pageAtModulus r (selectedPageZero P Q)) + (y : J → ℝ) (F : (J → (ZMod r)ˣ) → ℂ) (G : ∀ i, (J → (ZMod (p i))ˣ) → ℂ) + (δ : ℝ) + (hlocal : ∀ i, ‖(Fintype.card (J → (ZMod (p i))ˣ) : ℂ)⁻¹ * ∑ z, G i z‖ ≤ δ) : + ‖∑ z, (F (bulkResidueEquiv r p hc z).1 * + ∏ i, G i ((bulkResidueEquiv r p hc z).2 i)) * + ∏ j, (selectedPrimeLogDensity P Q (∏ i, bulkResidueModuli r p i) + (z j).val.val (y j) : ℂ)‖ ≤ + ‖bulkFrequencyPageMean P Q r y F‖ * δ ^ Fintype.card I * ∏ j, ‖(y j : ℂ)⁻¹‖ := by + have he := bulk_prime_density_crt r p hc P Q hpage y F G + refine (congrArg norm he).trans_le ?_ + rw [norm_mul, norm_mul] + simp only [norm_prod] + change (‖bulkFrequencyPageMean P Q r y F‖ * _) * _ ≤ _ + apply mul_le_mul_of_nonneg_right _ (Finset.prod_nonneg fun j _ => norm_nonneg _) + apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) + calc + _ ≤ ∏ _i : I, δ := Finset.prod_le_prod₀ (fun i _ => norm_nonneg _) (fun i _ => hlocal i) + _ = δ ^ Fintype.card I := by simp only [Finset.prod_const, Finset.card_univ] + +/-- The conjugations proved for the original moving slot diagrams give the +required quartet conjugations without any further combinatorial hypothesis. -/ +theorem normalized_transfer_bulk_mean {p : ℕ} [Fact p.Prime] + (hp : 3 ≤ p) (n m : ℕ) (hm : 0 < m) + (e : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (hgood : 4 * Fintype.card (arrangementGraph m e).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2))) + (S : Finset (ZMod p)) (hlo : (1 / 3 : ℝ) ≤ residueDensity S) + (hhi : residueDensity S ≤ 2 / 3) (hS : S.Nonempty) (hSp : S.card < p) + (β ε : ℝ) (hε : 0 ≤ ε) (hε1 : ε ≤ 1) + (hprincipal : 3 / Real.sqrt (p : ℝ) ≤ ε) (hβ : 2 * β ≤ ε) + (hbias : ∀ (χ : MulChar (ZMod p) ℂ), χ ≠ 1 → ∀ a : ZMod p, + ‖(S.card : ℂ)⁻¹ * ∑ x ∈ S, χ⁻¹ (-a - x)‖ ≤ β) + (d₁ d₂ : SpectatorDiagram p (n + 2)) + (hd : d₁.conjugations = transferConjugations (n + 2) false) + (δ : ℝ) (hδ : 0 ≤ δ) + (hnum : quartetTreeConstant n * (ε ^ 2 + Real.sqrt (3 / (p : ℝ))) ≤ δ ^ 2) : + ‖(Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod p)ˣ) : ℂ)⁻¹ * + ∑ z, d₁.bulkValue (normalizedResidueTransform S) z * + conj (d₂.bulkValue (normalizedResidueTransform S) (z ∘ e.symm))‖ ≤ δ := by + let c := treeLeafTupleEquiv Bool n (transferConjugations n false) + have hconj (j : TreeLeafIndex n) : + quartetBlockEquiv Bool n d₁.conjugations j = + ((c j, !(c j)), ((!(c j)), !(!(c j)))) := by + rw [hd] + simpa only [Bool.not_not] using transferConjugations_quartet n false j + exact normalized_bulk_spectator_mean_le hp n m hm e hgood S hlo hhi hS hSp + β ε hε hε1 hprincipal hβ hbias d₁ d₂ c (fun j => !(c j)) hconj δ hδ hnum + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPairedCutoffs.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPairedCutoffs.lean new file mode 100644 index 0000000000000000000000000000000000000000..05254c62c8c47fc54340a3c7f0a51bb97ff63e31 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPairedCutoffs.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkOriginalCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkLogFactors +import OAI.NumberTheory.Ostmann.Construction.ScheduledTreeBulkCoordinates +import OAI.NumberTheory.Ostmann.Characters.TreeTupleProfiles +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkBudgets + +namespace OAI + +/-! # Actual bulk leaf lists and their retained logarithmic cutoffs -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem treeLeafProduct_eq_prod {A : Type*} [CommMonoid A] (n : ℕ) + (a : TreeLeafTuple A n) : + treeLeafProduct n a = ∏ i : TreeLeafIndex n, treeLeafTupleEquiv A n a i := by + induction n with + | zero => + change A at a + change a = @Finset.prod Unit A _ Finset.univ (fun _ => a) + simp + | succ n ih => + change treeLeafProduct n a.1 * treeLeafProduct n a.2 = + ∏ i : TreeLeafIndex n ⊕ TreeLeafIndex n, + Sum.elim (treeLeafTupleEquiv A n a.1) (treeLeafTupleEquiv A n a.2) i + rw [Fintype.prod_sum_type, ih, ih] + rfl + +noncomputable def movingBulkPairedCutoffSlots {B : Type*} (n : ℕ) + (bulk : Bool → TreeLeafTuple (List B) n) : Fin (2 ^ n + 2 ^ n) → List B := + Fin.append (fun i => treeLeafTupleEquiv (List B) n (bulk false) ((treeLeafEnumeration n).symm i)) + (fun i => treeLeafTupleEquiv (List B) n (bulk true) ((treeLeafEnumeration n).symm i)) + +theorem movingBulkPairedCutoffSlots_product {B : Type*} (n : ℕ) + (bulk : Bool → TreeLeafTuple (List B) n) (f : List B → ℝ) : + (∏ j, f (movingBulkPairedCutoffSlots n bulk j)) = + treeLeafProduct n (treeLeafMap f n (bulk false)) * + treeLeafProduct n (treeLeafMap f n (bulk true)) := by + simp only [movingBulkPairedCutoffSlots, Fin.prod_univ_add, Fin.append_left, Fin.append_right, + treeLeafProduct_eq_prod, treeLeafTupleEquiv_map] + exact congrArg₂ (· * ·) + ((treeLeafEnumeration n).symm.prod_comp (fun i => f (treeLeafTupleEquiv (List B) n (bulk false) i))) + ((treeLeafEnumeration n).symm.prod_comp (fun i => f (treeLeafTupleEquiv (List B) n (bulk true) i))) + +theorem movingBulkPairedCutoffSlots_map {B C : Type*} (n : ℕ) + (bulk : Bool → TreeLeafTuple (List B) n) (g : B → C) (j : Fin (2 ^ n + 2 ^ n)) : + movingBulkPairedCutoffSlots n (fun b => treeLeafMap (List.map g) n (bulk b)) j = + (movingBulkPairedCutoffSlots n bulk j).map g := by + refine Fin.addCases ?_ ?_ j <;> intro i <;> + simp only [movingBulkPairedCutoffSlots, Fin.append_left, Fin.append_right, treeLeafTupleEquiv_map] + +theorem bulkLogCutoffWeight_map {B C : Type*} (value : C → ℝ) + (g : B → C) (cb : ℝ) (slots : List B) : + bulkLogCutoffWeight value cb (slots.map g) = + bulkLogCutoffWeight (value ∘ g) cb slots := by + simp only [bulkLogCutoffWeight, realSlotProduct, List.map_map] + +theorem treeLeafTuple_list_length {B : Type*} (n : ℕ) (bulk : TreeLeafTuple (List B) n) + (m : ℕ) (h : MovingLeafLengthLE n bulk m) (j : TreeLeafIndex n) : + (treeLeafTupleEquiv (List B) n bulk j).length ≤ m := by + induction n with + | zero => exact h + | succ n ih => + cases j with + | inl j => exact ih bulk.1 h.1 j + | inr j => exact ih bulk.2 h.2 j + +theorem movingBulkPairedCutoffSlots_length {B : Type*} (n m : ℕ) + (bulk : Bool → TreeLeafTuple (List B) n) + (h : ∀ b, MovingLeafLengthLE n (bulk b) m) (j : Fin (2 ^ n + 2 ^ n)) : + (movingBulkPairedCutoffSlots n bulk j).length ≤ m := by + refine Fin.addCases ?_ ?_ j <;> intro i + · simp only [movingBulkPairedCutoffSlots, Fin.append_left] + exact treeLeafTuple_list_length n (bulk false) m (h false) _ + · simp only [movingBulkPairedCutoffSlots, Fin.append_right] + exact treeLeafTuple_list_length n (bulk true) m (h true) _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPairedLogWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPairedLogWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..10fa4facb7008e34afebbc5746bcd5883369528a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPairedLogWeight.lean @@ -0,0 +1,40 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkPairedCutoffs + +namespace OAI + +/-! # The fixed outside factor in the two actual bulk leaf weights -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingBulkLeafProduct_eq_cutoffs {σ : Type*} + (value : σ → ℕ) (hvalue : ∀ a, 0 < value a) + (outside : List ℕ) (cb cd : ℝ) (n : ℕ) (bulk : TreeLeafTuple (List σ) n) : + treeLeafProduct (U := ℝ) n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n bulk) = + logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ (2 ^ n) * + treeLeafProduct n (treeLeafMap (fun slots => + bulkLogCutoffWeight (fun a => (value a : ℝ)) cb slots) n bulk) := by + simp only [treeLeafProduct_eq_prod, treeLeafTupleEquiv_map, + movingBulkListLogWeight_eq_cutoff value hvalue, Finset.prod_mul_distrib, + Finset.prod_const, Finset.card_univ, card_treeLeafIndex] + ring + +theorem movingBulkLeafProduct_pair_eq_cutoffs {σ : Type*} + (value : σ → ℕ) (hvalue : ∀ a, 0 < value a) + (outside : List ℕ) (cb cd : ℝ) (n : ℕ) (bulk : Bool → TreeLeafTuple (List σ) n) : + (treeLeafProduct (U := ℝ) n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n (bulk false)) : ℂ) * + star (treeLeafProduct (U := ℝ) n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n (bulk true)) : ℂ) = + (logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ + (2 ^ n + 2 ^ n) : ℝ) * + ((∏ j, bulkLogCutoffWeight (fun a => (value a : ℝ)) cb + (movingBulkPairedCutoffSlots n bulk j) : ℝ) : ℂ) := by + rw [movingBulkLeafProduct_eq_cutoffs value hvalue outside cb cd n (bulk false), + movingBulkLeafProduct_eq_cutoffs value hvalue outside cb cd n (bulk true), + movingBulkPairedCutoffSlots_product] + simp only [Complex.ofReal_mul, star_mul, Complex.star_def, Complex.conj_ofReal, pow_add, + Complex.ofReal_pow, map_pow] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPreorder.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPreorder.lean new file mode 100644 index 0000000000000000000000000000000000000000..0affbe894e7e56a87ca9d779fc8b92d4a8e98dd8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkPreorder.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkFrames + +namespace OAI + +/-! # The moving construction and the exposed bulk tree use one preorder -/ + +namespace Ostmann +open scoped Classical + +theorem movingBulkProducts_get_path {σ : Type*} (value : σ → ℕ) (n : ℕ) + (bulk : TreeLeafTuple (List σ) n) (path : List Bool) (hp : path.length < n) : + movingBulkProducts value n bulk path = + (actualChildProducts n (movingSlotValues value n bulk)).getD + (nodePathIndex n path) (1, 1) := by + induction n generalizing path with + | zero => simp at hp + | succ n ih => + cases path with + | nil => + simp only [movingBulkProducts, nodePathIndex, movingSlotValues, actualChildProducts, + List.getD_cons_zero, movingSlotValues_flatten] + | cons b path => + have hp' : path.length < n := by simpa using hp + have hidx := nodePathIndex_lt n path hp' + have hpow := Nat.one_le_two_pow (n := n) + cases b + · simp only [movingBulkProducts, nodePathIndex, Bool.false_eq_true, ite_false, + movingSlotValues, actualChildProducts] + rw [show 1 + nodePathIndex n path = nodePathIndex n path + 1 by omega, + List.getD_cons_succ, List.getD_append _ _ _ _ (by + rw [actualChildProducts_length]; exact hidx)] + exact ih bulk.1 path hp' + · simp only [movingBulkProducts, nodePathIndex, ite_true, + movingSlotValues, actualChildProducts] + rw [show 2 ^ n + nodePathIndex n path = (2 ^ n - 1 + nodePathIndex n path) + 1 by omega, + List.getD_cons_succ, List.getD_append_right _ _ _ _ (by + rw [actualChildProducts_length]; omega), actualChildProducts_length] + rw [show 2 ^ n - 1 + nodePathIndex n path - (2 ^ n - 1) = nodePathIndex n path by omega] + exact ih bulk.2 path hp' + +theorem movingBulkProducts_preorder {σ : Type*} (value : σ → ℕ) (n : ℕ) + (bulk : TreeLeafTuple (List σ) n) (j : Fin (2 ^ n - 1)) : + movingBulkProducts value n bulk (preorderNodePath n j) = + (actualChildProducts n (movingSlotValues value n bulk)).getD j.val (1, 1) := by + rw [movingBulkProducts_get_path value n bulk _ (preorderNodePath_length n j), + nodePathIndex_preorderNodePath] + +theorem treeLeafProduct_intCast (n : ℕ) (x : TreeLeafTuple ℕ n) : + treeLeafProduct n (treeLeafMap (fun a : ℕ => (a : ℤ)) n x) = + ((treeLeafProduct n x : ℕ) : ℤ) := by + induction n with + | zero => rfl + | succ n ih => simp only [treeLeafProduct, treeLeafMap, ih, Nat.cast_mul] + +theorem actualChildProducts_intCast (n : ℕ) (x : TreeLeafTuple ℕ n) : + actualChildProducts n (treeLeafMap (fun a : ℕ => (a : ℤ)) n x) = + (actualChildProducts n x).map (fun a => ((a.1 : ℤ), (a.2 : ℤ))) := by + induction n with + | zero => rfl + | succ n ih => + simp only [treeLeafMap, actualChildProducts, treeLeafProduct_intCast, ih, + List.map_cons, List.map_append] + +theorem movingBulkProducts_preorder_intCast {σ : Type*} (value : σ → ℕ) (n : ℕ) + (bulk : TreeLeafTuple (List σ) n) (j : Fin (2 ^ n - 1)) : + let b := movingBulkProducts value n bulk (preorderNodePath n j) + ((b.1 : ℤ), (b.2 : ℤ)) = + (actualChildProducts n (treeLeafMap (fun a : ℕ => (a : ℤ)) n + (movingSlotValues value n bulk))).getD j.val (1, 1) := by + rw [actualChildProducts_intCast, movingBulkProducts_preorder] + exact (List.getD_map _ (1, 1) (fun a : ℕ × ℕ => ((a.1 : ℤ), (a.2 : ℤ)))).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkRecursiveWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkRecursiveWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..28db99f3ffe86d4ed4dc69596d88da700f9e90c8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkRecursiveWeight.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkLogWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotSystem +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePrior + +namespace OAI + +/-! # Factoring terminal bulk weights from the original recursion -/ + +namespace Ostmann +open scoped Classical ComplexConjugate + +/-- The logarithmic bulk cutoffs are independent of every reconstructed +pivot and survive the right-branch conjugations unchanged. -/ +theorem movingSlotWeight_bulk_log {σ : Type*} (value : σ → ℕ) (tier : σ → ℕ) + (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (cutoff : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) (t : FrequencyTree ℤ n) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + cutoff n ⟨n, T, XL, XR⟩ t = + (movingBulkTreeLogWeight value tier k outside cb cd T : ℂ) * + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + F cutoff n ⟨n, T, XL, XR⟩ t := by + induction T generalizing XL XR with + | leaf => rfl + | @node n s CL CR U left right ihL ihR => + simp only [recursiveTransferWeight] + split_ifs + · simp only [movingSlotSystem, MovingSlotState.child, ite_true, + Bool.false_eq_true, ite_false] at ihL ihR ⊢ + rw [ihL, ihR] + simp only [movingBulkTreeLogWeight, + Complex.ofReal_mul, star_mul, Complex.star_def, Complex.conj_ofReal] + ring + · exact (mul_zero _).symm + +/-- The unchanged independent law already enforces the tier of every +compensation prime, including repeated draws. -/ +theorem movingCompensationPrior_levels {σ : Type*} (μ : σ → ℝ) + (tier : σ → ℕ) (j : ℕ) (hμ : ∀ a, μ a ≠ 0 → tier a = j) + (n : ℕ) (a : TreeLeafTuple (Fin 4 → σ) n) + (ha : movingCompensationPrior μ n a ≠ 0) : + ∀ i ∈ flattenMovingSlots n (movingCompensationSlots n a), tier i = j := by + induction n with + | zero => + intro i hi + obtain ⟨z, rfl⟩ := List.mem_ofFn.mp hi + exact hμ _ (Finset.prod_ne_zero_iff.mp ha z (Finset.mem_univ z)) + | succ n ih => + intro i hi + rcases List.mem_append.mp hi with hi | hi + · exact ih a.1 (left_ne_zero_of_mul ha) i hi + · exact ih a.2 (right_ne_zero_of_mul ha) i hi + +theorem movingSamplesPrior_levels {σ : Type*} (μ : ℕ → σ → ℝ) + (tier : σ → ℕ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + {n : ℕ} (a : MovingSampleSlots σ n) (ha : movingSamplesPrior μ a ≠ 0) : + a.Levels tier := by + induction a with + | leaf => trivial + | node u left right ihL ihR => + exact ⟨movingCompensationPrior_levels (μ _) tier _ (hμ _) _ u + (left_ne_zero_of_mul (left_ne_zero_of_mul ha)), + ihL (right_ne_zero_of_mul (left_ne_zero_of_mul ha)), + ihR (right_ne_zero_of_mul ha)⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..201e0514a0fdcf413643b9c8446b5d0e2be5fed3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingBulkSupport.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.BulkSlotNodup + +namespace OAI + +/-! # Removing the bulk coprimality tests in the literal sampled tree -/ + +namespace Ostmann +open scoped Classical + +theorem buildMovingSlotData_regular_support_frozen {σ : Type*} (n m : ℕ) + (tier : σ → ℕ) (slot : (TreeLeafIndex n × Fin m) ↪ σ) + (base value : σ → ℕ) (hv : ∀ i ∉ Set.range slot, value i = base i) + (hprime : ∀ i, (value i).Prime) + (hinj : Function.Injective (value ∘ slot)) + (hsep : ∀ i ∈ Set.range slot, ∀ j ∉ Set.range slot, value i ≠ value j) + (outside : List ℕ) (hout : ∀ j p, p ∈ outside → (value (slot j)).Coprime p) + (t : FrequencyTree ℤ n) (small : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (hsmallTier : ∀ i ∈ flattenMovingSlots n small, n ≤ tier i) + (hslotTier : ∀ j, n ≤ tier (slot j)) (hsamples : samples.Levels tier) : + movingRegularOutsidePairwise value outside + (buildMovingSlotData n t small (bulkSlotLeaves n m slot) samples) ↔ + movingNonbulkOutsidePairwise base (fun i => decide (i ∈ Set.range slot)) outside + (buildMovingSlotData n t small (bulkSlotLeaves n m slot) samples) := by + let bulk := fun i => decide (i ∈ Set.range slot) + have htrue (i : σ) : bulk i = true ↔ i ∈ Set.range slot := by simp [bulk] + have hfalse (i : σ) : bulk i = false ↔ i ∉ Set.range slot := by simp [bulk] + have hb (j) : bulk (slot j) = true := (htrue _).mpr ⟨j, rfl⟩ + have hgrade (i) (hi : bulk i = true) : n ≤ tier i := by + obtain ⟨j, rfl⟩ := (htrue i).mp hi + exact hslotTier j + have hn := buildMovingSlotData_bulk_nodup n m bulk tier slot hb hgrade t small samples + (fun i hi => (hfalse i).mpr (hsmall i hi)) hsmallTier hsamples + apply movingRegularOutsidePairwise_frozen value base bulk outside _ + (fun i hi => hv i ((hfalse i).mp hi)) (fun _ _ i _ => hprime i) hn + (bulk_value_injective value bulk slot (fun i hi => (htrue i).mp hi) hinj) + · intro L hL i hi j hj hij + cases hbi : bulk i with + | true => + have hbj : bulk j = false := by + cases hbj : bulk j with + | false => rfl + | true => exact False.elim (hij (hbi.trans hbj.symm)) + exact hsep i ((htrue i).mp hbi) j ((hfalse j).mp hbj) + | false => + have hbj : bulk j = true := by + cases hbj : bulk j with + | false => exact False.elim (hij (hbi.trans hbj.symm)) + | true => rfl + exact Ne.symm (hsep j ((htrue j).mp hbj) i ((hfalse i).mp hbi)) + · intro L hL i hi hbi p hp + obtain ⟨j, rfl⟩ := (htrue i).mp hbi + exact hout j p hp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCanonicalComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCanonicalComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ede5f4648a5214ad27f69684d0bc593dc2977ba --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCanonicalComparison.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCanonicalWeights +import OAI.NumberTheory.Ostmann.Arithmetic.RootMeshIntegral + +namespace OAI + +/-! # The original moving coefficient on a common residue-independent mesh -/ + +namespace Ostmann +open scoped Classical BigOperators +open MeasureTheory + +section +variable {σ I : Type*} (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (B : I → ℝ) (hB : ∀ i ∈ S, 0 ≤ B i) (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (XR a b M : ℕ) + +local notation "nodes" => T.formulaNodes value hvalue childBound pivotBound hf (HistoryFormula.prime false) (HistoryFormula.prime true) +local notation "coef" => movingResidueCoefficient q value F E g D S T nodes a b +local notation "profile" => fun x => movingRealGateWeight value T nodes X lo hi (topGiantReal x XR) +local notation "w" => fun x => coef * profile x +local notation "C" => ‖movingDataWeight F E T‖ * ∏ i ∈ S, B i ^ (2 ^ n) + +include hB hg in +theorem moving_canonical_profile_bound (x : ℝ) : ‖w x‖ ≤ C := by + rw [norm_mul] + have hc := movingResidueCoefficient_norm q value F E g D S B hB hg T nodes a b + calc + _ ≤ C * 1 := mul_le_mul hc (movingRealGateWeight_norm value T nodes X lo hi _) + (norm_nonneg _) (mul_nonneg (norm_nonneg _) + (Finset.prod_nonneg fun i hi => pow_nonneg (hB i hi) _)) + _ = _ := mul_one _ + +theorem moving_canonical_profile_cell (roots : Finset ℝ) + (hS : movingRealRootCuts value T nodes X lo hi false XR ⊆ roots) + (x y : ℝ) (hcode : rootCellCode roots x = rootCellCode roots y) : w x = w y := by + have he := movingRealGateWeight_rootCell value T nodes X lo hi false XR x y roots hS hcode + change profile x = profile y at he + exact congrArg (coef * ·) he + +include hB hg in +/-- The same supplied mesh works for every admissible residue pair. Its +cell multiplier is the literal residue coefficient times the real midpoint gate. -/ +theorem PublishedProgressionInput.moving_canonical_prime_integral + (P : PublishedProgressionInput) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) (Q : ℕ) + (hQ : 2 ≤ Q) (hq : 1 ≤ M) (hqQ : M ≤ Q) (ha : a.Coprime M) + (roots : Finset ℝ) (s : ℕ → ℝ) (hs : Monotone s) (N : ℕ) + (hu : 1 ≤ s 0) (hshort : s N ≤ s 0 + 1) + (hfree : ∀ j < N, ∀ r ∈ roots, r ∉ Set.Ioo (Real.exp (s j)) (Real.exp (s (j + 1)))) + (hS : movingRealRootCuts value T nodes X lo hi false XR ⊆ roots) + {k : ℕ} (W : Fin k → ClippedPolynomialFactor) + (hroots : ∀ i r, r ∈ (W i).polynomial.derivative.roots → r ∈ roots) : + ‖complexPrimeInterval M a (s 0) (s N) (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + movingWindowedSpectatorWeight q value F E X lo hi g D S T ⌊Real.exp y⌋₊ XR) * + smoothPolynomialWeight W (Real.exp y)) - + ∫ y in Set.Ioc (s 0) (s N), + w (Real.exp y) * smoothPolynomialWeight W (Real.exp y) * (selectedPrimeLogDensity P Q M a y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, + (‖w (Real.exp ((s j + s (j + 1)) / 2))‖ * smoothPolynomialBudget W * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ)))) + + 2 * C * smoothPolynomialBudget W * Real.exp (-(s j))) := by + rw [moving_canonical_prime_interval q value hvalue childBound pivotBound F E X lo hi + g D S T hf XR a b M hM hMq hR] + exact P.common_root_prime_integral roots s hs N hfree hQ hq hqQ ha hu hshort W hroots + w C (mul_nonneg (norm_nonneg _) (Finset.prod_nonneg fun i hi => pow_nonneg (hB i hi) _)) + (moving_canonical_profile_bound q value hvalue childBound pivotBound F E X lo hi g D S B hB hg T hf XR a b) + (moving_canonical_profile_cell q value hvalue childBound pivotBound F E X lo hi g D S T hf XR a b roots hS) + +include hB hg in +theorem moving_canonical_integer_integral + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) (hq : 0 < M) (G : ℝ) + (roots : Finset ℝ) (s : ℕ → ℝ) (hs : Monotone s) (N : ℕ) + (hfree : ∀ j < N, ∀ r ∈ roots, r ∉ Set.Ioo (Real.exp (s j)) (Real.exp (s (j + 1)))) + (hS : movingRealRootCuts value T nodes X lo hi false XR ⊆ roots) + {k : ℕ} (W : Fin k → ClippedPolynomialFactor) + (hroots : ∀ i r, r ∈ (W i).polynomial.derivative.roots → r ∈ roots) : + ‖complexIntegerInterval M a (s 0) (s N) G (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + movingWindowedSpectatorWeight q value F E X lo hi g D S T ⌊Real.exp y⌋₊ XR) * + smoothPolynomialWeight W (Real.exp y)) - + ∫ y in Set.Ioc (s 0) (s N), + w (Real.exp y) * smoothPolynomialWeight W (Real.exp y) * (integerLogDensity M G y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, + (‖w (Real.exp ((s j + s (j + 1)) / 2))‖ * smoothPolynomialBudget W * + (2 * Real.exp (-G)) + 2 * C * smoothPolynomialBudget W * Real.exp (-G)) := by + rw [moving_canonical_integer_interval q value hvalue childBound pivotBound F E X lo hi + g D S T hf XR a b M hM hMq hR] + exact common_root_integer_integral roots s hs N hfree M a hq G W hroots + w C (mul_nonneg (norm_nonneg _) (Finset.prod_nonneg fun i hi => pow_nonneg (hB i hi) _)) + (moving_canonical_profile_bound q value hvalue childBound pivotBound F E X lo hi g D S B hB hg T hf XR a b) + (moving_canonical_profile_cell q value hvalue childBound pivotBound F E X lo hi g D S T hf XR a b roots hS) + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCanonicalWeights.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCanonicalWeights.lean new file mode 100644 index 0000000000000000000000000000000000000000..56b209b947fe8cdd678aba1e1f1f208760fa1464 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCanonicalWeights.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRealCells +import OAI.NumberTheory.Ostmann.Arithmetic.MovingIntegerCells +import OAI.NumberTheory.Ostmann.Arithmetic.CommonRootMesh + +namespace OAI + +/-! # Canonical residue coefficients of the original moving weight -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingResidueCoefficient {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (a b : ℕ) : ℂ := + (movingResidueFlag nodes (topGiantInput a b) * movingSpectatorResidue q value g D S T a b) * + movingDataWeight F E T + +theorem movingResidueCoefficient_norm {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (B : I → ℝ) (hB : ∀ i ∈ S, 0 ≤ B i) (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (a b : ℕ) : + ‖movingResidueCoefficient q value F E g D S T nodes a b‖ ≤ + ‖movingDataWeight F E T‖ * ∏ i ∈ S, B i ^ (2 ^ n) := by + have hb := movingSpectatorResidue_norm q value g D S B hB hg T a b + unfold movingResidueCoefficient movingResidueFlag + split_ifs + · rw [one_mul, norm_mul, mul_comm] + exact mul_le_mul_of_nonneg_left hb (norm_nonneg _) + · simp only [zero_mul, norm_zero] + exact mul_nonneg (norm_nonneg _) (Finset.prod_nonneg fun i hi => pow_nonneg (hB i hi) _) + +theorem moving_original_canonical_coefficient {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XL XR a b M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + movingArithmeticIndicator value childBound pivotBound T XL XR * + movingWindowedSpectatorWeight q value F E X lo hi g D S T XL XR = + movingResidueCoefficient q value F E g D S T nodes a b * + movingRealGateWeight value T nodes X lo hi (topGiantReal XL XR) := by + dsimp only + rw [moving_original_nonsmooth_residue_factor q value hvalue childBound pivotBound F E + X lo hi g D S T hf XL XR a b M hM hMq hL hR] + simp only [movingResidueCoefficient, movingRealGateWeight, topGiantReal, Bool.false_eq_true, + ite_false, ite_true] + ring + +theorem moving_canonical_prime_interval {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a b M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) (u v : ℝ) (f : ℝ → ℂ) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + complexPrimeInterval M a u v (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + movingWindowedSpectatorWeight q value F E X lo hi g D S T ⌊Real.exp y⌋₊ XR) * f y) = + complexPrimeInterval M a u v (fun y => + (movingResidueCoefficient q value F E g D S T nodes a b * + movingRealGateWeight value T nodes X lo hi (topGiantReal (Real.exp y) XR)) * f y) := by + dsimp only + apply complexPrimeInterval_congr + intro p hp hprime hpa + have hp0 : (0 : ℝ) < p := by exact_mod_cast hprime.pos + rw [Real.exp_log hp0, Nat.floor_natCast, + moving_original_canonical_coefficient q value hvalue childBound pivotBound F E X lo hi + g D S T hf p XR a b M hM hMq (Int.natCast_modEq_iff.mpr hpa) hR] + +theorem moving_canonical_integer_interval {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a b M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) (u v G : ℝ) (f : ℝ → ℂ) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + complexIntegerInterval M a u v G (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + movingWindowedSpectatorWeight q value F E X lo hi g D S T ⌊Real.exp y⌋₊ XR) * f y) = + complexIntegerInterval M a u v G (fun y => + (movingResidueCoefficient q value F E g D S T nodes a b * + movingRealGateWeight value T nodes X lo hi (topGiantReal (Real.exp y) XR)) * f y) := by + dsimp only + apply complexIntegerInterval_congr + intro p hp hpa + have hp0 : (0 : ℝ) < p := by + have : 0 < p := lt_of_le_of_lt (Nat.zero_le _) (Finset.mem_Ioc.mp hp).1 + exact_mod_cast this + rw [Real.exp_log hp0, Nat.floor_natCast, + moving_original_canonical_coefficient q value hvalue childBound pivotBound F E X lo hi + g D S T hf p XR a b M hM hMq (Int.natCast_modEq_iff.mpr hpa) hR] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCellChoice.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCellChoice.lean new file mode 100644 index 0000000000000000000000000000000000000000..86fce4c165510da56b46ec7fb5c12a73084fdff5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCellChoice.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRoundedCellSums + +namespace OAI + +/-! # Integer cell centers outside a finite set of failures -/ + +namespace Ostmann +open scoped Classical + +/-- At most `card D` failures move an integer center by at most `card D + 1`. +This one-sided choice also preserves every lower endpoint target. -/ +theorem integer_cell_center_avoiding (D : Finset ℤ) (T : ℝ) : + ∃ c : ℤ, c ∉ D ∧ T ≤ (c : ℝ) ∧ (c : ℝ) ≤ T + D.card + 1 := by + let a : ℤ := ⌈T⌉ + let S := (Finset.range (D.card + 1)).image (fun j : ℕ => a + (j : ℤ)) + have hcard : S.card = D.card + 1 := by + rw [Finset.card_image_of_injective] + · exact Finset.card_range _ + · intro i j hij + exact_mod_cast (add_left_cancel hij : (i : ℤ) = (j : ℤ)) + have hex : ∃ c ∈ S, c ∉ D := by + by_contra! h + have hsub : S ⊆ D := h + have hc := Finset.card_le_card hsub + omega + obtain ⟨c, hc, hnot⟩ := hex + obtain ⟨j, hj, rfl⟩ := Finset.mem_image.mp hc + have hjR : (j : ℝ) ≤ D.card := by + exact_mod_cast (show j ≤ D.card from Nat.le_of_lt_succ (Finset.mem_range.mp hj)) + refine ⟨a + j, hnot, ?_, ?_⟩ + · push_cast + exact (Int.le_ceil T).trans (le_add_of_nonneg_right (Nat.cast_nonneg j)) + · push_cast + have ha : (a : ℝ) < T + 1 := Int.ceil_lt_add_one T + linarith + +theorem nat_cell_center_avoiding (D : Finset ℕ) (T : ℝ) (hT : 0 ≤ T) : + ∃ c : ℕ, c ∉ D ∧ T ≤ (c : ℝ) ∧ (c : ℝ) ≤ T + D.card + 1 := by + let a := ⌈T⌉₊ + let S := (Finset.range (D.card + 1)).image (fun j => a + j) + have hcard : S.card = D.card + 1 := by + rw [Finset.card_image_of_injective] + · exact Finset.card_range _ + · exact fun _ _ hij => Nat.add_left_cancel hij + have hex : ∃ c ∈ S, c ∉ D := by + by_contra! h + have hc := Finset.card_le_card (show S ⊆ D from h) + omega + obtain ⟨c, hc, hnot⟩ := hex + obtain ⟨j, hj, rfl⟩ := Finset.mem_image.mp hc + have hjR : (j : ℝ) ≤ D.card := by + exact_mod_cast (show j ≤ D.card from Nat.le_of_lt_succ (Finset.mem_range.mp hj)) + refine ⟨a + j, hnot, ?_, ?_⟩ + · push_cast + exact (Nat.le_ceil T).trans (le_add_of_nonneg_right (Nat.cast_nonneg j)) + · push_cast + have ha : (a : ℝ) < T + 1 := Nat.ceil_lt_add_one hT + linarith + +theorem compensation_cell_center_avoiding (D : Finset ℤ) (w : ℝ) : + ∃ c : ℤ, c ∉ D ∧ w ≤ 4 * (c : ℝ) ∧ + 4 * ((c : ℝ) + 1) ≤ w + 4 * (D.card + 2) := by + obtain ⟨c, hc, hlo, hhi⟩ := integer_cell_center_avoiding D (w / 4) + refine ⟨c, hc, ?_, ?_⟩ <;> linarith + +/-- All six protected top slots may use one good cell; the resulting error +is upward and does not weaken the protected lower bound. -/ +theorem protected_cell_center_avoiding (D : Finset ℤ) (J cb : ℝ) : + ∃ c : ℤ, c ∉ D ∧ J ≤ 6 * (c : ℝ) + cb ∧ + 6 * ((c : ℝ) + 1) + cb ≤ J + 6 * (D.card + 2) := by + obtain ⟨c, hc, hlo, hhi⟩ := integer_cell_center_avoiding D ((J - cb) / 6) + refine ⟨c, hc, ?_, ?_⟩ <;> linarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCellGap.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCellGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf87cbaa9c691370756676d8dfa6243a12faeefa --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCellGap.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyBudget +import OAI.NumberTheory.Ostmann.Construction.SpectatorBulkScale + +namespace OAI + +/-! # From the prescribed cell sums to the diagonal's scalar gap -/ + +namespace Ostmann +open Filter + +theorem spectatorStepGap_sub_one (BD Bz z r m : ℝ) : + spectatorStepGap (BD - 1) Bz z r m = spectatorStepGap BD Bz z r m - r * m := by + unfold spectatorStepGap + ring + +/-- `J + tail` is the protected and surviving compensation target in (7.4). +The two cell errors are paid by one unit of the coefficient of the step gap. -/ +theorem moving_cell_diagonal_gap (BD Bz z r m J tail w b cb small cg ec es : ℝ) + (hr : 0 ≤ r) + (hbalance : r * w = r * (J + tail) - spectatorStepGap BD Bz z r m) + (hupper : 4 * b ≤ w + ec) + (hlower : r * (J + tail) - es * r ≤ small + r * (cb - 1)) + (hcost : 2 * cg + 1 + (ec + es) * r ≤ r * m) : + 2 * cg + 1 + (r * 4) * b - (small + r * (cb - 1)) ≤ + -spectatorStepGap (BD - 1) Bz z r m := by + rw [spectatorStepGap_sub_one] + have hu := mul_le_mul_of_nonneg_left hupper hr + nlinarith only [hu, hlower, hbalance, hcost] + +theorem eventual_moving_cell_error_budget (k : ℕ) (hk : 2 ≤ k) (ec es : ℝ) : + ∀ᶠ L : ℝ in atTop, ∀ n : ℕ, ∀ cg : ℝ, cg ≤ (91 / 100 : ℝ) * L → + 2 * cg + 1 + (ec + es) * (2 ^ n : ℕ) ≤ + (2 ^ n : ℕ) * (spectatorBulkCount k L : ℝ) := by + filter_upwards [eventually_ge_atTop (max 1 (ec + es))] with L hL n cg hcg + have hL1 : 1 ≤ L := (le_max_left _ _).trans hL + have hLe : ec + es ≤ L := (le_max_right _ _).trans hL + have hr : (1 : ℝ) ≤ (2 ^ n : ℕ) := by exact_mod_cast Nat.one_le_two_pow + have hk4 : (16 : ℝ) ≤ (k : ℝ) ^ 4 := by + have hkR : (2 : ℝ) ≤ k := by exact_mod_cast hk + have h := pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) hkR 4 + norm_num at h + exact h + have hm := spectatorBulkCount_lower k L + have hm4 : 4 * L ≤ (spectatorBulkCount k L : ℝ) := by + nlinarith [mul_le_mul_of_nonneg_right hk4 (by linarith : 0 ≤ L)] + have he := mul_le_mul_of_nonneg_right hLe (by linarith : (0 : ℝ) ≤ (2 ^ n : ℕ)) + have hrl : L ≤ (2 ^ n : ℕ) * L := le_mul_of_one_le_left (by linarith) hr + have ht := mul_le_mul_of_nonneg_left hm4 (by linarith : (0 : ℝ) ≤ (2 ^ n : ℕ)) + nlinarith + +/-- The centers may each have an error proportional to `L`. Since the bulk +size is `k^4 L + O(1)`, the same one-unit gap reserve pays these errors. -/ +theorem moving_linear_cell_error_budget (k n : ℕ) (C L cg ec es : ℝ) + (hC : 0 ≤ C) (hk : 4 * C + 16 ≤ (k : ℝ) ^ 4) (hL : 1 ≤ L) + (hcg : cg ≤ (91 / 100 : ℝ) * L) (he : ec + es ≤ C * L) : + 2 * cg + 1 + (ec + es) * (2 ^ n : ℕ) ≤ + (2 ^ n : ℕ) * (spectatorBulkCount k L : ℝ) := by + have hr : (1 : ℝ) ≤ (2 ^ n : ℕ) := by exact_mod_cast Nat.one_le_two_pow + have hL0 : 0 ≤ L := by linarith + have hm := spectatorBulkCount_lower k L + have hkL := mul_le_mul_of_nonneg_right hk hL0 + have hCL := mul_nonneg hC hL0 + have hml : (C + 4) * L ≤ (spectatorBulkCount k L : ℝ) := by + nlinarith only [hm, hkL, hCL, hL] + have hem := mul_le_mul_of_nonneg_right he (by linarith : (0 : ℝ) ≤ (2 ^ n : ℕ)) + have hrL : L ≤ (2 ^ n : ℕ) * L := le_mul_of_one_le_left hL0 hr + have htotal := mul_le_mul_of_nonneg_left hml + (by linarith : (0 : ℝ) ≤ (2 ^ n : ℕ)) + nlinarith only [hcg, hL, hem, hrL, htotal] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingChildListSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingChildListSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..cdec45147d096e94a5e32acdf50a4dfbb66f9d6f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingChildListSupport.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCoefficientSupport + +namespace OAI + +/-! # The restored child lists supply the support used by the transfer -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Restoring compensation does not change its order-free current support. -/ +theorem movingFrequencyCoefficient_child_pairwise {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (u small bulk : TreeLeafTuple (List σ) n) (p X : ℕ) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n s + (appendMovingSlotLeaves n u small) bulk p X ≠ 0) : + (p :: X :: ((flattenMovingSlots n u).map value ++ + ((flattenMovingSlots n small ++ flattenMovingSlots n bulk).map value ++ outside))).Pairwise Nat.Coprime := by + have hs := (movingFrequencyCoefficient_nonzero_support value outside μ childBound + pivotBound V F φ G n s (appendMovingSlotLeaves n u small) bulk p X h).1 + have hp := (flattenMovingSlots_append_perm n u small).append_right (flattenMovingSlots n bulk) + have hp' := (((hp.map value).append_right outside).cons X).cons p + apply (hp'.pairwise_iff (fun h => h.symm)).mp at hs + simpa only [List.map_append, List.append_assoc] using hs + +/-- A restored child is disjoint from the inserted giant and its shared +compensation vector. These are precisely the product units needed in the +integer substitution. -/ +theorem restored_child_product_support (u small outside : List ℕ) (p X : ℕ) + (h : (p :: X :: (u ++ (small ++ outside))).Pairwise Nat.Coprime) : + (X :: (small ++ outside)).Pairwise Nat.Coprime ∧ + (X * small.prod).Coprime (p * u.prod) := by + obtain ⟨hp, htail⟩ := List.pairwise_cons.mp h + obtain ⟨hX, hrest⟩ := List.pairwise_cons.mp htail + obtain ⟨_, hsmall, hcross⟩ := List.pairwise_append.mp hrest + refine ⟨List.pairwise_cons.mpr ⟨?_, hsmall⟩, ?_⟩ + · exact fun a ha => hX a (List.mem_append_right u ha) + · apply Nat.Coprime.mul_right + · apply Nat.Coprime.mul_left + · exact (hp X List.mem_cons_self).symm + · apply Nat.coprime_list_prod_left_iff.mpr + intro a ha + exact (hp a (List.mem_cons_of_mem X + (List.mem_append_right u (List.mem_append_left outside ha)))).symm + · apply Nat.coprime_list_prod_right_iff.mpr + intro a ha + apply Nat.Coprime.mul_left + · exact hX a (List.mem_append_left (small ++ outside) ha) + · apply Nat.coprime_list_prod_left_iff.mpr + intro b hb + exact (hcross a ha b (List.mem_append_left outside hb)).symm + +/-- The inherited product in a nonzero child is coprime to the composite +pivot, even when the newly inserted giant is only an integer. -/ +theorem movingFrequencyCoefficient_child_products {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (u small bulk : TreeLeafTuple (List σ) n) (p X : ℕ) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n s + (appendMovingSlotLeaves n u small) bulk p X ≠ 0) : + (X :: (((flattenMovingSlots n small ++ flattenMovingSlots n bulk).map value) ++ outside)).Pairwise Nat.Coprime ∧ + (X * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n small ++ flattenMovingSlots n bulk)).Coprime + (p * MovingSlotReversal.naturalProduct value (flattenMovingSlots n u)) := by + exact restored_child_product_support _ _ _ p X + (movingFrequencyCoefficient_child_pairwise value outside μ childBound pivotBound V F φ G + n s u small bulk p X h) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingClearedRows.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingClearedRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f614197058d9b512a44e9442aa92615002541a0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingClearedRows.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOccurrenceNumerator + +namespace OAI + +/-! # Exact cleared rows before reduction modulo prime squares + +The row identities hold over the integers before any division or reduction. +This permits the same occurrence line to be used modulo a prime square. +-/ + +namespace Ostmann +open scoped Classical + +namespace PolynomialGiantRows + +theorem cleared_movingReverse {σ R : Type*} [CommRing R] + (T : PolynomialGiantRows σ) (φ : MvPolynomial σ ℤ →+* R) + (left : Bool) (v w u : MvPolynomial σ ℤ) (x y L H p : R) + (hL : φ T.rows.a * x + φ T.rows.b * y = φ T.denominator * L) + (hH : φ T.rows.c * x + φ T.rows.d * y = φ T.denominator * H) + (hp : φ v * H - φ w * L = φ u * p) : + let S := T.movingReverse left v w u + φ S.rows.a * x + φ S.rows.b * y = φ S.denominator * p ∧ + φ S.rows.c * x + φ S.rows.d * y = + φ S.denominator * (if left then L else H) := by + have hnew : φ (v * T.rows.c - w * T.rows.a) * x + + φ (v * T.rows.d - w * T.rows.b) * y = φ (T.denominator * u) * p := by + simp only [map_sub, map_mul] + linear_combination φ v * hH - φ w * hL + φ T.denominator * hp + have hkeepL : φ (u * T.rows.a) * x + φ (u * T.rows.b) * y = + φ (T.denominator * u) * L := by + simp only [map_mul] + linear_combination φ u * hL + have hkeepH : φ (u * T.rows.c) * x + φ (u * T.rows.d) * y = + φ (T.denominator * u) * H := by + simp only [map_mul] + linear_combination φ u * hH + cases left + · exact ⟨hnew, hkeepH⟩ + · exact ⟨hnew, hkeepL⟩ + +end PolynomialGiantRows + +/-- The actual natural path multiplied by the cleared denominator equals +its polynomial rows over any ring, in particular over `ℤ` and `ZMod (p²)`. -/ +theorem movingSlotNaturalPath_cleared {σ R : Type*} [CommRing R] + (value : σ → ℕ) (path : List (MovingSlotReversal σ)) (pair : ℕ × ℕ) + (hvalid : MovingSlotPathIntegral value path pair) : + let φ := MvPolynomial.eval₂Hom (Int.castRingHom R) (fun i => (value i : R)) + let T := movingPolynomialAncestors (path.map MovingSlotReversal.polynomial) + let out := movingSlotNaturalPath value path pair + φ T.rows.a * (pair.1 : R) + φ T.rows.b * (pair.2 : R) = + φ T.denominator * (out.1 : R) ∧ + φ T.rows.c * (pair.1 : R) + φ T.rows.d * (pair.2 : R) = + φ T.denominator * (out.2 : R) := by + let φ := MvPolynomial.eval₂Hom (Int.castRingHom R) (fun i => (value i : R)) + induction path with + | nil => simp [movingPolynomialAncestors, PolynomialGiantRows.identity, + GiantRows.identity, movingSlotNaturalPath] + | cons s path ih => + let out := movingSlotNaturalPath value path pair + have he : φ s.polynomial.v * (out.2 : R) - φ s.polynomial.w * (out.1 : R) = + φ s.polynomial.u * (s.naturalPivot value out.1 out.2 : R) := by + have hc := congrArg (fun z : ℤ => (z : R)) hvalid.2.2 + simp only [Int.cast_sub, Int.cast_mul, Int.cast_natCast, Nat.cast_mul] at hc + simp only [φ, MovingSlotReversal.polynomial, MovingSlotReversal.coefficient_nat_eval] + convert hc using 1 <;> ring + have h := PolynomialGiantRows.cleared_movingReverse + (movingPolynomialAncestors (path.map MovingSlotReversal.polynomial)) φ + s.left s.polynomial.v s.polynomial.w s.polynomial.u + (pair.1 : R) (pair.2 : R) (out.1 : R) (out.2 : R) + (s.naturalPivot value out.1 out.2 : R) (ih hvalid.1).1 (ih hvalid.1).2 he + cases hleft : s.left <;> + simpa only [List.map_cons, movingPolynomialAncestors, movingSlotNaturalPath, + MovingSlotReversal.naturalStep, MovingSlotReversal.polynomial, hleft, Bool.false_eq_true, ite_false, ite_true, out] using h + +/-- The single cleared line is the exact current numerator times the +ancestor denominator. No unit or primality hypotheses enter this identity. -/ +theorem movingSlotLine_cleared_numerator {σ R : Type*} [CommRing R] + (value : σ → ℕ) (path : List (MovingSlotReversal σ)) + (current : MovingSlotReversal σ) (XL XR : ℕ) + (hvalid : MovingSlotPathIntegral value path (XL, XR)) : + let φ := MvPolynomial.eval₂Hom (Int.castRingHom R) (fun i => (value i : R)) + let pair := movingSlotNaturalPath value path (XL, XR) + φ (movingSlotLine path current).a * (XL : R) + + φ (movingSlotLine path current).b * (XR : R) = + φ (movingSlotLine path current).denominator * + ((current.leftFrequency : R) * + ((pair.2 * MovingSlotReversal.naturalProduct value current.rightSlots : ℕ) : R) - + (current.rightFrequency : R) * + ((pair.1 * MovingSlotReversal.naturalProduct value current.leftSlots : ℕ) : R)) := by + let φ := MvPolynomial.eval₂Hom (Int.castRingHom R) (fun i => (value i : R)) + have h := movingSlotNaturalPath_cleared (R := R) value path (XL, XR) hvalid + change φ _ * (XL : R) + φ _ * (XR : R) = _ + simp only [movingSlotLine, movingHistoryLine, PolynomialGiantRows.numeratorLine, + map_sub, map_mul] + have he : φ current.polynomial.v * + ((movingSlotNaturalPath value path (XL, XR)).2 : R) - + φ current.polynomial.w * ((movingSlotNaturalPath value path (XL, XR)).1 : R) = + (current.leftFrequency : R) * + (((movingSlotNaturalPath value path (XL, XR)).2 * + MovingSlotReversal.naturalProduct value current.rightSlots : ℕ) : R) - + (current.rightFrequency : R) * + (((movingSlotNaturalPath value path (XL, XR)).1 * + MovingSlotReversal.naturalProduct value current.leftSlots : ℕ) : R) := by + simp only [φ, MovingSlotReversal.polynomial, MovingSlotReversal.coefficient_nat_eval, + Nat.cast_mul] + ring + rw [← he] + linear_combination φ current.polynomial.v * h.2 - φ current.polynomial.w * h.1 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCoefficientSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCoefficientSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..b42df8bc27a7abdcf10b3e0c8db5f5ea0589148f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCoefficientSupport.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeCoefficientNode +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularSlots + +namespace OAI + +/-! # Current support inherited from the original summed coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingFullSupport_local {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) + (h : movingFullSupport value outside T XL XR) : + movingLocalSupport value outside ⟨n, T, XL, XR⟩ := by + cases T with + | leaf => exact h + | node => exact ⟨h.1.1, h.2.1⟩ + +/-- A nonzero finite average contains a supported original sample. No +positivity, normalization, or conditioning of the prime prior is needed. -/ +theorem movingSupportedSampledWeight_nonzero_support {σ : Type*} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (XL XR : ℕ) + (h : movingSupportedSampledWeight value outside μ childBound pivotBound F E + n t small bulk XL XR ≠ 0) : + ∃ a : MovingSampleSlots σ n, + movingFullSupport value outside (buildMovingSlotData n t small bulk a) XL XR := by + rw [movingSupportedSampledWeight_eq, movingCompensatedAverage] at h + obtain ⟨a, _, ha⟩ := Finset.exists_ne_zero_of_sum_ne_zero h + have ht : movingSupportedSampleTerm value outside childBound pivotBound F E + n t small bulk XL XR a ≠ 0 := by + intro hz + exact ha (by rw [hz, mul_zero]) + unfold movingSupportedSampleTerm movingSupportedWeight at ht + refine ⟨a, ?_⟩ + by_contra hs + exact ht (ite_eq_right hs) + +/-- The root sum still has the actual current pairwise support and both +root-frequency units. These are the only support facts needed to attach the +original coefficient to the full Fourier transfer. -/ +theorem movingFrequencyCoefficient_nonzero_support {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G + n s small bulk XL XR ≠ 0) : + (XL :: XR :: ((flattenMovingSlots n small ++ flattenMovingSlots n bulk).map value ++ outside)).Pairwise Nat.Coprime ∧ + IsCoprime (XL : ℤ) s ∧ IsCoprime (XR : ℤ) s := by + rw [movingFrequencyCoefficient] at h + obtain ⟨t, _, ht⟩ := Finset.exists_ne_zero_of_sum_ne_zero h + obtain ⟨a, ha⟩ := movingSupportedSampledWeight_nonzero_support value outside μ childBound + pivotBound F (movingOriginalNode value childBound pivotBound φ G) n + (movingRootedFrequencyTree V n s t) small bulk XL XR ht + let T := buildMovingSlotData n (movingRootedFrequencyTree V n s t) small bulk a + have hlocal := movingFullSupport_local value outside T XL XR ha + have hreg := buildMovingSlotData_regular_perm n (movingRootedFrequencyTree V n s t) small bulk a + have hp : (T.currentSlots value XL XR ++ outside).Perm + (XL :: XR :: ((flattenMovingSlots n small ++ flattenMovingSlots n bulk).map value ++ outside)) := by + simpa only [MovingSlotData.currentSlots, List.cons_append] using + (((hreg.map value).cons XR).cons XL).append_right outside + have hpair := (hp.pairwise_iff (fun h => h.symm)).mp hlocal.1 + have hfreq : T.frequency = s := by + rw [(buildMovingSlotData_follows n _ small bulk a).root, movingRootedFrequencyTree_root] + have hL := ((T.frequencies_isCoprime (XL : ℤ)).mpr hlocal.2.1).root + have hR := ((T.frequencies_isCoprime (XR : ℤ)).mpr hlocal.2.2.1).root + exact ⟨hpair, hfreq ▸ hL, hfreq ▸ hR⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompactEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompactEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..506a0a09df5e7c97bb055ff9d033fa60a024cb1d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompactEnergy.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompactLeaf +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateExternalMultiplier +import OAI.NumberTheory.Ostmann.Characters.MixedExternalAverage + +namespace OAI + +/-! # Frequency truncation preserves the actual unsymmetrized energy -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem mixedExternalAverage_frequency_congr {B A : Type*} [Fintype B] [Fintype A] + (ν : B → A → ℝ) (N : ℕ) (u v r w center : ℝ) + (F H : ℤ → (B → A) → ℝ → ℝ → ℂ) + (h : ∀ s, s.natAbs ≤ N → ∀ y x z, F s y x z = H s y x z) : + mixedExternalAverage ν N u v r w center F = + mixedExternalAverage ν N u v r w center H := by + rw [mixedExternalAverage_finite, mixedExternalAverage_finite] + apply Finset.sum_congr rfl + intro x _ + rw [h x.1.val ((mem_transferFrequencyRange _ _).mp x.1.property)] + +theorem movingTemplate_compact_energy {σ I : Type} [Fintype σ] + (value : σ → ℕ) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n r m : ℕ) (law : MovingRegularSlot n r m → σ → ℝ) + (W : ℤ → (MovingRegularSlot n r m → σ) → ℝ → ℝ → ℂ) + (u v a b center : ℝ) : + mixedExternalAverage law (V n) u v a b center (fun s y x z => + (‖movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ s => if s = 0 then 0 else 1) + g Dq S ψ X lo hi) φ G n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) * W s y x z) = + mixedExternalAverage law (V n) u v a b center (fun s y x z => + (‖movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => movingCompactLeaf (V 0)) + g Dq S ψ X lo hi) φ G n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) * W s y x z) := by + apply mixedExternalAverage_frequency_congr + intro s hs y x z + rw [movingTemplateCoefficient_original_leaf_congr value q outside μ childBound pivotBound V + (fun s => if s = 0 then 0 else 1) (movingCompactLeaf (V 0)) + (fun s hs => by simp only [movingCompactLeaf, hs, ite_true]) + g Dq S ψ X lo hi φ G n r m s hs] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompactLeaf.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompactLeaf.lean new file mode 100644 index 0000000000000000000000000000000000000000..34a29100c0b9ca3d5185803ce9d349649c8ef35a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompactLeaf.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingScheduledLeafCongruence +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedMatchedCorrelation +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateCoefficient + +namespace OAI + +/-! # Compact leaf multipliers preserve the scheduled statistic -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- The zero frequency is removed and all live bottom frequencies are retained. -/ +noncomputable def movingCompactLeaf (V : ℕ) (s : ℤ) : ℂ := + if s.natAbs ≤ V then if s = 0 then 0 else 1 else 0 + +theorem movingCompactLeaf_zero (V : ℕ) : movingCompactLeaf V 0 = 0 := by + simp [movingCompactLeaf] + +theorem movingCompactLeaf_norm (V : ℕ) (s : ℤ) : + ‖movingCompactLeaf V s‖ ≤ if s.natAbs ≤ V then 1 else 0 := by + unfold movingCompactLeaf + split_ifs <;> simp + +theorem movingOriginalLeaf_congr {σ I : Type*} + (value : σ → ℕ) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (f h : ℤ → ℂ) (s : ℤ) (hs : f s = h s) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (x : MovingSlotState σ) : + movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi x s = + movingOriginalLeaf value q (fun _ => h) g Dq S ψ X lo hi x s := by + simp only [movingOriginalLeaf, movingWindowLeaf, movingDataLeaf, hs] + +theorem movingFrequencyCoefficient_original_leaf_congr {σ I : Type} [Fintype σ] + (value : σ → ℕ) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (outside : List ℕ) (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) + (f h : ℤ → ℂ) (hf : ∀ s, s.natAbs ≤ V 0 → f s = h s) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (s : ℤ) (hs : s.natAbs ≤ V n) + (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) : + movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s small bulk XL XR = + movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => h) g Dq S ψ X lo hi) φ G n s small bulk XL XR := by + apply movingFrequencyCoefficient_leaf_congr value outside μ childBound pivotBound V + _ _ _ φ G n s hs small bulk XL XR + intro x z hz + exact movingOriginalLeaf_congr value q f h z (hf z hz) g Dq S ψ X lo hi x + +theorem movingWeightedMatchedCorrelation_leaf_congr {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (f h : ℤ → ℂ) (hf : ∀ s, s.natAbs ≤ V 0 → f s = h s) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (W : ℤ → (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) : + movingWeightedMatchedCorrelation q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n small bulk W u v r w center = + movingWeightedMatchedCorrelation q value outside μ ν childBound pivotBound V h g Dq S + ψ X lo hi φ G n small bulk W u v r w center := by + unfold movingWeightedMatchedCorrelation + apply Finset.sum_congr rfl + intro s _ + have he := movingFrequencyCoefficient_original_leaf_congr value q outside μ + childBound pivotBound V f h hf g Dq S ψ X lo hi φ G n s.val + ((mem_transferFrequencyRange _ _).mp s.property) + simp_rw [he] + +theorem movingTemplateCoefficient_original_leaf_congr {σ I : Type} [Fintype σ] + (value : σ → ℕ) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (outside : List ℕ) (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) + (f h : ℤ → ℂ) (hf : ∀ s, s.natAbs ≤ V 0 → f s = h s) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n r m : ℕ) (s : ℤ) (hs : s.natAbs ≤ V n) + (y : MovingRegularSlot n r m → σ) (XL XR : ℕ) : + movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n r m s y XL XR = + movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => h) g Dq S ψ X lo hi) φ G n r m s y XL XR := + movingFrequencyCoefficient_original_leaf_congr value q outside μ childBound pivotBound V + f h hf g Dq S ψ X lo hi φ G n s hs _ _ XL XR + +theorem movingWeightedMatchedCorrelation_compact {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (W : ℤ → (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) : + movingWeightedMatchedCorrelation q value outside μ ν childBound pivotBound V + (fun s => if s = 0 then 0 else 1) g Dq S ψ X lo hi φ G n small bulk W u v r w center = + movingWeightedMatchedCorrelation q value outside μ ν childBound pivotBound V + (movingCompactLeaf (V 0)) g Dq S ψ X lo hi φ G n small bulk W u v r w center := by + apply movingWeightedMatchedCorrelation_leaf_congr + intro s hs + simp only [movingCompactLeaf, hs, ite_true] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensatedEquations.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensatedEquations.lean new file mode 100644 index 0000000000000000000000000000000000000000..e122afce7c4592493385cadeba21e000042c74c6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensatedEquations.lean @@ -0,0 +1,113 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNodeDivisibility +import OAI.NumberTheory.Ostmann.Construction.ScheduledNodeFrequencies +import OAI.NumberTheory.Ostmann.Construction.CompensatedAdaptiveCoefficients + +namespace OAI + +namespace Ostmann +open scoped Classical + +noncomputable def movingSampleAncestorScheme {σ : Type*} (value : σ → ℕ) + (S : Finset ℤ) (n : ℕ) (t : FrequencyTree S n) + (small : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) (XL XR : ℕ) : + PivotDependencyScheme (2 ^ n - 1) := + forwardTreeAncestorScheme S n t XL XR + (fun path => (movingFrameConstants value n small a path).leftSmall) + (fun path => (movingFrameConstants value n small a path).rightSmall) + +def movingSampleCompensation {σ : Type*} (value : σ → ℕ) (n : ℕ) + (small : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) + (j : Fin (2 ^ n - 1)) : ℤ := + (movingFrameConstants value n small a (preorderNodePath n j)).compensation + +theorem movingSampleNode_products {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (S : Finset ℤ) (n : ℕ) (t : FrequencyTree S n) + (small bulk : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) + (XL XR : ℕ) (j : Fin (2 ^ n - 1)) : + let tz := frequencyTreeMap Subtype.val n t + let x : MovingSlotState σ := ⟨n, buildMovingSlotData n tz small bulk a, XL, XR⟩ + let p := movingGiantArray value childBound pivotBound n x tz + let D := movingSampleAncestorScheme value S n t small a XL XR + let z := transferNodeArray (movingSlotSystem value childBound pivotBound) n x tz j + let b := (actualChildProducts n (treeLeafMap (fun q : ℕ => (q : ℤ)) n + (movingSlotValues value n bulk))).getD j.val (1, 1) + (z.state.compensation value : ℤ) = movingSampleCompensation value n small a j ∧ + (z.state.leftProduct value : ℤ) = D.rightCoefficient p j * b.1 ∧ + (z.state.rightProduct value : ℤ) = D.leftCoefficient p j * b.2 := by + dsimp only + let tz := frequencyTreeMap Subtype.val n t + let T := buildMovingSlotData n tz small bulk a + let x : MovingSlotState σ := ⟨n, T, XL, XR⟩ + let z := transferNodeArray (movingSlotSystem value childBound pivotBound) n x tz j + let p := movingGiantArray value childBound pivotBound n x tz + have hf := movingNodeAtPath_products value childBound pivotBound n tz small bulk a XL XR + (preorderNodePath n j) (preorderNodePath_length n j) + rw [← transferNodeArray_path] at hf + have hg := movingGiantArray_sources value childBound pivotBound n T tz XL XR j + have hb := movingBulkProducts_preorder_intCast value n bulk j + have hl := congrArg Prod.fst hg + have hr := congrArg Prod.snd hg + have hbl := congrArg Prod.fst hb + have hbr := congrArg Prod.snd hb + dsimp only at hl hr hbl hbr + refine ⟨congrArg (fun q : ℕ => (q : ℤ)) hf.1, ?_, ?_⟩ + · change (z.state.leftProduct value : ℤ) = _ + rw [hf.2.1, Nat.cast_mul, Nat.cast_mul] + change _ = (forwardTreeAncestorScheme S n t XL XR _ _).rightCoefficient p j * _ + rw [forwardTreeAncestorScheme_right, ← hl, ← hbl] + ring + · change (z.state.rightProduct value : ℤ) = _ + rw [hf.2.2, Nat.cast_mul, Nat.cast_mul] + change _ = (forwardTreeAncestorScheme S n t XL XR _ _).leftCoefficient p j * _ + rw [forwardTreeAncestorScheme_left, ← hr, ← hbr] + ring + +/-- No node equation is assumed here: all are forced by a nonzero original +recursive coefficient and its compensation cutoff. -/ +theorem movingSample_compensatedEquations {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (S : Finset ℤ) (n : ℕ) (t : FrequencyTree S n) + (small bulk : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) (XL XR : ℕ) + (hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound E) n + ⟨n, buildMovingSlotData n (frequencyTreeMap Subtype.val n t) small bulk a, XL, XR⟩ + (frequencyTreeMap Subtype.val n t) ≠ 0) : + let tz := frequencyTreeMap Subtype.val n t + let x : MovingSlotState σ := ⟨n, buildMovingSlotData n tz small bulk a, XL, XR⟩ + let b := actualChildProducts n (treeLeafMap (fun q : ℕ => (q : ℤ)) n + (movingSlotValues value n bulk)) + (movingSampleAncestorScheme value S n t small a XL XR).compensatedEquations + (movingSampleCompensation value n small a) + (fun j => (b.getD j.val (1, 1)).1) (fun j => (b.getD j.val (1, 1)).2) + (movingGiantArray value childBound pivotBound n x tz) := by + dsimp only + intro j + let sys := movingSlotSystem value childBound pivotBound + let tz := frequencyTreeMap Subtype.val n t + let x : MovingSlotState σ := ⟨n, buildMovingSlotData n tz small bulk a, XL, XR⟩ + let z := transferNodeArray sys n x tz j + have hv := recursiveTransferWeight_nonzero_valid sys F + (movingSlotCutoff value childBound pivotBound E) n x tz hw + have hz := transferNodeArray_valid sys n x tz hv j + have hd := movingSlotWeight_node_divisible value childBound pivotBound F E n x tz hw j + have hf := transferNodeArray_frequencies sys S n x t j + have hp := movingSampleNode_products value childBound pivotBound S n t small bulk a XL XR j + have he : (z.pivot sys : ℤ) = (z.state.compensation value : ℤ) * + movingGiantArray value childBound pivotBound n x tz j := by + dsimp only [movingGiantArray, movingNodeGiant] + exact_mod_cast (Nat.mul_div_cancel' hd.2).symm + have hroot := congrArg NodeFrequencies.root hf + have hleft := congrArg NodeFrequencies.left hf + have hright := congrArg NodeFrequencies.right hf + have h := hz.relation + change z.left * (z.state.rightProduct value : ℤ) - + z.right * (z.state.leftProduct value : ℤ) = z.root * (z.pivot sys : ℤ) at h + dsimp only [ReconstructedTransferNode.frequencies] at hroot hleft hright + rw [he, hp.1, hp.2.1, hp.2.2, hroot, hleft, hright] at h + simpa only [movingSampleAncestorScheme, forwardTreeAncestorScheme, treeAncestorScheme, + mul_assoc] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationFrequency.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationFrequency.lean new file mode 100644 index 0000000000000000000000000000000000000000..d37231ed1c2c5beeeb2bcb12af8638b439134318 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationFrequency.lean @@ -0,0 +1,45 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingProductFrequency +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantIntervalBridge + +namespace OAI + +/-! # The actual compensation tuple satisfies the integer frequency scale -/ +namespace Ostmann +open scoped Classical BigOperators + +theorem smoothGiant_integer_cell_lower (G : ℝ) (p : ℕ) + (hp : p ∈ Finset.Ioc ⌊Real.exp (G - 1)⌋₊ ⌊Real.exp (G + 1)⌋₊) : + Real.exp (G - 1) < (p : ℝ) := + (Nat.floor_lt (Real.exp_nonneg _)).mp (Finset.mem_Ioc.mp hp).1 + +/-- This discharges the scale premise for the original, unconditioned +compensation draw and every integer in the full outer cell. -/ +theorem movingProductNaturalCutoff_compensation_scale {σ : Type} [Fintype σ] + (value : σ → ℕ) (μ : ℕ → σ → ℝ) (G c : ℕ → ℝ) + (hμ : ∀ j x, μ j x ≠ 0 → Real.exp (c j - 1) ≤ (value x : ℝ)) + (W Y m : ℝ) (hm : 64 ≤ m) (hY : Y ≤ W) + (hgap : ∀ j, 2 * movingCellPivotExponent G c j ≤ + movingProductExponent (movingCellPivotExponent G c) W j) + (n : ℕ) (hH : 0 ≤ movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n) + (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (p : ℕ) (hp : Real.exp (G (n + 1) - 1) ≤ (p : ℝ)) : + 2 * movingProductNaturalCutoff (movingCellPivotExponent G c) W Y m n * + ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊ ≤ + movingProductNaturalCutoff (movingCellPivotExponent G c) W Y m (n + 1) * + (p * ∏ i, value (u i)) := by + let a := (movingTemplateCompensationEquiv σ n).symm u + have he : movingTemplateCompensationEquiv σ n a = u := Equiv.apply_symm_apply _ _ + have ha : movingCompensationPrior (μ n) n a ≠ 0 := by + rw [← movingTemplateCompensationEquiv_prior, he] + exact hu + have hlower := movingCompensation_pivot_lower_of_bound value (μ n) (c n) (G (n + 1)) + (hμ n) n a ha p hp + rw [movingTemplateCompensationEquiv_product, he] at hlower + exact movingProductNaturalCutoff_scale (movingCellPivotExponent G c) W Y m n hm hY + hgap hH (p * ∏ i, value (u i)) hlower + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationGapList.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationGapList.lean new file mode 100644 index 0000000000000000000000000000000000000000..0051a6b7d27540c176d4f39e5d6c63e2cf1fcfe3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationGapList.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationGeometry + +namespace OAI + +/-! # The prescribed normalized gaps in the backwards target recursion -/ + +namespace Ostmann +open Filter + +noncomputable def movingCompensationGaps (k : ℕ) (BD Bz L : ℝ) : List ℝ := + List.ofFn (fun i : Fin k => + spectatorStepGap BD Bz ((k : ℝ) ^ 4) ((2 : ℝ) ^ (i : ℕ)) (spectatorBulkCount k L) / + (2 : ℝ) ^ (i : ℕ)) + +noncomputable def movingCompensationGapRate (k : ℕ) (BD Bz : ℝ) : ℝ := + (BD + Bz * Real.log ((k : ℝ) ^ 4) + (2 / 5 : ℝ) * k * Real.log 2) * (k : ℝ) ^ 4 + +@[simp] theorem movingCompensationGaps_length (k : ℕ) (BD Bz L : ℝ) : + (movingCompensationGaps k BD Bz L).length = k := by simp [movingCompensationGaps] + +theorem movingCompensationGapRate_nonneg (k : ℕ) (hk : 0 < k) + (BD Bz : ℝ) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) : + 0 ≤ movingCompensationGapRate k BD Bz := by + have hk1 : (1 : ℝ) ≤ k := by exact_mod_cast hk + have hz : 1 ≤ (k : ℝ) ^ 4 := one_le_pow₀ hk1 + have hzlog := Real.log_nonneg hz + have h2log : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + unfold movingCompensationGapRate + positivity + +theorem movingCompensationGaps_bounds (k : ℕ) (hk : 0 < k) + (BD Bz L : ℝ) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) (hL : 0 ≤ L) : + ∀ d ∈ movingCompensationGaps k BD Bz L, + 0 ≤ d ∧ d ≤ movingCompensationGapRate k BD Bz * L := by + intro d hd + obtain ⟨i, rfl⟩ := List.mem_ofFn.mp hd + have hr : (0 : ℝ) < 2 ^ (i : ℕ) := by positivity + have heq : spectatorStepGap BD Bz ((k : ℝ) ^ 4) ((2 : ℝ) ^ (i : ℕ)) + (spectatorBulkCount k L) / (2 : ℝ) ^ (i : ℕ) = + (BD + Bz * Real.log ((k : ℝ) ^ 4) + + (2 / 5 : ℝ) * (i : ℕ) * Real.log 2) * (spectatorBulkCount k L : ℝ) := by + unfold spectatorStepGap + simp only [Real.log_pow] + field_simp [hr.ne'] + rw [heq] + have hz : 1 ≤ (k : ℝ) ^ 4 := one_le_pow₀ (by exact_mod_cast hk) + have hzlog := Real.log_nonneg hz + have h2log : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + have hi : ((i : ℕ) : ℝ) ≤ k := by exact_mod_cast i.isLt.le + have hc : 0 ≤ BD + Bz * Real.log ((k : ℝ) ^ 4) + (2 / 5 : ℝ) * (i : ℕ) * Real.log 2 := by positivity + have hc' : BD + Bz * Real.log ((k : ℝ) ^ 4) + (2 / 5 : ℝ) * (i : ℕ) * Real.log 2 ≤ + BD + Bz * Real.log ((k : ℝ) ^ 4) + (2 / 5 : ℝ) * k * Real.log 2 := by + nlinarith only [hi, h2log] + refine ⟨mul_nonneg hc (Nat.cast_nonneg _), ?_⟩ + have h1 := mul_le_mul_of_nonneg_right hc' (Nat.cast_nonneg (spectatorBulkCount k L) (α := ℝ)) + have h2 := mul_le_mul_of_nonneg_left (spectatorBulkCount_upper k L hL) + (hc.trans hc') + dsimp [movingCompensationGapRate] + nlinarith only [h1, h2] + +theorem eventual_prescribed_compensation_range (k : ℕ) (hk : 0 < k) + (BD Bz : ℝ) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) : + ∀ᶠ L : ℝ in atTop, ∀ J : ℝ, + 16 * Real.exp ((1 / 100 : ℝ) * L) ≤ J → + J ≤ 32 * Real.exp ((1 / 100 : ℝ) * L) → + ∀ w ∈ movingCompensationTargets J (movingCompensationGaps k BD Bz L), + Real.exp ((1 / 100 : ℝ) * L) ≤ w / 4 ∧ + w / 4 ≤ Real.exp ((105 / 10000 : ℝ) * L) := by + filter_upwards [eventual_moving_compensation_range k (movingCompensationGapRate k BD Bz) + (movingCompensationGapRate_nonneg k hk BD Bz hBD hBz), + eventually_ge_atTop (0 : ℝ)] with L htarget hL + intro J hJlo hJhi + exact htarget J (movingCompensationGaps k BD Bz L) + (by simp) hJlo hJhi (movingCompensationGaps_bounds k hk BD Bz L hBD hBz hL) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationGeometry.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a29c115c43a96f476df1d33a12045e0146c536c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationGeometry.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationTargets +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticErrorRates + +namespace OAI + +/-! # Every prescribed compensation target lies in the small-prime range -/ + +namespace Ostmann +open Filter + +theorem movingCompensationTargets_mem_bounds (J B : ℝ) (ds : List ℝ) + (hJ : 0 ≤ J) (hB : 0 ≤ B) (hd : ∀ d ∈ ds, 0 ≤ d ∧ d ≤ B) : + ∀ w ∈ movingCompensationTargets J ds, + J - 2 ^ ds.length * B ≤ w ∧ w ≤ 2 ^ ds.length * J := by + induction ds with + | nil => simp [movingCompensationTargets] + | cons d ds ih => + have hd0 := hd d (by simp) + have hds : ∀ e ∈ ds, 0 ≤ e ∧ e ≤ B := fun e he => hd e (by simp [he]) + have herror := movingCompensationTargetError_bounds B ds hds + have hsum := movingCompensationTargets_sum J ds + have hp : (1 : ℝ) ≤ 2 ^ ds.length := one_le_pow₀ (by norm_num) + have hpJ := mul_le_mul_of_nonneg_right hp hJ + have hpB : 0 ≤ (2 : ℝ) ^ ds.length * B := by positivity + have hpJ0 : 0 ≤ (2 : ℝ) ^ ds.length * J := by positivity + intro w hw + simp only [movingCompensationTargets, List.mem_cons] at hw + simp only [List.length_cons, pow_succ] + rcases hw with rfl | hw + · constructor <;> nlinarith only [hsum, herror.1, herror.2, hd0.1, hd0.2, hpJ, hpB, hpJ0] + · obtain ⟨hl, hu⟩ := ih hds w hw + constructor <;> nlinarith only [hl, hu, hpB, hpJ0] + +theorem eventual_moving_compensation_range (k : ℕ) (B : ℝ) (hB : 0 ≤ B) : + ∀ᶠ L : ℝ in atTop, ∀ (J : ℝ) (ds : List ℝ), ds.length ≤ k → + 16 * Real.exp ((1 / 100 : ℝ) * L) ≤ J → + J ≤ 32 * Real.exp ((1 / 100 : ℝ) * L) → + (∀ d ∈ ds, 0 ≤ d ∧ d ≤ B * L) → + ∀ w ∈ movingCompensationTargets J ds, + Real.exp ((1 / 100 : ℝ) * L) ≤ w / 4 ∧ + w / 4 ≤ Real.exp ((105 / 10000 : ℝ) * L) := by + let C := (2 : ℝ) ^ k * B + have hC : 0 ≤ C := by dsimp [C]; positivity + have ht : Tendsto (fun L : ℝ => Real.exp ((5 / 10000 : ℝ) * L)) atTop atTop := + Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num)) + filter_upwards [arithmetic_exponent_absorption 0 (1 / 100) 0 C 8 1 + (by norm_num) (by norm_num) (by norm_num) (by norm_num), + ht.eventually (eventually_ge_atTop (8 * (2 : ℝ) ^ k)), + eventually_ge_atTop (0 : ℝ)] with L hgap hratio hL + intro J ds hlen hJlo hJhi hd w hw + have hJ : 0 ≤ J := (by positivity : 0 ≤ 16 * Real.exp ((1 / 100 : ℝ) * L)).trans hJlo + have hpow : (2 : ℝ) ^ ds.length ≤ 2 ^ k := pow_le_pow_right₀ (by norm_num) hlen + have hpowB := mul_le_mul_of_nonneg_right hpow (mul_nonneg hB hL) + have hpowJ := mul_le_mul_of_nonneg_right hpow hJ + obtain ⟨hl, hu⟩ := movingCompensationTargets_mem_bounds J (B * L) ds hJ (mul_nonneg hB hL) hd w hw + simp only [pow_one, zero_mul, Real.exp_zero, mul_one] at hgap + have hCL : 0 ≤ C * L := mul_nonneg hC hL + have hcost : (2 : ℝ) ^ k * (B * L) ≤ 8 * Real.exp ((1 / 100 : ℝ) * L) := by + dsimp only [C] at hgap hCL + nlinarith only [hgap, hCL] + constructor + · nlinarith only [hl, hpowB, hcost, hJlo, Real.exp_nonneg ((1 / 100 : ℝ) * L)] + · have hscale := mul_le_mul_of_nonneg_right hratio + (Real.exp_nonneg ((1 / 100 : ℝ) * L)) + have heq : Real.exp ((5 / 10000 : ℝ) * L) * Real.exp ((1 / 100 : ℝ) * L) = + Real.exp ((105 / 10000 : ℝ) * L) := by rw [← Real.exp_add]; congr 1; ring + rw [heq] at hscale + have hJbound := mul_le_mul_of_nonneg_left hJhi (by positivity : 0 ≤ (2 : ℝ) ^ k) + nlinarith only [hu, hpowJ, hscale, hJbound] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationLines.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationLines.lean new file mode 100644 index 0000000000000000000000000000000000000000..09850b773f462dacbbaa04e58f9a88123f3cd15c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationLines.lean @@ -0,0 +1,139 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOccurrenceSquares +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSupport + +namespace OAI + +/-! # Compensation divisibility is the current internal-prime line condition + +The equivalence below is used before imposing integrality of the new giant. +Thus the line condition recovers the original compensation division instead +of merely being a consequence of an already integral history. +-/ + +namespace Ostmann +open scoped Classical + +theorem pairwise_coprime_list_prod_dvd_iff (U : List ℕ) + (hU : U.Pairwise Nat.Coprime) (Q : ℕ) : + U.prod ∣ Q ↔ ∀ b ∈ U, b ∣ Q := by + constructor + · intro h b hb + exact (List.dvd_prod hb).trans h + · induction U with + | nil => simp + | cons b U ih => + intro h + obtain ⟨hbU, hUU⟩ := List.pairwise_cons.mp hU + have hb := h b (by simp) + have ht := ih hUU (fun c hc => h c (List.mem_cons_of_mem b hc)) + exact (Nat.coprime_list_prod_right_iff.mpr hbU).mul_dvd_of_dvd_of_dvd hb ht + +theorem compensation_dvd_iff_numerator (U : List ℕ) (s N : ℤ) (Q : ℕ) + (hprime : ∀ b ∈ U, b.Prime) (hpair : U.Pairwise Nat.Coprime) + (hs : ∀ b ∈ U, ¬ b ∣ s.natAbs) (hN : N = s * Q) : + U.prod ∣ Q ↔ ∀ b ∈ U, (b : ℤ) ∣ N := by + rw [pairwise_coprime_list_prod_dvd_iff U hpair Q] + apply forall₂_congr + intro b hb + rw [hN] + have hcop : IsCoprime (b : ℤ) s := by + simpa only [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast] using + ((hprime b hb).coprime_iff_not_dvd.mpr (hs b hb)) + constructor + · intro h + exact dvd_mul_of_dvd_right (Int.natCast_dvd_natCast.mpr h) s + · intro h + exact Int.natCast_dvd_natCast.mp (hcop.dvd_of_dvd_mul_left h) + +/-- The cleared line and the actual current numerator have the same zero +test modulo an internal prime. Only the earlier path must be integral. -/ +theorem movingSlotLine_prime_zero_iff {σ : Type*} {p : ℕ} [Fact p.Prime] + (value : σ → ℕ) (path : List (MovingSlotReversal σ)) + (current : MovingSlotReversal σ) (XL XR : ℕ) + (hvalid : MovingSlotPathIntegral value path (XL, XR)) + (hu : ∀ s ∈ path, MovingSlotReversal.naturalReduction p value s.polynomial.u ≠ 0) : + let φ := MovingSlotReversal.naturalReduction p value + φ (movingSlotLine path current).a * (XL : ZMod p) + + φ (movingSlotLine path current).b * (XR : ZMod p) = 0 ↔ + (p : ℤ) ∣ current.integerNumerator value (movingSlotNaturalPath value path (XL, XR)) := by + have hd : MovingSlotReversal.naturalReduction p value + (movingSlotLine path current).denominator ≠ 0 := by + apply movingPolynomialAncestors_denominator + intro s hs + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs + exact hu t ht + have he := movingSlotLine_cleared_numerator (R := ZMod p) value path current XL XR hvalid + change _ = 0 ↔ _ + have hn : MovingSlotReversal.naturalReduction p value (movingSlotLine path current).a * + (XL : ZMod p) + + MovingSlotReversal.naturalReduction p value (movingSlotLine path current).b * (XR : ZMod p) = + MovingSlotReversal.naturalReduction p value (movingSlotLine path current).denominator * + (current.integerNumerator value (movingSlotNaturalPath value path (XL, XR)) : ZMod p) := by + simpa only [MovingSlotReversal.naturalReduction, MovingSlotReversal.integerNumerator, + Int.cast_sub, Int.cast_mul, Int.cast_natCast] using he + rw [hn, mul_eq_zero, or_iff_right hd] + exact ZMod.intCast_zmod_eq_zero_iff_dvd _ p + +/-- At a supported transfer node, the internal-prime congruences are +equivalent to the original compensation-product divisibility. -/ +theorem moving_compensation_division_iff_lines {σ : Type*} + (value : σ → ℕ) (path : List (MovingSlotReversal σ)) + (current : MovingSlotReversal σ) (XL XR Q : ℕ) + (hvalid : MovingSlotPathIntegral value path (XL, XR)) + (hprime : ∀ i ∈ current.compensationSlots, (value i).Prime) + (hpair : (current.compensationSlots.map value).Pairwise Nat.Coprime) + (hs : ∀ i ∈ current.compensationSlots, ¬ value i ∣ current.rootFrequency.natAbs) + (hu : ∀ i ∈ current.compensationSlots, ∀ s ∈ path, + MovingSlotReversal.naturalReduction (value i) value s.polynomial.u ≠ 0) + (hN : current.integerNumerator value (movingSlotNaturalPath value path (XL, XR)) = + current.rootFrequency * Q) : + MovingSlotReversal.naturalProduct value current.compensationSlots ∣ Q ↔ + ∀ i ∈ current.compensationSlots, + let φ := MovingSlotReversal.naturalReduction (value i) value + φ (movingSlotLine path current).a * (XL : ZMod (value i)) + + φ (movingSlotLine path current).b * (XR : ZMod (value i)) = 0 := by + rw [MovingSlotReversal.naturalProduct, + compensation_dvd_iff_numerator _ _ _ _ + (by intro b hb; obtain ⟨i, hi, rfl⟩ := List.mem_map.mp hb; exact hprime i hi) + hpair (by intro b hb; obtain ⟨i, hi, rfl⟩ := List.mem_map.mp hb; exact hs i hi) hN] + constructor + · intro h i hi + let : Fact (value i).Prime := ⟨hprime i hi⟩ + exact (movingSlotLine_prime_zero_iff value path current XL XR hvalid (hu i hi)).mpr + (h (value i) (List.mem_map.mpr ⟨i, hi, rfl⟩)) + · intro h b hb + obtain ⟨i, hi, rfl⟩ := List.mem_map.mp hb + let : Fact (value i).Prime := ⟨hprime i hi⟩ + exact (movingSlotLine_prime_zero_iff value path current XL XR hvalid (hu i hi)).mp (h i hi) + +/-- Every internal-prime line of the original integral tree vanishes. This +uses the actual occurrence path and allows a prime to represent several nodes. -/ +theorem MovingSlotData.integral_compensation_lines {σ : Type*} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + {n : ℕ} (T : MovingSlotData σ n) (hlevels : T.Levels tier) + (hfreq : ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (XL XR : ℕ) (hI : T.Integral value XL XR) : + ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, + let φ := MovingSlotReversal.naturalReduction (value i) value + φ (movingSlotLine o.path o.current).a * (XL : ZMod (value i)) + + φ (movingSlotLine o.path o.current).b * (XR : ZMod (value i)) = 0 := by + intro o ho i hi + let : Fact (value i).Prime := ⟨hprime i⟩ + have hu := T.occurrence_units_of_prime_types tier value hprime hdisjoint hlevels + o ho i (T.occurrence_compensation_level tier hlevels o ho i hi) (hfreq i) + have hv := T.occurrence_integral value XL XR hI o ho + apply (movingSlotLine_prime_zero_iff value o.path o.current XL XR hv.1 + (fun s hs => (hu.1 s hs).2.2)).mpr + have hd : value i ∣ MovingSlotReversal.naturalProduct value o.current.compensationSlots := + List.dvd_prod (List.mem_map.mpr ⟨i, hi, rfl⟩) + change (value i : ℤ) ∣ _ + rw [show o.current.integerNumerator value (movingSlotNaturalPath value o.path (XL, XR)) = + o.current.rootFrequency * ((MovingSlotReversal.naturalProduct value o.current.compensationSlots * + o.current.naturalPivot value (movingSlotNaturalPath value o.path (XL, XR)).1 + (movingSlotNaturalPath value o.path (XL, XR)).2 : ℕ) : ℤ) from hv.2.2] + exact dvd_mul_of_dvd_right (Int.natCast_dvd_natCast.mpr (dvd_mul_of_dvd_left hd _)) _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationProductBounds.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationProductBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..53f9063dd0a932ea623873c670745d6a7b480dc6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationProductBounds.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePrior +import OAI.NumberTheory.Ostmann.Construction.InitialSelectedPrior + +namespace OAI + +/-! # Actual compensation-prior support bounds for the first transfers -/ +namespace Ostmann +open scoped Classical BigOperators + +theorem movingCompensation_product_lower {σ : Type*} (value : σ → ℕ) + (μ : σ → ℝ) (c : ℝ) + (hlower : ∀ x, μ x ≠ 0 → Real.exp (c - 1) ≤ (value x : ℝ)) + (n : ℕ) (a : TreeLeafTuple (Fin 4 → σ) n) + (ha : movingCompensationPrior μ n a ≠ 0) : + Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * (c - 1)) ≤ + (MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingCompensationSlots n a)) : ℝ) := by + induction n with + | zero => + change Real.exp (4 * (c - 1)) ≤ + (MovingSlotReversal.naturalProduct value (List.ofFn a) : ℝ) + have hprod : (∏ i : Fin 4, Real.exp (c - 1)) ≤ ∏ i : Fin 4, (value (a i) : ℝ) := + Finset.prod_le_prod₀ (fun _ _ => Real.exp_nonneg _) + (fun i hi => hlower _ (Finset.prod_ne_zero_iff.mp ha i hi)) + simpa only [Finset.prod_const, Finset.card_univ, Fintype.card_fin, + ← Real.exp_nat_mul, MovingSlotReversal.naturalProduct, + List.map_ofFn, List.prod_ofFn, Function.comp_def, Nat.cast_prod, Nat.cast_ofNat] using hprod + | succ n ih => + have hL := ih a.1 (left_ne_zero_of_mul ha) + have hR := ih a.2 (right_ne_zero_of_mul ha) + change Real.exp (((2 ^ (n + 1) * 4 : ℕ) : ℝ) * (c - 1)) ≤ + (MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingCompensationSlots n a.1) ++ + flattenMovingSlots n (movingCompensationSlots n a.2)) : ℝ) + rw [movingNaturalProduct_append] + simp only [Nat.cast_mul] at hL hR ⊢ + calc + _ = Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * (c - 1)) * + Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * (c - 1)) := by + rw [← Real.exp_add] + congr 1 + push_cast + rw [pow_succ] + ring + _ ≤ _ := by + simpa only [Nat.cast_mul] using + mul_le_mul hL hR (Real.exp_nonneg _) (Nat.cast_nonneg _) + +theorem movingInsertedPivot_product_lower {σ : Type*} (value : σ → ℕ) + (μ : σ → ℝ) (c G : ℝ) (φ : ℝ → ℝ) + (hlower : ∀ x, μ x ≠ 0 → Real.exp (c - 1) ≤ (value x : ℝ)) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (n : ℕ) (a : TreeLeafTuple (Fin 4 → σ) n) + (ha : movingCompensationPrior μ n a ≠ 0) + (p : ℕ) (hp : 0 < p) (hφ : φ (Real.log p - G) ≠ 0) : + Real.exp (G - 1 + ((2 ^ n * 4 : ℕ) : ℝ) * (c - 1)) ≤ + (p * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingCompensationSlots n a)) : ℕ) := by + have habs : |Real.log p - G| < 1 := by + by_contra hn + exact hφ (hout _ (not_lt.mp hn)) + have hpR : (0 : ℝ) < p := by exact_mod_cast hp + have hpbound : Real.exp (G - 1) ≤ (p : ℝ) := by + have hlog : G - 1 ≤ Real.log (p : ℝ) := by linarith [(abs_lt.mp habs).1] + exact (Real.exp_le_exp.mpr hlog).trans_eq (Real.exp_log hpR) + rw [Real.exp_add] + simpa only [Nat.cast_mul] using + mul_le_mul hpbound (movingCompensation_product_lower value μ c hlower n a ha) + (Real.exp_nonneg _) (Nat.cast_nonneg _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..51e40a08d549256b8350b0aea444a5e6144dfb39 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationSupport.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeFrequencyAverage + +namespace OAI + +/-! # Compensation coincidences vanish on both original and arithmetic support -/ + +namespace Ostmann +open scoped Classical + +theorem movingRegularOutsidePairwise_root {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (h : movingRegularOutsidePairwise value outside T) : + (T.regularSlots.map value).Pairwise Nat.Coprime := by + have hr : (T.regularSlots.map value ++ outside).Pairwise Nat.Coprime := by + cases T with + | leaf => exact h + | node => exact h.1 + exact (List.pairwise_append.mp hr).1 + +theorem movingFullOutsidePairwise_regular {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) + (h : movingFullOutsidePairwise value outside T XL XR) : + movingRegularOutsidePairwise value outside T := by + induction T generalizing XL XR with + | leaf s regular => + exact h.tail.tail + | node s CL CR U left right ihL ihR => + exact ⟨h.1.tail.tail, ihL _ _ h.2.1, ihR _ _ h.2.2⟩ + +theorem MovingSlotData.compensationDistinct_of_regularSupport {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hc : T.RegularCoherent) (h : movingRegularOutsidePairwise value outside T) : + T.CompensationDistinct value := by + induction T with + | leaf => trivial + | node s CL CR U left right ihL ihR => + have hp := movingRegularOutsidePairwise_root value outside left h.2.1 + have hperm := (hc.1.map value).pairwise_iff (R := Nat.Coprime) (fun h => h.symm) + have hu : ((U ++ CL).map value).Pairwise Nat.Coprime := hperm.mp hp + rw [List.map_append] at hu + exact ⟨(List.pairwise_append.mp hu).1, ihL hc.2.2.1 h.2.1, + ihR hc.2.2.2 h.2.2⟩ + +theorem movingSupportedWeight_zero_of_compensation_collision {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hc : T.RegularCoherent) (hbad : ¬ T.CompensationDistinct value) + (XL XR : ℕ) (z : ℂ) : movingSupportedWeight value outside T XL XR z = 0 := by + apply ite_eq_right + intro h + exact hbad (T.compensationDistinct_of_regularSupport value outside hc + (movingFullOutsidePairwise_regular value outside T XL XR h.1)) + +theorem movingFrequencyPrimeAverage_zero_of_compensation_collision {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) (x y : ℝ) + (hc : ∀ b, (T b).RegularCoherent) + (hbad : ¬ ∀ b, (T b).CompensationDistinct value) : + movingFrequencyPrimeAverage value outside F E T nodes R r input Q x y = 0 := by + rw [movingFrequencyPrimeAverage_core] + have hn : ¬ ∀ b, movingRegularOutsidePairwise value outside (T b) ∧ + (∀ f ∈ nodes b, f.guard.frequencyBounds) := by + intro h + exact hbad (fun b => (T b).compensationDistinct_of_regularSupport value outside + (hc b) (h b).1) + rw [ite_eq_right hn, zero_mul] + +theorem MovingSlotData.compensationPrimeData_of_units {σ : Type*} + (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) {n : ℕ} (T : MovingSlotData σ n) + (hu : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hd : T.CompensationDistinct value) : T.CompensationPrimeData value := by + induction T with + | leaf => trivial + | node s CL CR U left right ihL ihR => + refine ⟨?_, hd.1, ?_, ihL (fun i => (hu i).2.1) hd.2.1, + ihR (fun i => (hu i).2.2) hd.2.2⟩ + · intro p hp + obtain ⟨i, _, rfl⟩ := List.mem_map.mp hp + exact hprime i + · intro p hp + obtain ⟨i, _, rfl⟩ := List.mem_map.mp hp + apply (hprime i).coprime_iff_not_dvd.mp + have h := (hu i).1 + change IsCoprime s (value i : ℤ) at h + rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast] at h + exact Nat.coprime_comm.mp h + +theorem movingSeparatedResidueCoefficient_zero_of_compensation_collision {σ I : Type*} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (R x y : ℤ) + (hc : T.RegularCoherent) (hbad : ¬ T.CompensationDistinct value) : + movingSeparatedResidueCoefficient q value outside F E g D S T nodes R x y = 0 := by + apply ite_eq_right + intro h + exact hbad (T.compensationDistinct_of_regularSupport value outside hc h.1) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationTargets.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationTargets.lean new file mode 100644 index 0000000000000000000000000000000000000000..45f628795d95070abe85efaaa639c1cb436be8f1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationTargets.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCellGap + +namespace OAI + +/-! # The backwards compensation-center construction of equation (7.4) -/ + +namespace Ostmann + +/-- The entries are ordered from the first removed type to the last. -/ +noncomputable def movingCompensationTargets (J : ℝ) : List ℝ → List ℝ + | [] => [] + | d :: ds => + let rest := movingCompensationTargets J ds + (J + rest.sum - d) :: rest + +noncomputable def movingCompensationTargetError : List ℝ → ℝ + | [] => 0 + | d :: ds => 2 * movingCompensationTargetError ds + d + +@[simp] theorem movingCompensationTargets_length (J : ℝ) (ds : List ℝ) : + (movingCompensationTargets J ds).length = ds.length := by + induction ds with + | nil => rfl + | cons d ds ih => simp only [movingCompensationTargets, List.length_cons, ih] + +theorem movingCompensationTargets_sum (J : ℝ) (ds : List ℝ) : + J + (movingCompensationTargets J ds).sum = + (2 : ℝ) ^ ds.length * J - movingCompensationTargetError ds := by + induction ds with + | nil => simp only [movingCompensationTargets, List.sum_nil, List.length_nil, + pow_zero, one_mul, movingCompensationTargetError, sub_zero, add_zero] + | cons d ds ih => + simp only [movingCompensationTargets, List.sum_cons, List.length_cons, + movingCompensationTargetError, pow_succ] + linarith + +theorem movingCompensationTargets_first (J d : ℝ) (ds : List ℝ) : + movingCompensationTargets J (d :: ds) = + ((2 : ℝ) ^ ds.length * J - movingCompensationTargetError ds - d) :: + movingCompensationTargets J ds := by + simp only [movingCompensationTargets, movingCompensationTargets_sum] + +theorem movingCompensationTargetError_bounds (B : ℝ) (ds : List ℝ) + (h : ∀ d ∈ ds, 0 ≤ d ∧ d ≤ B) : + 0 ≤ movingCompensationTargetError ds ∧ + movingCompensationTargetError ds ≤ ((2 : ℝ) ^ ds.length - 1) * B := by + induction ds with + | nil => simp only [movingCompensationTargetError, List.length_nil, pow_zero, + sub_self, zero_mul, le_refl, and_self] + | cons d ds ih => + have hd := h d (by simp) + have ht := ih (fun x hx => h x (by simp only [List.mem_cons]; exact Or.inr hx)) + simp only [movingCompensationTargetError, List.length_cons, pow_succ] + constructor <;> linarith + +theorem movingCompensationTargets_first_error (J d B : ℝ) (ds : List ℝ) + (h : ∀ e ∈ d :: ds, 0 ≤ e ∧ e ≤ B) : + |(J + (movingCompensationTargets J ds).sum - d) - (2 : ℝ) ^ ds.length * J| ≤ + (2 : ℝ) ^ ds.length * B := by + have hd := h d (by simp) + have ht := movingCompensationTargetError_bounds B ds + (fun x hx => h x (by simp only [List.mem_cons]; exact Or.inr hx)) + have hs := movingCompensationTargets_sum J ds + rw [abs_of_nonpos (by linarith : + J + (movingCompensationTargets J ds).sum - d - 2 ^ ds.length * J ≤ 0)] + linarith + +theorem movingCompensationTargets_balance (J gap r : ℝ) (hr : r ≠ 0) (ds : List ℝ) : + r * (J + (movingCompensationTargets J ds).sum - gap / r) = + r * (J + (movingCompensationTargets J ds).sum) - gap := by + field_simp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..a1e409b3e240c376fd7f4a1d50377e108c6afa9a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompensationWeight.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleCoordinates +import OAI.NumberTheory.Ostmann.Arithmetic.MovingScalarWindows +import OAI.NumberTheory.Ostmann.Arithmetic.InternalPatternWeight + +namespace OAI + +/-! # The exact compensation factors in the original history weight + +Every sampled prime occurs once in the factor `u` at the node where it is +sampled. Its subsequent appearances in descendants do not add factors of `u`. +-/ + +namespace Ostmann +open scoped Classical BigOperators + +def movingSampleProduct {A : Type*} (value : A → ℕ) : + {n : ℕ} → MovingSampleSlots A n → ℕ + | _, .leaf => 1 + | n + 1, .node u l r => + MovingSlotReversal.naturalProduct value (flattenMovingSlots n (movingCompensationSlots n u)) * + movingSampleProduct value l * movingSampleProduct value r + +theorem movingCompensationProduct_indexed {A : Type*} (value : A → ℕ) (n : ℕ) + (a : TreeLeafTuple (Fin 4 → A) n) : + MovingSlotReversal.naturalProduct value (flattenMovingSlots n (movingCompensationSlots n a)) = + ∏ t : TreeLeafIndex n, ∏ j : Fin 4, value (treeLeafTupleEquiv (Fin 4 → A) n a t j) := by + induction n with + | zero => + simp only [flattenMovingSlots, movingCompensationSlots, MovingSlotReversal.naturalProduct, + List.map_ofFn, List.prod_ofFn] + change (∏ j : Fin 4, value (a j)) = ∏ _t : Unit, ∏ j : Fin 4, value (a j) + simp only [Fintype.prod_unique] + | succ n ih => + simp only [movingCompensationSlots, flattenMovingSlots, movingNaturalProduct_append, ih] + change _ = ∏ t : TreeLeafIndex n ⊕ TreeLeafIndex n, + ∏ j : Fin 4, value (treeLeafTupleEquiv (Fin 4 → A) (n + 1) a t j) + rw [Fintype.prod_sum_type] + rfl + +theorem movingSampleProduct_coordinates {A : Type*} (value : A → ℕ) {n : ℕ} + (a : MovingSampleSlots A n) : + movingSampleProduct value a = + ∏ i : MovingSampleIndex n, value (movingSampleCoordinates A n a i) := by + induction a with + | leaf => rfl + | @node n u l r hl hr => + change _ = ∏ i : (TreeLeafIndex n × Fin 4) ⊕ (Bool × MovingSampleIndex n), _ + rw [Fintype.prod_sum_type, Fintype.prod_prod_type, Fintype.prod_prod_type, Fintype.prod_bool] + rw [movingSampleProduct, movingCompensationProduct_indexed, hl, hr] + simp only [movingSampleCoordinates, Equiv.coe_fn_mk] + ring + +noncomputable def movingCompensationExtra {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ + | _, .leaf _ _, _, _, _ => 1 + | _, .node _ _ _ u _ _, _, _, _ => MovingSlotReversal.naturalProduct value u + +/-- Factor all the actual `u` multipliers out of the scalar history +coefficient. Leaf weights and right-branch conjugations are retained. -/ +theorem movingDataWeight_compensations {σ : Type*} (value : σ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (a : MovingSampleSlots σ n) : + movingDataWeight F (movingCompensationExtra value) (buildMovingSlotData n t small bulk a) = + (movingSampleProduct value a : ℂ) * + movingDataWeight F (fun _ _ _ _ => 1) (buildMovingSlotData n t small bulk a) := by + induction a with + | leaf => simp only [buildMovingSlotData, movingDataWeight, movingSampleProduct, Nat.cast_one, one_mul] + | @node n u l r hl hr => + simp only [buildMovingSlotData, movingDataWeight, movingCompensationExtra, + hl, hr, movingSampleProduct, Nat.cast_mul, Complex.ofReal_natCast, + Complex.ofReal_one, one_mul, star_mul, star_natCast] + ring + +/-- Prior times compensation is precisely the dependent pattern weight +used in the internal-line comparison, before any coincidences are collapsed. -/ +theorem movingSamples_compensated_prior {A : Type*} (μ : ℕ → A → ℝ) + (value : A → ℕ) {n : ℕ} (a : MovingSampleSlots A n) : + (movingSampleProduct value a : ℝ) * movingSamplesPrior μ a = + ∏ i : MovingSampleIndex n, + (value (movingSampleCoordinates A n a i) : ℝ) * + μ (movingSampleTier i) (movingSampleCoordinates A n a i) := by + rw [movingSampleProduct_coordinates, movingSamplesPrior_coordinates, + Nat.cast_prod, Finset.prod_mul_distrib] + +theorem movingSamples_compensated_pattern {A C : Type*} (μ : ℕ → A → ℝ) + (value : A → ℕ) (n : ℕ) (pattern : MovingSampleIndex n → C) (x : C → A) : + let a := (movingSampleCoordinates A n).symm (x ∘ pattern) + (movingSampleProduct value a : ℝ) * movingSamplesPrior μ a = + internalPatternWeight pattern (fun i => μ (movingSampleTier i)) value x := by + dsimp only + rw [movingSamples_compensated_prior, Equiv.apply_symm_apply] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompleteCells.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompleteCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..295b85277f55bc2df93cef330e00c6cb99d69ea4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompleteCells.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWindowedSpectators +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticPrimeComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRootBudget + +namespace OAI + +/-! # Full moving coefficients on the common arithmetic and window cells -/ + +namespace Ostmann +open scoped BigOperators Classical +open MeasureTheory + +noncomputable def movingCompleteRootCuts {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR : ℕ) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) (X lo hi : ℝ) : Finset ℝ := + movingPrimeRootCuts value hvalue childBound pivotBound T hf XR F ∪ + movingWindowRootCuts value T Polynomial.X (Polynomial.C XR) X lo hi + +theorem movingCompleteRootCuts_card {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR : ℕ) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) (X lo hi : ℝ) : + (movingCompleteRootCuts value hvalue childBound pivotBound T hf XR F X lo hi).card ≤ + (2 ^ n - 1) * (3 * (7 * 2 ^ n)) + (∑ i, (F i).polynomial.derivative.natDegree) + 4 * 2 ^ n := by + apply (Finset.card_union_le _ _).trans + have hA := movingPrimeRootCuts_card value hvalue childBound pivotBound T hf XR F + have hB := movingTopRootCuts_card value hvalue childBound pivotBound T hf XR + have hW := movingWindowRootCuts_card value T Polynomial.X (Polynomial.C XR) X lo hi + (by simp) (by simp) + omega + +/-- The only variable coefficient left after the full smooth factorization +is now a bounded, explicitly derived cell multiplier. -/ +theorem PublishedProgressionInput.moving_windowed_prime_comparison + (P : PublishedProgressionInput) {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (B : I → ℝ) (hB : ∀ i ∈ S, 0 ≤ B i) (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M Q : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hQ : 2 ≤ Q) (hq : 1 ≤ M) (hqQ : M ≤ Q) (ha : a.Coprime M) + (u v : ℝ) (hu : 1 ≤ u) (huv : u ≤ v) (hshort : v ≤ u + 1) + {k : ℕ} (W : Fin k → ClippedPolynomialFactor) : + let roots := movingCompleteRootCuts value hvalue childBound pivotBound T hf XR W X lo hi + let C := ‖movingDataWeight F E T‖ * ∏ i ∈ S, B i ^ (2 ^ n) + ∃ (s : ℕ → ℝ) (N : ℕ) (d : ℕ → ℂ), + Monotone s ∧ s 0 = u ∧ s N = v ∧ N ≤ roots.card + 1 ∧ (∀ j, ‖d j‖ ≤ C) ∧ + ‖complexPrimeInterval M a u v (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + movingWindowedSpectatorWeight q value F E X lo hi g D S T ⌊Real.exp y⌋₊ XR) * + smoothPolynomialWeight W (Real.exp y)) - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + d j * smoothPolynomialWeight W (Real.exp y) * (selectedPrimeLogDensity P Q M a y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, + (‖d j‖ * smoothPolynomialBudget W * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ)))) + + 2 * C * smoothPolynomialBudget W * Real.exp (-(s j))) := by + let roots := movingCompleteRootCuts value hvalue childBound pivotBound T hf XR W X lo hi + have hrootA : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ roots := by + intro x hx + exact Finset.mem_union_left _ (Finset.mem_union_left _ hx) + have hrootW : movingWindowRootCuts value T Polynomial.X (Polynomial.C XR) X lo hi ⊆ roots := + Finset.subset_union_right + have hroots : ∀ i r, r ∈ (W i).polynomial.derivative.roots → r ∈ roots := by + intro i r hr + exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_biUnion.mpr + ⟨i, Finset.mem_univ _, Multiset.mem_toFinset.mpr hr⟩)) + have hC : 0 ≤ ‖movingDataWeight F E T‖ * ∏ i ∈ S, B i ^ (2 ^ n) := by + apply mul_nonneg (norm_nonneg _) + apply Finset.prod_nonneg + intro i hi + exact pow_nonneg (hB i hi) _ + exact P.moving_supported_prime_comparison value hvalue childBound pivotBound T hf XR a M Q + hM hQ hq hqQ ha u v hu huv hshort W roots hrootA hroots + (fun XL => movingWindowedSpectatorWeight q value F E X lo hi g D S T XL XR) _ hC + (fun XL _ => movingWindowedSpectatorWeight_norm q value F E X lo hi g D S B hB hg T XL XR) + (fun XL YL hX hY hres hcode => movingWindowedSpectatorWeight_cells q value hvalue F E X lo hi + g D S T hf XR M XL YL hMq roots hrootW + (hX.integral value hvalue childBound pivotBound T XL XR) + (hY.integral value hvalue childBound pivotBound T YL XR) hres hcode) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompleteIntegerCells.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompleteIntegerCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4cb15451c80523089126e3adf30ac5c53ab2106 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCompleteIntegerCells.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompleteCells +import OAI.NumberTheory.Ostmann.Arithmetic.MovingIntegerCells + +namespace OAI + +/-! # The full moving coefficient under the external integer law -/ + +namespace Ostmann +open scoped BigOperators Classical +open MeasureTheory + +theorem moving_windowed_integer_comparison {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (B : I → ℝ) (hB : ∀ i ∈ S, 0 ≤ B i) (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hM0 : 0 < M) (u v G : ℝ) (huv : u ≤ v) + {k : ℕ} (W : Fin k → ClippedPolynomialFactor) : + let roots := movingCompleteRootCuts value hvalue childBound pivotBound T hf XR W X lo hi + let C := ‖movingDataWeight F E T‖ * ∏ i ∈ S, B i ^ (2 ^ n) + ∃ (s : ℕ → ℝ) (N : ℕ) (d : ℕ → ℂ), + Monotone s ∧ s 0 = u ∧ s N = v ∧ N ≤ roots.card + 1 ∧ (∀ j, ‖d j‖ ≤ C) ∧ + ‖complexIntegerInterval M a u v G (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + movingWindowedSpectatorWeight q value F E X lo hi g D S T ⌊Real.exp y⌋₊ XR) * + smoothPolynomialWeight W (Real.exp y)) - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + d j * smoothPolynomialWeight W (Real.exp y) * (integerLogDensity M G y : ℂ)‖ ≤ + 4 * ((roots.card + 1 : ℕ) : ℝ) * C * smoothPolynomialBudget W * Real.exp (-G) := by + let roots := movingCompleteRootCuts value hvalue childBound pivotBound T hf XR W X lo hi + have hrootA : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ roots := by + intro x hx + exact Finset.mem_union_left _ (Finset.mem_union_left _ hx) + have hrootW : movingWindowRootCuts value T Polynomial.X (Polynomial.C XR) X lo hi ⊆ roots := + Finset.subset_union_right + have hroots : ∀ i r, r ∈ (W i).polynomial.derivative.roots → r ∈ roots := by + intro i r hr + exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_biUnion.mpr + ⟨i, Finset.mem_univ _, Multiset.mem_toFinset.mpr hr⟩)) + have hC : 0 ≤ ‖movingDataWeight F E T‖ * ∏ i ∈ S, B i ^ (2 ^ n) := by + apply mul_nonneg (norm_nonneg _) + apply Finset.prod_nonneg + intro i hi + exact pow_nonneg (hB i hi) _ + exact moving_supported_integer_comparison value hvalue childBound pivotBound T hf XR a M + hM hM0 u v G huv W roots hrootA hroots + (fun XL => movingWindowedSpectatorWeight q value F E X lo hi g D S T XL XR) _ hC + (fun XL _ => movingWindowedSpectatorWeight_norm q value F E X lo hi g D S B hB hg T XL XR) + (fun XL YL hX hY hres hcode => movingWindowedSpectatorWeight_cells q value hvalue F E X lo hi + g D S T hf XR M XL YL hMq roots hrootW + (hX.integral value hvalue childBound pivotBound T XL XR) + (hY.integral value hvalue childBound pivotBound T YL XR) hres hcode) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingConstructedLiveProductStep.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingConstructedLiveProductStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fa4ef32b70cf420a1e4091b3feb39fd0e2fd849 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingConstructedLiveProductStep.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDerivedLiveProductStep +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationFrequency +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeNext +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRecursiveTemplateCaps +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalLeafMultiplier + +namespace OAI + +/-! # The actual product and integer-frequency constructions give the transfer step -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- The cap, monotonicity and frequency-scale hypotheses are discharged by +one and the same terminal product and compensation-cell construction. -/ +theorem movingTemplatePrimeAmplitude_step_constructed_live {σ J : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : J → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (hF : ∀ {n} (T : MovingSlotData σ n), F T 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset J) + (ψ : SchwartzMap ℝ ℂ) (X lo hi W : ℝ) (hX : 0 < X) + (hwindow : X * hi ≤ Real.exp W) + (φ : ℝ → ℝ) (G c : ℕ → ℝ) (hout : ∀ t, 1 ≤ |t| → φ t = 0) + (hμlower : ∀ j x, μ j x ≠ 0 → Real.exp (c j - 1) ≤ (value x : ℝ)) + (n r m : ℕ) (Y reserveMass : ℝ) (hm : 64 ≤ reserveMass) (hY : Y ≤ W) + (hVeq : V = movingProductNaturalCutoff (movingCellPivotExponent G c) W Y reserveMass) + (hbudget : ∀ j, 2 * movingCellPivotExponent G c j ≤ + movingProductExponent (movingCellPivotExponent G c) W j) + (hpositive : 0 ≤ movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hHeq : H = ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊) + (hIlower : ∀ p ∈ I, Real.exp (G (n + 1) - 1) ≤ (p : ℝ)) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ), + (∏ i, ν i (y i)) ≠ 0 → ∀ ℓ, ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) + (hvg : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (hφsupport : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable‖ := by + have hV : Monotone V := by + rw [hVeq] + exact movingProductNaturalCutoff_monotone (movingCellPivotExponent G c) W Y reserveMass hbudget + have hcap : ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊ ≤ H := by rw [hHeq] + have hscale (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (p : ℕ) (hp : p ∈ I) : 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i)) := by + rw [hVeq, hHeq] + exact movingProductNaturalCutoff_compensation_scale value μ G c hμlower W Y reserveMass + hm hY hbudget n hpositive u hu p (hIlower p hp) + exact movingTemplatePrimeAmplitude_step_of_live_cells value hvalue outside μ childBound pivotBound V hV + q F hF g Dq S ψ X lo hi W hX hwindow φ G c hout hμlower n r m Pg I hPg hPI hI hφ + hpos hμ hμmass ν sets hsets hcard ggiant favorable hgiant H hcap hIlower hscale + hlarge hvg hφsupport hchild hgap hcomp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingConstructedProductStep.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingConstructedProductStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..4aeae58ea3f4884c9018f5a5890fcdf07d9cb137 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingConstructedProductStep.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDerivedProductStep +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationFrequency +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeNext +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRecursiveTemplateCaps +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalLeafMultiplier + +namespace OAI + +/-! # The actual product and integer-frequency constructions give the transfer step -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- The cap, monotonicity and frequency-scale hypotheses are discharged by +one and the same terminal product and compensation-cell construction. -/ +theorem movingTemplatePrimeAmplitude_step_constructed {σ J : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : J → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (hF : ∀ {n} (T : MovingSlotData σ n), F T 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset J) + (ψ : SchwartzMap ℝ ℂ) (X lo hi W : ℝ) (hX : 0 < X) + (hwindow : X * hi ≤ Real.exp W) + (φ : ℝ → ℝ) (G c : ℕ → ℝ) (hout : ∀ t, 1 ≤ |t| → φ t = 0) + (hμlower : ∀ j x, μ j x ≠ 0 → Real.exp (c j - 1) ≤ (value x : ℝ)) + (n r m : ℕ) (Y reserveMass : ℝ) (hm : 64 ≤ reserveMass) (hY : Y ≤ W) + (hVeq : V = movingProductNaturalCutoff (movingCellPivotExponent G c) W Y reserveMass) + (hbudget : ∀ j, 2 * movingCellPivotExponent G c j ≤ + movingProductExponent (movingCellPivotExponent G c) W j) + (hpositive : 0 ≤ movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hHeq : H = ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊) + (hIlower : ∀ p ∈ I, Real.exp (G (n + 1) - 1) ≤ (p : ℝ)) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ) ℓ, + ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) + (hvg : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (hφsupport : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable‖ := by + have hV : Monotone V := by + rw [hVeq] + exact movingProductNaturalCutoff_monotone (movingCellPivotExponent G c) W Y reserveMass hbudget + have hcap : ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊ ≤ H := by rw [hHeq] + have hscale (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (p : ℕ) (hp : p ∈ I) : 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i)) := by + rw [hVeq, hHeq] + exact movingProductNaturalCutoff_compensation_scale value μ G c hμlower W Y reserveMass + hm hY hbudget n hpositive u hu p (hIlower p hp) + exact movingTemplatePrimeAmplitude_step_of_cells value hvalue outside μ childBound pivotBound V hV + q F hF g Dq S ψ X lo hi W hX hwindow φ G c hout hμlower n r m Pg I hPg hPI hI hφ + hpos hμ hμmass ν sets hsets hcard ggiant favorable hgiant H hcap hIlower hscale + hlarge hvg hφsupport hchild hgap hcomp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCoprimeDescent.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCoprimeDescent.lean new file mode 100644 index 0000000000000000000000000000000000000000..343e5a16340dada1c60fe5c5fb012cdc22558670 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCoprimeDescent.lean @@ -0,0 +1,118 @@ +import Mathlib.Data.Nat.GCD.BigOperators +import Mathlib.Data.Nat.Squarefree +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotSystem +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticSupport + +namespace OAI + +/-! # Coprimality inherited by an actual moving reversal + +These are the support reductions in Section 8.1: the numerator is a unit at +all old slots, so an integral reconstructed pivot and its compensation are +already coprime to every inherited slot. Only their mutual coprimality and +the outside-prime tests remain. +-/ + +namespace Ostmann + +/-- The compensation product and reconstructed giant inherit every old +coprimality test directly from the integer relation. -/ +theorem moving_pivot_inherited_coprime (L R u p : ℕ) (s v w : ℤ) + (hLR : L.Coprime R) (hv : IsCoprime v (L : ℤ)) (hw : IsCoprime w (R : ℤ)) + (hrel : v * R - w * L = s * ((u * p : ℕ) : ℤ)) : + u.Coprime (L * R) ∧ p.Coprime (L * R) := by + have hr : v * (R : ℤ) - w * L = s * (u : ℤ) * p := by + simpa only [Nat.cast_mul, mul_assoc] using hrel + have h := reversal_inherited_coprime v w L R s u p hLR.isCoprime hv hw hr + constructor + · exact Nat.isCoprime_iff_coprime.mp (by simpa only [Nat.cast_mul] using h.2) + · exact Nat.isCoprime_iff_coprime.mp (by simpa only [Nat.cast_mul] using h.1) + +private theorem pairwise_append_of_products (A B : List ℕ) + (hA : A.Pairwise Nat.Coprime) (hB : B.Pairwise Nat.Coprime) + (hAB : A.prod.Coprime B.prod) : (A ++ B).Pairwise Nat.Coprime := by + apply List.pairwise_append.mpr + refine ⟨hA, hB, ?_⟩ + intro a ha b hb + exact (Nat.coprime_list_prod_left_iff.mp + (Nat.coprime_list_prod_right_iff.mp hAB b hb) a ha) + +private theorem coprime_products_of_pairwise_append (A B : List ℕ) + (h : (A ++ B).Pairwise Nat.Coprime) : A.prod.Coprime B.prod := by + have hc := (List.pairwise_append.mp h).2.2 + apply Nat.coprime_list_prod_left_iff.mpr + intro a ha + apply Nat.coprime_list_prod_right_iff.mpr + intro b hb + exact hc a ha b hb + +/-- The two actual child lists have precisely one new coprimality condition: +the inserted giant must be coprime to its own compensation list. All inherited +cross-list conditions follow from the numerator equation. -/ +theorem moving_children_pairwise_iff (L R U : List ℕ) (p : ℕ) (s v w : ℤ) + (hold : (L ++ R).Pairwise Nat.Coprime) + (hv : IsCoprime v (L.prod : ℤ)) (hw : IsCoprime w (R.prod : ℤ)) + (hrel : v * R.prod - w * L.prod = s * ((U.prod * p : ℕ) : ℤ)) : + ((p :: (U ++ L)).Pairwise Nat.Coprime ∧ (p :: (U ++ R)).Pairwise Nat.Coprime) ↔ + U.Pairwise Nat.Coprime ∧ p.Coprime U.prod := by + constructor + · rintro ⟨hleft, _⟩ + obtain ⟨hpu, hUL⟩ := List.pairwise_cons.mp hleft + refine ⟨(List.pairwise_append.mp hUL).1, Nat.coprime_list_prod_right_iff.mpr ?_⟩ + intro b hb + exact hpu b (List.mem_append_left _ hb) + · rintro ⟨hU, hpU⟩ + have hLR := coprime_products_of_pairwise_append L R hold + obtain ⟨hu, hp⟩ := moving_pivot_inherited_coprime L.prod R.prod U.prod p s v w hLR hv hw hrel + obtain ⟨hL, hR, _⟩ := List.pairwise_append.mp hold + have child (A : List ℕ) (hA : A.Pairwise Nat.Coprime) + (huA : U.prod.Coprime A.prod) (hpA : p.Coprime A.prod) : + (p :: (U ++ A)).Pairwise Nat.Coprime := by + apply List.pairwise_cons.mpr + refine ⟨?_, pairwise_append_of_products U A hU hA huA⟩ + intro b hb + rcases List.mem_append.mp hb with hb | hb + · exact Nat.coprime_list_prod_right_iff.mp hpU b hb + · exact Nat.coprime_list_prod_right_iff.mp hpA b hb + exact ⟨child L hL (Nat.coprime_mul_iff_right.mp hu).1 (Nat.coprime_mul_iff_right.mp hp).1, + child R hR (Nat.coprime_mul_iff_right.mp hu).2 (Nat.coprime_mul_iff_right.mp hp).2⟩ + +private theorem compensation_product_squarefree (U : List ℕ) + (hprime : ∀ b ∈ U, b.Prime) (hpair : U.Pairwise Nat.Coprime) : Squarefree U.prod := by + induction U with + | nil => simp + | cons b U ih => + obtain ⟨hbU, hU⟩ := List.pairwise_cons.mp hpair + have hcop : b.Coprime U.prod := Nat.coprime_list_prod_right_iff.mpr hbU + rw [List.prod_cons, Nat.squarefree_mul hcop] + exact ⟨(hprime b (by simp)).squarefree, + ih (fun c hc => hprime c (List.mem_cons_of_mem _ hc)) hU⟩ + +/-- The own-compensation unit test is exactly the nonvanishing numerator +condition modulo the square of each distinct sampled compensation prime. -/ +theorem moving_compensation_square_tests (U : List ℕ) (p : ℕ) (s : ℤ) + (hprime : ∀ b ∈ U, b.Prime) (hpair : U.Pairwise Nat.Coprime) + (hs : ∀ b ∈ U, ¬ b ∣ s.natAbs) : + p.Coprime U.prod ↔ ∀ b ∈ U, ¬ (b : ℤ) ^ 2 ∣ s * ((U.prod * p : ℕ) : ℤ) := by + have hsf := compensation_product_squarefree U hprime hpair + have heq (b : ℕ) (hb : b ∈ U) : + (¬ (b : ℤ) ^ 2 ∣ s * ((U.prod * p : ℕ) : ℤ)) ↔ ¬ b ∣ p := by + have hd : ((b : ℤ) ^ 2 ∣ s * ((U.prod * p : ℕ) : ℤ)) ↔ + b ^ 2 ∣ s.natAbs * U.prod * p := by + rw [← Nat.cast_pow, Int.natCast_dvd] + simp only [Int.natAbs_mul, Int.natAbs_natCast, mul_assoc] + rw [hd] + apply reversal_square_test b s.natAbs U.prod p (hprime b hb) (hs b hb) + (List.dvd_prod hb) + have h := Nat.squarefree_iff_prime_squarefree.mp hsf b (hprime b hb) + simpa only [pow_two] using h + rw [Nat.coprime_list_prod_right_iff] + constructor + · intro h b hb + exact (heq b hb).mpr ((hprime b hb).coprime_iff_not_dvd.mp (h b hb).symm) + · intro h b hb + exact ((hprime b hb).coprime_iff_not_dvd.mpr ((heq b hb).mp (h b hb))).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCoprimePeriods.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCoprimePeriods.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5c2c363fcbbb2be62b833fa76c07649da08d9c4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCoprimePeriods.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDenominators + +namespace OAI + +/-! # Coprimality of the actual arithmetic and spectator periods -/ + +namespace Ostmann +open scoped Classical + +private theorem aux_parts {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (s : ℤ) (CL CR U : List σ) (left right : MovingSlotData σ n) (p : ℕ) + (h : p.Coprime (movingAuxiliaryUnitPeriod value outside + (.node s CL CR U left right)).natAbs) : + p.Coprime (s.natAbs * MovingSlotReversal.naturalProduct value U) ∧ + p.Coprime (movingAuxiliaryUnitPeriod value outside left).natAbs ∧ + p.Coprime (movingAuxiliaryUnitPeriod value outside right).natAbs := by + simp only [movingAuxiliaryUnitPeriod, Int.natAbs_mul, Int.natAbs_natCast, + Nat.coprime_mul_iff_right] at h + exact ⟨h.1.1.2.1.mul_right h.1.1.2.2, h.1.2, h.2⟩ + +theorem MovingSlotData.formulaNodes_period_coprime {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (p : ℕ) (hfreq : T.Frequencies (fun s => p.Coprime s.natAbs)) + (haux : p.Coprime (movingAuxiliaryUnitPeriod value outside T).natAbs) + (L R : HistoryFormula Bool) + (hL : p.Coprime L.cleared.denominator.natAbs) + (hR : p.Coprime R.cleared.denominator.natAbs) : + p.Coprime (movingArithmeticPeriod (T.formulaNodes value hvalue childBound pivotBound hf L R)) := by + induction T generalizing L R with + | leaf => simp [formulaNodes, movingArithmeticPeriod] + | @node n s CL CR U left right ihL ihR => + let step := MovingSlotData.step s CL CR U left right false + let hu := MovingSlotReversal.naturalProduct_ne_zero value hvalue U + let G := step.giantFormula value hf.1 hu L R + obtain ⟨hcomp, hauxL, hauxR⟩ := aux_parts value outside s CL CR U left right p haux + have hG : p.Coprime G.cleared.denominator.natAbs := by + rw [step.giantFormula_denominator value hf.1 hu L R] + simpa only [Int.natAbs_mul, Int.natAbs_natCast, step, MovingSlotData.step] using (hcomp.mul_right hL).mul_right hR + have hl := ihL hf.2.1 hfreq.2.1 hauxL G L hG hL + have hr := ihR hf.2.2 hfreq.2.2 hauxR G R hG hR + have hhead : p.Coprime + ({ guard := (movingNodeGuard (MovingSlotReversal.naturalProduct value step.leftSlots) + (MovingSlotReversal.naturalProduct value step.rightSlots) + step.rootFrequency step.leftFrequency step.rightFrequency hf.1 + (childBound (n + 1)) (pivotBound (n + 1)) L R), + newGiant := G } : MovingFormulaNode).residuePeriod := by + rw [movingNode_residuePeriod step value hf.1 hu] + exact ((((hfreq.1.pow_right 3).mul_right hfreq.2.2.root).mul_right + (Nat.coprime_mul_iff_right.mp hcomp).2).mul_right (hL.pow_right 2)).mul_right (hR.pow_right 3) + simpa only [MovingSlotData.formulaNodes, movingArithmeticPeriod, List.map_cons, + List.map_append, List.prod_cons, List.prod_append, G, step, MovingSlotData.step] using hhead.mul_right (hl.mul_right hr) + +theorem movingTopPeriod_coprime_of_auxiliary {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (p : ℕ) (hfreq : T.Frequencies (fun s => p.Coprime s.natAbs)) + (haux : p.Coprime (movingAuxiliaryUnitPeriod value outside T).natAbs) : + p.Coprime (movingTopPeriod value hvalue childBound pivotBound T hf) := by + exact T.formulaNodes_period_coprime value hvalue outside childBound pivotBound hf p hfreq haux + (.prime false) (.prime true) (by simp [HistoryFormula.cleared, ClearedHistoryValue.ofVariable]) + (by simp [HistoryFormula.cleared, ClearedHistoryValue.ofVariable]) + +theorem movingSpectatorDenominator_dvd_auxiliary {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) : + movingSpectatorDenominator value T ∣ movingAuxiliaryUnitPeriod value outside T := by + induction T with + | leaf => exact one_dvd _ + | node s CL CR U left right ihL ihR => + change s * (MovingSlotReversal.naturalProduct value U : ℤ) * _ * _ ∣ _ + have h := mul_dvd_mul (mul_dvd_mul (dvd_refl + (s * (MovingSlotReversal.naturalProduct value U : ℤ))) ihL) ihR + exact h.trans ⟨(MovingSlotData.node s CL CR U left right).frequencyProduct * outside.prod, by + dsimp only [movingAuxiliaryUnitPeriod] + ring⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCutoffPolynomials.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCutoffPolynomials.lean new file mode 100644 index 0000000000000000000000000000000000000000..904cdfb89db67654b6dab92ad09e6c403afd45fc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCutoffPolynomials.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.Ostmann.Characters.LogCutoffPolynomial +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantArchimedean + +namespace OAI + +/-! # All actual logarithmic node cutoffs as polynomial factors -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def MovingSlotData.nodeCutoffPolynomials {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → Polynomial ℝ → Polynomial ℝ → List (ℕ × Polynomial ℝ) + | _, .leaf _ _, _, _ => [] + | n + 1, .node s CL CR u left right, L, R => + let P := (MovingSlotData.step s CL CR u left right false).pivotPolynomial value L R + (n + 1, P) :: (left.nodeCutoffPolynomials value P L ++ right.nodeCutoffPolynomials value P R) + +noncomputable def movingRealNodeCutoff {σ : Type*} (value : σ → ℕ) (φ : ℝ → ℝ) (G : ℕ → ℝ) : + {n : ℕ} → MovingSlotData σ n → ℝ → ℝ → ℂ + | _, .leaf _ _, _, _ => 1 + | n + 1, .node s CL CR u left right, L, R => + let p := (MovingSlotData.step s CL CR u left right false).realPivot value L R + (positiveLogCutoff φ (G (n + 1)) p : ℂ) * + movingRealNodeCutoff value φ G left p L * movingRealNodeCutoff value φ G right p R + +theorem MovingSlotData.nodeCutoffPolynomials_length {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) : + (T.nodeCutoffPolynomials value L R).length = 2 ^ n - 1 := by + induction T generalizing L R with + | leaf => rfl + | @node n s CL CR u left right ihL ihR => + simp only [nodeCutoffPolynomials, List.length_cons, List.length_append, ihL, ihR, pow_succ] + have := Nat.one_le_two_pow (n := n) + omega + +theorem MovingSlotData.nodeCutoffPolynomials_degree {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (d : ℕ) + (hL : L.natDegree ≤ d) (hR : R.natDegree ≤ d) : + ∀ f ∈ T.nodeCutoffPolynomials value L R, f.2.natDegree ≤ d := by + induction T generalizing L R with + | leaf => simp [nodeCutoffPolynomials] + | node s CL CR u left right ihL ihR => + have hp := (MovingSlotData.step s CL CR u left right false).pivotPolynomial_degree value L R d hL hR + intro f hf + rcases List.mem_cons.mp hf with h | h + · subst f; exact hp + · exact (List.mem_append.mp h).elim (ihL _ _ hp hL f) (ihR _ _ hp hR f) + +theorem MovingSlotData.nodeCutoffPolynomials_value {σ : Type*} (value : σ → ℕ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (z : ℝ) : + ((T.nodeCutoffPolynomials value L R).map + (fun f => (positiveLogCutoff φ (G f.1) (f.2.eval z) : ℂ))).prod = + movingRealNodeCutoff value φ G T (L.eval z) (R.eval z) := by + induction T generalizing L R with + | leaf => rfl + | node s CL CR u left right ihL ihR => + simp only [nodeCutoffPolynomials, List.map_cons, List.map_append, List.prod_cons, + List.prod_append, ihL, ihR, MovingSlotReversal.pivotPolynomial_eval, movingRealNodeCutoff] + ring + +noncomputable def movingNodeCutoffFactors {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (φ : ℝ → ℝ) + (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) : + Fin (T.nodeCutoffPolynomials value L R).length → ClippedPolynomialFactor := fun i => + let f := (T.nodeCutoffPolynomials value L R)[i] + logCutoffPolynomialFactor f.2 φ (G f.1) B D hB hD hφ hlip + +theorem movingNodeCutoffFactors_value {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (φ : ℝ → ℝ) + (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (z : ℝ) : + smoothPolynomialWeight (movingNodeCutoffFactors value T L R φ G B D hB hD hφ hlip) z = + movingRealNodeCutoff value φ G T (L.eval z) (R.eval z) := by + unfold smoothPolynomialWeight + simp only [movingNodeCutoffFactors, logCutoffPolynomialFactor_value _ _ _ _ _ _ _ hφ hlip hout] + rw [← T.nodeCutoffPolynomials_value value φ G L R z] + exact (Fin.prod_ofFn _).symm.trans (congrArg List.prod + (List.ofFn_getElem_eq_map (T.nodeCutoffPolynomials value L R) + (fun f => (positiveLogCutoff φ (G f.1) (f.2.eval z) : ℂ)))) + +theorem movingNodeCutoffFactors_budget {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (φ : ℝ → ℝ) + (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) : + smoothPolynomialBudget (movingNodeCutoffFactors value T L R φ G B D hB hD hφ hlip) = + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1) := by + unfold smoothPolynomialBudget + simp only [movingNodeCutoffFactors, logCutoffPolynomialFactor_budget, Finset.prod_const, + Finset.card_univ, Fintype.card_fin, T.nodeCutoffPolynomials_length] + +/-- With either top giant fixed, all node cutoff polynomials are affine. +Thus their derivatives have no roots and need no additional partition cuts. -/ +theorem movingNodeCutoffFactors_no_derivative_roots {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) + (hL : L.natDegree ≤ 1) (hR : R.natDegree ≤ 1) (φ : ℝ → ℝ) + (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (i : Fin (T.nodeCutoffPolynomials value L R).length) : + ((movingNodeCutoffFactors value T L R φ G B D hB hD hφ hlip i).polynomial.derivative).roots = 0 := by + have hp := T.nodeCutoffPolynomials_degree value L R 1 hL hR _ (List.getElem_mem i.isLt) + change (T.nodeCutoffPolynomials value L R)[i].2.natDegree ≤ 1 at hp + have hd := Polynomial.natDegree_derivative_le (T.nodeCutoffPolynomials value L R)[i].2 + have hc := Polynomial.card_roots' ((T.nodeCutoffPolynomials value L R)[i].2.derivative) + apply Multiset.card_eq_zero.mp + change ((T.nodeCutoffPolynomials value L R)[i].2.derivative).roots.card = 0 + omega + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCutoffReserve.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCutoffReserve.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c7784366b1139f90bf06e43d89be7780518b4f2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingCutoffReserve.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyBudget + +namespace OAI + +/-! # The actual Section 7 gaps supply both integer-transfer reserves -/ + +namespace Ostmann + +private theorem moving_sqrt_reserve (m : ℝ) (hm : 64 ≤ m) : Real.sqrt (4 * m) ≤ m / 4 := by + have hm0 : 0 ≤ m := by linarith + have hs := Real.sq_sqrt (show 0 ≤ 4 * m by positivity) + have hp := mul_nonneg hm0 (sub_nonneg.mpr hm) + nlinarith [Real.sqrt_nonneg (4 * m)] + +theorem movingStepGap_succ (BD Bz z m : ℝ) (n : ℕ) : + spectatorStepGap BD Bz z ((2 : ℝ) ^ (n + 1)) m = + 2 * spectatorStepGap BD Bz z ((2 : ℝ) ^ n) m + + (4 / 5 : ℝ) * (2 : ℝ) ^ n * Real.log 2 * m := by + unfold spectatorStepGap + rw [Real.log_pow, Real.log_pow] + push_cast + rw [pow_succ] + ring + +/-- The next pivot gap exceeds the current Fourier exponent by a positive +linear amount, uniformly over all tree levels. -/ +theorem movingCutoff_diagonal_reserve (Bs BD Bz z m : ℝ) + (hBD : Bs + 1 ≤ BD) (hBz : 8 ≤ Bz) + (hz : 1 ≤ z) (hm : 64 ≤ m) (n : ℕ) : + (3 / 20 : ℝ) * (2 : ℝ) ^ n * m ≤ + spectatorStepGap BD Bz z ((2 : ℝ) ^ n) m - movingCutoffExponent Bs BD Bz z m n := by + have hsqrt := moving_sqrt_reserve m hm + have hm0 : 0 ≤ m := by linarith + have hlogz := Real.log_nonneg hz + have hlog2 : (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 ⊢ + linarith + induction n with + | zero => + rw [movingCutoffExponent_zero] + simp only [spectatorStepGap, spectatorBaseGap, pow_zero, one_mul, Real.log_one, + mul_zero, add_zero] + have hb : Bs + 8 * Real.log z + 1 ≤ BD + Bz * Real.log z := by + nlinarith [mul_nonneg (show 0 ≤ Bz - 8 by linarith) hlogz] + nlinarith [mul_le_mul_of_nonneg_right hb hm0] + | succ n ih => + rw [movingStepGap_succ, movingCutoffExponent_succ, pow_succ] + have hr : 0 ≤ (2 : ℝ) ^ n := by positivity + have hsl := mul_le_mul_of_nonneg_left hsqrt hr + have hl := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hlog2 hr) hm0 + nlinarith + +/-- The frequency range at the next level has a square-root reserve after +paying both the previous frequency and the current pivot gap. -/ +theorem movingCutoff_frequency_reserve (Bs BD Bz z m : ℝ) (n : ℕ) : + movingCutoffExponent Bs BD Bz z m (n + 1) - + (movingCutoffExponent Bs BD Bz z m n + + spectatorStepGap BD Bz z ((2 : ℝ) ^ n) m) = + (2 : ℝ) ^ n * Real.sqrt (4 * m) := by + rw [movingCutoffExponent_succ] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDenominators.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDenominators.lean new file mode 100644 index 0000000000000000000000000000000000000000..c21c4232263c22f3007aa917e4447249e3dc582a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDenominators.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTopCells + +namespace OAI + +/-! # The actual cleared denominators in a moving history -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem MovingSlotReversal.giantFormula_denominator {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) (hs : step.rootFrequency ≠ 0) + (hu : MovingSlotReversal.naturalProduct value step.compensationSlots ≠ 0) + (L R : HistoryFormula Bool) : + (step.giantFormula value hs hu L R).cleared.denominator = + step.rootFrequency * (MovingSlotReversal.naturalProduct value step.compensationSlots : ℤ) * + L.cleared.denominator * R.cleared.denominator := by + simp only [giantFormula, HistoryFormula.cleared, ClearedHistoryValue.pivot, + ClearedHistoryValue.prod, ClearedHistoryValue.constant, Fintype.prod_bool, + Bool.false_eq_true, ite_false, ite_true, mul_one] + +theorem movingNodeGuard_denominators (CL CR : ℕ) (s v w : ℤ) (hs : s ≠ 0) + (childBound pivotBound : ℕ) (L R : HistoryFormula Bool) : + (movingNodeGuard CL CR s v w hs childBound pivotBound L R).pivot.cleared.denominator = + s * L.cleared.denominator * R.cleared.denominator ∧ + (movingNodeGuard CL CR s v w hs childBound pivotBound L R).rightProduct.cleared.denominator = + R.cleared.denominator := by + simp [movingNodeGuard, wordTransferGuard, wordTransferStep, movingNodeWord, + HistoryPivotStep.formula, HistoryFormula.bind, HistoryFormula.listProduct, + HistoryFormula.cleared, ClearedHistoryValue.pivot, ClearedHistoryValue.prod, + ClearedHistoryValue.constant] + +/-- The three residue tests cost only powers of the existing ancestor + denominators, one compensation product, and the actual node frequencies. -/ +theorem movingNode_residuePeriod {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) (hs : step.rootFrequency ≠ 0) + (hu : MovingSlotReversal.naturalProduct value step.compensationSlots ≠ 0) + (childBound pivotBound : ℕ) (L R : HistoryFormula Bool) : + ({ guard := movingNodeGuard (MovingSlotReversal.naturalProduct value step.leftSlots) + (MovingSlotReversal.naturalProduct value step.rightSlots) + step.rootFrequency step.leftFrequency step.rightFrequency hs childBound pivotBound L R + newGiant := step.giantFormula value hs hu L R } : MovingFormulaNode).residuePeriod = + step.rootFrequency.natAbs ^ 3 * step.rightFrequency.natAbs * + MovingSlotReversal.naturalProduct value step.compensationSlots * + L.cleared.denominator.natAbs ^ 2 * R.cleared.denominator.natAbs ^ 3 := by + have hg := movingNodeGuard_denominators (MovingSlotReversal.naturalProduct value step.leftSlots) + (MovingSlotReversal.naturalProduct value step.rightSlots) step.rootFrequency + step.leftFrequency step.rightFrequency hs childBound pivotBound L R + simp only [MovingFormulaNode.residuePeriod, MovingFormulaNode.testFormulas, + MovingFormulaNode.testModuli, Fin.prod_univ_succ, Matrix.cons_val_zero, Matrix.cons_val_succ, + Matrix.cons_val_fin_one, Fin.prod_univ_zero, mul_one] + rw [hg.1, hg.2, step.giantFormula_denominator value hs hu L R] + simp only [movingNodeGuard, wordTransferGuard, Int.natAbs_mul, Int.natAbs_natCast] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDerivedLiveProductStep.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDerivedLiveProductStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1ad6a259c9744c008420902d9bf28922ee9dea9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDerivedLiveProductStep.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeLiveStep +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeNext +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRecursiveTemplateCaps +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalLeafMultiplier + +namespace OAI + +/-! # Transfer with the product cap proved from the original terminal window -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- Both the product cap and the next amplitude are derived from the original +coefficient. The remaining hypotheses are the numerical range and separation +conditions of the concrete prime-cell construction. -/ +theorem movingTemplatePrimeAmplitude_step_of_live_cells {σ J : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (q : J → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (hF : ∀ {n} (T : MovingSlotData σ n), F T 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset J) + (ψ : SchwartzMap ℝ ℂ) (X lo hi W : ℝ) (hX : 0 < X) + (hwindow : X * hi ≤ Real.exp W) + (φ : ℝ → ℝ) (G c : ℕ → ℝ) (hout : ∀ t, 1 ≤ |t| → φ t = 0) + (hμlower : ∀ j x, μ j x ≠ 0 → Real.exp (c j - 1) ≤ (value x : ℝ)) + (n r m : ℕ) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hcap : ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊ ≤ H) + (hIlower : ∀ p ∈ I, Real.exp (G (n + 1) - 1) ≤ (p : ℝ)) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p ∈ I, + 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i))) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ), + (∏ i, ν i (y i)) ≠ 0 → ∀ ℓ, ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) + (hvg : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (hφsupport : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable‖ := by + let F₀ := movingOriginalLeaf value q F g Dq S ψ X lo hi + have hzero : ∀ x, F₀ x 0 = 0 := + movingOriginalLeaf_zero value q F hF g Dq S ψ X lo hi + have hH (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (p : ℕ) (hp : p ∈ I) (q' : Pg) (y : MovingRegularSlot n r m → σ) + (s : transferFrequencyRange (V n)) + (hc : movingTemplateCoefficient value outside μ childBound pivotBound V F₀ φ G + n (4 + r) m s.val (movingRestoreSample n r m u y) p q' ≠ 0) : + (q' : ℕ) * (∏ i, value (y i)) ≤ H := + (movingTemplateCoefficient_recursive_cell_cap value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi W hX hwindow φ G c hout hμlower n r m u hu + s.val y p q' (hIlower p hp) hc).trans hcap + exact movingTemplatePrimeAmplitude_step_on_live value hvalue outside μ childBound pivotBound V + hV F₀ hzero φ G n r m Pg I hPg hPI hI hφ hpos hμ hμmass ν sets hsets hcard + ggiant favorable hgiant H hH hscale hlarge hvg hφsupport hchild hgap hcomp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDerivedProductStep.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDerivedProductStep.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fbbafa662b440d56b5ea8e919dedd692e5489a2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDerivedProductStep.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSupportedStep +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeNext +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRecursiveTemplateCaps +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalLeafMultiplier + +namespace OAI + +/-! # Transfer with the product cap proved from the original terminal window -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- Both the product cap and the next amplitude are derived from the original +coefficient. The remaining hypotheses are the numerical range and separation +conditions of the concrete prime-cell construction. -/ +theorem movingTemplatePrimeAmplitude_step_of_cells {σ J : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (q : J → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (hF : ∀ {n} (T : MovingSlotData σ n), F T 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset J) + (ψ : SchwartzMap ℝ ℂ) (X lo hi W : ℝ) (hX : 0 < X) + (hwindow : X * hi ≤ Real.exp W) + (φ : ℝ → ℝ) (G c : ℕ → ℝ) (hout : ∀ t, 1 ≤ |t| → φ t = 0) + (hμlower : ∀ j x, μ j x ≠ 0 → Real.exp (c j - 1) ≤ (value x : ℝ)) + (n r m : ℕ) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : Pg ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : Pg, ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hcap : ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊ ≤ H) + (hIlower : ∀ p ∈ I, Real.exp (G (n + 1) - 1) ≤ (p : ℝ)) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p ∈ I, + 2 * V n * H ≤ V (n + 1) * (p * ∏ i, value (u i))) + (hlarge : ∀ (q : Pg) (y : MovingRegularSlot n r m → σ) ℓ, + ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) + (hvg : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (hφsupport : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable‖ := by + let F₀ := movingOriginalLeaf value q F g Dq S ψ X lo hi + have hzero : ∀ x, F₀ x 0 = 0 := + movingOriginalLeaf_zero value q F hF g Dq S ψ X lo hi + have hH (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (p : ℕ) (hp : p ∈ I) (q' : Pg) (y : MovingRegularSlot n r m → σ) + (s : transferFrequencyRange (V n)) + (hc : movingTemplateCoefficient value outside μ childBound pivotBound V F₀ φ G + n (4 + r) m s.val (movingRestoreSample n r m u y) p q' ≠ 0) : + (q' : ℕ) * (∏ i, value (y i)) ≤ H := + (movingTemplateCoefficient_recursive_cell_cap value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi W hX hwindow φ G c hout hμlower n r m u hu + s.val y p q' (hIlower p hp) hc).trans hcap + exact movingTemplatePrimeAmplitude_step_on_support value hvalue outside μ childBound pivotBound V + hV F₀ hzero φ G n r m Pg I hPg hPI hI hφ hpos hμ hμmass ν sets hsets hcard + ggiant favorable hgiant H hH hscale hlarge hvg hφsupport hchild hgap hcomp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..66d7207eab79402ccfd0dfb4f3a926eca382b423 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalEnergy.lean @@ -0,0 +1,176 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularDiagonal +import OAI.NumberTheory.Ostmann.Preliminaries.WeightedNormTriangle + +namespace OAI + +/-! # The original diagonal with its common transform and original prior -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- Only the finitely many attained keys are used; products and frequencies +need not have finite ambient types. -/ +theorem finite_diagonal_common_transform {A K : Type*} [Fintype A] [DecidableEq K] + (key : A → K) (W : A → ℂ) (G : K → ℂ) : + (∑ a, ∑ b, if key a = key b then + (W a * G (key a)) * conj (W b * G (key b)) else 0).re = + ∑ k ∈ Finset.univ.image key, ‖G k‖ ^ 2 * ‖groupedCoefficient key W k‖ ^ 2 := by + let T := Finset.univ.image key + let k : A → T := fun a => ⟨key a, Finset.mem_image.mpr ⟨a, Finset.mem_univ _, rfl⟩⟩ + have h := diagonal_common_transform k W (fun x => G x.val) + have hgroup (x : T) : groupedCoefficient k W x = groupedCoefficient key W x.val := by + unfold groupedCoefficient + apply Finset.sum_congr rfl + intro a _ + rw [show k a = x ↔ key a = x.val from Subtype.ext_iff] + calc + _ = ∑ x : T, ‖G x.val‖ ^ 2 * ‖groupedCoefficient key W x.val‖ ^ 2 := by + simpa only [hgroup, k, Subtype.mk.injEq] using h + _ = _ := by + simpa only [T] using Finset.sum_coe_sort T + (fun x : K => ‖G x‖ ^ 2 * ‖groupedCoefficient key W x‖ ^ 2) + +/-- The actual regular diagonal groups every ordered arrangement on the +same product/frequency fibre before taking its squared modulus. -/ +theorem moving_regular_pivot_diagonal {A H : Type*} [Fintype A] [Fintype H] + (p : A → H → ℕ) [∀ a i, Fact (p a i).Prime] + (g : ∀ q : ℕ, ZMod q → ℂ) (M : ℕ) (v : A → ℤ) (W : A → ℂ) + (hinj : ∀ a, W a ≠ 0 → Function.Injective (p a)) + (hv : ∀ a, W a ≠ 0 → v a ≠ 0) + (hsmall : ∀ a, W a ≠ 0 → ∀ i, (v a).natAbs < p a i) : + (pivotDiagonal (fun a => ∏ i, p a i) v + (fun a => W a * movingRegularTransform (p a) (fun i => g (p a i)) M (v a))).re = + ∑ k ∈ Finset.univ.image (fun a => ((∏ i, p a i), v a)), + ‖primeProductTransform g M k.1 k.2‖ ^ 2 * + ‖groupedCoefficient (fun a => ((∏ i, p a i), v a)) W k‖ ^ 2 := by + let key := fun a => ((∏ i, p a i), v a) + let T := fun k : ℕ × ℤ => primeProductTransform g M k.1 k.2 + have he : pivotDiagonal (fun a => ∏ i, p a i) v + (fun a => W a * movingRegularTransform (p a) (fun i => g (p a i)) M (v a)) = + ∑ a, ∑ b, if key a = key b then (W a * T (key a)) * conj (W b * T (key b)) else 0 := by + unfold pivotDiagonal + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + by_cases ha : W a = 0 + · simp only [ha, zero_mul, ite_self] + by_cases hb : W b = 0 + · simp only [hb, zero_mul, map_zero, mul_zero, ite_self] + have hiff := pivot_zero_numerator_iff (∏ i, p a i) (∏ i, p b i) + (Finset.prod_pos (fun i _ => (Fact.out : (p a i).Prime).pos)) (v a) (v b) + (hv a ha) (hv b hb) + (fun q hq hd => by + obtain ⟨i, rfl⟩ := prime_dvd_prime_product (p a) (fun i => Fact.out) q hq hd + exact hsmall a ha i) + (fun q hq hd => by + obtain ⟨i, rfl⟩ := prime_dvd_prime_product (p b) (fun i => Fact.out) q hq hd + exact hsmall b hb i) + have hk : (v a * (∏ i, p b i) - v b * (∏ i, p a i) = 0) ↔ key a = key b := by + simpa only [key, Prod.mk.injEq] using hiff + simp only [hk] + rw [movingRegularTransform_eq_primeProduct (p a) (hinj a ha), + movingRegularTransform_eq_primeProduct (p b) (hinj b hb)] + rw [he] + simpa only [key, T] using finite_diagonal_common_transform key W T + +/-- Cauchy on one fibre retains its original prior and charges the other +branch only through that fibre's original mass. -/ +theorem grouped_weighted_norm_sq_le {A K : Type*} [Fintype A] + (key : A → K) (μ : A → ℝ) (W : A → ℂ) (k : K) (θ : ℝ) + (hμ : ∀ a, 0 ≤ μ a) + (hmass : (∑ a, if key a = k then μ a else 0) ≤ θ) : + ‖groupedCoefficient key (fun a => (μ a : ℂ) * W a) k‖ ^ 2 ≤ + θ * ∑ a, if key a = k then μ a * ‖W a‖ ^ 2 else 0 := by + let S := Finset.univ.filter (fun a => key a = k) + have h := weighted_correlation_le_sqrt_energy S μ W (fun _ => 1) + (fun a _ => hμ a) + simp only [map_one, mul_one, norm_one, one_pow] at h + have hE : 0 ≤ ∑ a ∈ S, μ a * ‖W a‖ ^ 2 := + Finset.sum_nonneg fun a _ => mul_nonneg (hμ a) (sq_nonneg _) + have hM : 0 ≤ ∑ a ∈ S, μ a := Finset.sum_nonneg fun a _ => hμ a + have hsq := pow_le_pow_left₀ (norm_nonneg _) h 2 + rw [mul_pow, Real.sq_sqrt hE, Real.sq_sqrt hM] at hsq + have hmass' : (∑ a ∈ S, μ a) ≤ θ := by simpa only [S, Finset.sum_filter] using hmass + have hb := hsq.trans (mul_le_mul_of_nonneg_left hmass' hE) + simpa only [S, Finset.sum_filter, groupedCoefficient, mul_comm] using hb + +/-- The diagonal energy after grouping, suitable for the prior atom bound +and the subsequent regular-prime cancellation. -/ +theorem weighted_diagonal_common_transform_le {A K : Type*} [Fintype A] [Fintype K] + (key : A → K) (μ : A → ℝ) (W : A → ℂ) (G : K → ℂ) (θ : K → ℝ) + (hμ : ∀ a, 0 ≤ μ a) + (hmass : ∀ k, (∑ a, if key a = k then μ a else 0) ≤ θ k) : + (∑ a, ∑ b, if key a = key b then + ((μ a : ℂ) * W a * G (key a)) * conj ((μ b : ℂ) * W b * G (key b)) else 0).re ≤ + ∑ a, μ a * θ (key a) * ‖W a * G (key a)‖ ^ 2 := by + rw [diagonal_common_transform key (fun a => (μ a : ℂ) * W a) G] + calc + _ ≤ ∑ k, ‖G k‖ ^ 2 * (θ k * ∑ a, if key a = k then μ a * ‖W a‖ ^ 2 else 0) := by + apply Finset.sum_le_sum + intro k _ + exact mul_le_mul_of_nonneg_left (grouped_weighted_norm_sq_le key μ W k (θ k) hμ (hmass k)) + (sq_nonneg _) + _ = _ := by + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + rw [Finset.sum_eq_single (key a)] + · simp only [ite_true, norm_mul, mul_pow] + ring + · intro k _ hk + rw [ite_eq_right (Ne.symm hk), mul_zero, mul_zero] + · simp + +/-- The same fibre estimate for unbounded integer product/frequency keys. +Only the finite image of the sample space is introduced as a finite type. -/ +theorem finite_weighted_diagonal_common_transform_le {A K : Type*} + [Fintype A] [DecidableEq K] + (key : A → K) (μ : A → ℝ) (W : A → ℂ) (G : K → ℂ) (θ : K → ℝ) + (hμ : ∀ a, 0 ≤ μ a) + (hmass : ∀ k, (∑ a, if key a = k then μ a else 0) ≤ θ k) : + (∑ a, ∑ b, if key a = key b then + ((μ a : ℂ) * W a * G (key a)) * conj ((μ b : ℂ) * W b * G (key b)) else 0).re ≤ + ∑ a, μ a * θ (key a) * ‖W a * G (key a)‖ ^ 2 := by + let T := Finset.univ.image key + let k : A → T := fun a => ⟨key a, Finset.mem_image.mpr ⟨a, Finset.mem_univ _, rfl⟩⟩ + have h := weighted_diagonal_common_transform_le + k μ W (fun x => G x.val) (fun x => θ x.val) hμ (fun x => by + simpa only [Subtype.ext_iff, k] using hmass x.val) + simpa only [k, Subtype.mk.injEq] using h + +theorem finite_grouped_weighted_energy_le {A K : Type*} + [Fintype A] [DecidableEq K] + (key : A → K) (μ : A → ℝ) (W : A → ℂ) (G : K → ℂ) (θ : K → ℝ) + (hμ : ∀ a, 0 ≤ μ a) + (hmass : ∀ k, (∑ a, if key a = k then μ a else 0) ≤ θ k) : + (∑ k ∈ Finset.univ.image key, ‖G k‖ ^ 2 * + ‖groupedCoefficient key (fun a => (μ a : ℂ) * W a) k‖ ^ 2) ≤ + ∑ a, μ a * θ (key a) * ‖W a * G (key a)‖ ^ 2 := by + rw [← finite_diagonal_common_transform] + exact finite_weighted_diagonal_common_transform_le key μ W G θ hμ hmass + +/-- The actual giant-transfer diagonal is bounded using one original +prior and one matching-fibre mass, with no frequency-count loss. -/ +theorem moving_regular_pivot_diagonal_le {A H : Type*} [Fintype A] [Fintype H] + (p : A → H → ℕ) [∀ a i, Fact (p a i).Prime] + (g : ∀ q : ℕ, ZMod q → ℂ) (M : ℕ) (v : A → ℤ) + (μ : A → ℝ) (W : A → ℂ) (θ : ℕ × ℤ → ℝ) + (hμ : ∀ a, 0 ≤ μ a) + (hinj : ∀ a, (μ a : ℂ) * W a ≠ 0 → Function.Injective (p a)) + (hv : ∀ a, (μ a : ℂ) * W a ≠ 0 → v a ≠ 0) + (hsmall : ∀ a, (μ a : ℂ) * W a ≠ 0 → ∀ i, (v a).natAbs < p a i) + (hmass : ∀ k, (∑ a, if ((∏ i, p a i), v a) = k then μ a else 0) ≤ θ k) : + (pivotDiagonal (fun a => ∏ i, p a i) v + (fun a => (μ a : ℂ) * W a * + movingRegularTransform (p a) (fun i => g (p a i)) M (v a))).re ≤ + ∑ a, μ a * θ ((∏ i, p a i), v a) * + ‖W a * primeProductTransform g M (∏ i, p a i) (v a)‖ ^ 2 := by + rw [moving_regular_pivot_diagonal p g M v (fun a => (μ a : ℂ) * W a) hinj hv hsmall] + exact finite_grouped_weighted_energy_le (fun a => ((∏ i, p a i), v a)) μ W + (fun k => primeProductTransform g M k.1 k.2) θ hμ hmass + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalEnergyPatterns.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalEnergyPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..f17f64de5fe3f44b34dbf0266549b3ba807a53f2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalEnergyPatterns.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalDiagonalEnergy + +namespace OAI + +/-! # The complete diagonal energy is controlled by its signed pattern means -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalDiagonalEnergy_pattern_bound {B : Type} [Fintype B] + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (outside : List ℕ) + (n m : ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) (hV : Monotone V) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n + (fun i => Quotient.mk'' i) + (movingOriginalPatternDiagonalObservable (e s) (trees t) small slot (fun i => Quotient.mk'' i) + primes hprimes p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun _ => true) (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside childBound pivotBound + ψ X lo hi φ G Jleft Jright diagonal u v r w center) x + ‖movingOriginalDiagonalEnergy p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f g Dq Finset.univ ψ X lo hi φ G n small + (bulkSlotLeaves n m slot) greg Jleft Jright diagonal u v r w center‖ ≤ + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ∑ s : Setoid (Bool × MovingSampleIndex n), ‖term t s‖ := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let M := fun a b : FrequencyTree ℤ n => + movingOriginalDiagonalMean p (fun q : primes => (q : ℕ)) outside μ ν childBound pivotBound + f g Dq Finset.univ ψ X lo hi φ G n (fun side => if side then b else a) + small (bulkSlotLeaves n m slot) greg (frequencyRoot n a) Jleft Jright diagonal u v r w center + have hzL (a : ScheduledFrequencyIndex V n) (t : FrequencyTree ℤ n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M (scheduledFrequencyHistory V n a) t = 0 := + movingOriginalDiagonalMean_zero_frequency p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f hf g Dq Finset.univ ψ X lo hi φ G n _ small + (bulkSlotLeaves n m slot) greg _ Jleft Jright diagonal u v r w center false ha + have hzR (t : FrequencyTree ℤ n) (a : ScheduledFrequencyIndex V n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M t (scheduledFrequencyHistory V n a) = 0 := + movingOriginalDiagonalMean_zero_frequency p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f hf g Dq Finset.univ ψ X lo hi φ G n _ small + (bulkSlotLeaves n m slot) greg _ Jleft Jright diagonal u v r w center true ha + have hs := same_root_scheduled_pair_sum_le V n + (fun a b => ‖M (scheduledFrequencyHistory V n a) (scheduledFrequencyHistory V n b)‖) + (fun _ _ => norm_nonneg _) + have hh (a : transferFrequencyRange (V n)) (b : MovingDescendantFrequencyIndex V n) : + scheduledFrequencyHistory V n ((scheduledFrequencyRootEquiv V n).symm (a, b)) = + movingRootedFrequencyTree V n a.val b := by + rw [scheduledFrequencyRootEquiv_history, Equiv.apply_symm_apply] + simp_rw [hh] at hs + have he := paired_scheduled_history_sum_le V hV n (fun a b => ‖M a b‖) + (fun _ _ => norm_nonneg _) (fun a t ha => by rw [hzL a t ha, norm_zero]) + (fun t a ha => by rw [hzR t a ha, norm_zero]) + rw [movingOriginalDiagonalEnergy_eq] + apply le_trans _ (hs.trans (he.trans ?_)) + · apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro a _ + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro b _ + have hb := norm_sum_le (Finset.univ : Finset (MovingDescendantFrequencyIndex V n)) + (fun c => movingOriginalDiagonalMean p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f g Dq Finset.univ ψ X lo hi φ G n + (fun side => if side then movingRootedFrequencyTree V n a.val c + else movingRootedFrequencyTree V n a.val b) + small (bulkSlotLeaves n m slot) greg a.val Jleft Jright diagonal u v r w center) + simpa only [M, frequencyRoot_movingRootedFrequencyTree] using hb + · apply Finset.sum_le_sum + intro t _ + let trees := fun side => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + have hpatterns := movingOriginalDiagonalMean_finite_patterns trees small slot primes hprimes + p μ ν g Dq greg (frequencyRoot n (trees false)) f outside childBound pivotBound + ψ X lo hi φ G Jleft Jright diagonal u v r w center N e + have htrees : (fun side => if side then trees true else trees false) = trees := by + funext side + cases side <;> rfl + dsimp only at hpatterns + conv_lhs at hpatterns => rw [← htrees] + change M (trees false) (trees true) = _ at hpatterns + split_ifs + · rw [hpatterns] + exact norm_sum_le _ _ + · exact Finset.sum_nonneg (fun _ _ => norm_nonneg _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalEnergyRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalEnergyRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..2bb55687fc75b29afd16a3ad820c603d130ba9b5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalEnergyRate.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalEnergyPatterns +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticDiagonalPatternNormRate + +namespace OAI + +/-! # Applying the sharp arithmetic budget to the original diagonal energy -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalDiagonalEnergy_pattern_rate + (ψ : 𝓢(ℝ, ℂ)) (n k : ℕ) (hk : 0 < k) (hn : n ≤ k) + (Bwindow Cfreq Cprior ε : ℝ) (hCfreq : 0 ≤ Cfreq) (hCprior : 1 ≤ Cprior) + (hε : 0 < ε) (hdepth : 8 * Cprior ≤ (k : ℝ) ^ 3) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∃ D : ℝ, 0 ≤ D ∧ + (∀ d : ℕ, d ≠ 0 → (d : ℝ) ≤ Real.exp (2 * Cfreq * m) → + (d.divisors.card : ℝ) ≤ D) ∧ + ∀ (B : Type) [Fintype B] + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (X Δ hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (greg : ∀ q : ℕ, ZMod q → ℂ) (outside : List ℕ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s), + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let K := ((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt (Real.exp Δ)) ^ (2 ^ n) * + Bwindow ^ (2 ^ n - 1)) ^ 2 * + ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * 2 ^ (2 ^ n * m) + let err := Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n + (fun i => Quotient.mk'' i) + (movingOriginalPatternDiagonalObservable (e s) (trees t) small slot + (fun i => Quotient.mk'' i) primes hprimes p g Dq + (movingPatternRegularSlots (e s) n m small slot).get (fun _ => true) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside + childBound pivotBound ψ X (Real.exp Δ) hi φ G Jleft Jright diagonal u v r w center) x + Monotone V → f 0 = 0 → + (Sfreq.card : ℝ) ≤ Real.exp (Cfreq * m) → + (V n : ℝ) ≤ Real.exp (Cfreq * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + (∀ s t, ‖term t s‖ ≤ + ((2 : ℝ) ^ Fintype.card (Quotient s) * + (Real.exp (Cprior * L)) ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) * + (err + K * (frequencyLeafWeight (pairedFrequencyLeaf Sfreq (V 0)) n t * + ((frequencySplitList Sfreq n t).map (pairFrequencySupportBound D)).prod))) → + ‖movingOriginalDiagonalEnergy p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f g Dq Finset.univ ψ X (Real.exp Δ) hi φ G n small + (bulkSlotLeaves n m slot) greg Jleft Jright diagonal u v r w center‖ ≤ + Real.exp ((2 ^ n : ℕ) * Δ + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + ε * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + filter_upwards [arithmetic_diagonal_pattern_norm_rate ψ n k hk hn + Bwindow Cfreq Cprior ε hCfreq hCprior hε hdepth] with L hrate + dsimp only at hrate ⊢ + obtain ⟨D, hD, hdiv, hrate⟩ := hrate + refine ⟨D, hD, hdiv, ?_⟩ + intro B _ primes hprimes p _ μ ν childBound pivotBound V f g Dq X Δ hi φ G + small slot greg outside Jleft Jright diagonal u v r w center N e + let m := spectatorBulkCount k L + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n (fun i => Quotient.mk'' i) + (movingOriginalPatternDiagonalObservable (e s) (trees t) small slot (fun i => Quotient.mk'' i) + primes hprimes p g Dq (movingPatternRegularSlots (e s) n m small slot).get (fun _ => true) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside childBound pivotBound + ψ X (Real.exp Δ) hi φ G Jleft Jright diagonal u v r w center) x + intro hV hf hcard hVn hV0 hterm + have hS : ∀ s ∈ Sfreq, s ≠ 0 ∧ s.natAbs ≤ V n := by + intro s hs + exact ⟨(Finset.mem_erase.mp hs).1, + (mem_transferFrequencyRange _ _).mp (Finset.mem_erase.mp hs).2⟩ + have hsum := hrate Sfreq (V n) (V 0) Δ + (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcard hS hVn hV0 (by positivity) le_rfl + (fun s t => (‖term t s‖ : ℂ)) (by + intro s t + rw [Complex.norm_real, Real.norm_of_nonneg (norm_nonneg _)] + exact hterm s t) + have hnonneg : 0 ≤ ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ‖term t s‖ := by positivity + simp only [← Complex.ofReal_sum, Complex.norm_real, Real.norm_of_nonneg hnonneg] at hsum + have hactual := movingOriginalDiagonalEnergy_pattern_bound primes hprimes outside n + (spectatorBulkCount k L) p μ ν childBound pivotBound V f hf g Dq ψ X (Real.exp Δ) + hi φ G small slot greg Jleft Jright diagonal u v r w center hV N e + apply hactual.trans + rw [Finset.sum_comm] + exact hsum + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalErrorBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalErrorBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..3066b9db52185f4e7d9352e9d159be066f8425b8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalErrorBudget.lean @@ -0,0 +1,40 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticErrorRates +import OAI.NumberTheory.Ostmann.Construction.SpectatorBulkScale + +namespace OAI + +/-! # The retained comparison errors in the full diagonal estimate -/ + +namespace Ostmann +open Filter + +theorem moving_diagonal_four_term_bound (A bad D g e E : ℝ) + (hA : 0 ≤ A) (hbad0 : 0 ≤ bad) (heD : e ≤ D) (heg : e ≤ g) + (hbad : A * bad * D ≤ E) (hgood : A * g ≤ E) : + A * (4 * (bad * (D + 5 * e) + g + 5 * e)) ≤ 48 * E := by + have hb := mul_le_mul_of_nonneg_left heD (mul_nonneg hA hbad0) + have hg := mul_le_mul_of_nonneg_left heg hA + nlinarith only [hb, hg, hbad, hgood] + +theorem eventual_moving_comparison_error (k : ℕ) (gain : ℝ) (hgain : 0 ≤ gain) : + ∀ᶠ L : ℝ in atTop, + Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) ≤ + Real.exp (-gain * (spectatorBulkCount k L : ℝ)) := by + filter_upwards [arithmetic_exponent_absorption 0 (12 / 10000) 0 + (gain * (k : ℝ) ^ 4) 1 1 (by norm_num) (by norm_num) (by norm_num) (by norm_num), + eventually_ge_atTop (0 : ℝ)] with L h hL + have hm := mul_le_mul_of_nonneg_left (spectatorBulkCount_upper k L hL) hgain + simp only [pow_one, zero_mul, Real.exp_zero, mul_one, one_mul] at h + apply Real.exp_le_exp.mpr + nlinarith [mul_nonneg (mul_nonneg hgain (pow_nonneg (Nat.cast_nonneg k) 4)) hL] + +theorem moving_diagonal_reserve (B r m E : ℝ) (hrm : Real.log 48 ≤ 3 * r * m) + (hE : E ≤ 48 * Real.exp (-(2 * B + 6) * r * m)) : + E ≤ Real.exp (-(2 * B + 3) * r * m) := by + apply hE.trans + rw [← Real.exp_log (by norm_num : (0 : ℝ) < 48), ← Real.exp_add] + exact Real.exp_le_exp.mpr (by linarith) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalIntegralScale.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalIntegralScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f8266712a5fd4d496dd180cc64909c7f16f24f4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalIntegralScale.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalOuterWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCoefficientMass + +namespace OAI + +/-! # Removing the harmless constant normalization of the diagonal multiplier -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators + +theorem movingDiagonalOuterWeight_denormalize {A σ J : Type*} [Fintype J] + (prime : A → ℕ) (reg : J → σ) (active : J → Bool) + (φ : ℝ → ℝ) (Jleft Jright B D : ℝ) (diagonal : Bool) + (u v : ℝ) (x : σ → A) : + (diagonalOuterMajorant B D diagonal : ℂ) * + movingDiagonalOuterWeight prime reg active φ Jleft Jright B D diagonal u v x = + giantOuterWeight φ Jleft Jright diagonal (Real.exp u) (Real.exp v) * + (inactiveRegularDensity prime reg active x : ℂ) := by + unfold movingDiagonalOuterWeight + have hc : (diagonalOuterMajorant B D diagonal : ℂ) ≠ 0 := by + exact_mod_cast (diagonalOuterMajorant_pos B D diagonal).ne' + exact mul_div_cancel₀ _ hc + +/-- The normalized multiplier costs only its fixed outer majorant after both +integrals and the original signed pattern average. -/ +theorem movingPattern_diagonal_integral_norm {A B C J : Type*} + [Fintype A] [Fintype B] [Fintype C] [Fintype J] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (pattern : Bool × MovingSampleIndex n → C) + (reg : J → Fin (N + 1)) (active : J → Bool) + (φ : ℝ → ℝ) (Jleft Jright Bφ Dφ : ℝ) (diagonal : Bool) + (raw : ℝ → ℝ → (Fin (N + 1) → A) → ℂ) + (haar : (Fin (N + 1) → A) → ℂ) (u v a b center bound : ℝ) + (hbound : ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern + (fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + (movingDiagonalOuterWeight prime reg active φ Jleft Jright Bφ Dφ diagonal z y x * + raw z y x) * (Real.exp (z - center) : ℂ) / (y : ℂ)) x * haar x‖ ≤ bound) : + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern + (fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity prime reg active x : ℂ)) * raw z y x) * + (Real.exp (z - center) : ℂ) / (y : ℂ)) x * haar x‖ ≤ + diagonalOuterMajorant Bφ Dφ diagonal * bound := by + let K := diagonalOuterMajorant Bφ Dφ diagonal + have hK : 0 ≤ K := (diagonalOuterMajorant_pos Bφ Dφ diagonal).le + have he (x) : + (∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity prime reg active x : ℂ)) * raw z y x) * + (Real.exp (z - center) : ℂ) / (y : ℂ)) = + (K : ℂ) * (∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + (movingDiagonalOuterWeight prime reg active φ Jleft Jright Bφ Dφ diagonal z y x * + raw z y x) * (Real.exp (z - center) : ℂ) / (y : ℂ)) := by + rw [← integral_const_mul] + congr 1 + funext z + rw [← integral_const_mul] + congr 1 + funext y + rw [← movingDiagonalOuterWeight_denormalize prime reg active φ Jleft Jright Bφ Dφ diagonal z y x] + change (((K : ℂ) * _) * _) * _ / _ = _ + ring + let original := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity prime reg active x : ℂ)) * raw z y x) * + (Real.exp (z - center) : ℂ) / (y : ℂ) + let normalized := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + (movingDiagonalOuterWeight prime reg active φ Jleft Jright Bφ Dφ diagonal z y x * + raw z y x) * (Real.exp (z - center) : ℂ) / (y : ℂ) + change ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern original x * haar x‖ ≤ _ + change ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern normalized x * haar x‖ ≤ bound at hbound + have hsum : (∑ x, movingOriginalPatternWeight e μ ν prime n pattern original x * haar x) = + (K : ℂ) * ∑ x, movingOriginalPatternWeight e μ ν prime n pattern normalized x * haar x := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + conv_lhs => rw [movingOriginalPatternWeight_eq_coefficient_mul] + conv_rhs => rw [movingOriginalPatternWeight_eq_coefficient_mul] + change _ * (original x) * _ = _ * (_ * normalized x * _) + have hi : original x = (K : ℂ) * normalized x := he x + rw [hi] + ring + rw [hsum, norm_mul, Complex.norm_real, Real.norm_of_nonneg hK] + exact mul_le_mul_of_nonneg_left hbound hK + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalLiveSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalLiveSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..283aa4043cafad346712ccea73881002821c45c1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalLiveSupport.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeLiveSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms +import OAI.NumberTheory.Ostmann.Construction.SupportedAlphabetSum + +namespace OAI + +/-! # The literal diagonal is unchanged on removing zero-weight giant labels -/ +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +theorem pivotDiagonal_embedding_support {A B : Type*} [Fintype A] [Fintype B] + (e : B ↪ A) (L : A → ℕ) (v : A → ℤ) (c : A → ℂ) + (hc : ∀ a, a ∉ Set.range e → c a = 0) : + pivotDiagonal L v c = pivotDiagonal (L ∘ e) (v ∘ e) (c ∘ e) := by + unfold pivotDiagonal + rw [finite_sum_embedding_support e _ (fun a ha => by simp only [hc a ha, zero_mul, ite_self, Finset.sum_const_zero])] + apply Finset.sum_congr rfl + intro a _ + exact finite_sum_embedding_support e _ (fun b hb => by simp only [hc b hb, map_zero, mul_zero, ite_self]) + +theorem smoothGiantPrior_live_embed (P : Finset ℕ) (φ : ℝ → ℝ) (H : ℝ) + (p : smoothGiantLivePrimes P φ H) : + smoothGiantPrior (smoothGiantLivePrimes P φ H) φ H p = + smoothGiantPrior P φ H ⟨p, smoothGiantLivePrimes_subset P φ H p.property⟩ := by + simp only [smoothGiantPrior, smoothGiantLogNormalizer, smoothGiantMass_live] + +theorem movingAmplitudeDiagonal_live {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (P I : Finset ℕ) (H : ℝ) (ν : MovingRegularSlot n r m → σ → ℝ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + movingAmplitudeDiagonal value outside μ childBound pivotBound V F φ G n r m P I + (smoothGiantPrior P φ H) ν greg ggiant favorable = + movingAmplitudeDiagonal value outside μ childBound pivotBound V F φ G n r m + (smoothGiantLivePrimes P φ H) I (smoothGiantPrior (smoothGiantLivePrimes P φ H) φ H) + ν greg ggiant favorable := by + let e : MovingAmplitudeIndex σ (smoothGiantLivePrimes P φ H) n r m V ↪ + MovingAmplitudeIndex σ P n r m V := + ⟨fun a => (⟨a.1, smoothGiantLivePrimes_subset P φ H a.1.property⟩, a.2), by + intro a b hab + rcases a with ⟨a, a'⟩ + rcases b with ⟨b, b'⟩ + have hfirst : a = b := Subtype.ext (congrArg (fun z => (z.1 : ℕ)) hab) + have hsecond : a' = b' := congrArg Prod.snd hab + cases hfirst + cases hsecond + rfl⟩ + unfold movingAmplitudeDiagonal + dsimp only + apply Finset.sum_congr rfl + intro u _ + congr 1 + apply Finset.sum_congr rfl + intro p _ + congr 2 + have hsupport (a : MovingAmplitudeIndex σ P n r m V) (ha : a ∉ Set.range e) : + smoothGiantPrior P φ H a.1 = 0 := by + have hp : (a.1 : ℕ) ∉ smoothGiantLivePrimes P φ H := by + intro hp + apply ha + refine ⟨(⟨a.1, hp⟩, a.2), ?_⟩ + rfl + have hz : φ (Real.log (a.1 : ℕ) - H) = 0 := by + by_contra hn + exact hp (Finset.mem_filter.mpr ⟨a.1.property, hn⟩) + simp only [smoothGiantPrior, hz, mul_zero, zero_div] + rw [pivotDiagonal_embedding_support e _ _ _ (fun a ha => by + simp only [movingTemplateTransferWeight, movingAmplitudePrior, hsupport a ha, + zero_mul, Complex.ofReal_zero])] + apply congrArg (pivotDiagonal _ _) + funext a + have heval (b : MovingAmplitudeIndex σ (smoothGiantLivePrimes P φ H) n r m V) : + e b = (⟨b.1, smoothGiantLivePrimes_subset P φ H b.1.property⟩, b.2) := rfl + simp only [Function.comp_apply, heval, movingTemplateTransferWeight, + movingAmplitudePrior, smoothGiantPrior_live_embed] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalNumericalRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalNumericalRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..32966159e8d88e3ab1f719c701c5a2c85d8bb15d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalNumericalRate.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternInternalError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantErrorRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalOuterWeight + +namespace OAI + +/-! # Numerical simplification of the original diagonal comparison -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem diagonalOuterMajorant_eventually (B D : ℝ) : + ∀ᶠ L : ℝ in atTop, ∀ diagonal : Bool, + 2 * Real.exp 1 * diagonalOuterMajorant B D diagonal ≤ + Real.exp ((49 / 1000 : ℝ) * L) := by + have ht : Tendsto (fun L : ℝ => Real.exp ((49 / 1000 : ℝ) * L)) atTop atTop := + Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num)) + filter_upwards [ht.eventually_ge_atTop + (max (2 * Real.exp 1 * diagonalOuterMajorant B D false) + (2 * Real.exp 1 * diagonalOuterMajorant B D true))] with L hL diagonal + cases diagonal + · exact (le_max_left _ _).trans hL + · exact (le_max_right _ _).trans hL + +/-- The actual denominator and coefficient mass absorb all comparison costs. +The remaining main term `K` is the nonnegative leaf/split contribution. -/ +theorem movingPattern_diagonal_pointwise_rate (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin B D Cprior Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (hCprior : 1 ≤ Cprior) (hCmass : 0 ≤ Cmass) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (p : Fin m → ℕ) (c : ℕ) (E U α β amp lo hi rG K z : ℝ) (diagonal : Bool), + let κE := (2 : ℝ) ^ c * E ^ (4 * n * 2 ^ n - c) + let κ := (2 : ℝ) ^ c * (Real.exp (Cprior * L)) ^ (4 * n * 2 ^ n - c) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + c ≤ 4 * n * 2 ^ n → 0 ≤ E → E ≤ Real.exp (Cprior * L) → + 1 ≤ U → Real.log U ≤ Real.exp ((12 / 1000 : ℝ) * L) → + 0 ≤ α → α ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + 0 ≤ β → β ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + 0 ≤ amp → amp ≤ 4 → lo ≤ hi → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → 0 ≤ K → + z ≤ (κE * U ^ c) * (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + diagonalOuterMajorant B D diagonal * ((2 * Real.exp 1 * + (κE * (cost * movingInternalArithmeticError n c (2 ^ n * (r₀ + m + 4 * n + 4)) + (Real.exp (A * m)) U α β (Real.exp ((1 / 100 : ℝ) * L)) + K + + (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG) → + z ≤ κ * (K + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + filter_upwards [movingPattern_internal_arithmetic_error_rate ψ n r₀ k A Wwin B D Cmass + hA hWwin hCmass, movingPattern_giant_error_rate n Cprior hCprior, + diagonalOuterMajorant_eventually B D, eventually_ge_atTop (0 : ℝ)] + with L hinternal hgiant houter hL + dsimp only + intro p c E U α β amp lo hi rG K z diagonal hc hE hEup hU hUlog + hα hαup hβ hβup hamp hampup hhi hwidth hp hrG hK hz + let κE := (2 : ℝ) ^ c * E ^ (4 * n * 2 ^ n - c) + let κ := (2 : ℝ) ^ c * (Real.exp (Cprior * L)) ^ (4 * n * 2 ^ n - c) + let e₁ := Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + let e₂ := Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + let err := ((amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * spectatorBulkCount k L)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2) * + movingInternalArithmeticError n c (2 ^ n * (r₀ + spectatorBulkCount k L + 4 * n + 4)) + (Real.exp (A * spectatorBulkCount k L)) U α β (Real.exp ((1 / 100 : ℝ) * L)) + have hint : err ≤ e₂ := hinternal p c U α β amp lo hi hc hU hUlog hα hαup hβ hβup + hamp hampup hhi hwidth hp + have hUup : U ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + rw [← Real.exp_log (by linarith : 0 < U)] + exact Real.exp_le_exp.mpr hUlog + have hg := hgiant c hc E U hE hEup (by linarith) hUup + have hκE : 0 ≤ κE := by dsimp only [κE]; positivity + have hκmono : κE ≤ κ := mul_le_mul_of_nonneg_left (pow_le_pow_left₀ hE hEup _) (by positivity) + have hκ : 1 ≤ κ := one_le_mul_of_one_le_of_one_le (one_le_pow₀ (by norm_num)) + (one_le_pow₀ (Real.one_le_exp_iff.mpr (mul_nonneg (by linarith) hL))) + have hrG0 : 0 < rG := (Real.exp_pos _).trans_le hrG + have hscale : diagonalOuterMajorant B D diagonal * (2 * Real.exp 1) / rG ≤ 1 := by + apply (div_le_one hrG0).mpr + nlinarith only [(houter diagonal).trans hrG] + have herr0 : 0 ≤ err := by + apply mul_nonneg (by positivity) + exact movingInternalArithmeticError_nonneg n c _ _ U α β _ + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hU hα hβ (Real.exp_nonneg _) + have hb0 : 0 ≤ err + K + (e₁ + 2 * e₂) := by dsimp only [e₁, e₂]; positivity + have hstep : + diagonalOuterMajorant B D diagonal * + ((2 * Real.exp 1 * (κE * (err + K + (e₁ + 2 * e₂)))) / rG) ≤ + κ * (K + e₁ + 3 * e₂) := by + calc + _ = (diagonalOuterMajorant B D diagonal * (2 * Real.exp 1) / rG) * + (κE * (err + K + (e₁ + 2 * e₂))) := by ring + _ ≤ κE * (err + K + (e₁ + 2 * e₂)) := + mul_le_of_le_one_left (mul_nonneg hκE hb0) hscale + _ ≤ κE * (K + e₁ + 3 * e₂) := + mul_le_mul_of_nonneg_left (by linarith) hκE + _ ≤ κ * (K + e₁ + 3 * e₂) := + mul_le_mul_of_nonneg_right hκmono (by dsimp only [e₁, e₂]; positivity) + have hrest := add_le_add hg hstep + have hh : z ≤ e₂ + κ * (K + e₁ + 3 * e₂) := hz.trans hrest + have he₂ : e₂ ≤ κ * e₂ := le_mul_of_one_le_left (Real.exp_nonneg _) hκ + change z ≤ κ * (K + e₁ + 4 * e₂) + nlinarith only [hh, he₂] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalOuterWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalOuterWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..80782560cbc821869b8a9a2fa335d0c23269efe1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDiagonalOuterWeight.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterKernel +import OAI.NumberTheory.Ostmann.Construction.SelectedPrimeFubini + +namespace OAI + +/-! # Retaining the inactive regular density under the bulk prime average -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def inactiveRegularDensity {A σ J : Type*} [Fintype J] + (prime : A → ℕ) (reg : J → σ) (active : J → Bool) (x : σ → A) : ℝ := + ∏ j, if active j then 1 else 1 - (prime (x (reg j)) : ℝ)⁻¹ + +theorem inactiveRegularDensity_bounds {A σ J : Type*} [Fintype J] + (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (reg : J → σ) (active : J → Bool) (x : σ → A) : + 0 ≤ inactiveRegularDensity prime reg active x ∧ + inactiveRegularDensity prime reg active x ≤ 1 := by + have hlocal (j : J) : 0 ≤ (if active j then 1 else 1 - (prime (x (reg j)) : ℝ)⁻¹) ∧ + (if active j then 1 else 1 - (prime (x (reg j)) : ℝ)⁻¹) ≤ 1 := by + have hp : (1 : ℝ) ≤ prime (x (reg j)) := by exact_mod_cast (hprime _).one_le + cases active j + · simp only [Bool.false_eq_true, ite_false] + exact ⟨sub_nonneg.mpr ((inv_le_one₀ (by positivity)).mpr hp), + sub_le_self _ (by positivity)⟩ + · simp + exact ⟨Finset.prod_nonneg (fun j _ => (hlocal j).1), + Finset.prod_le_one₀ (fun j _ => (hlocal j).1) (fun j _ => (hlocal j).2)⟩ + +/-- Inactive factors use only the fixed nonbulk coordinates. -/ +theorem inactiveRegularDensity_joinBulkNonbulk {A σ J K : Type*} [Fintype J] + (prime : A → ℕ) (reg : J → σ) (active : J → Bool) (slot : K ↪ σ) + (hfixed : ∀ j, active j = false → reg j ∉ Set.range slot) + (x : σ → A) (z : K → A) : + inactiveRegularDensity prime reg active (joinBulkNonbulk slot z (fun i => x i)) = + inactiveRegularDensity prime reg active x := by + apply Finset.prod_congr rfl + intro j _ + cases ha : active j + · have hj : reg j ∉ Set.range slot := hfixed j ha + have he := joinBulkNonbulk_nonbulk slot z (fun i => x i) ⟨reg j, hj⟩ + simp only [Bool.false_eq_true, ite_false] + rw [he] + · simp only [ite_true] + +noncomputable def diagonalOuterMajorant (B D : ℝ) (diagonal : Bool) : ℝ := + 1 + giantOuterScalar diagonal * (2 * B + D * (Real.exp 2 - 1)) ^ 2 * + (if diagonal then 1 + Real.exp 2 else 2) + +theorem diagonalOuterMajorant_pos (B D : ℝ) (diagonal : Bool) : + 0 < diagonalOuterMajorant B D diagonal := by + unfold diagonalOuterMajorant + have hs : 0 ≤ giantOuterScalar diagonal := by + cases diagonal <;> simp [giantOuterScalar, (Real.exp_pos _).le] + have hh : 0 ≤ (if diagonal then 1 + Real.exp 2 else (2 : ℝ)) := by + cases diagonal <;> positivity + positivity + +noncomputable def movingDiagonalOuterWeight {A σ J : Type*} [Fintype J] + (prime : A → ℕ) (reg : J → σ) (active : J → Bool) + (φ : ℝ → ℝ) (Jleft Jright B D : ℝ) (diagonal : Bool) + (u v : ℝ) (x : σ → A) : ℂ := + (giantOuterWeight φ Jleft Jright diagonal (Real.exp u) (Real.exp v) * + (inactiveRegularDensity prime reg active x : ℂ)) / + (diagonalOuterMajorant B D diagonal : ℂ) + +theorem movingDiagonalOuterWeight_norm {A σ J : Type*} [Fintype J] + (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) (reg : J → σ) (active : J → Bool) + (φ : ℝ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) + (u v : ℝ) (x : σ → A) : + ‖movingDiagonalOuterWeight prime reg active φ Jleft Jright B D diagonal u v x‖ ≤ 1 := by + have hc := diagonalOuterMajorant_pos B D diagonal + have hd := inactiveRegularDensity_bounds prime hprime reg active x + have ho := giantOuterWeight_norm φ Jleft Jright B D hB hD hφ hlip hout diagonal + (Real.exp u) (Real.exp v) + unfold movingDiagonalOuterWeight + rw [norm_div, norm_mul, Complex.norm_real, Real.norm_of_nonneg hd.1, + Complex.norm_real, Real.norm_of_nonneg hc.le] + apply (div_le_one hc).mpr + calc + _ ≤ ‖giantOuterWeight φ Jleft Jright diagonal (Real.exp u) (Real.exp v)‖ * 1 := + mul_le_mul_of_nonneg_left hd.2 (norm_nonneg _) + _ ≤ diagonalOuterMajorant B D diagonal := by + rw [mul_one] + exact ho.trans (by unfold diagonalOuterMajorant; linarith) + +theorem movingDiagonalOuterWeight_measurable {A σ J : Type*} [Fintype J] + (prime : A → ℕ) (reg : J → σ) (active : J → Bool) + (φ : ℝ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (x : σ → A) : + Measurable (fun z : ℝ × ℝ => movingDiagonalOuterWeight prime reg active φ + Jleft Jright B D diagonal z.1 z.2 x) := by + have hm := (measurable_giantOuterWeight φ Jleft Jright B D hB hD hφ hlip hout diagonal).comp + ((Real.continuous_exp.measurable.comp measurable_fst).prodMk + (Real.continuous_exp.measurable.comp measurable_snd)) + exact (hm.mul_const _).div_const _ + +theorem movingDiagonalOuterWeight_bulk {A σ J K : Type*} [Fintype J] + (prime : A → ℕ) (reg : J → σ) (active : J → Bool) (slot : K ↪ σ) + (hfixed : ∀ j, active j = false → reg j ∉ Set.range slot) + (φ : ℝ → ℝ) (Jleft Jright B D : ℝ) (diagonal : Bool) + (u v : ℝ) (x : σ → A) (z : K → A) : + movingDiagonalOuterWeight prime reg active φ Jleft Jright B D diagonal u v + (joinBulkNonbulk slot z (fun i => x i)) = + movingDiagonalOuterWeight prime reg active φ Jleft Jright B D diagonal u v x := by + unfold movingDiagonalOuterWeight + rw [inactiveRegularDensity_joinBulkNonbulk prime reg active slot hfixed] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDirectRecursion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDirectRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..148cd31de917191790e6e185ad2b174b3336410c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDirectRecursion.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRootReconstruction + +namespace OAI + +/-! # The original sampled recursion with the explicit giant quotient -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original sample law and the two independent child sample trees are +retained. The inserted giant is exactly `(v H⁻ - w H⁺)/(s U)`, matching the +weighted integer off-diagonal, with every root support test still explicit. -/ +theorem movingSampledWeight_direct_node {σ : Type*} [Fintype σ] + (value : σ → ℕ) (μ : ℕ → σ → ℝ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ (n + 1)) + (small bulk : TreeLeafTuple (List σ) (n + 1)) (XL XR : ℕ) : + let E := movingCompensatedExtra value (movingOriginalNode value childBound pivotBound φ G) + movingSampledWeight value μ childBound pivotBound F E (n + 1) t small bulk XL XR = + ∑ a : TreeLeafTuple (Fin 4 → σ) n, + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let x := movingRootState n t CL CR (flattenMovingSlots n u) XL XR + let U := x.compensation value + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let p := reconstructedPivot + (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) (t.1 * U) + (movingCompensationPrior (μ n) n a : ℂ) * + if ValidTransferNode (movingSlotSystem value childBound pivotBound) x t.1 v w (p * U) ∧ + 0 < U then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) * + movingSampledWeight value μ childBound pivotBound F E n t.2.1 + (appendMovingSlotLeaves n u small.1) bulk.1 p XL * + star (movingSampledWeight value μ childBound pivotBound F E n t.2.2 + (appendMovingSlotLeaves n u small.2) bulk.2 p XR) + else 0 := by + intro E + rw [movingSampledWeight_node] + apply Finset.sum_congr rfl + intro a _ + dsimp only + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let x := movingRootState n t CL CR (flattenMovingSlots n u) XL XR + let U := x.compensation value + let sys := movingSlotSystem value childBound pivotBound + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let P := historyPivot sys x t.1 v w + let p := reconstructedPivot (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) (t.1 * U) + have hroot := movingSampleRootFactor_reconstructed value childBound pivotBound φ G n t + CL CR (flattenMovingSlots n u) XL XR + dsimp only at hroot + simp only [← Complex.ofReal_mul] at hroot + change movingSampleRootFactor value childBound pivotBound E n t CL CR + (flattenMovingSlots n u) XL XR = + if ValidTransferNode sys x t.1 v w (p * U) ∧ 0 < U then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) else 0 at hroot + change (movingCompensationPrior (μ n) n a : ℂ) * + movingSampleRootFactor value childBound pivotBound E n t CL CR + (flattenMovingSlots n u) XL XR * + movingSampledWeight value μ childBound pivotBound F E n t.2.1 + (appendMovingSlotLeaves n u small.1) bulk.1 (P / U) XL * + star (movingSampledWeight value μ childBound pivotBound F E n t.2.2 + (appendMovingSlotLeaves n u small.2) bulk.2 (P / U) XR) = + (movingCompensationPrior (μ n) n a : ℂ) * + (if ValidTransferNode sys x t.1 v w (p * U) ∧ 0 < U then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) * + movingSampledWeight value μ childBound pivotBound F E n t.2.1 + (appendMovingSlotLeaves n u small.1) bulk.1 p XL * + star (movingSampledWeight value μ childBound pivotBound F E n t.2.2 + (appendMovingSlotLeaves n u small.2) bulk.2 p XR) + else 0) + rw [hroot] + by_cases h : ValidTransferNode sys x t.1 v w (p * U) ∧ 0 < U + · have hP : P = p * U := h.1.historyPivot_eq + have hp : P / U = p := by rw [hP, Nat.mul_div_left _ h.2] + rw [ite_eq_left h, ite_eq_left h, hp] + ring + · rw [ite_eq_right h, ite_eq_right h] + simp only [mul_zero, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDominatedLineComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDominatedLineComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..01ef2226f6f5c0c5cf4ca0705b15468d250728f5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingDominatedLineComparison.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingActualLineComparison +import OAI.NumberTheory.Ostmann.ZeroDensity.FinitePriorDensity + +namespace OAI + +/-! # Symbolic line comparison under the dominated equality-pattern law -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The complete original pattern weight may be used directly once its product +of line scalars is dominated by the representative priors. In particular, the +pattern law is not assumed to be independent. -/ +theorem moving_dominated_line_product_comparison {A J : Type*} + [Fintype A] [Nonempty A] [Fintype J] {N n : ℕ} + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (T : Bool → MovingSlotData (Fin (N + 1)) n) (tier : Fin (N + 1) → ℕ) + (hlevels : ∀ side, (T side).Levels tier) + (rep : J → Fin (N + 1)) (base : ∀ j, MovingPairRepresentativeOccurrences T (rep j)) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ side, (T side).SizeLE d) + (hfreq : ∀ side, (T side).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : Fin (N + 1) → A → ℝ) (hμ : ∀ i a, 0 ≤ μ i a) + (hmass : ∀ i, ∑ a, μ i a = 1) + (α β V : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hmax : ∀ i a, μ i a ≤ α) (hpmax : ∀ j a, μ (rep j) a ≤ β) + (hprimeSize : ∀ j a, μ (rep j) a ≠ 0 → V ≤ Real.log (prime a : ℝ)) + (weight : (Fin (N + 1) → A) → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hweight : ∀ x, ‖weight x‖ * ∏ j, internalLineScalar true (prime (x (rep j))) ≤ B * productPrior μ x) + (hdisjoint : ∀ x, weight x ≠ 0 → ∀ i j, + tier i ≠ tier j → prime (x i) ≠ prime (x j)) + (hunique : ∀ x, weight x ≠ 0 → ∀ j i, prime (x i) = prime (x (rep j)) → i = rep j) + (hfmod : ∀ x, weight x ≠ 0 → ∀ j side, + (T side).Frequencies (fun s => (s : ZMod (prime (x (rep j)))) ≠ 0)) : + ‖∑ x, weight x * + ((∏ j, (movingSampledInternalProbability prime hprime T x (rep j) : ℂ)) - + ∏ j, (internalLineFlagWeight true (prime (x (rep j))) + (fun s => arithmeticTestFlag (lineTestPolynomials + (movingIndexedLine T (rep j) (base j)) ⟨(base j).1, (base j).2.val⟩ s = 0)) : ℂ))‖ ≤ + 2 * B * (Fintype.card J * (2 + Fintype.card (MovingPairOccurrenceIndex T))) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β) := by + let prior := fun x : Fin (N + 1) → A => productPrior μ x + let c := fun x : Fin (N + 1) → A => + ∏ j, internalLineScalar true (prime (x (rep j))) + have hc (x : Fin (N + 1) → A) : 0 < c x := by + apply Finset.prod_pos + intro j _ + simp only [internalLineScalar, ite_true] + exact inv_pos.mpr (Nat.cast_pos.mpr (hprime (x (rep j))).pos) + have hprior (x : Fin (N + 1) → A) : 0 ≤ prior x := productPrior_nonneg μ hμ x + have hd (x : Fin (N + 1) → A) : finitePriorDensity prior weight x ≠ 0 → weight x ≠ 0 := + finitePriorDensity_ne_zero prior weight x + have h := moving_actual_line_product_comparison prime hpInj hprime T tier hlevels rep base + d F U hF hU hsize hfreq hvalues μ hμ hmass α β V hα hβ hV hmax hpmax hprimeSize + (finitePriorDensity prior weight) B hB + (finitePriorDensity_bound prior weight c B hprior hB hweight) + (fun x hx => hdisjoint x (hd x hx)) (fun x hx => hunique x (hd x hx)) + (fun x hx => hfmod x (hd x hx)) + convert h using 1 + congr 1 + apply Finset.sum_congr rfl + intro x _ + rw [finitePriorDensity_cancel prior weight c B hc hweight x] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingEarlyCellCaps.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingEarlyCellCaps.lean new file mode 100644 index 0000000000000000000000000000000000000000..cffbcdc0595253631b981d61748d6943dcb36f00 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingEarlyCellCaps.lean @@ -0,0 +1,121 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFirstProductBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationProductBounds + +namespace OAI + +/-! # Concrete product caps for the first two integer extensions -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +private theorem ceiling_exp_double (E : ℝ) (hE : 0 ≤ E) : + (⌈Real.exp E⌉₊ : ℝ) ≤ 2 * Real.exp E := by + have h := (Nat.ceil_lt_add_one (Real.exp_pos E).le).le + have he := Real.one_le_exp hE + linarith + +theorem first_two_cell_caps (T₀ T₁ E W : ℝ) (hE : 0 ≤ E) + (hW : W ≤ Real.exp (T₀ + E)) : + W ≤ Real.exp T₀ * (⌈Real.exp E⌉₊ : ℝ) ∧ + ((⌈Real.exp E⌉₊ ^ 2 : ℕ) : ℝ) ≤ + Real.exp T₁ * (⌈Real.exp (2 * E - T₁ + Real.log 4)⌉₊ : ℝ) := by + constructor + · apply hW.trans + rw [Real.exp_add] + exact mul_le_mul_of_nonneg_left (Nat.le_ceil (Real.exp E)) (Real.exp_nonneg _) + · have hc := ceiling_exp_double E hE + have hs := mul_self_le_mul_self (Nat.cast_nonneg ⌈Real.exp E⌉₊) hc + have hce := Nat.le_ceil (Real.exp (2 * E - T₁ + Real.log 4)) + calc + _ ≤ (2 * Real.exp E) ^ 2 := by simpa only [Nat.cast_pow, pow_two, Nat.cast_mul] using hs + _ = Real.exp T₁ * Real.exp (2 * E - T₁ + Real.log 4) := by + rw [← Real.exp_add] + have heq : T₁ + (2 * E - T₁ + Real.log 4) = 2 * E + Real.log 4 := by ring + rw [heq, Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 4), + show 2 * E = E + E by ring, Real.exp_add] + ring + _ ≤ _ := mul_le_mul_of_nonneg_left hce (Real.exp_nonneg _) + +theorem movingCompensation_pivot_lower_of_bound {σ : Type*} (value : σ → ℕ) + (μ : σ → ℝ) (c G : ℝ) + (hlower : ∀ x, μ x ≠ 0 → Real.exp (c - 1) ≤ (value x : ℝ)) + (n : ℕ) (a : TreeLeafTuple (Fin 4 → σ) n) + (ha : movingCompensationPrior μ n a ≠ 0) (p : ℕ) + (hp : Real.exp (G - 1) ≤ (p : ℝ)) : + Real.exp (G - 1 + ((2 ^ n * 4 : ℕ) : ℝ) * (c - 1)) ≤ + (p * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingCompensationSlots n a)) : ℕ) := by + rw [Real.exp_add] + simpa only [Nat.cast_mul] using + mul_le_mul hp (movingCompensation_product_lower value μ c hlower n a ha) + (Real.exp_nonneg _) (Nat.cast_nonneg _) + +theorem movingFrequencyCoefficient_initial_cell_cap {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi c E : ℝ) (hX : 0 < X) (hE : 0 ≤ E) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (hμ : ∀ x, μ 0 x ≠ 0 → Real.exp (c - 1) ≤ (value x : ℝ)) + (hwindow : X * hi ≤ Real.exp (G 1 - 1 + 4 * (c - 1) + E)) + (a : Fin 4 → σ) (ha : movingCompensationPrior (μ 0) 0 a ≠ 0) + (s : ℤ) (small bulk : List σ) (p XR : ℕ) + (hp : 0 < p) (hpbound : Real.exp (G 1 - 1) ≤ (p : ℝ)) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G 0 s + (List.ofFn a ++ small) bulk p XR ≠ 0) : + XR * MovingSlotReversal.naturalProduct value (small ++ bulk) ≤ ⌈Real.exp E⌉₊ := by + have hlow := movingCompensation_pivot_lower_of_bound value (μ 0) c (G 1) hμ 0 a ha p hpbound + have hU := movingCompensation_product_lower value (μ 0) c hμ 0 a ha + have hUp : 0 < MovingSlotReversal.naturalProduct value (List.ofFn a) := by + have hpos := (Real.exp_pos _).trans_le hU + exact_mod_cast hpos + have hc := (first_two_cell_caps (G 1 - 1 + 4 * (c - 1)) 0 E (X * hi) hE hwindow).1 + exact movingFrequencyCoefficient_initial_retained_bound value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi (Real.exp (G 1 - 1 + 4 * (c - 1))) hX φ G s + (List.ofFn a) small bulk p XR ⌈Real.exp E⌉₊ hp hUp (by simpa only [flattenMovingSlots, movingCompensationSlots, Nat.pow_zero, one_mul, Nat.cast_ofNat] using hlow) hc h + +theorem movingFrequencyCoefficient_one_cell_cap {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi c₀ c₁ E : ℝ) (hX : 0 < X) (hE : 0 ≤ E) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (hout : ∀ t, 1 ≤ |t| → φ t = 0) + (hμ₀ : ∀ x, μ 0 x ≠ 0 → Real.exp (c₀ - 1) ≤ (value x : ℝ)) + (hμ₁ : ∀ x, μ 1 x ≠ 0 → Real.exp (c₁ - 1) ≤ (value x : ℝ)) + (hwindow : X * hi ≤ Real.exp (G 1 - 1 + 4 * (c₀ - 1) + E)) + (a : (Fin 4 → σ) × (Fin 4 → σ)) (ha : movingCompensationPrior (μ 1) 1 a ≠ 0) + (s : ℤ) (small bulk : List σ × List σ) (p XR : ℕ) + (hp : 0 < p) (hpbound : Real.exp (G 2 - 1) ≤ (p : ℝ)) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G 1 s + (List.ofFn a.1 ++ small.1, List.ofFn a.2 ++ small.2) bulk p XR ≠ 0) : + XR * MovingSlotReversal.naturalProduct value + ((small.1 ++ bulk.1) ++ (small.2 ++ bulk.2)) ≤ + ⌈Real.exp (2 * E - (G 2 - 1 + 8 * (c₁ - 1)) + Real.log 4)⌉₊ := by + let T₀ := G 1 - 1 + 4 * (c₀ - 1) + let T₁ := G 2 - 1 + 8 * (c₁ - 1) + have hlow := movingCompensation_pivot_lower_of_bound value (μ 1) c₁ (G 2) hμ₁ 1 a ha p hpbound + have hU := movingCompensation_product_lower value (μ 1) c₁ hμ₁ 1 a ha + have hUp : 0 < MovingSlotReversal.naturalProduct value (List.ofFn a.1 ++ List.ofFn a.2) := by + have hpos := (Real.exp_pos _).trans_le hU + exact_mod_cast hpos + have hmin (b : Fin 4 → σ) (hb : movingCompensationPrior (μ 0) 0 b ≠ 0) + (p' : ℕ) (hp' : 0 < p') (hφ' : φ (Real.log p' - G 1) ≠ 0) : + Real.exp T₀ ≤ (p' * MovingSlotReversal.naturalProduct value (List.ofFn b) : ℕ) := by + have hlow' := movingInsertedPivot_product_lower value (μ 0) c₀ (G 1) φ hμ₀ hout 0 b hb p' hp' hφ' + simpa only [T₀, flattenMovingSlots, movingCompensationSlots, Nat.pow_zero, one_mul, + Nat.cast_ofNat] using hlow' + have hcaps := first_two_cell_caps T₀ T₁ E (X * hi) hE hwindow + apply movingFrequencyCoefficient_one_retained_bound value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi (Real.exp T₀) hX φ G hmin ⌈Real.exp E⌉₊ hcaps.1 s + (List.ofFn a.1, List.ofFn a.2) small bulk p XR _ hp hUp (Real.exp T₁) _ hcaps.2 h + simpa only [T₁, flattenMovingSlots, movingCompensationSlots, Nat.reducePow, Nat.reduceMul, + Nat.cast_ofNat] using hlow + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingEarlyTemplateCaps.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingEarlyTemplateCaps.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0bc7a79426a259017065a9fac5c8adbb6aba266 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingEarlyTemplateCaps.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingEarlyCellCaps +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateIntegerNode + +namespace OAI + +/-! # The first two product caps on the literal restored templates -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateCoefficient_initial_cell_cap {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi c E : ℝ) (hX : 0 < X) (hE : 0 ≤ E) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (hμ : ∀ x, μ 0 x ≠ 0 → Real.exp (c - 1) ≤ (value x : ℝ)) + (hwindow : X * hi ≤ Real.exp (G 1 - 1 + 4 * (c - 1) + E)) + (r m : ℕ) (u : TreeLeafIndex 0 × Fin 4 → σ) (hu : (∏ i, μ 0 (u i)) ≠ 0) + (s : ℤ) (y : MovingRegularSlot 0 r m → σ) (p XR : ℕ) + (hp : 0 < p) (hpbound : Real.exp (G 1 - 1) ≤ (p : ℝ)) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G 0 (4 + r) m s + (movingRestoreSample 0 r m u y) p XR ≠ 0) : + XR * (∏ i, value (y i)) ≤ ⌈Real.exp E⌉₊ := by + let a := (movingTemplateCompensationEquiv σ 0).symm u + have he : movingTemplateCompensationEquiv σ 0 a = u := Equiv.apply_symm_apply _ _ + have ha : movingCompensationPrior (μ 0) 0 a ≠ 0 := by + rw [← movingTemplateCompensationEquiv_prior, he] + exact hu + rw [← he, movingTemplateCoefficient_restored] at h + let small : List σ := treeLeafMap (List.map y) 0 (movingTemplateSmall 0 r m) + let bulk : List σ := treeLeafMap (List.map y) 0 (bulkSlotLeaves 0 m (movingTemplateBulk 0 r m)) + have hc := movingFrequencyCoefficient_initial_cell_cap value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi c E hX hE φ G hμ hwindow a ha s + small bulk p XR hp hpbound h + have hid := movingTemplateMapped_product value 0 r m y + change MovingSlotReversal.naturalProduct value (small ++ bulk) = _ at hid + rwa [hid] at hc + +theorem movingTemplateCoefficient_one_cell_cap {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi c₀ c₁ E : ℝ) (hX : 0 < X) (hE : 0 ≤ E) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (hout : ∀ t, 1 ≤ |t| → φ t = 0) + (hμ₀ : ∀ x, μ 0 x ≠ 0 → Real.exp (c₀ - 1) ≤ (value x : ℝ)) + (hμ₁ : ∀ x, μ 1 x ≠ 0 → Real.exp (c₁ - 1) ≤ (value x : ℝ)) + (hwindow : X * hi ≤ Real.exp (G 1 - 1 + 4 * (c₀ - 1) + E)) + (r m : ℕ) (u : TreeLeafIndex 1 × Fin 4 → σ) (hu : (∏ i, μ 1 (u i)) ≠ 0) + (s : ℤ) (y : MovingRegularSlot 1 r m → σ) (p XR : ℕ) + (hp : 0 < p) (hpbound : Real.exp (G 2 - 1) ≤ (p : ℝ)) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G 1 (4 + r) m s + (movingRestoreSample 1 r m u y) p XR ≠ 0) : + XR * (∏ i, value (y i)) ≤ + ⌈Real.exp (2 * E - (G 2 - 1 + 8 * (c₁ - 1)) + Real.log 4)⌉₊ := by + let a := (movingTemplateCompensationEquiv σ 1).symm u + have he : movingTemplateCompensationEquiv σ 1 a = u := Equiv.apply_symm_apply _ _ + have ha : movingCompensationPrior (μ 1) 1 a ≠ 0 := by + rw [← movingTemplateCompensationEquiv_prior, he] + exact hu + rw [← he, movingTemplateCoefficient_restored] at h + let small : List σ × List σ := treeLeafMap (List.map y) 1 (movingTemplateSmall 1 r m) + let bulk : List σ × List σ := treeLeafMap (List.map y) 1 (bulkSlotLeaves 1 m (movingTemplateBulk 1 r m)) + have hc := movingFrequencyCoefficient_one_cell_cap value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi c₀ c₁ E hX hE φ G hout hμ₀ hμ₁ hwindow a ha s small bulk p XR hp hpbound h + have hid := movingTemplateMapped_product value 1 r m y + change MovingSlotReversal.naturalProduct value ((small.1 ++ small.2) ++ (bulk.1 ++ bulk.2)) = _ at hid + have hperm : MovingSlotReversal.naturalProduct value ((small.1 ++ bulk.1) ++ (small.2 ++ bulk.2)) = + MovingSlotReversal.naturalProduct value ((small.1 ++ small.2) ++ (bulk.1 ++ bulk.2)) := by + simp only [movingNaturalProduct_append] + ring + rwa [hperm, hid] at hc + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldBulkComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldBulkComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..e69cd16a309cf757055540a77e0b5976c1acd0c1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldBulkComparison.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFieldDiagram +import OAI.NumberTheory.Ostmann.Construction.NormalizedSpectatorComparison + +namespace OAI + +/-! # Good-matching decay for the separated field spectator diagrams -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +theorem moving_field_good_spectator_comparison {σ : Type*} {q : ℕ} [Fact q.Prime] + (hq : 3 ≤ q) (value : σ → ℕ) (n m : ℕ) (hm : 0 < m) + (e : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (hgood : 4 * Fintype.card (arrangementGraph m e).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2))) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List σ) (n + 2)) + (samples : Bool → MovingSampleSlots σ (n + 2)) + (hfreq : ∀ side, movingGiantFrequencyUnits q (n + 2) (t side)) + (hsmall : ∀ side, + ((treeLeafProduct (n + 2) (movingSlotValues value (n + 2) (small side)) : ℕ) : ZMod q) ≠ 0) + (hsamples : ∀ side, ((samples side).values value).UnitsAt q) + (D A B : Bool → (ZMod q)ˣ) + (S : Finset (ZMod q)) (hlo : (1 / 3 : ℝ) ≤ residueDensity S) + (hhi : residueDensity S ≤ 2 / 3) (hS : S.Nonempty) (hSq : S.card < q) + (β ε : ℝ) (hε : 0 ≤ ε) (hε1 : ε ≤ 1) + (hprincipal : 3 / Real.sqrt (q : ℝ) ≤ ε) (hβ : 2 * β ≤ ε) + (hbias : ∀ (χ : MulChar (ZMod q) ℂ), χ ≠ 1 → ∀ a : ZMod q, + ‖(S.card : ℂ)⁻¹ * ∑ x ∈ S, χ⁻¹ (-a - x)‖ ≤ β) : + ∃ d : Bool → SpectatorDiagram q (n + 2), + (∀ (bulk : Bool → TreeLeafTuple (List σ) (n + 2)) + (z : Bool → TreeLeafTuple (ZMod q)ˣ (n + 2)), + (∀ side, TreeNaturalLift (n + 2) (movingSlotValues value (n + 2) (bulk side)) (z side)) → + (movingModularSpectator value q (normalizedResidueTransform S) (D false) + (buildMovingSlotData (n + 2) (t false) (small false) (bulk false) (samples false)) + (A false) (B false) * + conj (movingModularSpectator value q (normalizedResidueTransform S) (D true) + (buildMovingSlotData (n + 2) (t true) (small true) (bulk true) (samples true)) + (A true) (B true))) = + (d false).value (normalizedResidueTransform S) (z false) * + conj ((d true).value (normalizedResidueTransform S) (z true))) ∧ + ‖(Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod q)ˣ) : ℂ)⁻¹ * + (∑ x : TreeLeafIndex (n + 2) × Fin m → (ZMod q)ˣ, + (d false).bulkValue (normalizedResidueTransform S) x * + conj ((d true).bulkValue (normalizedResidueTransform S) (x ∘ e.symm)))‖ ^ 2 ≤ + quartetTreeConstant n * (ε ^ 2 + Real.sqrt (3 / (q : ℝ))) := by + obtain ⟨d, hconj, hd⟩ := moving_field_pair_diagrams value (n + 2) t small samples + hfreq hsmall hsamples D A B + refine ⟨d, hd (normalizedResidueTransform S), ?_⟩ + let c := treeLeafTupleEquiv Bool n (transferConjugations n false) + apply normalized_spectator_bulk_comparison hq n m hm e hgood S hlo hhi hS hSq + β ε hε hε1 hprincipal hβ hbias (d false) (d true) c (fun j => !(c j)) + intro j + rw [hconj false] + simpa only [Bool.not_not] using transferConjugations_quartet n false j + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldDiagram.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldDiagram.lean new file mode 100644 index 0000000000000000000000000000000000000000..f85c1bbc069b7e6d88120afd9fed719279b99e6e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldDiagram.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFieldSpectator +import OAI.NumberTheory.Ostmann.Construction.SpectatorProductNorm + +namespace OAI + +/-! # Fixed diagrams for the separated modular spectator factors -/ + +namespace Ostmann +open scoped Classical ComplexConjugate + +/-- The diagram is chosen from the small slots and frequencies before any +bulk values or giant residues are supplied. -/ +theorem buildMovingSlotData_field_diagram {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (n : ℕ) (t : FrequencyTree ℤ n) + (small : TreeLeafTuple (List σ) n) (samples : MovingSampleSlots σ n) + (hfreq : movingGiantFrequencyUnits q n t) + (hsmall : ((treeLeafProduct n (movingSlotValues value n small) : ℕ) : ZMod q) ≠ 0) + (hsamples : (samples.values value).UnitsAt q) : + ∃ (U : (ZMod q)ˣ) (R : RationalTreeData (ZMod q)ˣ n U), + ∀ (g : ZMod q → ℂ) (D A B : (ZMod q)ˣ) + (bulk : TreeLeafTuple (List σ) n) (z : TreeLeafTuple (ZMod q)ˣ n), + TreeNaturalLift n (movingSlotValues value n bulk) z → + movingModularSpectator value q g D (buildMovingSlotData n t small bulk samples) A B = + rationalTreeAmplitude g D R A B (transferConjugations n false) z := by + let T := buildMovingGiantTree n t (movingSlotValues value n small) (samples.values value) + have hT : T.UnitsAt q := buildMovingGiantTree_units t _ _ hfreq hsmall hsamples + obtain ⟨U, R, _, _, hR⟩ := T.exists_field_diagram hT + refine ⟨U, R, ?_⟩ + intro g D A B bulk z hz + rw [buildMovingSlotData_modular_spectator value g D n t small bulk samples A B z hz] + exact hR g D A B z false + +theorem moving_field_pair_diagrams {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (n : ℕ) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List σ) n) (samples : Bool → MovingSampleSlots σ n) + (hfreq : ∀ side, movingGiantFrequencyUnits q n (t side)) + (hsmall : ∀ side, ((treeLeafProduct n (movingSlotValues value n (small side)) : ℕ) : ZMod q) ≠ 0) + (hsamples : ∀ side, ((samples side).values value).UnitsAt q) + (D A B : Bool → (ZMod q)ˣ) : + ∃ d : Bool → SpectatorDiagram q n, + (∀ side, (d side).conjugations = transferConjugations n false) ∧ + ∀ (g : ZMod q → ℂ) (bulk : Bool → TreeLeafTuple (List σ) n) + (z : Bool → TreeLeafTuple (ZMod q)ˣ n), + (∀ side, TreeNaturalLift n (movingSlotValues value n (bulk side)) (z side)) → + (movingModularSpectator value q g (D false) + (buildMovingSlotData n (t false) (small false) (bulk false) (samples false)) (A false) (B false) * + conj (movingModularSpectator value q g (D true) + (buildMovingSlotData n (t true) (small true) (bulk true) (samples true)) (A true) (B true))) = + (d false).value g (z false) * conj ((d true).value g (z true)) := by + have h side := buildMovingSlotData_field_diagram value n (t side) (small side) (samples side) + (hfreq side) (hsmall side) (hsamples side) + choose U R hR using h + let d (side : Bool) : SpectatorDiagram q n := + ⟨D side, U side, R side, A side, B side, transferConjugations n false⟩ + refine ⟨d, fun _ => rfl, ?_⟩ + intro g bulk z hz + rw [hR false g (D false) (A false) (B false) (bulk false) (z false) (hz false), + hR true g (D true) (A true) (B true) (bulk true) (z true) (hz true)] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldGiant.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldGiant.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd9f0a927d9620d6f293d8130a65c33bcd3743c5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldGiant.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantTree + +namespace OAI + +/-! # The actual moving-giant recursion directly over the spectator field -/ + +namespace Ostmann +open scoped Classical ComplexConjugate + +noncomputable def movingFieldGiantAmplitude {q : ℕ} [Fact q.Prime] + (g : ZMod q → ℂ) (D : (ZMod q)ˣ) : + {n C : ℕ} → MovingGiantTree n C → ZMod q → ZMod q → + TreeLeafTuple (ZMod q)ˣ n → ℂ + | _, _, .leaf s C, x, y, z => + g ((s : ZMod q) / ((D : ZMod q) * x * y * C * (show (ZMod q)ˣ from z))) + | n + 1, _, .node s CL CR u left right, x, y, z => + let v := reconstructedEntry (s : ZMod q) (left.frequency : ZMod q) + (right.frequency : ZMod q) (u : ZMod q) + (x * CL * (treeLeafProduct n z.1 : (ZMod q)ˣ)) + (y * CR * (treeLeafProduct n z.2 : (ZMod q)ˣ)) + if v = 0 then 0 else + movingFieldGiantAmplitude g D left v x z.1 * + conj (movingFieldGiantAmplitude g D right v y z.2) + +/-- This is a field identity on all bulk residues, so the later averaging +does not require an integer lift satisfying the original division tests. -/ +theorem MovingGiantTree.exists_field_diagram {q : ℕ} [Fact q.Prime] + {n C : ℕ} (T : MovingGiantTree n C) (hT : T.UnitsAt q) : + ∃ (U : (ZMod q)ˣ) (R : RationalTreeData (ZMod q)ˣ n U), + (C : ZMod q) = U ∧ (T.frequency : ZMod q) = R.frequency ∧ + ∀ (g : ZMod q → ℂ) (D A B : (ZMod q)ˣ) + (z : TreeLeafTuple (ZMod q)ˣ n) (b : Bool), + (if b then conj (movingFieldGiantAmplitude g D T A B z) + else movingFieldGiantAmplitude g D T A B z) = + rationalTreeAmplitude g D R A B (transferConjugations n b) z := by + induction T with + | leaf s C => + let S : (ZMod q)ˣ := Units.mk0 (s : ZMod q) hT.1 + let U : (ZMod q)ˣ := Units.mk0 (C : ZMod q) hT.2 + refine ⟨U, .leaf S U, rfl, rfl, ?_⟩ + intro g D A B z b + have he : (s : ZMod q) / ((D : ZMod q) * A * B * C * (show (ZMod q)ˣ from z)) = + (rationalTreeArgument S U D A B z : ZMod q) := by + simp only [rationalTreeArgument, Units.val_div_eq_div_val, Units.val_mul, + S, U, Units.val_mk0] + cases b <;> simp only [movingFieldGiantAmplitude, he, rationalTreeAmplitude, + transferConjugations, Bool.false_eq_true, ↓reduceIte, Complex.star_def] + | @node n s CL CR u left right ihL ihR => + obtain ⟨hs, hCL, hCR, hu, hl, hr⟩ := hT + let S : (ZMod q)ˣ := Units.mk0 (s : ZMod q) hs + let A₀ : (ZMod q)ˣ := Units.mk0 (CL : ZMod q) hCL + let B₀ : (ZMod q)ˣ := Units.mk0 (CR : ZMod q) hCR + let U₀ : (ZMod q)ˣ := Units.mk0 (u : ZMod q) hu + obtain ⟨UL, L, hUL, hfL, hL⟩ := ihL hl + obtain ⟨UR, R, hUR, hfR, hR⟩ := ihR hr + have eL : UL = U₀ * A₀ := by + apply Units.ext + simpa only [U₀, A₀, Units.val_mul, Units.val_mk0, Nat.cast_mul] using hUL.symm + have eR : UR = U₀ * B₀ := by + apply Units.ext + simpa only [U₀, B₀, Units.val_mul, Units.val_mk0, Nat.cast_mul] using hUR.symm + subst UL + subst UR + refine ⟨A₀ * B₀, .node S A₀ B₀ U₀ L R, ?_, rfl, ?_⟩ + · simp only [Nat.cast_mul, Units.val_mul, Units.val_mk0, A₀, B₀] + intro g D A B z b + let v := reconstructedEntry (s : ZMod q) (left.frequency : ZMod q) + (right.frequency : ZMod q) (u : ZMod q) + ((A : ZMod q) * CL * (treeLeafProduct n z.1 : (ZMod q)ˣ)) + ((B : ZMod q) * CR * (treeLeafProduct n z.2 : (ZMod q)ˣ)) + have hrec : reconstructedEntry (S : ZMod q) L.frequency R.frequency U₀ + ((A * A₀ * treeLeafProduct n z.1 : (ZMod q)ˣ) : ZMod q) + ((B * B₀ * treeLeafProduct n z.2 : (ZMod q)ˣ) : ZMod q) = v := by + simp only [v, hfL, hfR, S, U₀, A₀, B₀, Units.val_mul, Units.val_mk0] + by_cases hv : v = 0 + · cases b <;> simp only [movingFieldGiantAmplitude, show + reconstructedEntry (s : ZMod q) (left.frequency : ZMod q) (right.frequency : ZMod q) + (u : ZMod q) ((A : ZMod q) * CL * (treeLeafProduct n z.1 : (ZMod q)ˣ)) + ((B : ZMod q) * CR * (treeLeafProduct n z.2 : (ZMod q)ˣ)) = 0 from hv, + ↓reduceIte, map_zero, rationalTreeAmplitude, hrec, hv, Bool.false_eq_true, dite_true] + · let V : (ZMod q)ˣ := Units.mk0 v hv + have hleft := hL g D V A z.1 b + have hright := hR g D V B z.2 (!b) + have hV : Units.mk0 + (reconstructedEntry (S : ZMod q) L.frequency R.frequency U₀ + ((A * A₀ * treeLeafProduct n z.1 : (ZMod q)ˣ) : ZMod q) + ((B * B₀ * treeLeafProduct n z.2 : (ZMod q)ˣ) : ZMod q)) + (by rw [hrec]; exact hv) = V := Units.ext hrec + simp only [movingFieldGiantAmplitude, show + reconstructedEntry (s : ZMod q) (left.frequency : ZMod q) (right.frequency : ZMod q) + (u : ZMod q) ((A : ZMod q) * CL * (treeLeafProduct n z.1 : (ZMod q)ˣ)) + ((B : ZMod q) * CR * (treeLeafProduct n z.2 : (ZMod q)ˣ)) ≠ 0 from hv, + ↓reduceIte, rationalTreeAmplitude, transferConjugations] + rw [dite_eq_right (by rw [hrec]; exact hv), hV, ← hleft, ← hright] + cases b <;> simp [V, v] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldSpectator.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldSpectator.lean new file mode 100644 index 0000000000000000000000000000000000000000..b9fcd38d7b9f4f3e3e1bb55a4be9f2e9e9f01bf2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldSpectator.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFieldGiant +import OAI.NumberTheory.Ostmann.Arithmetic.MovingModularSpectator +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleSpectator + +namespace OAI + +/-! # The separated spectator factor on every field residue pair -/ + +namespace Ostmann +open scoped Classical + +@[simp] theorem MovingGiantTree.castConstant_fieldAmplitude {q : ℕ} [Fact q.Prime] + (g : ZMod q → ℂ) (D : (ZMod q)ˣ) {n C E : ℕ} (h : C = E) + (T : MovingGiantTree n C) (x y : ZMod q) (bulk : TreeLeafTuple (ZMod q)ˣ n) : + movingFieldGiantAmplitude g D (T.castConstant h) x y bulk = + movingFieldGiantAmplitude g D T x y bulk := by + subst E + rfl + +theorem buildMovingSlotData_modular_spectator {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (g : ZMod q → ℂ) (D : (ZMod q)ˣ) (n : ℕ) + (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) (x y : ZMod q) + (z : TreeLeafTuple (ZMod q)ˣ n) + (hz : TreeNaturalLift n (movingSlotValues value n bulk) z) : + movingModularSpectator value q g D (buildMovingSlotData n t small bulk samples) x y = + movingFieldGiantAmplitude g D + (buildMovingGiantTree n t (movingSlotValues value n small) (samples.values value)) x y z := by + induction samples generalizing x y with + | leaf => + change (MovingSlotReversal.naturalProduct value (show List σ from bulk) : ZMod q) = + (show (ZMod q)ˣ from z) at hz + simp only [buildMovingSlotData, movingModularSpectator, MovingSampleSlots.values, + buildMovingGiantTree, movingFieldGiantAmplitude, movingSlotValues, treeLeafProduct, + flattenMovingSlots, movingNaturalProduct_append, Nat.cast_mul, hz] + congr 2 + ring + | @node n samples left right ihL ihR => + change TreeNaturalLift n (movingSlotValues value n bulk.1) z.1 ∧ + TreeNaturalLift n (movingSlotValues value n bulk.2) z.2 at hz + let u := movingCompensationSlots n samples + let L := buildMovingSlotData n t.2.1 (appendMovingSlotLeaves n u small.1) bulk.1 left + let R := buildMovingSlotData n t.2.2 (appendMovingSlotLeaves n u small.2) bulk.2 right + let p := (MovingSlotData.step t.1 + (flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1) + (flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2) + (flattenMovingSlots n u) L R false).modularPivot value q x y + have hp : p = reconstructedEntry (t.1 : ZMod q) + ((frequencyRoot n t.2.1 : ℤ) : ZMod q) ((frequencyRoot n t.2.2 : ℤ) : ZMod q) + (treeLeafProduct n (compensationLeafProducts n (movingCompensationValues value n samples)) : ℕ) + (x * (treeLeafProduct n (movingSlotValues value n small.1) : ℕ) * + (treeLeafProduct n z.1 : (ZMod q)ˣ)) + (y * (treeLeafProduct n (movingSlotValues value n small.2) : ℕ) * + (treeLeafProduct n z.2 : (ZMod q)ˣ)) := by + simp only [p, L, R, MovingSlotReversal.modularPivot, MovingSlotData.step, + buildMovingSlotData_frequency, movingNaturalProduct_append, movingSlotValues_flatten, + reconstructedEntry, Nat.cast_mul] + rw [hz.1.product, hz.2.product, ← movingCompensationValues_product] + congr 1 + ring + have hL := ihL t.2.1 (appendMovingSlotLeaves n u small.1) bulk.1 p x z.1 hz.1 + have hR := ihR t.2.2 (appendMovingSlotLeaves n u small.2) bulk.2 p y z.2 hz.2 + change (if p = 0 then 0 else + movingModularSpectator value q g D L p x * star (movingModularSpectator value q g D R p y)) = _ + rw [hL, hR] + simp only [buildMovingGiantTree, MovingSampleSlots.values, movingSlotValues, + movingFieldGiantAmplitude, MovingGiantTree.castConstant_frequency, + buildMovingGiantTree_frequency, MovingGiantTree.castConstant_fieldAmplitude] + rw [← hp] + dsimp only [u] + rw [movingSlotValues_append, movingSlotValues_append, movingCompensationValues_product] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldUnitAverage.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldUnitAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..0902cb2357e7134217cc5c18e60de318b04d1f10 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFieldUnitAverage.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedAverages +import OAI.NumberTheory.Ostmann.Characters.AffineAction + +namespace OAI + +/-! # Exact restriction of a spectator's mixed average to unit pairs -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingModularSpectator_zero {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (g : ZMod q → ℂ) (hg : g 0 = 0) (D : (ZMod q)ˣ) + {n : ℕ} (T : MovingSlotData σ n) (x y : ZMod q) (hzero : x = 0 ∨ y = 0) : + movingModularSpectator value q g D T x y = 0 := by + induction T generalizing x y with + | leaf s regular => + rcases hzero with h | h <;> + simp only [movingModularSpectator, h, zero_mul, mul_zero, div_zero, hg] + | node s CL CR U left right ihL ihR => + simp only [movingModularSpectator] + split_ifs + · rfl + · rcases hzero with h | h + · rw [ihL _ _ (Or.inr h), zero_mul] + · rw [ihR _ _ (Or.inr h), star_zero, mul_zero] + +theorem movingSpectatorHaarAverage_eq_units {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (g : ZMod q → ℂ) (hg : g 0 = 0) (D : Bool → (ZMod q)ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) : + movingSpectatorHaarAverage value q g D T = + ((Fintype.card (ZMod q)ˣ : ℂ) / (q : ℂ)) * + ((Fintype.card ((ZMod q)ˣ × (ZMod q)ˣ) : ℂ)⁻¹ * + ∑ z : (ZMod q)ˣ × (ZMod q)ˣ, movingSpectatorPairFactor value q g D T z.1 z.2) := by + have hz (y : (ZMod q)ˣ) : movingSpectatorPairFactor value q g D T 0 y = 0 := by + rw [movingSpectatorPairFactor, movingModularSpectator_zero value g hg (D false) (T false) + 0 y (Or.inl rfl), zero_mul] + have hs : (∑ z : ZMod q × (ZMod q)ˣ, movingSpectatorPairFactor value q g D T z.1 z.2) = + ∑ z : (ZMod q)ˣ × (ZMod q)ˣ, movingSpectatorPairFactor value q g D T z.1 z.2 := by + simp only [Fintype.sum_prod_type] + rw [Finset.sum_comm, Finset.sum_comm (f := fun x y : (ZMod q)ˣ => + movingSpectatorPairFactor value q g D T x y)] + apply Finset.sum_congr rfl + intro y _ + exact (sum_units_eq_sum_of_zero (fun x => movingSpectatorPairFactor value q g D T x y) (hz y)).symm + have hq : (q : ℂ) ≠ 0 := by exact_mod_cast (Fact.out : q.Prime).ne_zero + have hu : (Fintype.card (ZMod q)ˣ : ℂ) ≠ 0 := by + exact_mod_cast (Fintype.card_ne_zero : Fintype.card (ZMod q)ˣ ≠ 0) + simp only [movingSpectatorHaarAverage, hs, Fintype.card_prod, ZMod.card, Nat.cast_mul] + field_simp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFinalGap.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFinalGap.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3dfc6a32d9ed40db17b6e41c2d699d9ff9cf12d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFinalGap.lean @@ -0,0 +1,41 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Asymptotics +import OAI.NumberTheory.Ostmann.Construction.DiagonalGapBudget + +namespace OAI + +/-! # The polynomial bulk scale leaves a strict final overlap margin -/ + +namespace Ostmann +open Filter Asymptotics + +/-- At the manuscript's scale `z = k^4`, every fixed logarithmic cost is +smaller than any fixed positive multiple of `log (2^k)`. -/ +theorem eventually_polynomial_scale_log_margin (B C δ : ℝ) (hδ : 0 < δ) : + ∀ᶠ k : ℕ in atTop, + B + C * Real.log ((k : ℝ) ^ 4) < δ * Real.log ((2 : ℝ) ^ k) := by + have hlog := (((Real.isLittleO_log_id_atTop.const_mul_left (4 * C)).add + (isLittleO_const_id_atTop B)).bound + (by positivity : 0 < δ * Real.log 2 / 2)) + filter_upwards [(tendsto_natCast_atTop_atTop (R := ℝ)).eventually hlog, + eventually_ge_atTop (1 : ℕ)] with k hk hk1 + have hk0 : (0 : ℝ) < k := by exact_mod_cast hk1 + simp only [Real.norm_eq_abs, id_eq, abs_of_pos hk0] at hk + rw [Real.log_pow, Real.log_pow] + norm_num only [Nat.cast_ofNat] + have h := (le_abs_self _).trans hk + have hpos : 0 < δ * Real.log 2 * (k : ℝ) := by positivity + nlinarith + +/-- The `3/4` bad-arrangement saving dominates the `2/5` cutoff exponent, +with the full base-gap and fixed logarithmic costs of (9.8). -/ +theorem eventually_moving_final_gap (Bs BD Bz C B : ℝ) : + ∀ᶠ k : ℕ in atTop, + BD + 2 * Bs + (Bz + 16) * Real.log ((k : ℝ) ^ 4) + C + 2 * B + 2 < + (7 / 20 : ℝ) * Real.log ((2 : ℝ) ^ k) := by + filter_upwards [eventually_polynomial_scale_log_margin (BD + 2 * Bs + C + 2 * B + 2) + (Bz + 16) (7 / 20) (by norm_num)] with k hk + linarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFinalRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFinalRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..b00a8f47b6a44ec790b9a1dfa5fb5951d2f6d7cd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFinalRate.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyBudget +import OAI.NumberTheory.Ostmann.Arithmetic.MovingStatisticDecay + +namespace OAI + +/-! # Specializing the final decay to the actual frequency rate -/ + +namespace Ostmann +open Filter + +theorem eventually_moving_frequency_rate_margin (Bs BD Bz B : ℝ) : + ∀ᶠ k : ℕ in atTop, + movingFrequencyRate Bs BD Bz ((k : ℝ) ^ 4) k + + (2 : ℝ) ^ k * (-(3 / 4 : ℝ) * Real.log ((2 : ℝ) ^ k) + 5 / 4) + + ((2 : ℝ) ^ k * (Bs + 8 * Real.log ((k : ℝ) ^ 4)) + + (Real.log 12 + 1) * (2 : ℝ) ^ k + 1) < + -((2 * B + 1) * (2 : ℝ) ^ k) := by + filter_upwards [eventually_moving_final_gap Bs BD Bz (Real.log 12 + 21 / 4) B] with k hk + have hr : 1 ≤ (2 : ℝ) ^ k := one_le_pow₀ (by norm_num) + have hh := mul_lt_mul_of_pos_left hk (show 0 < (2 : ℝ) ^ k by positivity) + unfold movingFrequencyRate + nlinarith only [hh, hr] + +theorem bulk_exponential_lower_contradicts_decay (B r m : ℝ) (hm : 0 < m) (hr : 0 < r) + (η : ℂ) (hlower : Real.exp (-B * r * m) ≤ ‖η‖) + (hupper : ‖η‖ ^ 2 ≤ Real.exp (-((2 * B + 1) * r) * m)) : False := by + have hs := pow_le_pow_left₀ (Real.exp_pos (-B * r * m)).le hlower 2 + have heq : Real.exp (-B * r * m) ^ 2 = Real.exp (-(2 * B * r) * m) := by + rw [pow_two, ← Real.exp_add] + congr 1 + ring + rw [heq] at hs + have hlt : Real.exp (-((2 * B + 1) * r) * m) < Real.exp (-(2 * B * r) * m) := + Real.exp_lt_exp.mpr (by nlinarith [mul_pos hr hm]) + exact (not_lt_of_ge (hs.trans hupper)) hlt + +/-- The precise numerical upper bound already proved for the selected-prior +statistic contradicts the lower bound preserved by the transfer iteration. -/ +theorem eventually_moving_numeric_contradiction (Bs BD Bz B C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ k : ℕ in atTop, ∀ᶠ L : ℝ in atTop, + let m := spectatorBulkCount k L + let r : ℝ := (2 : ℝ) ^ k + let z : ℝ := (k : ℝ) ^ 4 + let A := movingFrequencyRate Bs BD Bz z k + let D := Bs + 8 * Real.log z + ∀ V : ℕ, (V : ℝ) ≤ Real.exp (A * m) → 0 ≤ A → + ∀ Δ : ℝ, Δ ≤ D * m → ∀ η : ℂ, + Real.exp (-B * r * m) ≤ ‖η‖ → + ‖η‖ ^ 2 ≤ C * (2 * V + 1 : ℕ) * Real.exp 2 * + (((((2 ^ k + 1) * (2 ^ k) ^ (2 * 2 ^ k) : ℕ) : ℝ)) * + Real.exp (r * m * (-(3 / 4 : ℝ) * Real.log ((2 : ℝ) ^ k) + 5 / 4)) * + (Real.exp (r * Δ + (Real.log 12 + 1) * r * m + m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-(A + (2 * B + 1) * r + 1) * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) → False := by + filter_upwards [eventually_moving_frequency_rate_margin Bs BD Bz B, + eventually_ge_atTop (1 : ℕ)] with k hmargin hk + let A := movingFrequencyRate Bs BD Bz ((k : ℝ) ^ 4) k + by_cases hA : 0 ≤ A + · have hd := eventually_moving_statistic_decay_with_base k hk ((2 : ℝ) ^ k) C + (((2 ^ k + 1) * (2 ^ k) ^ (2 * 2 ^ k) : ℕ) : ℝ) A + (-(3 / 4 : ℝ) * Real.log ((2 : ℝ) ^ k) + 5 / 4) + (Bs + 8 * Real.log ((k : ℝ) ^ 4)) 1 (A + (2 * B + 1) * (2 : ℝ) ^ k + 1) + ((2 * B + 1) * (2 : ℝ) ^ k) (by positivity) hC (by positivity) hA hmargin (by dsimp only [A]; linarith) + filter_upwards [hd, (spectatorBulkCount_tendsto k hk).eventually (eventually_gt_atTop (0 : ℝ))] + with L hd hm + dsimp only + intro V hV _ Δ hΔ η hlower hupper + apply bulk_exponential_lower_contradicts_decay B ((2 : ℝ) ^ k) + (spectatorBulkCount k L) hm (by positivity) η hlower + apply hd V hV Δ hΔ η + simpa only [one_mul] using hupper + · exact Filter.Eventually.of_forall (fun L V _ hA' => (hA hA').elim) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFirstExtendedWindows.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFirstExtendedWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..73afa1a5ff512a95f948d39abef372ea20326da1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFirstExtendedWindows.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInitialCoefficient + +namespace OAI + +/-! # Both terminal windows survive extension of the outer giants to integers -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- A nonzero first node contains a nonzero pair of terminal coefficients, even +when either outer giant has been extended to a positive integer. All original +cross-branch support tests stay inside the selected summand. -/ +theorem movingFrequencyCoefficient_one_extended_children {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (s : ℤ) + (small bulk : List σ × List σ) (XL XR : ℕ) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G + 1 s small bulk XL XR ≠ 0) : + ∃ (a : Fin 4 → σ) (v w : transferFrequencyRange (V 0)), + let u := List.ofFn a + let p := movingTopPivot value (small.1 ++ bulk.1) (small.2 ++ bulk.2) + u XL XR s v.val w.val + movingCompensationPrior (μ 0) 0 a ≠ 0 ∧ 0 < p ∧ + 0 < MovingSlotReversal.naturalProduct value u ∧ + φ (Real.log p - G 1) ≠ 0 ∧ + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G 0 v.val + (u ++ small.1) bulk.1 p XL ≠ 0 ∧ + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G 0 w.val + (u ++ small.2) bulk.2 p XR ≠ 0 := by + rw [movingFrequencyCoefficient_node value outside μ childBound pivotBound V F φ G + 0 s small bulk XL XR] at h + obtain ⟨v, _, hv⟩ := Finset.exists_ne_zero_of_sum_ne_zero h + obtain ⟨w, _, hw⟩ := Finset.exists_ne_zero_of_sum_ne_zero hv + obtain ⟨a, _, ha⟩ := Finset.exists_ne_zero_of_sum_ne_zero hw + dsimp only at ha + have hm : movingCompensationPrior (μ 0) 0 a ≠ 0 := by + intro hz + exact ha (by rw [hz, Complex.ofReal_zero, zero_mul]) + have hb := right_ne_zero_of_mul ha + split_ifs at hb with hg + · have hpos := hg.2.1.pivot_pos + have hp : 0 < movingTopPivot value (small.1 ++ bulk.1) (small.2 ++ bulk.2) + (List.ofFn a) XL XR s v.val w.val := Nat.pos_of_mul_pos_right hpos + have hphi : φ (Real.log (movingTopPivot value (small.1 ++ bulk.1) + (small.2 ++ bulk.2) (List.ofFn a) XL XR s v.val w.val) - G 1) ≠ 0 := by + intro hz + apply left_ne_zero_of_mul (left_ne_zero_of_mul hb) + change (((MovingSlotReversal.naturalProduct value (List.ofFn a) : ℝ) * + φ (Real.log (movingTopPivot value (small.1 ++ bulk.1) (small.2 ++ bulk.2) + (List.ofFn a) XL XR s v.val w.val) - G 1) : ℝ) : ℂ) = 0 + rw [hz, mul_zero, Complex.ofReal_zero] + refine ⟨a, v, w, hm, hp, hg.2.2, hphi, ?_, ?_⟩ + · rw [movingFrequencyCoefficient_levelZero_sample] + exact right_ne_zero_of_mul (left_ne_zero_of_mul hb) + · rw [movingFrequencyCoefficient_levelZero_sample] + exact star_ne_zero.mp (right_ne_zero_of_mul hb) + · exact (hb rfl).elim + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFirstNodeWindows.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFirstNodeWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..28fac0fc21587d8f3c48d06594ff58290728be48 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFirstNodeWindows.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInitialCoefficient + +namespace OAI + +/-! # The first recursive node retains both original terminal windows -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingPrimeNodeFactor_support {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (CL CR u : List σ) (XL XR : ℕ) (s v w : ℤ) + (h : movingPrimeNodeFactor value outside childBound pivotBound φ G n CL CR u + XL XR s v w ≠ 0) : + 0 < movingTopPivot value CL CR u XL XR s v w ∧ + 0 < MovingSlotReversal.naturalProduct value u ∧ + φ (Real.log (movingTopPivot value CL CR u XL XR s v w) - G (n + 1)) ≠ 0 := by + unfold movingPrimeNodeFactor at h + dsimp only at h + split_ifs at h with hg + · have hp : 0 < movingTopPivot value CL CR u XL XR s v w * + MovingSlotReversal.naturalProduct value u := hg.2.1.2.2.2.1 + refine ⟨(Nat.pos_of_mul_pos_right hp), hg.2.2, ?_⟩ + intro hz + exact h (by simp only [hz, mul_zero, Complex.ofReal_zero]) + · exact (h rfl).elim + +theorem movingFrequencyCoefficient_one_children {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (s : ℤ) (hs : s ≠ 0) (hsV : s.natAbs ≤ V 1) + (small bulk : List σ × List σ) (XL XR : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) (hVL : V 1 < XL) (hVR : V 1 < XR) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G + 1 s small bulk XL XR ≠ 0) : + ∃ (a : Fin 4 → σ) (v w : transferFrequencyRange (V 0)), + let u := List.ofFn a + let CL := small.1 ++ bulk.1 + let CR := small.2 ++ bulk.2 + let p := movingTopPivot value CL CR u XL XR s v.val w.val + movingCompensationPrior (μ 0) 0 a ≠ 0 ∧ + movingPrimeNodeFactor value outside childBound pivotBound φ G 0 CL CR u + XL XR s v.val w.val ≠ 0 ∧ + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G 0 v.val + (u ++ small.1) bulk.1 p XL ≠ 0 ∧ + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G 0 w.val + (u ++ small.2) bulk.2 p XR ≠ 0 := by + rw [movingFrequencyCoefficient_prime_node value outside μ childBound pivotBound V hV F hF + φ G 0 s hs hsV small bulk XL XR hXL hXR hVL hVR] at h + obtain ⟨a, _, ha⟩ := Finset.exists_ne_zero_of_sum_ne_zero h + have hprior : movingCompensationPrior (μ 0) 0 a ≠ 0 := by + intro hz + exact ha (by rw [hz, Complex.ofReal_zero, zero_mul]) + obtain ⟨v, _, hv⟩ := Finset.exists_ne_zero_of_sum_ne_zero (right_ne_zero_of_mul ha) + obtain ⟨w, _, hw⟩ := Finset.exists_ne_zero_of_sum_ne_zero hv + refine ⟨a, v, w, hprior, ?_, ?_, ?_⟩ + · exact left_ne_zero_of_mul (left_ne_zero_of_mul hw) + · exact right_ne_zero_of_mul (left_ne_zero_of_mul hw) + · exact star_ne_zero.mp (right_ne_zero_of_mul hw) + +theorem movingFrequencyCoefficient_one_window_witness {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hX : 0 < X) + (hF : ∀ x, movingOriginalLeaf value q F g Dq S ψ X lo hi x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (s : ℤ) (hs : s ≠ 0) (hsV : s.natAbs ≤ V 1) + (small bulk : List σ × List σ) (XL XR : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) (hVL : V 1 < XL) (hVR : V 1 < XR) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G 1 s small bulk XL XR ≠ 0) : + ∃ (a : Fin 4 → σ) (v w : transferFrequencyRange (V 0)), + let u := List.ofFn a + let CL := small.1 ++ bulk.1 + let CR := small.2 ++ bulk.2 + let p := movingTopPivot value CL CR u XL XR s v.val w.val + movingCompensationPrior (μ 0) 0 a ≠ 0 ∧ 0 < p ∧ + 0 < MovingSlotReversal.naturalProduct value u ∧ + φ (Real.log p - G 1) ≠ 0 ∧ + (X * lo ≤ (p * XL * MovingSlotReversal.naturalProduct value ((u ++ small.1) ++ bulk.1) : ℕ) ∧ + ((p * XL * MovingSlotReversal.naturalProduct value ((u ++ small.1) ++ bulk.1) : ℕ) : ℝ) ≤ X * hi) ∧ + (X * lo ≤ (p * XR * MovingSlotReversal.naturalProduct value ((u ++ small.2) ++ bulk.2) : ℕ) ∧ + ((p * XR * MovingSlotReversal.naturalProduct value ((u ++ small.2) ++ bulk.2) : ℕ) : ℝ) ≤ X * hi) := by + obtain ⟨a, v, w, hm, hn, hl, hr⟩ := movingFrequencyCoefficient_one_children value outside μ + childBound pivotBound V hV (movingOriginalLeaf value q F g Dq S ψ X lo hi) hF + φ G s hs hsV small bulk XL XR hXL hXR hVL hVR h + have hnode := movingPrimeNodeFactor_support value outside childBound pivotBound φ G 0 + (small.1 ++ bulk.1) (small.2 ++ bulk.2) (List.ofFn a) XL XR s v.val w.val hn + refine ⟨a, v, w, hm, hnode.1, hnode.2.1, hnode.2.2, ?_, ?_⟩ + · exact movingFrequencyCoefficient_initial_window value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi hX φ G v.val _ _ _ _ hl + · exact movingFrequencyCoefficient_initial_window value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi hX φ G w.val _ _ _ _ hr + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFirstProductBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFirstProductBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..3fb832e59f7faaa788ede5876c2298041efa6ee5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFirstProductBound.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFirstExtendedWindows + +namespace OAI + +/-! # The first recursive product bound from the two original windows -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- Nonzero first-level coefficients retain both terminal windows. Removing the +shared inner pivot from each gives a bound on the full current product. -/ +theorem movingFrequencyCoefficient_one_product_bound {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi lower : ℝ) (hX : 0 < X) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (hmin : ∀ a : Fin 4 → σ, movingCompensationPrior (μ 0) 0 a ≠ 0 → + ∀ p : ℕ, 0 < p → φ (Real.log p - G 1) ≠ 0 → + lower ≤ (p * MovingSlotReversal.naturalProduct value (List.ofFn a) : ℕ)) + (H : ℕ) (hcap : X * hi ≤ lower * H) + (s : ℤ) + (small bulk : List σ × List σ) (XL XR : ℕ) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G 1 s small bulk XL XR ≠ 0) : + (XL * MovingSlotReversal.naturalProduct value (small.1 ++ bulk.1)) * + (XR * MovingSlotReversal.naturalProduct value (small.2 ++ bulk.2)) ≤ H ^ 2 := by + obtain ⟨a, v, w, hm, hp, hU, hphi, hl, hr⟩ := + movingFrequencyCoefficient_one_extended_children value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G s small bulk XL XR h + let p := movingTopPivot value (small.1 ++ bulk.1) (small.2 ++ bulk.2) + (List.ofFn a) XL XR s v.val w.val + have hlow := hmin a hm p hp hphi + have hleft := movingFrequencyCoefficient_initial_retained_bound value outside μ + childBound pivotBound V q F g Dq S ψ X lo hi lower hX φ G v.val (List.ofFn a) + small.1 bulk.1 p XL H hp hU hlow hcap hl + have hright := movingFrequencyCoefficient_initial_retained_bound value outside μ + childBound pivotBound V q F g Dq S ψ X lo hi lower hX φ G w.val (List.ofFn a) + small.2 bulk.2 p XR H hp hU hlow hcap hr + simpa only [pow_two] using Nat.mul_le_mul hleft hright + +theorem movingFrequencyCoefficient_one_retained_bound {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi lower : ℝ) (hX : 0 < X) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (hmin : ∀ a : Fin 4 → σ, movingCompensationPrior (μ 0) 0 a ≠ 0 → + ∀ p : ℕ, 0 < p → φ (Real.log p - G 1) ≠ 0 → + lower ≤ (p * MovingSlotReversal.naturalProduct value (List.ofFn a) : ℕ)) + (H : ℕ) (hcap : X * hi ≤ lower * H) + (s : ℤ) + (comp small bulk : List σ × List σ) (XL XR K : ℕ) + (hp : 0 < XL) + (hcomp : 0 < MovingSlotReversal.naturalProduct value (comp.1 ++ comp.2)) + (outerLower : ℝ) + (houter : outerLower ≤ (XL * MovingSlotReversal.naturalProduct value (comp.1 ++ comp.2) : ℕ)) + (hK : ((H ^ 2 : ℕ) : ℝ) ≤ outerLower * K) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G 1 s (comp.1 ++ small.1, comp.2 ++ small.2) bulk XL XR ≠ 0) : + XR * MovingSlotReversal.naturalProduct value + ((small.1 ++ bulk.1) ++ (small.2 ++ bulk.2)) ≤ K := by + have hb := movingFrequencyCoefficient_one_product_bound value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi lower hX φ G hmin H hcap s + (comp.1 ++ small.1, comp.2 ++ small.2) bulk XL XR h + have hid : + (XL * MovingSlotReversal.naturalProduct value ((comp.1 ++ small.1) ++ bulk.1)) * + (XR * MovingSlotReversal.naturalProduct value ((comp.2 ++ small.2) ++ bulk.2)) = + (XL * MovingSlotReversal.naturalProduct value (comp.1 ++ comp.2)) * + (XR * MovingSlotReversal.naturalProduct value + ((small.1 ++ bulk.1) ++ (small.2 ++ bulk.2))) := by + simp only [movingNaturalProduct_append] + ring + change (XL * MovingSlotReversal.naturalProduct value ((comp.1 ++ small.1) ++ bulk.1)) * + (XR * MovingSlotReversal.naturalProduct value ((comp.2 ++ small.2) ++ bulk.2)) ≤ H ^ 2 at hb + rw [hid] at hb + have hbR : ((XL * MovingSlotReversal.naturalProduct value (comp.1 ++ comp.2) : ℕ) : ℝ) * + (XR * MovingSlotReversal.naturalProduct value + ((small.1 ++ bulk.1) ++ (small.2 ++ bulk.2)) : ℕ) ≤ ((H ^ 2 : ℕ) : ℝ) := by + exact_mod_cast hb + have hcR : (0 : ℝ) < (XL * MovingSlotReversal.naturalProduct value (comp.1 ++ comp.2) : ℕ) := by + exact_mod_cast Nat.mul_pos hp hcomp + have ht := hbR.trans (hK.trans (mul_le_mul_of_nonneg_right houter (Nat.cast_nonneg K))) + exact_mod_cast (mul_le_mul_iff_right₀ hcR).mp ht + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFormulaNodes.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFormulaNodes.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5fff1a93824f65f333d2aa5373e5dcef0cb2364 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFormulaNodes.lean @@ -0,0 +1,108 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantFormulas + +namespace OAI + +/-! # All rational node formulas of the concrete moving sampler -/ + +namespace Ostmann +open scoped Classical + +structure MovingFormulaNode where + guard : WordTransferGuard Bool + newGiant : HistoryFormula Bool + +noncomputable def MovingSlotData.formulaNodes {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) : + {n : ℕ} → (T : MovingSlotData σ n) → T.Frequencies (· ≠ 0) → + HistoryFormula Bool → HistoryFormula Bool → List MovingFormulaNode + | _, .leaf _ _, _, _, _ => [] + | n + 1, .node s CL CR u left right, hf, L, R => + let step := MovingSlotData.step s CL CR u left right false + let P := step.giantFormula value hf.1 + (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) L R + { guard := movingNodeGuard (MovingSlotReversal.naturalProduct value CL) + (MovingSlotReversal.naturalProduct value CR) s left.frequency right.frequency hf.1 + (childBound (n + 1)) (pivotBound (n + 1)) L R + newGiant := P } :: + (left.formulaNodes value hvalue childBound pivotBound hf.2.1 P L ++ + right.formulaNodes value hvalue childBound pivotBound hf.2.2 P R) + +theorem MovingSlotData.formulaNodes_length {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (L R : HistoryFormula Bool) : + (T.formulaNodes value hvalue childBound pivotBound hf L R).length = 2 ^ n - 1 := by + induction T generalizing L R with + | leaf s regular => rfl + | @node n s CL CR u left right ihL ihR => + simp only [formulaNodes, List.length_cons, List.length_append, ihL, ihR, pow_succ] + have := Nat.one_le_two_pow (n := n) + omega + +/-- Every node formula is constructed before the top giants are evaluated. +Nonzero original coefficients imply all its exact arithmetic guard and +compensation-integrality tests, including both recursive branches. -/ +theorem movingSlotWeight_formulaNodes {σ : Type*} + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hf : T.Frequencies (· ≠ 0)) (XL XR : ℕ) (L R : HistoryFormula Bool) (a : Bool → ℤ) + (hL : L.value (fun b => (a b : ℚ)) = (XL : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (XR : ℚ)) + (hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t ≠ 0) : + ∀ f ∈ T.formulaNodes value hvalue childBound pivotBound hf L R, + f.guard.ValidAt a ∧ f.newGiant.IntegralAt a := by + let sys := movingSlotSystem value childBound pivotBound + let cutoff := movingSlotCutoff value childBound pivotBound extra + induction T generalizing XL XR L R with + | leaf s regular => simp [MovingSlotData.formulaNodes] + | @node n s CL CR u left right ihL ihR => + let x : MovingSlotState σ := ⟨n + 1, .node s CL CR u left right, XL, XR⟩ + let step := MovingSlotData.step s CL CR u left right false + let p := step.naturalPivot value XL XR + let G := step.giantFormula value hf.1 + (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) L R + have hI := movingSlotWeight_nonzero_integral value childBound pivotBound F extra + (.node s CL CR u left right) t hT XL XR hw + have hG : G.value (fun b => (a b : ℚ)) = (p : ℚ) := + step.giantFormula_value value hf.1 (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) + L R a XL XR hL hR hI.1 + have hGI : G.IntegralAt a := ⟨(p : ℤ), by simpa only [Int.cast_natCast] using hG⟩ + obtain ⟨Q, hQ, _, _⟩ := recursiveTransferWeight_nonzero_valid sys F cutoff (n + 1) x t hw + have hQ' : ValidTransferNode sys x s left.frequency right.frequency Q := by + simpa only [← hT.1, ← hT.2.1.root, ← hT.2.2.root] using hQ + have hg := (movingNodeGuard_iff value childBound pivotBound s CL CR u left right hf.1 + XL XR L R a hL hR).mpr ⟨Q, hQ'⟩ + have hQp : Q / MovingSlotReversal.naturalProduct value u = p := by + rw [← hQ.historyPivot_eq] + simp only [historyPivot, sys, movingSlotSystem, MovingSlotState.leftProduct, + MovingSlotState.rightProduct, x, ← hT.1, ← hT.2.1.root, ← hT.2.2.root, + p, step, MovingSlotReversal.naturalPivot, MovingSlotData.step, movingGiantPivot, Nat.mul_one] + have hnode := recursiveTransferWeight_node sys F cutoff n x t Q hQ + have hnL : recursiveTransferWeight sys F cutoff n ⟨n, left, p, XL⟩ t.2.1 ≠ 0 := by + intro hz + apply hw + rw [hnode] + change (cutoff x t.1 _ _ : ℂ) * recursiveTransferWeight sys F cutoff n + ⟨n, left, Q / _, XL⟩ t.2.1 * _ = 0 + rw [hQp, hz, mul_zero, zero_mul] + have hnR : recursiveTransferWeight sys F cutoff n ⟨n, right, p, XR⟩ t.2.2 ≠ 0 := by + intro hz + apply hw + rw [hnode] + change _ * star (recursiveTransferWeight sys F cutoff n ⟨n, right, Q / _, XR⟩ t.2.2) = 0 + rw [hQp, hz, star_zero, mul_zero] + have hl := ihL t.2.1 hT.2.1 hf.2.1 p XL G L hG hL hnL + have hr := ihR t.2.2 hT.2.2 hf.2.2 p XR G R hG hR hnR + intro f hmem + rcases List.mem_cons.mp hmem with h | h + · subst f + exact ⟨hg, hGI⟩ + · rcases List.mem_append.mp h with h | h + · exact hl f h + · exact hr f h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..321d506516af4dfaa91a5dc2ab07990d642fa39f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierBudget.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFourierVariation +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticErrorRates + +namespace OAI + +/-! # Fixed-depth cost of the constructed Fourier variation bound -/ + +namespace Ostmann +open scoped SchwartzMap + +/-- Frequencies of size exp(O(m)) give a variation cost exp(O(m)). The +constant is chosen before the bulk size and both top giant coordinates. -/ +theorem movingFourierVariationBudget_exp (ψ : 𝓢(ℝ, ℂ)) (n : ℕ) + (A lo hi : ℝ) (hA : 0 ≤ A) (hhi : lo ≤ hi) : + ∃ C : ℝ, 0 < C ∧ ∀ m : ℝ, 0 ≤ m → + movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n ≤ Real.exp (C * (m + 1)) := by + let B := SchwartzMap.seminorm ℝ 0 0 ψ + let D := SchwartzMap.seminorm ℝ 0 1 ψ + let W := hi - lo + let K := 2 * B + B * W + D * W + let r : ℝ := (2 ^ n : ℕ) + have hB : 0 ≤ B := (norm_nonneg (ψ 0)).trans (ψ.norm_le_seminorm ℝ 0) + have hD : 0 ≤ D := schwartz_profile_lip_nonneg ψ + have hW : 0 ≤ W := sub_nonneg.mpr hhi + have hK : 0 ≤ K := by dsimp only [K]; positivity + have hr : 0 < r := by dsimp only [r]; positivity + refine ⟨r * (K + A + 1), by positivity, ?_⟩ + intro m hm + have hE : 1 ≤ Real.exp (A * m) := Real.one_le_exp_iff.mpr (mul_nonneg hA hm) + have hpoly : 2 * B + (B + D * Real.exp (A * m)) * W ≤ K * Real.exp (A * m) := by + have := mul_nonneg (show 0 ≤ 2 * B + B * W by positivity) (sub_nonneg.mpr hE) + dsimp only [K] + nlinarith + have hKe : K ≤ Real.exp K := by linarith [Real.add_one_le_exp K] + have hbase : 2 * B + (B + D * Real.exp (A * m)) * W ≤ Real.exp (K + A * m) := by + rw [Real.exp_add] + exact hpoly.trans (mul_le_mul_of_nonneg_right hKe (Real.exp_pos _).le) + unfold movingFourierVariationBudget + change (2 * B + (B + D * Real.exp (A * m)) * W) ^ (2 ^ n) ≤ _ + apply (pow_le_pow_left₀ (by positivity) hbase (2 ^ n)).trans + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + change r * (K + A * m) ≤ r * (K + A + 1) * (m + 1) + have hKm := mul_nonneg hK hm + nlinarith + +/-- Uniform in moving endpoints whose width has the actual exponential scale. -/ +theorem movingFourierVariationBudget_exp_window (ψ : 𝓢(ℝ, ℂ)) (n : ℕ) + (A H : ℝ) (hA : 0 ≤ A) (hH : 0 ≤ H) : + ∃ C : ℝ, 0 < C ∧ ∀ m : ℝ, 0 ≤ m → ∀ lo hi : ℝ, lo ≤ hi → + hi - lo ≤ Real.exp (H * m) → + movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n ≤ + Real.exp (C * (m + 1)) := by + let B := SchwartzMap.seminorm ℝ 0 0 ψ + let D := SchwartzMap.seminorm ℝ 0 1 ψ + let K := 3 * B + D + let r : ℝ := (2 ^ n : ℕ) + have hB : 0 ≤ B := (norm_nonneg (ψ 0)).trans (ψ.norm_le_seminorm ℝ 0) + have hD : 0 ≤ D := schwartz_profile_lip_nonneg ψ + have hK : 0 ≤ K := by dsimp only [K]; positivity + have hr : 0 < r := by dsimp only [r]; positivity + refine ⟨r * (K + A + H + 1), by positivity, ?_⟩ + intro m hm lo hi hhi hwidth + have heA : 1 ≤ Real.exp (A * m) := Real.one_le_exp_iff.mpr (mul_nonneg hA hm) + have heH : 1 ≤ Real.exp (H * m) := Real.one_le_exp_iff.mpr (mul_nonneg hH hm) + have heAll : Real.exp (A * m) * Real.exp (H * m) = Real.exp ((A + H) * m) := by + rw [← Real.exp_add] + congr 1 + ring + have hproduct : 1 ≤ Real.exp (A * m) * Real.exp (H * m) := + heH.trans (le_mul_of_one_le_left (Real.exp_nonneg _) heA) + have hHproduct : Real.exp (H * m) ≤ Real.exp (A * m) * Real.exp (H * m) := + le_mul_of_one_le_left (Real.exp_nonneg _) heA + have hpoly : 2 * B + (B + D * Real.exp (A * m)) * (hi - lo) ≤ + K * Real.exp ((A + H) * m) := by + calc + _ ≤ 2 * B + (B + D * Real.exp (A * m)) * Real.exp (H * m) := by gcongr + _ ≤ K * (Real.exp (A * m) * Real.exp (H * m)) := by + dsimp only [K] + nlinarith [mul_le_mul_of_nonneg_left hproduct hB, + mul_le_mul_of_nonneg_left hHproduct hB] + _ = _ := by rw [heAll] + have hKe : K ≤ Real.exp K := by linarith [Real.add_one_le_exp K] + have hbase : 2 * B + (B + D * Real.exp (A * m)) * (hi - lo) ≤ + Real.exp (K + (A + H) * m) := by + rw [Real.exp_add] + exact hpoly.trans (mul_le_mul_of_nonneg_right hKe (Real.exp_nonneg _)) + unfold movingFourierVariationBudget + change (2 * B + (B + D * Real.exp (A * m)) * (hi - lo)) ^ (2 ^ n) ≤ _ + apply (pow_le_pow_left₀ (by positivity) hbase (2 ^ n)).trans + rw [← Real.exp_nat_mul] + apply Real.exp_le_exp.mpr + change r * (K + (A + H) * m) ≤ r * (K + A + H + 1) * (m + 1) + nlinarith [mul_nonneg hK hm] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..a25138766911a5b11c45f32e78532fc33f824b58 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierFactor.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantArchimedean + +namespace OAI + +/-! # Polynomial smooth factors in the full moving-giant coefficient -/ + +namespace Ostmann +open scoped Classical ComplexConjugate + +noncomputable def movingFourierLeaf {σ : Type*} (value : σ → ℕ) + (ψ : ℝ → ℂ) (X : ℝ) (x : MovingSlotState σ) (s : ℤ) : ℂ := + normalizedFourierProfile ψ s ((movingSlotModulus value x : ℝ) / X) + +noncomputable def movingFourierTree {σ : Type*} (value : σ → ℕ) (ψ : ℝ → ℂ) (X : ℝ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → ℂ + | _, .leaf s regular, XL, XR => + normalizedFourierProfile ψ s + ((XL * XR * MovingSlotReversal.naturalProduct value regular : ℕ) / X) + | _, .node s CL CR u left right, XL, XR => + let p := (MovingSlotData.step s CL CR u left right false).naturalPivot value XL XR + movingFourierTree value ψ X left p XL * star (movingFourierTree value ψ X right p XR) + +noncomputable def movingPolynomialFourierTree {σ : Type*} + (value : σ → ℕ) (ψ : ℝ → ℂ) (X z : ℝ) : + {n : ℕ} → MovingSlotData σ n → Polynomial ℝ → Polynomial ℝ → ℂ + | _, .leaf s regular, L, R => + normalizedFourierProfile ψ s + ((L * R * Polynomial.C (MovingSlotReversal.naturalProduct value regular : ℝ)).eval z / X) + | _, .node s CL CR u left right, L, R => + let p := (MovingSlotData.step s CL CR u left right false).pivotPolynomial value L R + movingPolynomialFourierTree value ψ X z left p L * + star (movingPolynomialFourierTree value ψ X z right p R) + +theorem movingPolynomialFourierTree_eq {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (ψ : ℝ → ℂ) (X z : ℝ) + {n : ℕ} (T : MovingSlotData σ n) (hfreq : T.Frequencies (· ≠ 0)) + (XL XR : ℕ) (hI : T.Integral value XL XR) (L R : Polynomial ℝ) + (hL : L.eval z = (XL : ℝ)) (hR : R.eval z = (XR : ℝ)) : + movingPolynomialFourierTree value ψ X z T L R = movingFourierTree value ψ X T XL XR := by + induction T generalizing XL XR L R with + | leaf s regular => + simp only [movingPolynomialFourierTree, movingFourierTree, Polynomial.eval_mul, + Polynomial.eval_C, hL, hR, Nat.cast_mul] + | node s CL CR u left right ihL ihR => + let step := MovingSlotData.step s CL CR u left right false + have hp : (step.pivotPolynomial value L R).eval z = (step.naturalPivot value XL XR : ℝ) := by + rw [MovingSlotReversal.pivotPolynomial_eval, hL, hR] + exact step.realPivot_eq value XL XR hfreq.1 + (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) hI.1 + exact congrArg₂ (fun a b : ℂ => a * star b) + (ihL hfreq.2.1 _ _ hI.2.1 _ _ hp hL) (ihR hfreq.2.2 _ _ hI.2.2 _ _ hp hR) + +/-- The exact Fourier factorization preserves all original support terms, +including terms whose full coefficient is zero. -/ +theorem movingSlotWeight_fourier {σ : Type*} + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (ψ : ℝ → ℂ) (X : ℝ) {n : ℕ} + (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) (XL XR : ℕ) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => F x s * movingFourierLeaf value ψ X x s) + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t = + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t * + movingFourierTree value ψ X T XL XR := by + let sys := movingSlotSystem value childBound pivotBound + let cutoff := movingSlotCutoff value childBound pivotBound extra + induction T generalizing XL XR with + | leaf s regular => + have hs : s = t := hT + simp only [recursiveTransferWeight, movingFourierLeaf, movingSlotModulus, + movingFourierTree, hs] + | @node n s CL CR u left right ihL ihR => + let x : MovingSlotState σ := ⟨n + 1, .node s CL CR u left right, XL, XR⟩ + let p := (MovingSlotData.step s CL CR u left right false).naturalPivot value XL XR + have hp : historyPivot sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) / + MovingSlotReversal.naturalProduct value u = p := by + simp only [historyPivot, sys, movingSlotSystem, + MovingSlotState.leftProduct, MovingSlotState.rightProduct, x, + ← hT.1, ← hT.2.1.root, ← hT.2.2.root, p, + MovingSlotReversal.naturalPivot, MovingSlotData.step, movingGiantPivot, Nat.mul_one] + change recursiveTransferWeight sys _ cutoff (n + 1) x t = _ + simp only [recursiveTransferWeight] + split_ifs + · change (cutoff x t.1 _ _ : ℂ) * + recursiveTransferWeight sys _ cutoff n ⟨n, left, _, XL⟩ t.2.1 * + star (recursiveTransferWeight sys _ cutoff n ⟨n, right, _, XR⟩ t.2.2) = + ((cutoff x t.1 _ _ : ℂ) * recursiveTransferWeight sys F cutoff n ⟨n, left, _, XL⟩ t.2.1 * + star (recursiveTransferWeight sys F cutoff n ⟨n, right, _, XR⟩ t.2.2)) * _ + rw [hp, ihL t.2.1 hT.2.1 p XL, ihR t.2.2 hT.2.2 p XR] + change _ = _ * (movingFourierTree value ψ X left p XL * star (movingFourierTree value ψ X right p XR)) + simp only [star_mul] + ring + · exact (zero_mul _).symm + +/-- The polynomial smooth extension agrees with the full coefficient on +its proved integer support. No polynomial realization premise is required. -/ +theorem movingSlotWeight_polynomial_fourier {σ : Type*} + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (ψ : ℝ → ℂ) (X z : ℝ) {n : ℕ} + (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hfreq : T.Frequencies (· ≠ 0)) (XL XR : ℕ) (L R : Polynomial ℝ) + (hL : L.eval z = (XL : ℝ)) (hR : R.eval z = (XR : ℝ)) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => F x s * movingFourierLeaf value ψ X x s) + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t = + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t * + movingPolynomialFourierTree value ψ X z T L R := by + rw [movingSlotWeight_fourier value childBound pivotBound F extra ψ X T t hT XL XR] + by_cases hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t = 0 + · rw [hw, zero_mul, zero_mul] + · have hi := movingSlotWeight_nonzero_integral value childBound pivotBound F extra T t hT XL XR hw + rw [movingPolynomialFourierTree_eq value hvalue ψ X z T hfreq XL XR hi L R hL hR] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierPolynomials.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierPolynomials.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb6410b60f803ec27fea9bc999be61146a2d36e6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierPolynomials.lean @@ -0,0 +1,127 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFourierFactor +import OAI.NumberTheory.Ostmann.Characters.PolynomialWeightPair +import OAI.NumberTheory.Ostmann.Construction.TransferConjugations + +namespace OAI + +/-! # The concrete polynomial factors in the moving Fourier history -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate SchwartzMap + +noncomputable def movingLeafIndexEquiv (n : ℕ) : TreeLeafIndex n ≃ Fin (2 ^ n) := + Fintype.equivFinOfCardEq (card_treeLeafIndex n) + +def MovingSlotData.leafFrequencies {σ : Type*} : + {n : ℕ} → MovingSlotData σ n → TreeLeafIndex n → ℤ + | _, .leaf s _, _ => s + | _, .node _ _ _ _ left _right, .inl i => left.leafFrequencies i + | _, .node _ _ _ _ _left right, .inr i => right.leafFrequencies i + +theorem movingPolynomialFourierTree_product {σ : Type*} + (value : σ → ℕ) (ψ : ℝ → ℂ) (X z : ℝ) {n : ℕ} (T : MovingSlotData σ n) + (L R : Polynomial ℝ) (b : Bool) : + (∏ i : TreeLeafIndex n, + if treeLeafTupleEquiv Bool n (transferConjugations n b) i then + conj (normalizedFourierProfile ψ (T.leafFrequencies i) + ((T.leafPolynomials value L R i).eval z / X)) + else normalizedFourierProfile ψ (T.leafFrequencies i) + ((T.leafPolynomials value L R i).eval z / X)) = + if b then conj (movingPolynomialFourierTree value ψ X z T L R) + else movingPolynomialFourierTree value ψ X z T L R := by + induction T generalizing L R b with + | leaf s regular => + change (∏ _ : Unit, if b then conj _ else _) = _ + simp only [Fintype.prod_unique] + rfl + | @node n s CL CR u left right ihL ihR => + change (∏ i : TreeLeafIndex n ⊕ TreeLeafIndex n, _) = _ + rw [Fintype.prod_sum_type] + change (∏ i : TreeLeafIndex n, if treeLeafTupleEquiv Bool n (transferConjugations n b) i + then conj _ else _) * + (∏ i : TreeLeafIndex n, if treeLeafTupleEquiv Bool n (transferConjugations n (!b)) i + then conj _ else _) = _ + simp only [MovingSlotData.leafFrequencies, MovingSlotData.leafPolynomials] + rw [ihL, ihR] + cases b + · rfl + · simp only [Bool.not_true, Bool.false_eq_true, ite_false, ite_true] + change star _ * _ = star (_ * star _) + rw [star_mul, star_star] + exact mul_comm _ _ + +noncomputable def movingLeafNormalizedPolynomial {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (L R : Polynomial ℝ) (X : ℝ) (i : TreeLeafIndex n) : Polynomial ℝ := + Polynomial.C X⁻¹ * T.leafPolynomials value L R i + +theorem movingLeafNormalizedPolynomial_eval {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (L R : Polynomial ℝ) (X z : ℝ) (i : TreeLeafIndex n) : + (movingLeafNormalizedPolynomial value T L R X i).eval z = + (T.leafPolynomials value L R i).eval z / X := by + simp only [movingLeafNormalizedPolynomial, Polynomial.eval_mul, Polynomial.eval_C, div_eq_mul_inv] + ring + +/-- Exactly one clipped Fourier polynomial per terminal leaf, with the +conjugation imposed by its actual left/right path. -/ +noncomputable def movingFourierPolynomialFactors {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) : Fin (2 ^ n) → ClippedPolynomialFactor := + fun j => + let i := (movingLeafIndexEquiv n).symm j + let f := fourierPolynomialFactor (movingLeafNormalizedPolynomial value T L R X i) + ψ (T.leafFrequencies i) lo hi hlo hhi + if treeLeafTupleEquiv Bool n (transferConjugations n false) i then f.conjugate else f + +theorem movingFourierPolynomialFactors_value {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (z : ℝ) + (hrange : ∀ i, (T.leafPolynomials value L R i).eval z / X ∈ Set.Icc lo hi) : + smoothPolynomialWeight (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi) z = + movingPolynomialFourierTree value ψ X z T L R := by + rw [smoothPolynomialWeight] + have he := (movingLeafIndexEquiv n).prod_comp + (fun j => (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi j).value z) + rw [← he] + have ht (i : TreeLeafIndex n) : + (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi + (movingLeafIndexEquiv n i)).value z = + if treeLeafTupleEquiv Bool n (transferConjugations n false) i then + conj (normalizedFourierProfile ψ (T.leafFrequencies i) + ((T.leafPolynomials value L R i).eval z / X)) + else normalizedFourierProfile ψ (T.leafFrequencies i) + ((T.leafPolynomials value L R i).eval z / X) := by + simp only [movingFourierPolynomialFactors, Equiv.symm_apply_apply] + have hv := ClippedPolynomialFactor.value_of_mem + (fourierPolynomialFactor (movingLeafNormalizedPolynomial value T L R X i) + ψ (T.leafFrequencies i) lo hi hlo hhi) z + (by simpa only [fourierPolynomialFactor, movingLeafNormalizedPolynomial_eval] using hrange i) + have hv' : (fourierPolynomialFactor (movingLeafNormalizedPolynomial value T L R X i) + ψ (T.leafFrequencies i) lo hi hlo hhi).value z = + normalizedFourierProfile ψ (T.leafFrequencies i) + ((T.leafPolynomials value L R i).eval z / X) := by + rw [hv] + exact congrArg (normalizedFourierProfile ψ (T.leafFrequencies i)) + (movingLeafNormalizedPolynomial_eval value T L R X z i) + split_ifs + · rw [ClippedPolynomialFactor.conjugate_value] + exact congrArg conj hv' + · exact hv' + simp_rw [ht] + exact movingPolynomialFourierTree_product value ψ X z T L R false + +theorem movingFourierPolynomialFactors_degree {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hL : L.natDegree ≤ 1) (hR : R.natDegree ≤ 1) (j : Fin (2 ^ n)) : + (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi j).polynomial.natDegree ≤ 2 := by + have hp := T.leafPolynomials_degree value L R 1 hL hR ((movingLeafIndexEquiv n).symm j) + have hn : (movingLeafNormalizedPolynomial value T L R X + ((movingLeafIndexEquiv n).symm j)).natDegree ≤ 2 := by + apply Polynomial.natDegree_mul_le.trans + simpa only [Polynomial.natDegree_C, zero_add, mul_one] using hp + dsimp only [movingFourierPolynomialFactors] + split_ifs <;> exact hn + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierSupported.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierSupported.lean new file mode 100644 index 0000000000000000000000000000000000000000..6ee26ca81d2f534bb8fb67dce2eeb58206c7c427 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierSupported.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFourierVariation + +namespace OAI + +/-! # The supported original coefficient is the constructed polynomial weight -/ + +namespace Ostmann +open scoped Classical SchwartzMap + +/-- Every terminal factor of a nonzero recursive coefficient is nonzero. +This statement keeps the concrete moving giant and terminal modulus. -/ +theorem movingSlotWeight_leaf_support {σ : Type*} + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (P : ℕ → ℤ → Prop) + (hF : ∀ x s, F x s ≠ 0 → P (movingSlotModulus value x) s) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (XL XR : ℕ) + (hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t ≠ 0) : + ∀ i, P (T.leafModuli value XL XR i) (T.leafFrequencies i) := by + let sys := movingSlotSystem value childBound pivotBound + let cutoff := movingSlotCutoff value childBound pivotBound extra + induction T generalizing XL XR with + | leaf s regular => + intro i + have hs : s = t := hT + subst s + exact hF ⟨0, .leaf t regular, XL, XR⟩ t hw + | @node n s CL CR u left right ihL ihR => + let x : MovingSlotState σ := ⟨n + 1, .node s CL CR u left right, XL, XR⟩ + let p := (MovingSlotData.step s CL CR u left right false).naturalPivot value XL XR + have hp : historyPivot sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) / + MovingSlotReversal.naturalProduct value u = p := by + simp only [historyPivot, sys, movingSlotSystem, MovingSlotState.leftProduct, + MovingSlotState.rightProduct, x, ← hT.1, ← hT.2.1.root, ← hT.2.2.root, p, + MovingSlotReversal.naturalPivot, MovingSlotData.step, movingGiantPivot, Nat.mul_one] + have hvalid := recursiveTransferWeight_nonzero_valid sys F cutoff (n + 1) x t hw + obtain ⟨Q, hQ, _, _⟩ := hvalid + have hnode := recursiveTransferWeight_node sys F cutoff n x t Q hQ + have hQp : Q / MovingSlotReversal.naturalProduct value u = p := by + rw [← hQ.historyPivot_eq] + exact hp + have hL : recursiveTransferWeight sys F cutoff n ⟨n, left, p, XL⟩ t.2.1 ≠ 0 := by + intro hz + apply hw + rw [hnode] + change (cutoff x t.1 _ _ : ℂ) * + recursiveTransferWeight sys F cutoff n ⟨n, left, Q / _, XL⟩ t.2.1 * _ = 0 + rw [hQp, hz, mul_zero, zero_mul] + have hR : recursiveTransferWeight sys F cutoff n ⟨n, right, p, XR⟩ t.2.2 ≠ 0 := by + intro hz + apply hw + rw [hnode] + change _ * star (recursiveTransferWeight sys F cutoff n ⟨n, right, Q / _, XR⟩ t.2.2) = 0 + rw [hQp, hz, star_zero, mul_zero] + intro i + cases i with + | inl i => exact ihL t.2.1 hT.2.1 p XL hL i + | inr i => exact ihR t.2.2 hT.2.2 p XR hR i + +noncomputable def movingWindowLeaf {σ : Type*} (value : σ → ℕ) + (X lo hi : ℝ) (F : MovingSlotState σ → ℤ → ℂ) (x : MovingSlotState σ) (s : ℤ) : ℂ := + if (movingSlotModulus value x : ℝ) / X ∈ Set.Icc lo hi then F x s else 0 + +/-- The original sharp terminal windows suffice for the clipped polynomial +extension. All node and prime restrictions remain in the scalar coefficient. -/ +theorem moving_windowed_fourier_polynomial {σ : Type*} + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hfreq : T.Frequencies (· ≠ 0)) (XL XR : ℕ) (L R : Polynomial ℝ) (z : ℝ) + (hL : L.eval z = (XL : ℝ)) (hR : R.eval z = (XR : ℝ)) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => movingWindowLeaf value X lo hi F x s * movingFourierLeaf value ψ X x s) + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t = + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (movingWindowLeaf value X lo hi F) (movingSlotCutoff value childBound pivotBound extra) + n ⟨n, T, XL, XR⟩ t * + smoothPolynomialWeight (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi) z := by + rw [movingSlotWeight_polynomial_fourier value hvalue childBound pivotBound + (movingWindowLeaf value X lo hi F) extra ψ X z T t hT hfreq XL XR L R hL hR] + by_cases hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (movingWindowLeaf value X lo hi F) (movingSlotCutoff value childBound pivotBound extra) + n ⟨n, T, XL, XR⟩ t = 0 + · rw [hw, zero_mul, zero_mul] + · have hI := movingSlotWeight_nonzero_integral value childBound pivotBound + (movingWindowLeaf value X lo hi F) extra T t hT XL XR hw + have hr := movingSlotWeight_leaf_support value childBound pivotBound + (movingWindowLeaf value X lo hi F) extra (fun M _ => (M : ℝ) / X ∈ Set.Icc lo hi) + (fun x s hx => by + by_contra hn + exact hx (by simp only [movingWindowLeaf, ite_eq_right hn])) T t hT XL XR hw + rw [movingFourierPolynomialFactors_value value T L R ψ X lo hi hlo hhi z] + intro i + rw [T.leafPolynomials_eval value hvalue hfreq XL XR hI L R z hL hR i] + exact hr i + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierVariation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierVariation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac9e81143f92be0b46260c3b59c1359a532296e6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFourierVariation.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFourierPolynomials + +namespace OAI + +/-! # Constructed variation bounds for the actual moving Fourier factors -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem MovingSlotData.leafFrequencies_bound {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) (V : ℝ) (h : T.Frequencies (fun s => |(s : ℝ)| ≤ V)) + (i : TreeLeafIndex n) : |(T.leafFrequencies i : ℝ)| ≤ V := by + induction T with + | leaf s regular => exact h + | node s CL CR u left right ihL ihR => + cases i with + | inl i => exact ihL h.2.1 i + | inr i => exact ihR h.2.2 i + +noncomputable def movingFourierVariationBudget (ψ : 𝓢(ℝ, ℂ)) + (V lo hi : ℝ) (n : ℕ) : ℝ := + (2 * SchwartzMap.seminorm ℝ 0 0 ψ + + (SchwartzMap.seminorm ℝ 0 0 ψ + SchwartzMap.seminorm ℝ 0 1 ψ * V) * (hi - lo)) ^ (2 ^ n) + +theorem movingFourierPolynomialFactors_budget {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : T.Frequencies (fun s => |(s : ℝ)| ≤ V)) : + smoothPolynomialBudget (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi) ≤ + movingFourierVariationBudget ψ V lo hi n := by + unfold smoothPolynomialBudget movingFourierVariationBudget + calc + _ ≤ ∏ _j : Fin (2 ^ n), + (2 * SchwartzMap.seminorm ℝ 0 0 ψ + + (SchwartzMap.seminorm ℝ 0 0 ψ + SchwartzMap.seminorm ℝ 0 1 ψ * V) * (hi - lo)) := by + apply Finset.prod_le_prod₀ + · intro j _ + let f := movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi j + exact add_nonneg (mul_nonneg (by norm_num) f.bound_nonneg) + (mul_nonneg f.lip_nonneg (sub_nonneg.mpr f.lo_le_hi)) + · intro j _ + have hv := T.leafFrequencies_bound V hV ((movingLeafIndexEquiv n).symm j) + have hd := mul_le_mul_of_nonneg_left hv (schwartz_profile_lip_nonneg ψ) + have he := mul_le_mul_of_nonneg_right (add_le_add (le_rfl : SchwartzMap.seminorm ℝ 0 0 ψ ≤ SchwartzMap.seminorm ℝ 0 0 ψ) hd) + (sub_nonneg.mpr hhi) + dsimp only [movingFourierPolynomialFactors] + split_ifs <;> exact add_le_add le_rfl he + _ = _ := by simp + +/-- At most one derivative root per terminal quadratic is needed. Both the +root cut set and the variation bound are built from the actual history. -/ +theorem movingFourierPolynomialFactors_variation {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hL : L.natDegree ≤ 1) (hR : R.natDegree ≤ 1) + (hV : T.Frequencies (fun s => |(s : ℝ)| ≤ V)) : + ∃ S : Finset ℝ, S.card ≤ 2 ^ n ∧ + ∀ (u : ℕ → ℝ), Monotone u → ∀ N : ℕ, + rootCellCode S (u 0) = rootCellCode S (u (N - 1)) → + discreteVariation (fun j => smoothPolynomialWeight + (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi) (u j)) N ≤ + movingFourierVariationBudget ψ V lo hi n := by + let F := movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi + let S := polynomialRootCuts (fun i => (F i).polynomial.derivative) + have hdeg (i : Fin (2 ^ n)) : (F i).polynomial.derivative.natDegree ≤ 1 := by + have h := movingFourierPolynomialFactors_degree value T L R ψ X lo hi hlo hhi hL hR i + change (F i).polynomial.natDegree ≤ 2 at h + exact (Polynomial.natDegree_derivative_le _).trans (by omega) + refine ⟨S, ?_, ?_⟩ + · apply (polynomialRootCuts_card _).trans + calc + _ ≤ ∑ _i : Fin (2 ^ n), 1 := Finset.sum_le_sum (fun i _ => hdeg i) + _ = 2 ^ n := by simp + · intro u hu N hcode + apply (smoothPolynomialWeight_variation F S _ u hu N hcode).trans + (movingFourierPolynomialFactors_budget value T L R ψ X lo hi V hlo hhi hV) + intro i r hr + exact Finset.mem_biUnion.mpr ⟨i, Finset.mem_univ _, Multiset.mem_toFinset.mpr hr⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..a307f01b4f8ed08eb1b60b30818018356b91f8a5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyBudget.lean @@ -0,0 +1,128 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFinalGap +import OAI.NumberTheory.Ostmann.Construction.RoundedEnergyCutoffs + +namespace OAI + +/-! # The actual accumulated gaps and rounded frequency cutoffs of Section 7 -/ + +namespace Ostmann +open scoped BigOperators + +/-- The square-root reserve agrees with the proved bottom cutoff at `4m`. -/ +noncomputable def movingCutoffExponent (Bs BD Bz z m : ℝ) (n : ℕ) : ℝ := + spectatorBaseGap Bs z m + + ∑ j ∈ Finset.range n, spectatorStepGap BD Bz z ((2 : ℝ) ^ j) m + + (2 : ℝ) ^ n * Real.sqrt (4 * m) + +noncomputable def movingNaturalCutoff (Bs BD Bz z m : ℝ) (n : ℕ) : ℕ := + ⌊Real.exp (movingCutoffExponent Bs BD Bz z m n)⌋₊ + +/-- One unit of reserve is left for the root-frequency count. -/ +noncomputable def movingFrequencyRate (Bs BD Bz z : ℝ) (n : ℕ) : ℝ := + (2 : ℝ) ^ n * (Bs + 8 * Real.log z + BD + Bz * Real.log z + + (2 / 5 : ℝ) * Real.log ((2 : ℝ) ^ n) + 2) + +theorem movingCutoffExponent_zero (Bs BD Bz z m : ℝ) : + movingCutoffExponent Bs BD Bz z m 0 = spectatorBaseGap Bs z m + Real.sqrt (4 * m) := by + simp [movingCutoffExponent] + +theorem movingCutoffExponent_succ (Bs BD Bz z m : ℝ) (n : ℕ) : + movingCutoffExponent Bs BD Bz z m (n + 1) = + movingCutoffExponent Bs BD Bz z m n + + spectatorStepGap BD Bz z ((2 : ℝ) ^ n) m + (2 : ℝ) ^ n * Real.sqrt (4 * m) := by + simp only [movingCutoffExponent, Finset.sum_range_succ, pow_succ] + ring + +private theorem moving_sum_two_pow (n : ℕ) : + (∑ j ∈ Finset.range n, (2 : ℝ) ^ j) + 1 = (2 : ℝ) ^ n := by + induction n with + | zero => simp + | succ n ih => + rw [Finset.sum_range_succ, pow_succ] + linarith + +theorem movingCutoffExponent_bound (Bs BD Bz z m : ℝ) (n : ℕ) + (hBs : 0 ≤ Bs) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) (hz : 1 ≤ z) (hm : 4 ≤ m) : + movingCutoffExponent Bs BD Bz z m n ≤ + (movingFrequencyRate Bs BD Bz z n - (2 : ℝ) ^ n) * m := by + let Q := BD + Bz * Real.log z + (2 / 5 : ℝ) * Real.log ((2 : ℝ) ^ n) + have hr : 1 ≤ (2 : ℝ) ^ n := one_le_pow₀ (by norm_num) + have hlogz : 0 ≤ Real.log z := Real.log_nonneg hz + have hlogr : 0 ≤ Real.log ((2 : ℝ) ^ n) := Real.log_nonneg hr + have hQ : 0 ≤ Q := by dsimp only [Q]; positivity + have hm0 : 0 ≤ m := by linarith + have hsum : (∑ j ∈ Finset.range n, spectatorStepGap BD Bz z ((2 : ℝ) ^ j) m) ≤ + (2 : ℝ) ^ n * Q * m := by + calc + _ ≤ ∑ j ∈ Finset.range n, (2 : ℝ) ^ j * Q * m := by + apply Finset.sum_le_sum + intro j hj + have hjn : j ≤ n := (Finset.mem_range.mp hj).le + have hp : (2 : ℝ) ^ j ≤ (2 : ℝ) ^ n := pow_le_pow_right₀ (by norm_num) hjn + have hl := Real.log_le_log (by positivity : 0 < (2 : ℝ) ^ j) hp + have hc : BD + Bz * Real.log z + (2 / 5 : ℝ) * Real.log ((2 : ℝ) ^ j) ≤ Q := by + dsimp only [Q] + linarith + unfold spectatorStepGap + nlinarith only [mul_le_mul_of_nonneg_left hc (mul_nonneg (by positivity : 0 ≤ (2 : ℝ) ^ j) hm0)] + _ = (∑ j ∈ Finset.range n, (2 : ℝ) ^ j) * Q * m := by + rw [Finset.sum_mul, Finset.sum_mul] + _ ≤ (2 : ℝ) ^ n * Q * m := by + have hh := moving_sum_two_pow n + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (by linarith : (∑ j ∈ Finset.range n, (2 : ℝ) ^ j) ≤ (2 : ℝ) ^ n) hQ) hm0 + have hsqrt : Real.sqrt (4 * m) ≤ m := by + have hs := Real.sq_sqrt (show 0 ≤ 4 * m by positivity) + have hp : 0 ≤ m * (m - 4) := mul_nonneg hm0 (by linarith) + nlinarith [Real.sqrt_nonneg (4 * m)] + have hbase : Bs + 8 * Real.log z ≤ (2 : ℝ) ^ n * (Bs + 8 * Real.log z) := by + exact le_mul_of_one_le_left (by positivity) hr + have hr0 : 0 ≤ (2 : ℝ) ^ n := by positivity + have hb := mul_le_mul_of_nonneg_right hbase hm0 + have hs := mul_le_mul_of_nonneg_left hsqrt hr0 + unfold movingCutoffExponent spectatorBaseGap movingFrequencyRate + dsimp only [Q] at hsum + nlinarith only [hsum, hb, hs] + +theorem movingNaturalCutoff_frequency_bound (Bs BD Bz z m : ℝ) (n : ℕ) + (hBs : 0 ≤ Bs) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) (hz : 1 ≤ z) (hm : 4 ≤ m) : + (movingNaturalCutoff Bs BD Bz z m n : ℝ) ≤ Real.exp (movingFrequencyRate Bs BD Bz z n * m) ∧ + ((transferFrequencyRange (movingNaturalCutoff Bs BD Bz z m n)).card : ℝ) ≤ + Real.exp (movingFrequencyRate Bs BD Bz z n * m) := by + let E := movingCutoffExponent Bs BD Bz z m n + let A := movingFrequencyRate Bs BD Bz z n + have hE := movingCutoffExponent_bound Bs BD Bz z m n hBs hBD hBz hz hm + have hfloor : (movingNaturalCutoff Bs BD Bz z m n : ℝ) ≤ Real.exp E := + Nat.floor_le (Real.exp_pos _).le + have hE0 : 0 ≤ E := by + dsimp only [E, movingCutoffExponent, spectatorBaseGap] + have hlogz := Real.log_nonneg hz + apply add_nonneg + · apply add_nonneg (mul_nonneg (by positivity) (by linarith)) + apply Finset.sum_nonneg + intro j _ + have hl := Real.log_nonneg (one_le_pow₀ (by norm_num : (1 : ℝ) ≤ 2) : 1 ≤ (2 : ℝ) ^ j) + unfold spectatorStepGap + positivity + · positivity + have hmargin : Real.log 3 ≤ (2 : ℝ) ^ n * m := by + have hr : 1 ≤ (2 : ℝ) ^ n := one_le_pow₀ (by norm_num) + have hlog := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 3) + nlinarith + have hcard : ((transferFrequencyRange (movingNaturalCutoff Bs BD Bz z m n)).card : ℝ) ≤ + 3 * Real.exp E := by + rw [card_transferFrequencyRange] + push_cast + have he1 := Real.one_le_exp hE0 + linarith + have hfinal : 3 * Real.exp E ≤ Real.exp (A * m) := by + rw [← Real.exp_log (by norm_num : (0 : ℝ) < 3), ← Real.exp_add] + apply Real.exp_le_exp.mpr + dsimp only [A, E] + nlinarith only [hE, hmargin] + exact ⟨hfloor.trans ((by nlinarith [Real.exp_pos E] : Real.exp E ≤ 3 * Real.exp E).trans hfinal), + hcard.trans hfinal⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyCoefficient.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..d729d8fd62b9a28b93ad5c748cc33d09997c1334 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyCoefficient.lean @@ -0,0 +1,146 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGuardedDirectRecursion +import OAI.NumberTheory.Ostmann.Construction.ScheduledFrequencyHistory + +namespace OAI + +/-! # Summing the actual sampled coefficient over its internal frequencies -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The root frequency is fixed by the amplitude; only its descendants are +summed here, each under its own level cutoff. -/ +def MovingDescendantFrequencyIndex (V : ℕ → ℕ) : ℕ → Type + | 0 => Unit + | n + 1 => ScheduledFrequencyIndex V n × ScheduledFrequencyIndex V n + +instance movingDescendantFrequencyIndexFintype (V : ℕ → ℕ) (n : ℕ) : + Fintype (MovingDescendantFrequencyIndex V n) := by + cases n <;> dsimp only [MovingDescendantFrequencyIndex] <;> infer_instance + +noncomputable def movingRootedFrequencyTree (V : ℕ → ℕ) : + (n : ℕ) → ℤ → MovingDescendantFrequencyIndex V n → FrequencyTree ℤ n + | 0, s, _ => s + | n + 1, s, t => (s, scheduledFrequencyHistory V n t.1, scheduledFrequencyHistory V n t.2) + +def scheduledFrequencyRootEquiv (V : ℕ → ℕ) (n : ℕ) : + ScheduledFrequencyIndex V n ≃ transferFrequencyRange (V n) × MovingDescendantFrequencyIndex V n := by + cases n with + | zero => exact (Equiv.prodUnique _ Unit).symm + | succ n => exact Equiv.refl _ + +theorem scheduledFrequencyRootEquiv_history (V : ℕ → ℕ) (n : ℕ) + (t : ScheduledFrequencyIndex V n) : + scheduledFrequencyHistory V n t = + movingRootedFrequencyTree V n (scheduledFrequencyRootEquiv V n t).1.val + (scheduledFrequencyRootEquiv V n t).2 := by + cases n <;> rfl + +/-- The original root sum can be reindexed without counting a root twice. -/ +theorem scheduledFrequency_sum_rooted (V : ℕ → ℕ) (n : ℕ) + (f : FrequencyTree ℤ n → ℂ) : + (∑ t : ScheduledFrequencyIndex V n, f (scheduledFrequencyHistory V n t)) = + ∑ s : transferFrequencyRange (V n), ∑ t : MovingDescendantFrequencyIndex V n, + f (movingRootedFrequencyTree V n s.val t) := by + have he := (scheduledFrequencyRootEquiv V n).sum_comp + (fun t => f (movingRootedFrequencyTree V n t.1.val t.2)) + simp_rw [← scheduledFrequencyRootEquiv_history] at he + rw [Fintype.sum_prod_type] at he + exact he + +/-- This is the current coefficient after the original internal prime samples +and all descendant frequencies have been summed. Root guards remain in each +term and are never turned into a conditioned probability law. -/ +noncomputable def movingFrequencyCoefficient {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) : ℂ := + ∑ t : MovingDescendantFrequencyIndex V n, + movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n + (movingRootedFrequencyTree V n s t) small bulk XL XR + +/-- At a successor level the two child histories are independent finite +indices, while each root compensation vector is shared exactly once. -/ +theorem movingFrequencyCoefficient_node {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (small bulk : TreeLeafTuple (List σ) (n + 1)) (XL XR : ℕ) : + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G + (n + 1) s small bulk XL XR = + ∑ l : ScheduledFrequencyIndex V n, ∑ r : ScheduledFrequencyIndex V n, + ∑ a : TreeLeafTuple (Fin 4 → σ) n, + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let t := (s, scheduledFrequencyHistory V n l, scheduledFrequencyHistory V n r) + let x := movingRootState n t CL CR (flattenMovingSlots n u) XL XR + let U := x.compensation value + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let p := reconstructedPivot + (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) (s * U) + (movingCompensationPrior (μ n) n a : ℂ) * + if movingLocalSupport value outside x ∧ + (ValidTransferNode (movingSlotSystem value childBound pivotBound) x s v w (p * U) ∧ + 0 < U) then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) * + movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n t.2.1 + (appendMovingSlotLeaves n u small.1) bulk.1 p XL * + star (movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n t.2.2 + (appendMovingSlotLeaves n u small.2) bulk.2 p XR) + else 0 := by + unfold movingFrequencyCoefficient + change (∑ t : ScheduledFrequencyIndex V n × ScheduledFrequencyIndex V n, _) = _ + rw [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro l _ + apply Finset.sum_congr rfl + intro r _ + exact movingSupportedSampledWeight_direct_node value outside μ childBound pivotBound F φ G n + (s, scheduledFrequencyHistory V n l, scheduledFrequencyHistory V n r) small bulk XL XR + +/-- Identification with the already proved original prime-pattern expansion. +This links the finite frequency coefficient to the arithmetic comparison. -/ +theorem movingFrequencyCoefficient_original {σ I : Type} [Fintype σ] + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : SchwartzMap ℝ ℂ) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (s : ℤ) (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) : + movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s small bulk XL XR = + ∑ t : MovingDescendantFrequencyIndex V n, + movingOriginalSampleAverage q value outside μ childBound pivotBound F g Dq S ψ X lo hi φ G + n (movingRootedFrequencyTree V n s t) small bulk XL XR := by + simp only [movingFrequencyCoefficient, movingOriginalSampleAverage_eq] + +/-- The frequency square has exactly two independent descendant histories. +In particular no bound by the number of histories has been used here. -/ +theorem movingFrequencyCoefficient_square {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) : + ‖movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G + n s small bulk XL XR‖ ^ 2 = + (∑ t : MovingDescendantFrequencyIndex V n, ∑ u : MovingDescendantFrequencyIndex V n, + movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n + (movingRootedFrequencyTree V n s t) small bulk XL XR * + star (movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n + (movingRootedFrequencyTree V n s u) small bulk XL XR)).re := by + rw [movingFrequencyCoefficient] + simp only [← Finset.mul_sum, ← Finset.sum_mul, Complex.star_def] + rw [← map_sum (starRingEnd ℂ), Complex.mul_conj'] + norm_cast + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..a022ec410f86cb56375d14e393429d29001108a5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyEnergy.lean @@ -0,0 +1,159 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHistoryUniqueness +import OAI.NumberTheory.Ostmann.Preliminaries.TransferCauchy + +namespace OAI + +/-! # Frequency energy under the unchanged internal sample law -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingRootedFrequencyTree_injective (V : ℕ → ℕ) (n : ℕ) (s : ℤ) : + Function.Injective (movingRootedFrequencyTree V n s) := by + cases n with + | zero => + change Function.Injective (fun _ : Unit => (s : ℤ)) + exact fun _ _ _ => Subsingleton.elim _ _ + | succ n => + intro a b h + exact Prod.ext + (scheduledFrequencyHistory_injective V n (congrArg (fun t => t.2.1) h)) + (scheduledFrequencyHistory_injective V n (congrArg (fun t => t.2.2) h)) + +private theorem norm_sum_sq_single_support {D : Type*} [Fintype D] (f : D → ℂ) + (h : ∀ d e, f d ≠ 0 → f e ≠ 0 → d = e) : + ‖∑ d, f d‖ ^ 2 = ∑ d, ‖f d‖ ^ 2 := by + by_cases hf : ∃ d, f d ≠ 0 + · obtain ⟨d, hd⟩ := hf + have hz (e) (he : e ≠ d) : f e = 0 := by + by_contra hn + exact he (h e d hn hd) + rw [Fintype.sum_eq_single d hz, Fintype.sum_eq_single d] + intro e he + simp only [hz e he, norm_zero, zero_pow (by decide : 2 ≠ 0)] + · push Not at hf + simp only [hf, Finset.sum_const_zero, norm_zero, zero_pow (by decide : 2 ≠ 0)] + +/-- Fixing the original samples makes the descendant sum have at most one +nonzero term. No bound by the number of frequency histories occurs. -/ +theorem movingRecursiveWeight_root_energy {σ : Type*} + (value : σ → ℕ) (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (s : ℤ) (small bulk : TreeLeafTuple (List σ) n) + (a : MovingSampleSlots σ n) (XL XR : ℕ) : + let W := fun t => recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound E) n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ t + ‖∑ d : MovingDescendantFrequencyIndex V n, W (movingRootedFrequencyTree V n s d)‖ ^ 2 = + ∑ d : MovingDescendantFrequencyIndex V n, ‖W (movingRootedFrequencyTree V n s d)‖ ^ 2 := by + dsimp only + apply norm_sum_sq_single_support + intro d e hd he + apply movingRootedFrequencyTree_injective V n s + apply movingRecursiveWeight_history_unique value childBound pivotBound F E n _ _ small bulk a XL XR hd he + cases n <;> rfl + +theorem scheduledFrequency_sum_rooted_real (V : ℕ → ℕ) (n : ℕ) + (f : FrequencyTree ℤ n → ℝ) : + (∑ t : ScheduledFrequencyIndex V n, f (scheduledFrequencyHistory V n t)) = + ∑ s : transferFrequencyRange (V n), ∑ t : MovingDescendantFrequencyIndex V n, + f (movingRootedFrequencyTree V n s.val t) := by + have he := (scheduledFrequencyRootEquiv V n).sum_comp + (fun t => f (movingRootedFrequencyTree V n t.1.val t.2)) + simp_rw [← scheduledFrequencyRootEquiv_history] at he + rw [Fintype.sum_prod_type] at he + exact he + +/-- Jensen is applied only to the original independent sample law, after +the unique-history square. All node compensations and guards remain in `W`. -/ +theorem movingSampledWeight_frequency_energy {σ : Type*} [Fintype σ] + (value : σ → ℕ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hmass : ∀ j, ∑ a, μ j a = 1) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) : + let W := fun t a => recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingLocalExtra E)) n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ t + (∑ s : transferFrequencyRange (V n), + ‖∑ d : MovingDescendantFrequencyIndex V n, + movingSampledWeight value μ childBound pivotBound F E n + (movingRootedFrequencyTree V n s.val d) small bulk XL XR‖ ^ 2) ≤ + ∑ a : MovingSampleSlots σ n, movingSamplesPrior μ a * + ∑ t : ScheduledFrequencyIndex V n, ‖W (scheduledFrequencyHistory V n t) a‖ ^ 2 := by + intro W + have hpoint (s : transferFrequencyRange (V n)) : + ‖∑ d : MovingDescendantFrequencyIndex V n, + movingSampledWeight value μ childBound pivotBound F E n + (movingRootedFrequencyTree V n s.val d) small bulk XL XR‖ ^ 2 ≤ + ∑ a : MovingSampleSlots σ n, movingSamplesPrior μ a * + ∑ d : MovingDescendantFrequencyIndex V n, + ‖W (movingRootedFrequencyTree V n s.val d) a‖ ^ 2 := by + simp only [movingSampledWeight] + rw [Finset.sum_comm] + simp only [← Finset.mul_sum] + apply (probability_weighted_norm_sq_le (movingSamplesPrior μ) + (movingSamplesPrior_nonneg μ hμ) (movingSamplesPrior_mass μ hmass n) _).trans_eq + apply Finset.sum_congr rfl + intro a _ + congr 1 + exact movingRecursiveWeight_root_energy value childBound pivotBound V F + (movingLocalExtra E) n s.val small bulk a XL XR + calc + _ ≤ ∑ s : transferFrequencyRange (V n), ∑ a : MovingSampleSlots σ n, + movingSamplesPrior μ a * ∑ d : MovingDescendantFrequencyIndex V n, + ‖W (movingRootedFrequencyTree V n s.val d) a‖ ^ 2 := + Finset.sum_le_sum (fun s _ => hpoint s) + _ = _ := by + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + rw [← Finset.mul_sum, ← scheduledFrequency_sum_rooted_real V n (fun t => ‖W t a‖ ^ 2)] + +/-- The same estimate for the manuscript coefficient itself. The squared +node-product is explicit, ready for the arithmetic support estimate; the +spectators, Fourier factors and every support mask remain in the sample term. -/ +theorem movingFrequencyCoefficient_energy {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hmass : ∀ j, ∑ a, μ j a = 1) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) : + (∑ s : transferFrequencyRange (V n), + ‖movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G + n s.val small bulk XL XR‖ ^ 2) ≤ + ∑ a : MovingSampleSlots σ n, movingSamplesPrior μ a * + (movingSampleProduct value a : ℝ) ^ 2 * + ∑ t : ScheduledFrequencyIndex V n, + ‖movingSupportedSampleTerm value outside childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n + (scheduledFrequencyHistory V n t) small bulk XL XR a‖ ^ 2 := by + let E := movingOriginalNode value childBound pivotBound φ G + have h := movingSampledWeight_frequency_energy value μ hμ hmass childBound pivotBound V + (movingGuardedLeaf value outside F) + (movingGuardedExtra value outside (movingLocalExtra (movingCompensatedExtra value E))) + n small bulk XL XR + change (∑ s : transferFrequencyRange (V n), + ‖movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G + n s.val small bulk XL XR‖ ^ 2) ≤ _ at h + apply h.trans_eq + apply Finset.sum_congr rfl + intro a _ + rw [mul_assoc] + congr 1 + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro t _ + dsimp only + rw [movingLocalExtra_guarded, + movingSupportedWeight_recursive value outside childBound pivotBound F + (movingLocalExtra (movingCompensatedExtra value E)) _ _ + (buildMovingSlotData_follows _ _ _ _ _), + movingLocalExtra_compensated, movingRecursiveWeight_compensated, movingSupportedWeight_mul, + norm_mul, mul_pow] + simp only [Complex.norm_natCast] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyFormulaGate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyFormulaGate.lean new file mode 100644 index 0000000000000000000000000000000000000000..a77b45d4eeebf3e94ddb4baa968d9b24ac362ac4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyFormulaGate.lean @@ -0,0 +1,149 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSignedFormulas + +namespace OAI + +/-! # The original formula gate in frequency and internal-prime coordinates -/ + +namespace Ostmann +open scoped Classical + +theorem movingNodeGuard_signed_values {σ : Type*} + (value : σ → ℕ) (step : MovingSlotReversal σ) (hs : step.rootFrequency ≠ 0) + (childBound pivotBound : ℕ) (L R : HistoryFormula Bool) (a : Bool → ℤ) (x y : ℤ) + (hL : L.value (fun b => (a b : ℚ)) = (x : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (y : ℚ)) : + let g := movingNodeGuard (MovingSlotReversal.naturalProduct value step.leftSlots) + (MovingSlotReversal.naturalProduct value step.rightSlots) + step.rootFrequency step.leftFrequency step.rightFrequency hs childBound pivotBound L R + g.pivot.value (fun b => (a b : ℚ)) = + (step.signedNumerator value x y : ℚ) / step.rootFrequency ∧ + g.rightProduct.value (fun b => (a b : ℚ)) = + ((y * MovingSlotReversal.naturalProduct value step.rightSlots : ℤ) : ℚ) := by + dsimp only + simp only [movingNodeGuard, wordTransferGuard, wordTransferStep, HistoryPivotStep.formula, + movingNodeWord, HistoryFormula.value_bind, HistoryFormula.value_solve, + HistoryFormula.value_listProduct, List.map_cons, List.map_nil, List.prod_cons, + List.prod_nil, HistoryFormula.value_prime, Bool.false_eq_true, ite_false, ite_true, + HistoryFormula.value_product, HistoryFormula.value_external, hL, hR, + MovingSlotReversal.signedNumerator, Int.cast_sub, Int.cast_mul, Int.cast_natCast, + mul_one, and_self] + +theorem movingNodeGuard_residue_of_signedIntegral {σ : Type*} + (value : σ → ℕ) (step : MovingSlotReversal σ) (hs : step.rootFrequency ≠ 0) + (childBound pivotBound : ℕ) (L R : HistoryFormula Bool) (a : Bool → ℤ) (x y : ℤ) + (hL : L.value (fun b => (a b : ℚ)) = (x : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (y : ℚ)) + (hI : step.SignedIntegralAt value x y) + (hroot : IsCoprime step.rootFrequency + (y * MovingSlotReversal.naturalProduct value step.rightSlots : ℤ)) + (hpivot : IsCoprime step.rightFrequency + ((MovingSlotReversal.naturalProduct value step.compensationSlots : ℤ) * step.signedPivot value x y)) : + (movingNodeGuard (MovingSlotReversal.naturalProduct value step.leftSlots) + (MovingSlotReversal.naturalProduct value step.rightSlots) + step.rootFrequency step.leftFrequency step.rightFrequency hs childBound pivotBound L R).residueAt a := by + let g := movingNodeGuard (MovingSlotReversal.naturalProduct value step.leftSlots) + (MovingSlotReversal.naturalProduct value step.rightSlots) + step.rootFrequency step.leftFrequency step.rightFrequency hs childBound pivotBound L R + have hv := movingNodeGuard_signed_values value step hs childBound pivotBound L R a x y hL hR + have hP : g.pivot.value (fun b => (a b : ℚ)) = + (((MovingSlotReversal.naturalProduct value step.compensationSlots : ℤ) * step.signedPivot value x y : ℤ) : ℚ) := by + rw [hv.1, hI] + push_cast + field_simp + change g.residueAt a + unfold WordTransferGuard.residueAt + rw [g.pivot.smallDivisionTest_of_value a _ hP, + g.rightProduct.smallDivisionTest_of_value a _ hv.2] + constructor + · change IsUnit (((MovingSlotReversal.naturalProduct value step.compensationSlots : ℤ) * + step.signedPivot value x y : ℤ) : ZMod step.rightFrequency.natAbs) + rwa [ZMod.coe_int_isUnit_iff_isCoprime, Int.natCast_natAbs, IsCoprime.abs_left_iff] + · change IsUnit ((y * (MovingSlotReversal.naturalProduct value step.rightSlots : ℤ) : ℤ) : + ZMod step.rootFrequency.natAbs) + rwa [ZMod.coe_int_isUnit_iff_isCoprime, Int.natCast_natAbs, IsCoprime.abs_left_iff] + +theorem movingSignedFrequencyUnits_local {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (x y : ℤ) + (h : movingSignedFrequencyUnits value T x y) : movingFrequencyLocalUnits T x y := by + cases T with + | leaf => exact h + | node => exact h.1 + +theorem MovingSlotData.formulaNodes_residue_of_signedIntegral {σ : Type*} + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) + (hsmall : ∀ i, T.Frequencies (fun f => IsCoprime f (value i : ℤ))) + (L R : HistoryFormula Bool) (a : Bool → ℤ) (x y : ℤ) + (hL : L.value (fun b => (a b : ℚ)) = (x : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (y : ℚ)) + (hI : T.SignedIntegral value x y) (hunit : movingSignedFrequencyUnits value T x y) : + ∀ f ∈ T.formulaNodes value hvalue childBound pivotBound hf L R, f.residueTests a := by + induction T generalizing L R x y with + | leaf => simp [formulaNodes] + | @node n s CL CR U left right ihL ihR => + let step := MovingSlotData.step s CL CR U left right false + have hU := MovingSlotReversal.naturalProduct_ne_zero value hvalue U + let G := step.giantFormula value hf.1 hU L R + have hG := step.giantFormula_of_signed_integral value hf.1 hU L R a x y hL hR hI.1 + have hroot : IsCoprime s (y * (MovingSlotReversal.naturalProduct value CR : ℤ)) := by + apply IsCoprime.mul_right + · exact ((MovingSlotData.node s CL CR U left right).frequencies_isCoprime y |>.mpr hunit.1.2).root.symm + · exact (movingNaturalProduct_coprime value CR s + (fun i _ => (hsmall i).root.symm)).symm + have hpivot : IsCoprime right.frequency + ((MovingSlotReversal.naturalProduct value U : ℤ) * step.signedPivot value x y) := by + apply IsCoprime.mul_right + · exact (movingNaturalProduct_coprime value U right.frequency + (fun i _ => (hsmall i).2.2.root.symm)).symm + · exact ((right.frequencies_isCoprime (step.signedPivot value x y)).mpr + (movingSignedFrequencyUnits_local value right _ _ hunit.2.2).1).root.symm + have hguard := movingNodeGuard_residue_of_signedIntegral value step hf.1 + (childBound (n + 1)) (pivotBound (n + 1)) L R a x y hL hR hI.1 hroot hpivot + have hl := ihL hf.2.1 (fun i => (hsmall i).2.1) G L _ _ hG hL hI.2.1 hunit.2.1 + have hr := ihR hf.2.2 (fun i => (hsmall i).2.2) G R _ _ hG hR hI.2.2 hunit.2.2 + intro f hmem + rcases List.mem_cons.mp hmem with hmem | hmem + · subst f + exact (MovingFormulaNode.residueTests_iff _ a).mpr + ⟨hguard, step.giantFormula_signed_integral_iff value hf.1 hU L R a x y hL hR |>.mpr hI.1⟩ + · rcases List.mem_append.mp hmem with hmem | hmem + · exact hl f hmem + · exact hr f hmem + +theorem moving_formula_residue_frequency_internal_iff {σ : Type*} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) (R₀ : ℤ) + (hsmallR : ∀ i, IsCoprime (value i : ℤ) R₀) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hlevels : T.Levels tier) (hf : T.Frequencies (· ≠ 0)) + (hsmall : ∀ i, T.Frequencies (fun f => IsCoprime f (value i : ℤ))) + (hfmod : ∀ i, T.Frequencies (fun f => (f : ZMod (value i)) ≠ 0)) + (hR₀ : T.frequencyProduct ∣ R₀) (hdistinct : T.CompensationDistinct value) + (L R : HistoryFormula Bool) (a : Bool → ℤ) (x y : ℤ) + (hL : L.value (fun b => (a b : ℚ)) = (x : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (y : ℚ)) : + let nodes := T.formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound hf L R + movingResidueGate nodes a ∧ movingSignedFrequencyUnits value T x y ↔ + (∀ f ∈ nodes, f.guard.frequencyBounds) ∧ + movingFrequencyGate value R₀ T x y ∧ movingPrimeLineSupport value T x y := by + let hvalue := fun i => (hprime i).ne_zero + let nodes := T.formulaNodes value hvalue childBound pivotBound hf L R + have hint := T.formulaNodes_signed_integral_iff value hvalue childBound pivotBound hf L R a x y hL hR + have hsplit := moving_frequency_internal_split tier value hprime hdisjoint R₀ hsmallR + T hlevels hf hfmod hR₀ hdistinct x y + change (movingResidueGate nodes a ∧ _) ↔ (∀ f ∈ nodes, _) ∧ _ ∧ _ + constructor + · rintro ⟨hres, hunit⟩ + have hI : T.SignedIntegral value x y := hint.mp (fun f hf => + (f.residueTests_iff a).mp (hres f hf).1 |>.2) + exact ⟨fun f hf => (hres f hf).2, hsplit.mpr ⟨hI, hunit⟩⟩ + · rintro ⟨hb, hg, hl⟩ + obtain ⟨hI, hunit⟩ := hsplit.mp ⟨hg, hl⟩ + have htests := T.formulaNodes_residue_of_signedIntegral value hvalue childBound pivotBound + hf hsmall L R a x y hL hR hI hunit + exact ⟨fun f hf => ⟨htests f hf, hb f hf⟩, hunit⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyModelPage.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyModelPage.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d064461acf4fe93b287fe12e7778d24317484bb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyModelPage.lean @@ -0,0 +1,28 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantSupport +import OAI.NumberTheory.Ostmann.Arithmetic.BulkResidueCoprime + +namespace OAI + +/-! # The bulk Page projection for the actual frequency model -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem frequencyModel_bulk_page_projection {I : Type*} [Fintype I] + (S : Finset ℤ) (n V cutoff : ℕ) (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) (hcut : V < cutoff) + (p : I → ℕ) (z : Option PrimitiveRealZero) + (hp : ∀ i, (p i).Prime ∧ cutoff ≤ p i) + (hdelete : ∀ e, z = some e → ∀ q, + deletedConductorPrime e.modulus cutoff = some q → ∀ i, q ≠ p i) : + pageAtModulus (∏ i, bulkResidueModuli (frequencyModelBase S n t ^ (n - 1 + 2)) p i) z = + pageAtModulus (frequencyModelBase S n t ^ (n - 1 + 2)) z := by + have h := frequencyModel_page_projection S n V cutoff t hS hcut ∅ p z + (by simp) hp (by simp) hdelete + rw [movingArithmeticModuli_product] at h + simpa only [Fintype.prod_sum_type, bulkResidueModuli, Fintype.prod_unique, + Finset.prod_empty, one_pow, one_mul, mul_one] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyModelRange.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyModelRange.lean new file mode 100644 index 0000000000000000000000000000000000000000..6482d8ea78e858780494ff872aaec2e903e18a68 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyModelRange.lean @@ -0,0 +1,43 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantBounds +import OAI.NumberTheory.Ostmann.Arithmetic.BulkResidueCoprime + +namespace OAI + +/-! # The concrete frequency-model modulus in the bulk progression range -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +theorem movingFrequencyModel_bulk_range (n k : ℕ) (A : ℝ) (hA : 0 ≤ A) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (S : Finset ℤ) (N : ℕ) (t : FrequencyTree (S × S) n) (p : Fin m → ℕ), + (∀ s ∈ S, s ≠ 0) → (∀ s ∈ S, s.natAbs ≤ N) → + (N : ℝ) ≤ Real.exp (A * m) → + (∀ i, (p i).Prime) → Function.Injective p → (∀ i, N < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + let r := frequencyModelBase S n t ^ (n - 1 + 2) + let M := ∏ i, bulkResidueModuli r p i + 0 < r ∧ 0 < M ∧ + Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j)) ∧ + M ≤ bulkProgressionCutoff L := by + let d : ℕ := 2 * (2 ^ (n + 1) - 1) * (n - 1 + 2) + filter_upwards [bulkResidueModulus_progression_range ((d : ℝ) * A) ((k : ℝ) ^ 4) + (by positivity) (by positivity), eventually_ge_atTop (0 : ℝ)] with L hL hL0 + dsimp only + intro S N t p hS hN hbound hp hinj hNp hupper + let r := frequencyModelBase S n t ^ (n - 1 + 2) + have hr : 0 < r := pow_pos (frequencyModelBase_pos S n t hS) _ + have hrbound : (r : ℝ) ≤ Real.exp (((d : ℝ) * A) * spectatorBulkCount k L) := by + simpa only [d, r, mul_assoc] using frequencyModelModulus_exp_bound S N n t + (A * spectatorBulkCount k L) hN hbound + refine ⟨hr, bulkResidueModulus_positive r hr p (fun i => (hp i).pos), ?_, + hL _ r p (spectatorBulkCount_upper k L hL0) hrbound hupper⟩ + apply bulkResidueModuli_pairwise r p hp hinj + intro i + exact ((prime_coprime_frequencyModelBase S N (p i) n (hp i) (hNp i) + (fun s hs => ⟨hS s hs, hN s hs⟩) t).pow_right _).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyModulus.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..84ebde42669bc39c78e7e6bf2bfee0d5d58274d7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyModulus.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingUnitPeriodBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkBudgets +import OAI.NumberTheory.Ostmann.Arithmetic.BulkResidueCoprime + +namespace OAI + +/-! # The concrete frequency modulus for the original pair of histories -/ + +namespace Ostmann +open scoped Classical + +def movingPairFrequencyBase {σ : Type*} {n : ℕ} (T : Bool → MovingSlotData σ n) : ℤ := + (T false).frequencyProduct * (T true).frequencyProduct + +def movingPairFrequencyModulus {σ : Type*} {n : ℕ} (T : Bool → MovingSlotData σ n) : ℕ := + (movingPairFrequencyBase T).natAbs ^ (n + 1) + +theorem movingPairFrequencyBase_dvd {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (b : Bool) : + (T b).frequencyProduct ∣ movingPairFrequencyBase T := by + cases b + · exact dvd_mul_right _ _ + · exact dvd_mul_left _ _ + +theorem movingPairFrequencyModulus_precision {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) : + movingPairFrequencyBase T ^ (n + 1) ∣ (movingPairFrequencyModulus T : ℤ) := by + apply Int.dvd_natCast.mpr + simp only [Int.natAbs_pow, movingPairFrequencyModulus] + exact dvd_rfl + +theorem movingPairFrequencyModulus_pos {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) : + 0 < movingPairFrequencyModulus T := by + apply pow_pos + exact Int.natAbs_pos.mpr (mul_ne_zero + ((T false).frequencyProduct_ne_zero (hf false)) + ((T true).frequencyProduct_ne_zero (hf true))) + +theorem movingPairFrequencyModulus_bound {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (B : ℕ) + (hf : ∀ b, (T b).Frequencies (fun s => s.natAbs ≤ B)) : + movingPairFrequencyModulus T ≤ B ^ (2 * (2 ^ (n + 1) - 1) * (n + 1)) := by + have h := Nat.mul_le_mul ((T false).frequencyProduct_bound B (hf false)) + ((T true).frequencyProduct_bound B (hf true)) + have hp := Nat.pow_le_pow_left h (n + 1) + simpa only [movingPairFrequencyModulus, movingPairFrequencyBase, Int.natAbs_mul, + ← pow_add, ← pow_mul, ← two_mul] using hp + +theorem movingPairFrequencyModulus_exp {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (B : ℕ) (A m : ℝ) + (hf : ∀ b, (T b).Frequencies (fun s => s.natAbs ≤ B)) + (hB : (B : ℝ) ≤ Real.exp (A * m)) : + (movingPairFrequencyModulus T : ℝ) ≤ + Real.exp ((2 * (2 ^ (n + 1) - 1) * (n + 1) : ℕ) * (A * m)) := by + calc + _ ≤ (B : ℝ) ^ (2 * (2 ^ (n + 1) - 1) * (n + 1)) := by + exact_mod_cast movingPairFrequencyModulus_bound T B hf + _ ≤ Real.exp (A * m) ^ (2 * (2 ^ (n + 1) - 1) * (n + 1)) := + pow_le_pow_left₀ (Nat.cast_nonneg _) hB _ + _ = _ := (Real.exp_nat_mul _ _).symm + +/-- The hypotheses on the original frequency list supply all frequency +period and nonzero-modulus requirements of the prime comparison. -/ +theorem movingPattern_frequency_modulus {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hf : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) : + let T := movingPatternFinBulkData e n m t small slot perm pattern + 0 < movingPairFrequencyModulus T ∧ + (∀ b, (T b).frequencyProduct ∣ movingPairFrequencyBase T) ∧ + movingPairFrequencyBase T ^ (n + 1) ∣ (movingPairFrequencyModulus T : ℤ) := by + dsimp only + exact ⟨movingPairFrequencyModulus_pos _ + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hf), + movingPairFrequencyBase_dvd _, movingPairFrequencyModulus_precision _⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyPrimeSquare.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyPrimeSquare.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5a3b772bdbcad21bf9d6c408fcfb3900a1be4a1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyPrimeSquare.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPrimeExpansion + +namespace OAI + +/-! # The actual coefficient square inside the original two prime intervals -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap ComplexConjugate + +/-- Expanding the square and exchanging the finite prime sums introduces +exactly the two independent descendant histories used in the arithmetic norm. -/ +theorem movingFrequencyCoefficient_original_prime_square {σ I : Type} [Fintype σ] + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (s : ℤ) (small bulk : TreeLeafTuple (List σ) n) (u v r w : ℝ) : + let W := fun (a : MovingDescendantFrequencyIndex V n) (x y : ℝ) => + movingOriginalSampleAverage q value outside μ childBound pivotBound F g Dq S ψ X lo hi φ G + n (movingRootedFrequencyTree V n s a) small bulk ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ + complexPrimeInterval 1 0 r w (fun y => complexPrimeInterval 1 0 u v (fun x => + (‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s small bulk + ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊‖ ^ 2 : ℂ))) = + ∑ a : MovingDescendantFrequencyIndex V n, ∑ b : MovingDescendantFrequencyIndex V n, + complexPrimeInterval 1 0 r w (fun y => complexPrimeInterval 1 0 u v (fun x => + W a x y * star (W b x y))) := by + intro W + have heq (x y : ℝ) : + (‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s small bulk + ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊‖ ^ 2 : ℂ) = + ∑ a : MovingDescendantFrequencyIndex V n, ∑ b : MovingDescendantFrequencyIndex V n, + W a x y * star (W b x y) := by + rw [movingFrequencyCoefficient_original] + change (‖∑ a, W a x y‖ ^ 2 : ℂ) = _ + calc + _ = (∑ a, W a x y) * star (∑ b, W b x y) := by + rw [Complex.star_def, Complex.mul_conj'] + _ = _ := by + simp only [star_sum, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + simp_rw [heq, complexPrimeInterval_sum] + +/-- Two descendant histories in a coefficient square share their root. +Their inclusion in the full pair of scheduled histories is injective. -/ +def sameRootScheduledPairEmbedding (V : ℕ → ℕ) (n : ℕ) : + (transferFrequencyRange (V n) × + (MovingDescendantFrequencyIndex V n × MovingDescendantFrequencyIndex V n)) ↪ + (ScheduledFrequencyIndex V n × ScheduledFrequencyIndex V n) where + toFun a := ((scheduledFrequencyRootEquiv V n).symm (a.1, a.2.1), + (scheduledFrequencyRootEquiv V n).symm (a.1, a.2.2)) + inj' := by + intro a b h + have hl := congrArg (scheduledFrequencyRootEquiv V n) (congrArg Prod.fst h) + have hr := congrArg (scheduledFrequencyRootEquiv V n) (congrArg Prod.snd h) + simp only [Equiv.apply_symm_apply] at hl hr + apply Prod.ext + · exact congrArg (fun t : transferFrequencyRange (V n) × + MovingDescendantFrequencyIndex V n => t.1) hl + · apply Prod.ext + · exact congrArg (fun t : transferFrequencyRange (V n) × + MovingDescendantFrequencyIndex V n => t.2) hl + · exact congrArg (fun t : transferFrequencyRange (V n) × + MovingDescendantFrequencyIndex V n => t.2) hr + +/-- Enlarging only the shared-root restriction costs no factor. This is used +after the exact original prime-pair expansion of each coefficient square. -/ +theorem same_root_scheduled_pair_sum_le (V : ℕ → ℕ) (n : ℕ) + (F : ScheduledFrequencyIndex V n → ScheduledFrequencyIndex V n → ℝ) + (hF : ∀ a b, 0 ≤ F a b) : + (∑ s : transferFrequencyRange (V n), ∑ a : MovingDescendantFrequencyIndex V n, + ∑ b : MovingDescendantFrequencyIndex V n, + F ((scheduledFrequencyRootEquiv V n).symm (s, a)) + ((scheduledFrequencyRootEquiv V n).symm (s, b))) ≤ + ∑ a : ScheduledFrequencyIndex V n, ∑ b : ScheduledFrequencyIndex V n, F a b := by + let e := sameRootScheduledPairEmbedding V n + have h : (∑ t ∈ Finset.univ.map e, F t.1 t.2) ≤ + ∑ t : ScheduledFrequencyIndex V n × ScheduledFrequencyIndex V n, F t.1 t.2 := + Finset.sum_le_sum_of_subset_of_nonneg + (Finset.subset_univ (Finset.univ.map e)) + (by intro a _ _; exact hF a.1 a.2) + rw [Finset.sum_map] at h + change (∑ a : transferFrequencyRange (V n) × + (MovingDescendantFrequencyIndex V n × MovingDescendantFrequencyIndex V n), + F ((scheduledFrequencyRootEquiv V n).symm (a.1, a.2.1)) + ((scheduledFrequencyRootEquiv V n).symm (a.1, a.2.2))) ≤ _ at h + simpa only [Fintype.sum_prod_type] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyRateMonotone.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyRateMonotone.lean new file mode 100644 index 0000000000000000000000000000000000000000..054526184c5fd83b397eccbeb7ecf3be014ad0c4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyRateMonotone.lean @@ -0,0 +1,32 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyBudget + +namespace OAI + +/-! # One frequency budget covers every depth of the finite schedule -/ +namespace Ostmann + +theorem movingFrequencyRate_nonneg (Bs BD Bz z : ℝ) + (hBs : 0 ≤ Bs) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) (hz : 1 ≤ z) (n : ℕ) : + 0 ≤ movingFrequencyRate Bs BD Bz z n := by + have hl := Real.log_nonneg hz + have hr := Real.log_nonneg (one_le_pow₀ (by norm_num : (1 : ℝ) ≤ 2) (n := n)) + unfold movingFrequencyRate + positivity + +theorem movingFrequencyRate_monotone (Bs BD Bz z : ℝ) + (hBs : 0 ≤ Bs) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) (hz : 1 ≤ z) : + Monotone (movingFrequencyRate Bs BD Bz z) := by + intro n k hnk + have hp : (2 : ℝ) ^ n ≤ (2 : ℝ) ^ k := pow_le_pow_right₀ (by norm_num) hnk + have hl := Real.log_nonneg hz + have hr := Real.log_nonneg (one_le_pow₀ (by norm_num : (1 : ℝ) ≤ 2) (n := n)) + have hlr := Real.log_le_log (by positivity : 0 < (2 : ℝ) ^ n) hp + unfold movingFrequencyRate + apply mul_le_mul hp + (show Bs + 8 * Real.log z + BD + Bz * Real.log z + 2 / 5 * Real.log ((2 : ℝ) ^ n) + 2 ≤ + Bs + 8 * Real.log z + BD + Bz * Real.log z + 2 / 5 * Real.log ((2 : ℝ) ^ k) + 2 by linarith) + (by positivity) (by positivity) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyResidues.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..632557717c436c04f83e0a3bd6ba131be176e6d6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFrequencyResidues.lean @@ -0,0 +1,168 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationLines +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAuxiliaryPeriod + +namespace OAI + +/-! # Frequency residues with compensation factors inverted + +Unlike the signed integer recursion, this recursion divides only by the +frequency. Compensation factors are inverted modulo a frequency power, so +no internal prime enters its period. One power is consumed per reversal. +-/ + +namespace Ostmann +open scoped Classical + +def MovingSlotReversal.signedNumerator {σ : Type*} (s : MovingSlotReversal σ) + (value : σ → ℕ) (XL XR : ℤ) : ℤ := + s.leftFrequency * (XR * (naturalProduct value s.rightSlots : ℤ)) - + s.rightFrequency * (XL * (naturalProduct value s.leftSlots : ℤ)) + +def MovingSlotReversal.frequencyPivot {σ : Type*} (s : MovingSlotReversal σ) + (value : σ → ℕ) (R : ℤ) (k : ℕ) (XL XR : ℤ) : ℤ := + (s.signedNumerator value XL XR / s.rootFrequency) * + Int.gcdA (naturalProduct value s.compensationSlots : ℤ) (R ^ k) + +theorem coprime_bezout_inverse_modEq (u R : ℤ) (hu : IsCoprime u R) (k : ℕ) : + u * Int.gcdA u (R ^ k) ≡ 1 [ZMOD R ^ k] := by + have h := Int.gcd_eq_gcd_ab u (R ^ k) + have hg : Int.gcd u (R ^ k) = 1 := Int.isCoprime_iff_gcd_eq_one.mp hu.pow_right + rw [hg] at h + apply Int.modEq_iff_dvd.mpr + refine ⟨Int.gcdB u (R ^ k), ?_⟩ + linear_combination h + +theorem MovingSlotReversal.signedNumerator_modEq {σ : Type*} (s : MovingSlotReversal σ) + (value : σ → ℕ) (XL XR YL YR M : ℤ) + (hL : XL ≡ YL [ZMOD M]) (hR : XR ≡ YR [ZMOD M]) : + s.signedNumerator value XL XR ≡ s.signedNumerator value YL YR [ZMOD M] := + ((hR.mul_right _).mul_left _).sub ((hL.mul_right _).mul_left _) + +theorem MovingSlotReversal.frequencyPivot_modEq {σ : Type*} (s : MovingSlotReversal σ) + (value : σ → ℕ) (R : ℤ) (k : ℕ) (hs : s.rootFrequency ≠ 0) + (hsR : s.rootFrequency ∣ R) (XL XR YL YR : ℤ) + (hL : XL ≡ YL [ZMOD R ^ (k + 1)]) (hR : XR ≡ YR [ZMOD R ^ (k + 1)]) : + s.frequencyPivot value R k XL XR ≡ s.frequencyPivot value R k YL YR [ZMOD R ^ k] := by + have hd : s.rootFrequency * R ^ k ∣ R ^ (k + 1) := by + simpa only [pow_succ, mul_comm] using mul_dvd_mul hsR (dvd_refl (R ^ k)) + exact (int_modEq_ediv _ _ _ _ hs + ((s.signedNumerator_modEq value XL XR YL YR _ hL hR).of_dvd hd)).mul_right _ + +theorem MovingSlotReversal.frequencyPivot_nat_modEq {σ : Type*} (s : MovingSlotReversal σ) + (value : σ → ℕ) (R : ℤ) (k : ℕ) (hs : s.rootFrequency ≠ 0) + (hu : IsCoprime (naturalProduct value s.compensationSlots : ℤ) R) + (XL XR : ℕ) (hI : s.IntegralAt value (XL, XR)) : + s.frequencyPivot value R k XL XR ≡ (s.naturalPivot value XL XR : ℤ) [ZMOD R ^ k] := by + have hn : s.signedNumerator value XL XR = s.rootFrequency * + ((naturalProduct value s.compensationSlots : ℤ) * s.naturalPivot value XL XR) := by + simpa only [signedNumerator, Nat.cast_mul] using hI.2 + unfold frequencyPivot + rw [hn, Int.mul_ediv_cancel_left _ hs] + have h := (coprime_bezout_inverse_modEq _ R hu k).mul_right + (s.naturalPivot value XL XR : ℤ) + simpa only [one_mul, mul_assoc, mul_comm, mul_left_comm] using h + +def movingFrequencyLocalUnits {σ : Type*} {n : ℕ} (T : MovingSlotData σ n) + (XL XR : ℤ) : Prop := + IsCoprime XL T.frequencyProduct ∧ IsCoprime XR T.frequencyProduct + +def movingFrequencyGate {σ : Type*} (value : σ → ℕ) (R : ℤ) : + {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → Prop + | _, T@(.leaf _ _), XL, XR => movingFrequencyLocalUnits T XL XR + | n + 1, T@(.node s CL CR U left right), XL, XR => + let step := MovingSlotData.step s CL CR U left right false + let p := step.frequencyPivot value R (n + 1) XL XR + movingFrequencyLocalUnits T XL XR ∧ s ∣ step.signedNumerator value XL XR ∧ + movingFrequencyGate value R left p XL ∧ movingFrequencyGate value R right p XR + +theorem movingFrequencyLocalUnits_modEq {σ : Type*} {n : ℕ} (T : MovingSlotData σ n) + (XL XR YL YR M : ℤ) (hM : T.frequencyProduct ∣ M) + (hL : XL ≡ YL [ZMOD M]) (hR : XR ≡ YR [ZMOD M]) : + movingFrequencyLocalUnits T XL XR ↔ movingFrequencyLocalUnits T YL YR := by + exact and_congr (int_modEq_isCoprime_iff (hL.of_dvd hM)) + (int_modEq_isCoprime_iff (hR.of_dvd hM)) + +theorem MovingSlotData.frequencyProduct_node_dvd {σ : Type*} {n : ℕ} + (s : ℤ) (CL CR U : List σ) (left right : MovingSlotData σ n) (R : ℤ) + (h : (MovingSlotData.node s CL CR U left right).frequencyProduct ∣ R) : + s ∣ R ∧ left.frequencyProduct ∣ R ∧ right.frequencyProduct ∣ R := by + refine ⟨?_, ?_, ?_⟩ + · exact dvd_trans ⟨left.frequencyProduct * right.frequencyProduct, by + simp only [frequencyProduct]; ring⟩ h + · exact dvd_trans ⟨s * right.frequencyProduct, by + simp only [frequencyProduct]; ring⟩ h + · exact (dvd_mul_left _ _).trans h + +/-- The entire frequency block has a period containing only frequencies. +The compensation primes have disappeared from the period. -/ +theorem movingFrequencyGate_modEq {σ : Type*} (value : σ → ℕ) (R : ℤ) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (hR : T.frequencyProduct ∣ R) (XL XR YL YR : ℤ) + (hL : XL ≡ YL [ZMOD R ^ (n + 1)]) (hRight : XR ≡ YR [ZMOD R ^ (n + 1)]) : + movingFrequencyGate value R T XL XR ↔ movingFrequencyGate value R T YL YR := by + induction T generalizing XL XR YL YR with + | leaf s regular => + exact movingFrequencyLocalUnits_modEq _ _ _ _ _ _ + (by simpa using hR) hL hRight + | @node n s CL CR U left right ihL ihR => + have hd := MovingSlotData.frequencyProduct_node_dvd s CL CR U left right R hR + have hp := (MovingSlotData.step s CL CR U left right false).frequencyPivot_modEq + value R (n + 1) hf.1 hd.1 XL XR YL YR hL hRight + have hpow : R ∣ R ^ (n + 1 + 1) := dvd_pow_self R (by omega) + have hnum := (MovingSlotData.step s CL CR U left right false).signedNumerator_modEq + value XL XR YL YR _ hL hRight + have hdiv : s ∣ (MovingSlotData.step s CL CR U left right false).signedNumerator value XL XR ↔ + s ∣ (MovingSlotData.step s CL CR U left right false).signedNumerator value YL YR := + (hnum.of_dvd (hd.1.trans hpow)).dvd_iff + have hlocal := movingFrequencyLocalUnits_modEq + (MovingSlotData.node s CL CR U left right) XL XR YL YR _ (hR.trans hpow) hL hRight + change (_ ∧ _ ∧ _ ∧ _) ↔ (_ ∧ _ ∧ _ ∧ _) + exact and_congr hlocal (and_congr hdiv (and_congr + (ihL hf.2.1 hd.2.1 _ _ _ _ hp (hL.of_dvd (pow_dvd_pow R (by omega)))) + (ihR hf.2.2 hd.2.2 _ _ _ _ hp (hRight.of_dvd (pow_dvd_pow R (by omega)))))) + +theorem movingNaturalProduct_coprime {σ : Type*} (value : σ → ℕ) (slots : List σ) + (R : ℤ) (h : ∀ i ∈ slots, IsCoprime (value i : ℤ) R) : + IsCoprime (MovingSlotReversal.naturalProduct value slots : ℤ) R := by + induction slots with + | nil => simpa [MovingSlotReversal.naturalProduct] using (isCoprime_one_left (x := R)) + | cons i slots ih => + simpa only [MovingSlotReversal.naturalProduct, List.map_cons, List.prod_cons, Nat.cast_mul] using + (h i List.mem_cons_self).mul_left (ih (fun j hj => h j (List.mem_cons_of_mem i hj))) + +/-- On an original integral history this frequency-only recursion is exactly +the original subtree-frequency unit support. No stronger giant unit test is +inserted and all frequency divisibility tests remain in the new recursion. -/ +theorem movingFrequencyGate_nat_iff {σ : Type*} (value : σ → ℕ) (R : ℤ) + (hsmall : ∀ i, IsCoprime (value i : ℤ) R) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (hR : T.frequencyProduct ∣ R) (XL XR : ℕ) (hI : T.Integral value XL XR) : + movingFrequencyGate value R T XL XR ↔ movingAuxiliaryUnits value [] T XL XR := by + induction T generalizing XL XR with + | leaf s regular => + simp only [movingFrequencyGate, movingFrequencyLocalUnits, movingAuxiliaryUnits, + movingAuxiliaryLocalUnits, List.prod_nil, Nat.cast_one, isCoprime_one_right, and_true] + | @node n s CL CR U left right ihL ihR => + let step := MovingSlotData.step s CL CR U left right false + let p := step.naturalPivot value XL XR + let r := step.frequencyPivot value R (n + 1) XL XR + have hd := MovingSlotData.frequencyProduct_node_dvd s CL CR U left right R hR + have hp : r ≡ (p : ℤ) [ZMOD R ^ (n + 1)] := + step.frequencyPivot_nat_modEq value R (n + 1) hf.1 + (movingNaturalProduct_coprime value U R (fun i _ => hsmall i)) XL XR hI.1 + have hl := movingFrequencyGate_modEq value R left hf.2.1 hd.2.1 r XL p XL hp (Int.ModEq.refl _) + have hr := movingFrequencyGate_modEq value R right hf.2.2 hd.2.2 r XR p XR hp (Int.ModEq.refl _) + have hn : s ∣ step.signedNumerator value XL XR := by + have h := hI.1.2 + exact ⟨_, by simpa only [step, MovingSlotReversal.signedNumerator, + MovingSlotData.step, Nat.cast_mul] using h⟩ + change (movingFrequencyLocalUnits _ _ _ ∧ s ∣ step.signedNumerator value XL XR ∧ + movingFrequencyGate value R left r XL ∧ movingFrequencyGate value R right r XR) ↔ _ + rw [hl, hr, ihL hf.2.1 hd.2.1 p XL hI.2.1, ihR hf.2.2 hd.2.2 p XR hI.2.2] + simp only [movingAuxiliaryUnits, movingAuxiliaryLocalUnits, movingFrequencyLocalUnits, + List.prod_nil, Nat.cast_one, isCoprime_one_right, and_true, hn, true_and] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullCoefficientTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullCoefficientTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..883df8a166edfa36581b207c8b9ac94057fddd98 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullCoefficientTransfer.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeCoefficientSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalLiveSupport + +namespace OAI + +/-! # Coefficient-supported transfer with the full original giant prior -/ +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +theorem movingTemplatePrimeAmplitude_step_full_coefficients {σ J : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : J → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (hF : ∀ {n} (T : MovingSlotData σ n), F T 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset J) + (ψ : SchwartzMap ℝ ℂ) (X lo hi W : ℝ) (hX : 0 < X) + (hwindow : X * hi ≤ Real.exp W) + (φ : ℝ → ℝ) (G c : ℕ → ℝ) (hout : ∀ t, 1 ≤ |t| → φ t = 0) + (hμlower : ∀ j x, μ j x ≠ 0 → Real.exp (c j - 1) ≤ (value x : ℝ)) + (n r m : ℕ) (Y reserveMass : ℝ) (hm : 64 ≤ reserveMass) (hY : Y ≤ W) + (hVeq : V = movingProductNaturalCutoff (movingCellPivotExponent G c) W Y reserveMass) + (hbudget : ∀ j, 2 * movingCellPivotExponent G c j ≤ + movingProductExponent (movingCellPivotExponent G c) W j) + (hpositive : 0 ≤ movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n) + (Pg I : Finset ℕ) (hPg : ∀ p ∈ Pg, p.Prime) (hPI : smoothGiantLivePrimes Pg φ (G (n + 1)) ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass Pg φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (ν : MovingRegularSlot n r m → σ → ℝ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ q : smoothGiantLivePrimes Pg φ (G (n + 1)), ∀ x, ggiant q (-x) = conj (ggiant q x)) + (H : ℕ) + (hHeq : H = ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊) + (hIlower : ∀ p ∈ I, Real.exp (G (n + 1) - 1) ≤ (p : ℝ)) + (hlarge : ∀ (q : smoothGiantLivePrimes Pg φ (G (n + 1))) (y : MovingRegularSlot n r m → σ), + (∏ i, ν i (y i)) ≠ 0 → ∀ ℓ, ℓ.Prime → ℓ ∣ (q : ℕ) * (∏ i, value (y i)) → V (n + 1) < ℓ) + (hvg : ∀ q : smoothGiantLivePrimes Pg φ (G (n + 1)), V (n + 1) < (q : ℕ)) + (hφsupport : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : smoothGiantLivePrimes Pg φ (G (n + 1)), ∀ right : MovingRegularSlot n r m → σ, (∏ i, ν i (right i)) ≠ 0 → + ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ) (w : ℤ), + movingTemplateCoefficient value outside μ childBound pivotBound V (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n (4 + r) m w + (movingRestoreSample n r m u right) p XR ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + let ρ := smoothGiantPrior Pg φ (G (n + 1)) + let greg := normalizedResidueFamily sets + Real.exp (-smoothGiantLogNormalizer Pg φ (G (n + 1))) * + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable‖ ^ 2 ≤ + movingAmplitudeDiagonal value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n r m Pg I + ρ ν greg ggiant favorable + + ‖movingTemplatePrimeAmplitude value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G (n + 1) r m + Pg ρ (movingTemplateDoubledPrior n r m ν) greg ggiant favorable‖ := by + dsimp only + rw [movingTemplatePrimeAmplitude_live (P := Pg), + movingAmplitudeDiagonal_live (P := Pg), + movingTemplatePrimeAmplitude_live (P := Pg)] + have hnorm : smoothGiantLogNormalizer Pg φ (G (n + 1)) = + smoothGiantLogNormalizer (smoothGiantLivePrimes Pg φ (G (n + 1))) φ (G (n + 1)) := by + simp only [smoothGiantLogNormalizer, smoothGiantMass_live] + rw [hnorm] + exact movingTemplatePrimeAmplitude_step_constructed_coefficients value hvalue outside μ + childBound pivotBound V q F hF g Dq S ψ X lo hi W hX hwindow φ G c hout hμlower + n r m Y reserveMass hm hY hVeq hbudget hpositive + (smoothGiantLivePrimes Pg φ (G (n + 1))) I + (fun p hp => hPg p (smoothGiantLivePrimes_subset Pg φ (G (n + 1)) hp)) hPI hI hφ + (by simpa only [smoothGiantMass_live] using hpos) hμ hμmass ν sets hsets hcard + ggiant favorable hgiant H hHeq hIlower hlarge hvg hφsupport hchild hgap hcomp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullFourier.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullFourier.lean new file mode 100644 index 0000000000000000000000000000000000000000..e93059e3b33566478bb5cf9bab15bc2465356263 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullFourier.lean @@ -0,0 +1,43 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFourierSupported +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFourierBudget +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorProduct + +namespace OAI + +/-! # The full supported coefficient with its explicit polynomial smooth part -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- The actual full integrand separates into its original support coefficient, +the constructed Fourier polynomials, and the actual moving spectator trees. +This includes every zero-support term. -/ +theorem moving_full_fourier_decomposition {σ I : Type*} + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (hextra : ∀ i x s v w, extra x s v w ≠ 0 → + (historyPivot (movingSlotSystem value childBound pivotBound) x s v w : ZMod (q i)) ≠ 0) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hfreq : T.Frequencies (· ≠ 0)) (XL XR : ℕ) (L R : Polynomial ℝ) (z : ℝ) + (hL : L.eval z = (XL : ℝ)) (hR : R.eval z = (XR : ℝ)) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => (movingWindowLeaf value X lo hi F x s * movingFourierLeaf value ψ X x s) * + ∏ i ∈ S, spectatorHistoryLeaf (movingSlotModulus value) (g i) (D i) x s) + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t = + (recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (movingWindowLeaf value X lo hi F) (movingSlotCutoff value childBound pivotBound extra) + n ⟨n, T, XL, XR⟩ t * + smoothPolynomialWeight (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi) z) * + ∏ i ∈ S, movingSlotSpectator value (g i) (D i) T XL XR := by + rw [movingSlotWeight_spectator_product q value childBound pivotBound _ extra hextra + g D S T t hT XL XR] + rw [moving_windowed_fourier_polynomial value hvalue childBound pivotBound F extra + ψ X lo hi hlo hhi T t hT hfreq XL XR L R z hL hR] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullHarmonicCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullHarmonicCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..4547b5fb5a43f4744e038e2b086c46ebf9debd43 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullHarmonicCost.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicCounterpart +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSmallProductLower + +namespace OAI + +/-! # The counterpart cost retaining every actual small-cell endpoint -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem moving_harmonic_full_counterpart_le (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (cg Gmin totalLower : ℝ) + (X : ℕ) (y : MovingRegularSlot n r m → ℕ) + (hX : Real.exp Gmin ≤ (X : ℝ)) + (hy : Real.exp (totalLower) ≤ ((∏ i, y i : ℕ) : ℝ)) : + (Real.exp cg / X) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, y i : ℕ) : ℝ)⁻¹ ≤ + Real.exp (cg - Gmin - totalLower) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) := by + let K := ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) + have hK : 0 ≤ K := mul_nonneg (Nat.cast_nonneg _) + (Finset.prod_nonneg (fun i _ => inv_nonneg.mpr + (Finset.sum_nonneg (fun q _ => inv_nonneg.mpr (Nat.cast_nonneg q))))) + have hp : 0 < Real.exp Gmin * Real.exp (totalLower) := by positivity + have hden : Real.exp Gmin * Real.exp (totalLower) ≤ + (X : ℝ) * ((∏ i, y i : ℕ) : ℝ) := + mul_le_mul hX hy (Real.exp_nonneg _) (Nat.cast_nonneg _) + calc + _ = (Real.exp cg / ((X : ℝ) * ((∏ i, y i : ℕ) : ℝ))) * K := by + dsimp only [K] + simp only [div_eq_mul_inv, mul_inv_rev] + ring + _ ≤ (Real.exp cg / (Real.exp Gmin * Real.exp (totalLower))) * K := + mul_le_mul_of_nonneg_right (div_le_div_of_nonneg_left (Real.exp_nonneg _) hp hden) hK + _ = _ := by + rw [← Real.exp_add, ← Real.exp_sub] + rw [show cg - (Gmin + totalLower) = + cg - Gmin - totalLower by ring] + dsimp only [K] + ring + +/-- Both the small-cell endpoints and the terminal bulk bin remain in the +same denominator, so the compensation cost can cancel against their sum. -/ +theorem movingTemplate_restored_full_harmonic_cost_le {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (hvalue : ∀ a, 0 < value a) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (y : MovingRegularSlot n r m → σ) (hn : n < k) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (lower : TreeLeafIndex n × Fin r → ℝ) + (hlower : ∀ j, Real.exp (lower j) ≤ (value (y (j.1, .inl j.2)) : ℝ)) + (XL XR : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) (cg Gmin : ℝ) + (hX : Real.exp Gmin ≤ (XR : ℝ)) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n (4 + r) m s (movingRestoreSample n r m u y) XL XR ≠ 0) : + (Real.exp cg / XR) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, value (y i) : ℕ) : ℝ)⁻¹ ≤ + Real.exp (cg - Gmin - ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1))) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) := by + exact moving_harmonic_full_counterpart_le n r m Q cg Gmin + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1)) XR (value ∘ y) hX + (movingTemplateCoefficient_restored_full_product_lower value tier hvalue k outside cb cd μ hμ + childBound pivotBound V F φ G n r m s u hu y hn hsmall hbulk lower hlower XL XR h) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullLiveTransformTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullLiveTransformTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..81ede9551c81afd0de6899f365421fe7bd6d5b8f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullLiveTransformTransfer.lean @@ -0,0 +1,128 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullTransformTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularLiveOffDiagonal +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantSupportedTransfer + +namespace OAI + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance liveFullTransferSum_neZero {J H : Type*} (Q : J → ℕ) (L : H → ℕ) + [∀ j, NeZero (Q j)] [∀ i, NeZero (L i)] (i : J ⊕ H) : + NeZero (Sum.elim Q L i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +theorem smoothGiantPrior_full_transform_transfer_on_live + {Y A J H : Type*} [Fintype Y] [Fintype A] [Fintype J] [Fintype H] + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (hI : ∀ p ∈ I, 0 < p) + (φ : ℝ → ℝ) (G : ℝ) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass P φ G) + (μ : Y → ℝ) (hμ : ∀ y, 0 ≤ μ y) (hμmass : ∑ y, μ y = 1) + (U : Y → ℕ) (hU : ∀ y, 0 < U y) + (Q : Y → P → J → ℕ) [∀ y p j, Fact (Q y p j).Prime] + (gQ : ∀ y p j, ZMod (Q y p j) → ℂ) + (hQprod : ∀ y p, (∏ j, Q y p j) = (p : ℕ) * U y) + (giant : J) (S : ∀ y p j, Finset (ZMod (Q y p j))) + (hgQ : ∀ y p x, ‖gQ y p giant x‖ ≤ 1) + (hregular : ∀ y p j, j ≠ giant → gQ y p j = normalizedResidueTransform (S y p j)) + (hS : ∀ y p j, j ≠ giant → (S y p j).Nonempty) + (hSp : ∀ y p j, j ≠ giant → (S y p j).card < Q y p j) + (L : Y → A → H → ℕ) [∀ y a i, Fact (L y a i).Prime] + (gL : ∀ y a i, ZMod (L y a i) → ℂ) + (hgL : ∀ y a i x, gL y a i (-x) = conj (gL y a i x)) + (D : Y → ℕ) (v : Y → A → ℤ) (W : Y → ℕ → A → ℂ) + (hrowSupport : ∀ y (p : P) a, W y p a ≠ 0 → + Pairwise (fun i j => (Q y p i).Coprime (Q y p j)) ∧ + ∀ j, (D y).Coprime (Q y p j)) + (hsupport : ∀ y p, p ∈ I → ∀ a, W y p a ≠ 0 → + Pairwise (fun i j => (L y a i).Coprime (L y a j)) ∧ + (∏ i, L y a i).Coprime (p * U y) ∧ ∀ i, (D y).Coprime (L y a i)) + (N B V : ℕ) + (hv : ∀ y p, p ∈ I → ∀ a, W y p a ≠ 0 → (v y a).natAbs ≤ N) + (hL : ∀ y, μ y ≠ 0 → ∀ p, p ∈ I → ∀ a, W y p a ≠ 0 → (∏ i, L y a i) ≤ B) + (hscale : ∀ y, μ y ≠ 0 → ∀ p, p ∈ I → 2 * N * B ≤ V * (p * U y)) + (hlarge : ∀ y p, p ∈ I → ∀ a, W y p a ≠ 0 → + ∀ q, q.Prime → q ∣ ∏ i, L y a i → V < q) : + Real.exp (-smoothGiantLogNormalizer P φ G) * + ‖∑ y, (μ y : ℂ) * ∑ p : P, (smoothGiantPrior P φ G p : ℂ) * + ∑ a, W y p a * movingRegularTransform (Sum.elim (Q y p) (L y a)) + (movingSumFactors (Q y p) (L y a) (gQ y p) (gL y a)) (D y) (v y a)‖ ^ 2 ≤ + (∑ y, μ y * (U y : ℝ) * ∑ p ∈ I, φ (Real.log p - G) * + (pivotDiagonal (fun a => ∏ i, L y a i) (v y) + (movingRegularCoefficient (L y) (gL y) (D y) (U y) (v y) (W y) p)).re) + + ‖∑ y, ((μ y * (U y : ℝ) : ℝ) : ℂ) * + ∑ s ∈ transferFrequencyRange V, ∑ a, ∑ b, + if validTransferredPivot I + (v y a * (∏ i, L y b i) - v y b * (∏ i, L y a i)) (s * U y) then + let p := reconstructedPivot + (v y a * (∏ i, L y b i) - v y b * (∏ i, L y a i)) (s * U y) + (φ (Real.log p - G) : ℂ) * W y p a * conj (W y p b) * + movingRegularTransform (Sum.elim (L y a) (L y b)) + (movingSumFactors (L y a) (L y b) (gL y a) (gL y b)) (D y) s + else 0‖ := by + let c := fun y => movingRegularCoefficient (L y) (gL y) (D y) (U y) (v y) (W y) + have hc (y : Y) (p : ℕ) (a : A) (h : c y p a ≠ 0) : W y p a ≠ 0 := by + intro hz + apply h + simp only [c, movingRegularCoefficient, hz, zero_mul] + have ht := smoothGiantPrior_transfer_on_prior P I hP hPI hI φ G hφ hpos μ hμ hμmass U hU + (fun y p => movingGuardedRow (Q y p) (gQ y p) (D y)) + (fun y p => by + simpa only [Nat.cast_mul] using + movingGuardedRow_energy (Q y p) (gQ y p) (D y) ((p : ℕ) * U y) + (hQprod y p) giant (S y p) (hgQ y p) (hregular y p) (hS y p) (hSp y p)) + (fun y a => ∏ i, L y a i) v c + (fun y p hp a h => (hsupport y p hp a (hc y p a h)).2.1) N B V + (fun y p hp a h => hv y p hp a (hc y p a h)) + (fun y hy p hp a h => hL y hy p hp a (hc y p a h)) hscale + have hsum : (∑ y, (μ y : ℂ) * ∑ p : P, (smoothGiantPrior P φ G p : ℂ) * + ∑ a, movingGuardedRow (Q y p) (gQ y p) (D y) + (positiveIntegerPivotKey ((p : ℕ) * U y) + (Nat.mul_pos (hP p p.property).pos (hU y)) (∏ i, L y a i) (v y a)) * c y p a) = + ∑ y, (μ y : ℂ) * ∑ p : P, (smoothGiantPrior P φ G p : ℂ) * + ∑ a, W y p a * movingRegularTransform (Sum.elim (Q y p) (L y a)) + (movingSumFactors (Q y p) (L y a) (gQ y p) (gL y a)) (D y) (v y a) := by + apply Finset.sum_congr rfl + intro y _ + congr 1 + apply Finset.sum_congr rfl + intro p _ + congr 1 + apply Finset.sum_congr rfl + intro a _ + by_cases hz : W y p a = 0 + · simp only [c, movingRegularCoefficient, hz, zero_mul, mul_zero] + · have hs := hrowSupport y p a hz + rw [moving_full_transform_guarded (Q y p) (L y a) (gQ y p) (gL y a) + (D y) ((p : ℕ) * U y) (hQprod y p) + (Nat.mul_pos (hP p p.property).pos (hU y)) (v y a) hs.1 hs.2 + (hsupport y p (hPI p.property) a hz).2.1] + dsimp only [c, movingRegularCoefficient] + ring + rw [hsum] at ht + convert ht using 1 + congr 1 + congr 1 + apply Finset.sum_congr rfl + intro y _ + congr 1 + dsimp only [c] + rw [movingGiantOffDiagonal_regular_on_live (L y) (gL y) (hgL y) I V (U y) (D y) + (v y) (fun p => φ (Real.log p - G)) (W y) (hsupport y) (hlarge y)] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + split_ifs + · congr 1 + congr 1 + funext i + cases i <;> rfl + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullModulus.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..c887180fa6c4a574e470671bab640f4ebe29961c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullModulus.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingUnitSampleBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorModulus + +namespace OAI + +/-! # A concrete common modulus for every full-support residue test -/ + +namespace Ostmann +open scoped BigOperators Classical + +theorem MovingSlotData.compensation_dvd_spectatorDenominator {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) : + ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, + (value i : ℤ) ∣ movingSpectatorDenominator value T := by + induction T with + | leaf => simp [occurrences] + | node s CL CR U left right ihL ihR => + intro o ho i hi + rcases List.mem_cons.mp ho with ho | ho + · subst o + have hd : value i ∣ MovingSlotReversal.naturalProduct value U := + List.dvd_prod (List.mem_map.mpr ⟨i, hi, rfl⟩) + have hz : (value i : ℤ) ∣ (MovingSlotReversal.naturalProduct value U : ℤ) := by exact_mod_cast hd + exact dvd_mul_of_dvd_left (dvd_mul_of_dvd_left (dvd_mul_of_dvd_right hz s) _) _ + · rcases List.mem_append.mp ho with ho | ho + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + exact dvd_mul_of_dvd_left (dvd_mul_of_dvd_right (ihL o' ho' i hi) _) _ + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + exact dvd_mul_of_dvd_right (ihR o' ho' i hi) _ + +noncomputable def movingFullPairModulusBase {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) : ℕ := + ∏ b : Bool, movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S * + (movingGiantUnitPeriod value outside (T b)).natAbs + +noncomputable def movingFullPairModulus {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) : ℕ := + (movingFullPairModulusBase value hvalue outside childBound pivotBound T hf q S) ^ 2 + +theorem movingFullPairModulus_components {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (b : Bool) : + movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S ∣ + movingFullPairModulusBase value hvalue outside childBound pivotBound T hf q S ∧ + (movingGiantUnitPeriod value outside (T b)).natAbs ∣ + movingFullPairModulusBase value hvalue outside childBound pivotBound T hf q S := by + have h := Finset.dvd_prod_of_mem + (fun b => movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S * + (movingGiantUnitPeriod value outside (T b)).natAbs) (Finset.mem_univ b) + exact ⟨(dvd_mul_right _ _).trans h, (dvd_mul_left _ _).trans h⟩ + +theorem movingFullPairModulus_pos {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (hout : outside.prod ≠ 0) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (hq : ∀ i ∈ S, 0 < q i) : + 0 < movingFullPairModulus value hvalue outside childBound pivotBound T hf q S := by + apply pow_pos + apply Finset.prod_pos + intro b _ + exact Nat.mul_pos (movingSpectatorModulus_pos value hvalue childBound pivotBound (T b) (hf b) q S hq) + (Int.natAbs_pos.mpr (movingGiantUnitPeriod_ne_zero value hvalue outside hout (T b) (hf b))) + +/-- The one common modulus supplies all four divisibility conditions used in +exact two-history factorization, including every compensation-prime square. -/ +theorem movingFullPairModulus_tests {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) : + let M := movingFullPairModulus value hvalue outside childBound pivotBound T hf q S + (∀ b, movingTopPeriod value hvalue childBound pivotBound (T b) (hf b) ∣ M) ∧ + (∀ b, ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value (T b) ∣ (M : ℤ)) ∧ + (∀ b, movingGiantUnitPeriod value outside (T b) ∣ (M : ℤ)) ∧ + (∀ b, ∀ o ∈ (T b).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ (M : ℤ)) := by + let N := movingFullPairModulusBase value hvalue outside childBound pivotBound T hf q S + have hN : N ∣ N ^ 2 := ⟨N, pow_two N⟩ + have hc := movingFullPairModulus_components value hvalue outside childBound pivotBound T hf q S + have hs (b : Bool) : movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S ∣ N ^ 2 := + (hc b).1.trans hN + refine ⟨fun b => (movingTopPeriod_dvd_spectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S).trans (hs b), + fun b i hi => ?_, fun b => ?_, fun b o ho i hi => ?_⟩ + · exact (spectator_dvd_movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S i hi).trans + (by exact_mod_cast hs b) + · exact (Int.dvd_natAbs.mpr (dvd_refl (movingGiantUnitPeriod value outside (T b)))).trans + (by exact_mod_cast (hc b).2.trans hN) + · have hd : value i ∣ (movingSpectatorDenominator value (T b)).natAbs := by + exact_mod_cast Int.dvd_natAbs.mpr ((T b).compensation_dvd_spectatorDenominator value o ho i hi) + have hds : (movingSpectatorDenominator value (T b)).natAbs ∣ + movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S := by + refine ⟨movingTopPeriod value hvalue childBound pivotBound (T b) (hf b) * ∏ j ∈ S, q j, ?_⟩ + simp only [movingSpectatorModulus] + ring + have hpow := pow_dvd_pow_of_dvd (hd.trans (hds.trans (hc b).1)) 2 + exact_mod_cast hpow + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullModulusScale.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullModulusScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea65d9f1c44eb9cd876ad77ba835845803f56347 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullModulusScale.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullModulus +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorScale + +namespace OAI + +/-! # The complete two-history modulus fits the published progression range -/ + +namespace Ostmann +open Filter Asymptotics +open scoped BigOperators Classical + +def movingFullModulusExponent (n : ℕ) : ℕ := + 4 * (4 ^ n - 1) + 2 * (2 ^ n - 1) + movingGiantUnitExponent n + +theorem movingFullPairModulus_bound {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (B : ℕ) (hB : 1 ≤ B) + (hfreq : ∀ b, (T b).Frequencies (fun s => s.natAbs ≤ B)) + (hcomp : ∀ b, (T b).CompensationBound value B) + (hregular : ∀ b, (T b).RegularBound value B) (hout : outside.prod ≤ B) : + movingFullPairModulus value hvalue outside childBound pivotBound T hf q S ≤ + (B ^ movingFullModulusExponent n * ∏ i ∈ S, q i) ^ 4 := by + have ht (b : Bool) : + movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S * + (movingGiantUnitPeriod value outside (T b)).natAbs ≤ + B ^ movingFullModulusExponent n * ∏ i ∈ S, q i := by + calc + _ ≤ (B ^ (4 * (4 ^ n - 1) + 2 * (2 ^ n - 1)) * ∏ i ∈ S, q i) * + B ^ movingGiantUnitExponent n := + Nat.mul_le_mul (movingSpectatorModulus_bound value hvalue childBound pivotBound + (T b) (hf b) q S B hB (hfreq b) (hcomp b)) + (movingGiantUnitPeriod_bound value outside (T b) B (hfreq b) (hcomp b) (hregular b) hout) + _ = _ := by rw [movingFullModulusExponent, pow_add]; ring + have hp := Finset.prod_le_prod (fun b (_ : b ∈ (Finset.univ : Finset Bool)) => ht b) + have hh := Nat.pow_le_pow_left hp 2 + simpa only [movingFullPairModulus, movingFullPairModulusBase, Finset.prod_const, + Finset.card_univ, Fintype.card_bool, ← pow_mul] using hh + +theorem movingFullPairModulus_exp {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (B : ℕ) (hB : 1 ≤ B) + (hfreq : ∀ b, (T b).Frequencies (fun s => s.natAbs ≤ B)) + (hcomp : ∀ b, (T b).CompensationBound value B) + (hregular : ∀ b, (T b).RegularBound value B) (hout : outside.prod ≤ B) + (b r : ℝ) (hb : (B : ℝ) ≤ Real.exp b) (hr : ((∏ i ∈ S, q i : ℕ) : ℝ) ≤ Real.exp r) : + (movingFullPairModulus value hvalue outside childBound pivotBound T hf q S : ℝ) ≤ + Real.exp (4 * ((movingFullModulusExponent n : ℝ) * b + r)) := by + calc + _ ≤ ((B : ℝ) ^ movingFullModulusExponent n * (∏ i ∈ S, q i : ℕ)) ^ 4 := by + exact_mod_cast movingFullPairModulus_bound value hvalue outside childBound pivotBound T hf q S B hB hfreq hcomp hregular hout + _ ≤ ((Real.exp b) ^ movingFullModulusExponent n * Real.exp r) ^ 4 := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_nat_mul]; congr 1 + +theorem movingFullModulus_exponent_budget (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, + 4 * ((movingFullModulusExponent n : ℝ) * + (C * L ^ d + C * L ^ d * Real.exp ((1 / 100 : ℝ) * L)) + + ((1 / 1000 : ℝ) * L) * Real.exp ((1 / 1000 : ℝ) * L)) ≤ + Real.exp ((12 / 1000 : ℝ) * L) := by + let E : ℝ := movingFullModulusExponent n + have hpoly := (isLittleO_pow_exp_pos_mul_atTop d + (by norm_num : (0 : ℝ) < 12 / 1000)).const_mul_left (4 * E * C) + have hprime : (fun L : ℝ => (4 * E * C) * (Real.exp ((1 / 100 : ℝ) * L) * L ^ d)) =o[atTop] + (fun L => Real.exp ((12 / 1000 : ℝ) * L)) := by + simpa only [Real.rpow_natCast] using + (isLittleO_exp_mul_rpow_of_lt (d : ℝ) (by norm_num : (1 / 100 : ℝ) < 12 / 1000)).const_mul_left (4 * E * C) + have hspec : (fun L : ℝ => (4 / 1000 : ℝ) * (Real.exp ((1 / 1000 : ℝ) * L) * L)) =o[atTop] + (fun L => Real.exp ((12 / 1000 : ℝ) * L)) := by + simpa only [Real.rpow_one] using + (isLittleO_exp_mul_rpow_of_lt 1 (by norm_num : (1 / 1000 : ℝ) < 12 / 1000)).const_mul_left (4 / 1000) + filter_upwards [((hpoly.add hprime).add hspec).bound (by norm_num : (0 : ℝ) < 1)] with L hL + simp only [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), one_mul] at hL + have h := (le_abs_self _).trans hL + change 4 * (E * (C * L ^ d + C * L ^ d * Real.exp ((1 / 100 : ℝ) * L)) + + ((1 / 1000 : ℝ) * L) * Real.exp ((1 / 1000 : ℝ) * L)) ≤ _ + convert h using 1 + ring + +theorem movingFullPairModulus_progression_range {σ : Type*} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (B : ℕ), 1 ≤ B → (∀ b, (T b).Frequencies (fun s => s.natAbs ≤ B)) → + (∀ b, (T b).CompensationBound value B) → (∀ b, (T b).RegularBound value B) → + outside.prod ≤ B → + (B : ℝ) ≤ Real.exp (C * L ^ d + C * L ^ d * Real.exp ((1 / 100 : ℝ) * L)) → + ∀ (S : Finset ℕ) (R : ℕ), (∀ q ∈ S, 0 < q ∧ q ≤ R) → + (R : ℝ) ≤ Real.exp ((1 / 1000 : ℝ) * L) → + movingFullPairModulus value hvalue outside childBound pivotBound T hf id S ≤ + ⌊Real.exp (Real.exp ((12 / 1000 : ℝ) * L))⌋₊ := by + filter_upwards [movingFullModulus_exponent_budget n C d, eventually_ge_atTop (0 : ℝ)] with L hL hL0 + intro value hvalue outside childBound pivotBound T hf B hB hfreq hcomp hregular hout hb S R hS hR + apply Nat.le_floor + exact (movingFullPairModulus_exp value hvalue outside childBound pivotBound T hf id S B hB + hfreq hcomp hregular hout _ _ hb (small_spectator_product_exp S R hS _ (by positivity) hR)).trans + (Real.exp_le_exp.mpr hL) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullPageDeletion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullPageDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2d21e8e0d1d7341a37eb512d4b2e807e3549f03 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullPageDeletion.lean @@ -0,0 +1,160 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSplitModulusBound +import OAI.NumberTheory.Ostmann.ZeroDensity.PageRegularAverage + +namespace OAI + +/-! # Conductor-prime deletion for the complete sampled modulus -/ + +namespace Ostmann +open scoped Classical BigOperators + +private theorem naturalProduct_coprime_right {σ : Type*} (r : ℕ) (value : σ → ℕ) + (h : ∀ i, r.Coprime (value i)) (s : List σ) : + r.Coprime (MovingSlotReversal.naturalProduct value s) := by + induction s with + | nil => simp [MovingSlotReversal.naturalProduct] + | cons i s ih => + simpa only [MovingSlotReversal.naturalProduct, List.map_cons, List.prod_cons] using + (h i).mul_right ih + +theorem MovingSlotData.frequencyProduct_coprime {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) (r : ℕ) (hf : T.Frequencies (fun s => r.Coprime s.natAbs)) : + r.Coprime T.frequencyProduct.natAbs := by + induction T with + | leaf => exact hf + | node s CL CR U left right ihL ihR => + simpa only [MovingSlotData.frequencyProduct, Int.natAbs_mul] using + (hf.1.mul_right (ihL hf.2.1)).mul_right (ihR hf.2.2) + +theorem movingGiantUnitPeriod_coprime {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) (r : ℕ) + (hf : T.Frequencies (fun s => r.Coprime s.natAbs)) + (hvalue : ∀ i, r.Coprime (value i)) (hout : r.Coprime outside.prod) : + r.Coprime (movingGiantUnitPeriod value outside T).natAbs := by + have hfreq := T.frequencyProduct_coprime r hf + induction T with + | leaf s slots => + simpa only [movingGiantUnitPeriod, Int.natAbs_mul, Int.natAbs_natCast, + MovingSlotData.regularSlots] using + (hfreq.mul_right (naturalProduct_coprime_right r value hvalue slots)).mul_right hout + | node s CL CR U left right ihL ihR => + have hlocal := (hfreq.mul_right (naturalProduct_coprime_right r value hvalue + (MovingSlotData.node s CL CR U left right).regularSlots)).mul_right hout + have hcomp := hf.1.mul_right (naturalProduct_coprime_right r value hvalue U) + simpa only [movingGiantUnitPeriod, Int.natAbs_mul, Int.natAbs_natCast] using + ((hlocal.mul_right hcomp).mul_right (ihL hf.2.1 + (left.frequencyProduct_coprime r hf.2.1))).mul_right + (ihR hf.2.2 (right.frequencyProduct_coprime r hf.2.2)) + +theorem movingFullPairModulus_coprime {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (r : ℕ) + (hfreq : ∀ b, (T b).Frequencies (fun s => r.Coprime s.natAbs)) + (hvalues : ∀ i, r.Coprime (value i)) (hout : r.Coprime outside.prod) + (hq : ∀ i ∈ S, r.Coprime (q i)) : + r.Coprime (movingFullPairModulus value hvalue outside childBound pivotBound T hf q S) := by + apply Nat.Coprime.pow_right + apply Nat.coprime_prod_right_iff.mpr + intro b _ + have hg := movingGiantUnitPeriod_coprime value outside (T b) r (hfreq b) hvalues hout + have ha := hg.of_dvd_right (Int.natAbs_dvd_natAbs.mpr + (movingAuxiliaryUnitPeriod_dvd_full value outside (T b))) + have ht := movingTopPeriod_coprime_of_auxiliary value hvalue outside childBound pivotBound + (T b) (hf b) r (hfreq b) ha + have hd := ha.of_dvd_right (Int.natAbs_dvd_natAbs.mpr + (movingSpectatorDenominator_dvd_auxiliary value outside (T b))) + exact (((ht.mul_right hd).mul_right (Nat.coprime_prod_right_iff.mpr hq)).mul_right hg) + +/-- The deleted large conductor prime cannot divide the full modulus: its +remaining prime factors come from the sampled values, spectators and frequencies. -/ +theorem movingFullPairModulus_deleted_prime_coprime {σ I : Type*} + (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : Bool → MovingSlotData σ n) + (hf : ∀ b, (T b).Frequencies (· ≠ 0)) (q : I → ℕ) (S : Finset I) + (hq : ∀ i ∈ S, (q i).Prime) (hout : ∀ p ∈ outside, p.Prime) + (V cutoff : ℕ) (hV : V < cutoff) + (hfreq : ∀ b, (T b).Frequencies (fun s => s.natAbs ≤ V)) + (r : ℕ) (hr : r.Prime) (hcut : cutoff ≤ r) + (hvalues : ∀ i, value i ≠ r) (hspec : ∀ i ∈ S, q i ≠ r) + (houtside : r ∉ outside) : + r.Coprime (movingFullPairModulus value (fun i => (hprime i).ne_zero) outside + childBound pivotBound T hf q S) := by + have hsmall (s : ℤ) (hs : s ≠ 0) (hsV : s.natAbs ≤ V) : r.Coprime s.natAbs := by + apply hr.coprime_iff_not_dvd.mpr + intro hd + have hpos : 0 < s.natAbs := Int.natAbs_pos.mpr hs + have hle := Nat.le_of_dvd hpos hd + omega + have hfreq' : ∀ b, (T b).Frequencies (fun s => r.Coprime s.natAbs) := by + have go {d : ℕ} (U : MovingSlotData σ d) : + U.Frequencies (· ≠ 0) → U.Frequencies (fun s => s.natAbs ≤ V) → + U.Frequencies (fun s => r.Coprime s.natAbs) := by + induction U with + | leaf s slots => exact fun hn hb => hsmall s hn hb + | node s CL CR U left right ihL ihR => + intro hn hb + exact ⟨hsmall s hn.1 hb.1, ihL hn.2.1 hb.2.1, ihR hn.2.2 hb.2.2⟩ + exact fun b => go (T b) (hf b) (hfreq b) + have hval : ∀ i, r.Coprime (value i) := by + intro i + apply hr.coprime_iff_not_dvd.mpr + intro hd + exact hvalues i ((Nat.prime_dvd_prime_iff_eq hr (hprime i)).mp hd).symm + apply movingFullPairModulus_coprime value (fun i => (hprime i).ne_zero) outside + childBound pivotBound T hf q S r hfreq' hval + · apply Nat.coprime_list_prod_right_iff.mpr + intro p hp + apply hr.coprime_iff_not_dvd.mpr + intro hd + exact houtside (((Nat.prime_dvd_prime_iff_eq hr (hout p hp)).mp hd).symm ▸ hp) + · intro i hi + apply hr.coprime_iff_not_dvd.mpr + intro hd + exact hspec i hi ((Nat.prime_dvd_prime_iff_eq hr (hq i hi)).mp hd).symm + +/-- The regular block has no exceptional-character factor after the one +prescribed conductor-prime deletion. Its Page weight remains on the reduced block. -/ +theorem movingSplitModulus_page_projection {σ I : Type*} + (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : Bool → MovingSlotData σ n) + (hf : ∀ b, (T b).Frequencies (· ≠ 0)) (q : I → ℕ) (S : Finset I) + (hq : ∀ i ∈ S, (q i).Prime) (hout : ∀ p ∈ outside, p.Prime) + (V cutoff : ℕ) (hV : V < cutoff) + (hfreq : ∀ b, (T b).Frequencies (fun s => s.natAbs ≤ V)) + (z : Option PrimitiveRealZero) + (hvalues : ∀ e, z = some e → ∀ r, deletedConductorPrime e.modulus cutoff = some r → + ∀ i, value i ≠ r) + (hspec : ∀ e, z = some e → ∀ r, deletedConductorPrime e.modulus cutoff = some r → + ∀ i ∈ S, q i ≠ r) + (houtside : ∀ e, z = some e → ∀ r, deletedConductorPrime e.modulus cutoff = some r → r ∉ outside) + (hlarge : ∀ i, cutoff ≤ value i) + (hcop : (MovingSlotReversal.naturalProduct value (T false).regularSlots).Coprime + (movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf q S)) : + pageAtModulus (MovingSlotReversal.naturalProduct value (T false).regularSlots * + movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf q S) z = + pageAtModulus (movingReducedPairModulus value (fun i => (hprime i).ne_zero) + outside childBound pivotBound T hf q S) z := by + apply pageAtModulus_regular_factor z _ _ cutoff + · intro r hr hd + by_contra hlt + have hc : r.Coprime (MovingSlotReversal.naturalProduct value (T false).regularSlots) := by + apply naturalProduct_coprime_right r value + intro i + apply hr.coprime_iff_not_dvd.mpr + intro hri + have he := (Nat.prime_dvd_prime_iff_eq hr (hprime i)).mp hri + have hi := hlarge i + omega + exact hr.coprime_iff_not_dvd.mp hc hd + · intro e he r hr hd + have hc := movingFullPairModulus_deleted_prime_coprime value hprime outside childBound pivotBound + T hf q S hq hout V cutoff hV hfreq r (deletedConductorPrime_spec hr).1 + (deletedConductorPrime_spec hr).2.2 (hvalues e he r hr) (hspec e he r hr) (houtside e he r hr) + exact ((deletedConductorPrime_spec hr).1.coprime_iff_not_dvd.mp hc) + (hd.trans (movingSplitModulus_dvd_full value (fun i => (hprime i).ne_zero) outside + childBound pivotBound T hf q S _ rfl hcop)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullPair.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6291cd6bd1b429c45fac449c79525ac9f050ce1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullPair.lean @@ -0,0 +1,125 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullSpectator +import OAI.NumberTheory.Ostmann.Arithmetic.SampledSpectatorComparison + +namespace OAI + +/-! # The good-matching diagram for the full moving-giant coefficients -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +noncomputable def movingSampleBaseWeight {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (samples : MovingSampleSlots σ n) (XL XR : ℕ) : ℂ := + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n + ⟨n, buildMovingSlotData n t small bulk samples, XL, XR⟩ t + +noncomputable def movingSampleFullWeight {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) (g : ZMod q → ℂ) (D : (ZMod q)ˣ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) (XL XR : ℕ) : ℂ := + movingSampleBaseWeight value childBound pivotBound + (fun x s => F x s * spectatorHistoryLeaf (movingSlotModulus value) g D x s) + extra n t small bulk samples XL XR + +theorem moving_sample_full_weight_factor {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (hextra : ∀ x s v w, extra x s v w ≠ 0 → + (historyPivot (movingSlotSystem value childBound pivotBound) x s v w : ZMod q) ≠ 0) + (g : ZMod q → ℂ) (D : (ZMod q)ˣ) (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (samples : MovingSampleSlots σ n) (XL XR : ℕ) : + movingSampleFullWeight value childBound pivotBound F extra g D n t small bulk samples XL XR = + movingSampleBaseWeight value childBound pivotBound F extra n t small bulk samples XL XR * + movingGiantAmplitude g D + (buildMovingGiantTree n t (movingSlotValues value n small) (samples.values value)) + XL XR (movingSlotValues value n bulk) := by + unfold movingSampleFullWeight movingSampleBaseWeight + rw [movingSlotWeight_spectator value childBound pivotBound F extra hextra g D _ t + (buildMovingSlotData_follows n t small bulk samples) XL XR, buildMovingSlotData_spectator] + +/-- The quartet bound is now attached to the actual full coefficient, with +its original arithmetic and smooth support retained in the scalar factor. -/ +theorem moving_full_pair_good_comparison {σ : Type*} {q : ℕ} [Fact q.Prime] (hq : 3 ≤ q) + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → MovingSlotState σ → ℤ → ℂ) + (extra : Bool → MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (hextra : ∀ b x s v w, extra b x s v w ≠ 0 → + (historyPivot (movingSlotSystem value childBound pivotBound) x s v w : ZMod q) ≠ 0) + (n m : ℕ) (hm : 0 < m) (e : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (hgood : 4 * Fintype.card (arrangementGraph m e).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2))) + (t : Bool → FrequencyTree ℤ (n + 2)) (small : Bool → TreeLeafTuple (List σ) (n + 2)) + (samples : Bool → MovingSampleSlots σ (n + 2)) + (hfreq : ∀ b, movingGiantFrequencyUnits q (n + 2) (t b)) + (hsmall : ∀ b, ((treeLeafProduct (n + 2) (movingSlotValues value (n + 2) (small b)) : ℕ) : ZMod q) ≠ 0) + (hsamples : ∀ b, ((samples b).values value).UnitsAt q) + (D : Bool → (ZMod q)ˣ) (XL XR : Bool → ℕ) (A B : Bool → (ZMod q)ˣ) + (hA : ∀ b, (XL b : ZMod q) = A b) (hB : ∀ b, (XR b : ZMod q) = B b) + (S : Finset (ZMod q)) (hlo : (1 / 3 : ℝ) ≤ residueDensity S) + (hhi : residueDensity S ≤ 2 / 3) (hS : S.Nonempty) (hSq : S.card < q) + (β ε : ℝ) (hε : 0 ≤ ε) (hε1 : ε ≤ 1) + (hprincipal : 3 / Real.sqrt (q : ℝ) ≤ ε) (hβ : 2 * β ≤ ε) + (hbias : ∀ (χ : MulChar (ZMod q) ℂ), χ ≠ 1 → ∀ a : ZMod q, + ‖(S.card : ℂ)⁻¹ * ∑ x ∈ S, χ⁻¹ (-a - x)‖ ≤ β) : + ∃ d₁ d₂ : SpectatorDiagram q (n + 2), + (∀ (bulk₁ bulk₂ : TreeLeafTuple (List σ) (n + 2)) + (y₁ y₂ : TreeLeafTuple (ZMod q)ˣ (n + 2)), + TreeNaturalLift (n + 2) (movingSlotValues value (n + 2) bulk₁) y₁ → + TreeNaturalLift (n + 2) (movingSlotValues value (n + 2) bulk₂) y₂ → + movingSampleFullWeight value childBound pivotBound (F false) (extra false) + (normalizedResidueTransform S) (D false) (n + 2) (t false) (small false) bulk₁ + (samples false) (XL false) (XR false) * + conj (movingSampleFullWeight value childBound pivotBound (F true) (extra true) + (normalizedResidueTransform S) (D true) (n + 2) (t true) (small true) bulk₂ + (samples true) (XL true) (XR true)) = + (movingSampleBaseWeight value childBound pivotBound (F false) (extra false) + (n + 2) (t false) (small false) bulk₁ (samples false) (XL false) (XR false) * + conj (movingSampleBaseWeight value childBound pivotBound (F true) (extra true) + (n + 2) (t true) (small true) bulk₂ (samples true) (XL true) (XR true))) * + (d₁.value (normalizedResidueTransform S) y₁ * conj (d₂.value (normalizedResidueTransform S) y₂))) ∧ + ‖(Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod q)ˣ) : ℂ)⁻¹ * + (∑ x : TreeLeafIndex (n + 2) × Fin m → (ZMod q)ˣ, + d₁.bulkValue (normalizedResidueTransform S) x * + conj (d₂.bulkValue (normalizedResidueTransform S) (x ∘ e.symm)))‖ ^ 2 ≤ + quartetTreeConstant n * (ε ^ 2 + Real.sqrt (3 / (q : ℝ))) := by + obtain ⟨d₁, d₂, hd, hbound⟩ := sampled_good_spectator_comparison hq n m hm e hgood + (t false) (t true) (movingSlotValues value (n + 2) (small false)) + (movingSlotValues value (n + 2) (small true)) ((samples false).values value) + ((samples true).values value) (hfreq false) (hfreq true) (hsmall false) (hsmall true) + (hsamples false) (hsamples true) (D false) (D true) (XL false) (XR false) (XL true) (XR true) + (A false) (B false) (A true) (B true) (hA false) (hB false) (hA true) (hB true) + S hlo hhi hS hSq β ε hε hε1 hprincipal hβ hbias + refine ⟨d₁, d₂, ?_, hbound⟩ + intro bulk₁ bulk₂ y₁ y₂ hy₁ hy₂ + let W₁ := movingSampleBaseWeight value childBound pivotBound (F false) (extra false) + (n + 2) (t false) (small false) bulk₁ (samples false) (XL false) (XR false) + let W₂ := movingSampleBaseWeight value childBound pivotBound (F true) (extra true) + (n + 2) (t true) (small true) bulk₂ (samples true) (XL true) (XR true) + have hI (b : Bool) (bulk : TreeLeafTuple (List σ) (n + 2)) + (hW : movingSampleBaseWeight value childBound pivotBound (F b) (extra b) + (n + 2) (t b) (small b) bulk (samples b) (XL b) (XR b) ≠ 0) : + (buildMovingGiantTree (n + 2) (t b) (movingSlotValues value (n + 2) (small b)) + ((samples b).values value)).Integral (XL b) (XR b) (movingSlotValues value (n + 2) bulk) := by + apply (buildMovingSlotData_integral value (n + 2) (t b) (small b) bulk (samples b) (XL b) (XR b)).mp + exact movingSlotWeight_nonzero_integral value childBound pivotBound (F b) (extra b) _ _ + (buildMovingSlotData_follows (n + 2) (t b) (small b) bulk (samples b)) _ _ hW + have he := hd (movingSlotValues value (n + 2) bulk₁) (movingSlotValues value (n + 2) bulk₂) + y₁ y₂ (W₁ * conj W₂) hy₁ hy₂ (fun h => by + have h₁ : W₁ ≠ 0 := fun hz => h (by rw [hz, zero_mul]) + have h₂ : W₂ ≠ 0 := fun hz => h (by rw [hz, map_zero, mul_zero]) + exact ⟨hI false bulk₁ h₁, hI true bulk₂ h₂⟩) + rw [moving_sample_full_weight_factor value childBound pivotBound (F false) (extra false) + (hextra false), moving_sample_full_weight_factor value childBound pivotBound (F true) (extra true) + (hextra true)] + simp only [map_mul] + change (W₁ * _) * (conj W₂ * _) = _ + convert he using 1 + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullResidues.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..00629019ee3274e9a43302edca8f4fbe280bb0d0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullResidues.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullSupport + +namespace OAI + +/-! # The full moving support as one explicit residue mask -/ + +namespace Ostmann +open scoped Classical + +noncomputable def movingSquareLineSupport {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℤ) : Prop := + ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, + let φ := MovingSlotReversal.naturalReduction (value i ^ 2) value + φ (movingSlotLine o.path o.current).a * (XL : ZMod (value i ^ 2)) + + φ (movingSlotLine o.path o.current).b * (XR : ZMod (value i ^ 2)) ≠ 0 + +theorem movingSquareLineSupport_modEq {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR YL YR M : ℤ) + (hM : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hL : XL ≡ YL [ZMOD M]) (hR : XR ≡ YR [ZMOD M]) : + movingSquareLineSupport value T XL XR ↔ movingSquareLineSupport value T YL YR := by + apply forall₂_congr + intro o ho + apply forall₂_congr + intro i hi + have hl : (XL : ZMod (value i ^ 2)) = (YL : ZMod (value i ^ 2)) := + (ZMod.intCast_eq_intCast_iff _ _ _).mpr (hL.of_dvd (by exact_mod_cast hM o ho i hi)) + have hr : (XR : ZMod (value i ^ 2)) = (YR : ZMod (value i ^ 2)) := + (ZMod.intCast_eq_intCast_iff _ _ _).mpr (hR.of_dvd (by exact_mod_cast hM o ho i hi)) + dsimp only + rw [hl, hr] + +/-- All terms here are periodic; the mutual top-giant gcd is kept outside. -/ +noncomputable def movingFullResidueSupport {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℤ) : Prop := + movingRegularOutsidePairwise value outside T ∧ movingSquareLineSupport value T XL XR ∧ + movingSignedGiantUnits value outside T XL XR + +theorem movingFullResidueSupport_modEq {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (XL XR YL YR M : ℤ) + (hunit : movingGiantUnitPeriod value outside T ∣ M) + (hsquare : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hL : XL ≡ YL [ZMOD M]) (hR : XR ≡ YR [ZMOD M]) : + movingFullResidueSupport value outside T XL XR ↔ movingFullResidueSupport value outside T YL YR := by + unfold movingFullResidueSupport + rw [movingSquareLineSupport_modEq value T XL XR YL YR M hsquare hL hR, + movingSignedGiantUnits_modEq value hvalue outside T hf XL XR YL YR + (hL.of_dvd hunit) (hR.of_dvd hunit)] + +/-- The manuscript's pairwise, outside-list and all-subtree-frequency tests +are identified exactly, on the integral support already forced by the weight. -/ +theorem movingFullSupport_residue_iff {σ : Type*} (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hlevels : T.Levels tier) (hcoh : T.RegularCoherent) (hc : T.CompensationPrimeData value) + (hf : T.Frequencies (· ≠ 0)) + (hsmall : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (XL XR a b : ℕ) (M : ℤ) (hI : T.Integral value XL XR) + (hunit : movingGiantUnitPeriod value outside T ∣ M) + (hsquare : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + (movingFullOutsidePairwise value outside T XL XR ∧ movingNaturalGiantUnits value outside T XL XR) ↔ + XL.Coprime XR ∧ movingFullResidueSupport value outside T a b := by + have hvalue : ∀ i, value i ≠ 0 := fun i => (hprime i).ne_zero + rw [movingFullOutsidePairwise_square_iff value outside T hcoh hc hsmall XL XR hI, + T.squareTests_iff_lines tier value hprime hdisjoint hlevels hfmod XL XR hI] + have hsq : (∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, + let φ := MovingSlotReversal.naturalReduction (value i ^ 2) value + φ (movingSlotLine o.path o.current).a * (XL : ZMod (value i ^ 2)) + + φ (movingSlotLine o.path o.current).b * (XR : ZMod (value i ^ 2)) ≠ 0) ↔ + movingSquareLineSupport value T XL XR := by + simp only [movingSquareLineSupport, Int.cast_natCast] + rw [hsq, ← movingSignedGiantUnits_nat value hvalue outside T hf XL XR hI] + change XL.Coprime XR ∧ movingFullResidueSupport value outside T XL XR ↔ _ + rw [movingFullResidueSupport_modEq value hvalue outside T hf XL XR a b M hunit hsquare hL hR] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSmooth.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSmooth.lean new file mode 100644 index 0000000000000000000000000000000000000000..42c5cc7e94625bdfec13d20a9c2d94b59195104e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSmooth.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSmoothPolynomials +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullFourier + +namespace OAI + +/-! # The full original smooth factor in the moving arithmetic coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- Every original logarithmic node cutoff and normalized Fourier leaf is +represented by the one constructed polynomial family. Arithmetic restrictions +and compensation powers stay in the original scalar coefficient. -/ +theorem moving_full_smooth_polynomial {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hfreq : T.Frequencies (· ≠ 0)) (XL XR : ℕ) (L R : Polynomial ℝ) (z : ℝ) + (hL : L.eval z = (XL : ℝ)) (hR : R.eval z = (XR : ℝ)) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => movingWindowLeaf value X lo hi F x s * movingFourierLeaf value ψ X x s) + (movingSlotCutoff value childBound pivotBound + (movingPhiExtra value childBound pivotBound extra φ G)) n ⟨n, T, XL, XR⟩ t = + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (movingWindowLeaf value X lo hi F) (movingSlotCutoff value childBound pivotBound extra) + n ⟨n, T, XL, XR⟩ t * + smoothPolynomialWeight (movingSmoothPolynomialFactors value T L R ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip) z := by + rw [movingSlotWeight_node_cutoff value childBound pivotBound _ extra φ G T t hT XL XR, + moving_windowed_fourier_polynomial value hvalue childBound pivotBound F extra ψ X lo hi + hlo hhi T t hT hfreq XL XR L R z hL hR] + by_cases hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (movingWindowLeaf value X lo hi F) (movingSlotCutoff value childBound pivotBound extra) + n ⟨n, T, XL, XR⟩ t = 0 + · simp only [hw, zero_mul] + · have hI := movingSlotWeight_nonzero_integral value childBound pivotBound + (movingWindowLeaf value X lo hi F) extra T t hT XL XR hw + rw [movingNaturalNodeCutoff_eq_real value hvalue φ G T hfreq XL XR hI, + movingSmoothPolynomialFactors_value value T L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout z, + hL, hR] + ring + +/-- The complete moving coefficient splits into the original scalar support, +its actual smooth polynomial weight, and all of its spectator trees. No +nonzero-term hypothesis is needed. -/ +theorem moving_full_smooth_spectator_decomposition {σ I : Type*} + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (hextra : ∀ i x s v w, extra x s v w ≠ 0 → + (historyPivot (movingSlotSystem value childBound pivotBound) x s v w : ZMod (q i)) ≠ 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hfreq : T.Frequencies (· ≠ 0)) (XL XR : ℕ) (L R : Polynomial ℝ) (z : ℝ) + (hL : L.eval z = (XL : ℝ)) (hR : R.eval z = (XR : ℝ)) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => (movingWindowLeaf value X lo hi F x s * movingFourierLeaf value ψ X x s) * + ∏ i ∈ S, spectatorHistoryLeaf (movingSlotModulus value) (g i) (Dq i) x s) + (movingSlotCutoff value childBound pivotBound + (movingPhiExtra value childBound pivotBound extra φ G)) n ⟨n, T, XL, XR⟩ t = + (recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (movingWindowLeaf value X lo hi F) (movingSlotCutoff value childBound pivotBound extra) + n ⟨n, T, XL, XR⟩ t * + smoothPolynomialWeight (movingSmoothPolynomialFactors value T L R ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip) z) * + ∏ i ∈ S, movingSlotSpectator value (g i) (Dq i) T XL XR := by + have hcut : ∀ i x s v w, movingPhiExtra value childBound pivotBound extra φ G x s v w ≠ 0 → + (historyPivot (movingSlotSystem value childBound pivotBound) x s v w : ZMod (q i)) ≠ 0 := by + intro i x s v w h + apply hextra i x s v w + intro he + exact h (by simp only [movingPhiExtra, he, zero_mul]) + rw [movingSlotWeight_spectator_product q value childBound pivotBound _ _ hcut g Dq S T t hT XL XR, + moving_full_smooth_polynomial value hvalue childBound pivotBound F extra ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip hout T t hT hfreq XL XR L R z hL hR] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSpectator.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSpectator.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c918590f90bdf1f83a3c60271a867a2fd4bd0a3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSpectator.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleSpectator + +namespace OAI + +/-! # A fixed rational spectator diagram for the full original coefficient -/ + +namespace Ostmann +open scoped Classical + +/-- The diagram is fixed before the bulk values and giants are supplied. +Its equality with the full coefficient is proved from the recursive weight, +including every original cutoff and the compensation divisibility tests. -/ +theorem moving_full_coefficient_spectator_diagram {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (hextra : ∀ x s v w, extra x s v w ≠ 0 → + (historyPivot (movingSlotSystem value childBound pivotBound) x s v w : ZMod q) ≠ 0) + (n : ℕ) (t : FrequencyTree ℤ n) (small : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) + (hfreq : movingGiantFrequencyUnits q n t) + (hsmall : ((treeLeafProduct n (movingSlotValues value n small) : ℕ) : ZMod q) ≠ 0) + (hsamples : (samples.values value).UnitsAt q) : + ∃ (C : (ZMod q)ˣ) (R : RationalTreeData (ZMod q)ˣ n C), + ∀ (g : ZMod q → ℂ) (D : (ZMod q)ˣ) (bulk : TreeLeafTuple (List σ) n) + (bulkResidue : TreeLeafTuple (ZMod q)ˣ n) (XL XR : ℕ) (A B : (ZMod q)ˣ), + (XL : ZMod q) = A → (XR : ZMod q) = B → + TreeNaturalLift n (movingSlotValues value n bulk) bulkResidue → + let state : MovingSlotState σ := ⟨n, buildMovingSlotData n t small bulk samples, XL, XR⟩ + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => F x s * spectatorHistoryLeaf (movingSlotModulus value) g D x s) + (movingSlotCutoff value childBound pivotBound extra) n state t = + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n state t * + rationalTreeAmplitude g D R A B (transferConjugations n false) bulkResidue := by + let T := buildMovingGiantTree n t (movingSlotValues value n small) (samples.values value) + have hT : T.UnitsAt q := buildMovingGiantTree_units t _ _ hfreq hsmall hsamples + obtain ⟨C, R, _, _, hR⟩ := T.exists_residue_diagram hT + refine ⟨C, R, ?_⟩ + intro g D bulk bulkResidue XL XR A B hA hB hbulk + dsimp only + let state : MovingSlotState σ := ⟨n, buildMovingSlotData n t small bulk samples, XL, XR⟩ + let W := recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n state t + rw [movingSlotWeight_spectator value childBound pivotBound F extra hextra g D _ t + (buildMovingSlotData_follows n t small bulk samples) XL XR, + buildMovingSlotData_spectator] + by_cases hW : W = 0 + · change W * _ = W * _ + rw [hW, zero_mul, zero_mul] + · have hi := movingSlotWeight_nonzero_integral value childBound pivotBound F extra + (buildMovingSlotData n t small bulk samples) t (buildMovingSlotData_follows n t small bulk samples) + XL XR hW + have hi' := (buildMovingSlotData_integral value n t small bulk samples XL XR).mp hi + have he := hR g D XL XR A B (movingSlotValues value n bulk) bulkResidue hA hB hbulk hi' false + change W * _ = W * _ + exact congrArg (fun z : ℂ => W * z) he + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3e67f038f2d4bcc169a488ff960a2a6b8c5758e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSupport.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSignedUnits +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOccurrenceSquares + +namespace OAI + +/-! # Full pairwise and subtree-frequency support, with the top giant pair separated -/ + +namespace Ostmann +open scoped Classical + +private theorem coprime_naturalProduct {σ : Type*} (value : σ → ℕ) (s : ℤ) (L : List σ) + (h : ∀ i ∈ L, IsCoprime s (value i : ℤ)) : + IsCoprime s (MovingSlotReversal.naturalProduct value L : ℤ) := by + induction L with + | nil => simpa [MovingSlotReversal.naturalProduct] using (isCoprime_one_right (x := s)) + | cons a L ih => + simpa only [MovingSlotReversal.naturalProduct, List.map_cons, List.prod_cons, Nat.cast_mul] + using (h a List.mem_cons_self).mul_right (ih (fun i hi => h i (List.mem_cons_of_mem a hi))) + +theorem movingNaturalGiantUnits_cross {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) + (hsmall : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) (XL XR : ℕ) + (hu : movingNaturalGiantUnits value outside T XL XR) : + T.CrossFrequencyUnits value XL XR := by + induction T generalizing XL XR with + | leaf => trivial + | node s CL CR U left right ihL ihR => + have hXL := (left.frequencies_isCoprime (XL : ℤ)).mpr + (hu.1.1.of_isCoprime_of_dvd_right ⟨s * right.frequencyProduct, by + simp only [MovingSlotData.frequencyProduct]; ring⟩) + have hXR := (right.frequencies_isCoprime (XR : ℤ)).mpr + (hu.1.2.1.of_isCoprime_of_dvd_right ⟨s * left.frequencyProduct, by + simp only [MovingSlotData.frequencyProduct]; ring⟩) + refine ⟨?_, ?_, ihL (fun i => (hsmall i).2.1) _ _ hu.2.1, + ihR (fun i => (hsmall i).2.2) _ _ hu.2.2⟩ + · simpa only [Nat.cast_mul] using hXL.root.symm.mul_right + (coprime_naturalProduct value left.frequency CL (fun i _ => (hsmall i).2.1.root)) + · simpa only [Nat.cast_mul] using hXR.root.symm.mul_right + (coprime_naturalProduct value right.frequency CR (fun i _ => (hsmall i).2.2.root)) + +theorem MovingSlotData.currentPairwise_iff {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (XL XR : ℕ) : + T.CurrentPairwise value XL XR ↔ XL.Coprime XR ∧ + (T.regularSlots.map value).Pairwise Nat.Coprime ∧ + XL.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) ∧ + XR.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) := by + simp only [CurrentPairwise, currentSlots, List.pairwise_cons, List.mem_cons, + forall_eq_or_imp, MovingSlotReversal.naturalProduct, Nat.coprime_list_prod_right_iff] + tauto + +/-- The outside list is fixed while the current regular slots change. These +small-slot tests are independent of both top giant values. -/ +def movingRegularOutsidePairwise {σ : Type*} (value : σ → ℕ) (outside : List ℕ) : + {n : ℕ} → MovingSlotData σ n → Prop + | _, T@(.leaf _ _) => (T.regularSlots.map value ++ outside).Pairwise Nat.Coprime + | _, T@(.node _ _ _ _ left right) => + (T.regularSlots.map value ++ outside).Pairwise Nat.Coprime ∧ + movingRegularOutsidePairwise value outside left ∧ movingRegularOutsidePairwise value outside right + +/-- Literal pairwise support at every current state, including the fixed +outside list from the manuscript's recursive average. -/ +def movingFullOutsidePairwise {σ : Type*} (value : σ → ℕ) (outside : List ℕ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → Prop + | _, T@(.leaf _ _), XL, XR => (T.currentSlots value XL XR ++ outside).Pairwise Nat.Coprime + | _, T@(.node s CL CR U left right), XL, XR => + let p := (MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR + (T.currentSlots value XL XR ++ outside).Pairwise Nat.Coprime ∧ + movingFullOutsidePairwise value outside left p XL ∧ movingFullOutsidePairwise value outside right p XR + +private theorem currentOutsidePairwise_iff {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) + (hu : movingLocalGiantUnits value outside T XL XR) : + (T.currentSlots value XL XR ++ outside).Pairwise Nat.Coprime ↔ + T.CurrentPairwise value XL XR ∧ (T.regularSlots.map value ++ outside).Pairwise Nat.Coprime := by + have hXL := Nat.coprime_list_prod_right_iff.mp (hu.2.2.2.2.1.natCoprime) + have hXR := Nat.coprime_list_prod_right_iff.mp (hu.2.2.2.2.2.natCoprime) + simp only [MovingSlotData.currentSlots, MovingSlotData.CurrentPairwise, + List.cons_append, List.pairwise_cons, List.mem_cons, List.mem_append, + forall_eq_or_imp] + constructor + · rintro ⟨⟨hp, hl⟩, hr, hs⟩ + exact ⟨⟨⟨hp, fun a ha => hl a (Or.inl ha)⟩, + (fun a ha => hr a (Or.inl ha)), (List.pairwise_append.mp hs).1⟩, hs⟩ + · rintro ⟨⟨⟨hp, hl⟩, hr, _⟩, hs⟩ + exact ⟨⟨hp, fun a ha => ha.elim (hl a) (hXL a)⟩, + (fun a ha => ha.elim (hr a) (hXR a)), hs⟩ + +theorem movingFullOutsidePairwise_iff {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) + (hu : movingNaturalGiantUnits value outside T XL XR) : + movingFullOutsidePairwise value outside T XL XR ↔ + T.FullPairwise value XL XR ∧ movingRegularOutsidePairwise value outside T := by + induction T generalizing XL XR with + | leaf s regular => exact currentOutsidePairwise_iff value outside _ XL XR hu + | node s CL CR U left right ihL ihR => + simp only [movingFullOutsidePairwise, MovingSlotData.FullPairwise, + movingRegularOutsidePairwise, currentOutsidePairwise_iff value outside _ XL XR hu.1, + ihL _ _ hu.2.1, ihR _ _ hu.2.2] + tauto + +/-- The only nonperiodic coprimality test left after descent is the mutual +coprimality of the two top giants. All subtree and outside tests remain. -/ +theorem movingFullOutsidePairwise_square_iff {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (hcoh : T.RegularCoherent) + (hc : T.CompensationPrimeData value) + (hsmall : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) (XL XR : ℕ) + (hI : T.Integral value XL XR) : + (movingFullOutsidePairwise value outside T XL XR ∧ movingNaturalGiantUnits value outside T XL XR) ↔ + XL.Coprime XR ∧ movingRegularOutsidePairwise value outside T ∧ + T.PrimeSquareTests value XL XR ∧ movingNaturalGiantUnits value outside T XL XR := by + have htop (hu : movingNaturalGiantUnits value outside T XL XR) : + XL.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) ∧ + XR.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) := by + cases T with + | leaf => exact ⟨hu.2.2.1.natCoprime, hu.2.2.2.1.natCoprime⟩ + | node => exact ⟨hu.1.2.2.1.natCoprime, hu.1.2.2.2.1.natCoprime⟩ + have hregular (hs : movingRegularOutsidePairwise value outside T) : + (T.regularSlots.map value).Pairwise Nat.Coprime := by + have h : (T.regularSlots.map value ++ outside).Pairwise Nat.Coprime := by + cases T with + | leaf => exact hs + | node => exact hs.1 + exact (List.pairwise_append.mp h).1 + constructor + · rintro ⟨hp, hu⟩ + obtain ⟨hf, hs⟩ := (movingFullOutsidePairwise_iff value outside T XL XR hu).mp hp + obtain ⟨ht, hsq⟩ := (T.fullPairwise_iff_squareTests value hcoh hc XL XR hI + (movingNaturalGiantUnits_cross value outside T hsmall XL XR hu)).mp hf + exact ⟨(T.currentPairwise_iff value XL XR).mp ht |>.1, hs, hsq, hu⟩ + · rintro ⟨hpair, hs, hsq, hu⟩ + refine ⟨(movingFullOutsidePairwise_iff value outside T XL XR hu).mpr ⟨?_, hs⟩, hu⟩ + apply (T.fullPairwise_iff_squareTests value hcoh hc XL XR hI + (movingNaturalGiantUnits_cross value outside T hsmall XL XR hu)).mpr + exact ⟨(T.currentPairwise_iff value XL XR).mpr ⟨hpair, hregular hs, htop hu⟩, hsq⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSupportedTransformTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSupportedTransformTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a6197985780cc025fc3fe957a8cb284790d3bd2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullSupportedTransformTransfer.lean @@ -0,0 +1,126 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullTransformTransfer +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantSupportedTransfer + +namespace OAI + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance supportedFullTransferSum_neZero {J H : Type*} (Q : J → ℕ) (L : H → ℕ) + [∀ j, NeZero (Q j)] [∀ i, NeZero (L i)] (i : J ⊕ H) : + NeZero (Sum.elim Q L i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +theorem smoothGiantPrior_full_transform_transfer_on_prior + {Y A J H : Type*} [Fintype Y] [Fintype A] [Fintype J] [Fintype H] + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (hI : ∀ p ∈ I, 0 < p) + (φ : ℝ → ℝ) (G : ℝ) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass P φ G) + (μ : Y → ℝ) (hμ : ∀ y, 0 ≤ μ y) (hμmass : ∑ y, μ y = 1) + (U : Y → ℕ) (hU : ∀ y, 0 < U y) + (Q : Y → P → J → ℕ) [∀ y p j, Fact (Q y p j).Prime] + (gQ : ∀ y p j, ZMod (Q y p j) → ℂ) + (hQprod : ∀ y p, (∏ j, Q y p j) = (p : ℕ) * U y) + (giant : J) (S : ∀ y p j, Finset (ZMod (Q y p j))) + (hgQ : ∀ y p x, ‖gQ y p giant x‖ ≤ 1) + (hregular : ∀ y p j, j ≠ giant → gQ y p j = normalizedResidueTransform (S y p j)) + (hS : ∀ y p j, j ≠ giant → (S y p j).Nonempty) + (hSp : ∀ y p j, j ≠ giant → (S y p j).card < Q y p j) + (L : Y → A → H → ℕ) [∀ y a i, Fact (L y a i).Prime] + (gL : ∀ y a i, ZMod (L y a i) → ℂ) + (hgL : ∀ y a i x, gL y a i (-x) = conj (gL y a i x)) + (D : Y → ℕ) (v : Y → A → ℤ) (W : Y → ℕ → A → ℂ) + (hrowSupport : ∀ y (p : P) a, W y p a ≠ 0 → + Pairwise (fun i j => (Q y p i).Coprime (Q y p j)) ∧ + ∀ j, (D y).Coprime (Q y p j)) + (hsupport : ∀ y p, p ∈ I → ∀ a, W y p a ≠ 0 → + Pairwise (fun i j => (L y a i).Coprime (L y a j)) ∧ + (∏ i, L y a i).Coprime (p * U y) ∧ ∀ i, (D y).Coprime (L y a i)) + (N B V : ℕ) + (hv : ∀ y p, p ∈ I → ∀ a, W y p a ≠ 0 → (v y a).natAbs ≤ N) + (hL : ∀ y, μ y ≠ 0 → ∀ p, p ∈ I → ∀ a, W y p a ≠ 0 → (∏ i, L y a i) ≤ B) + (hscale : ∀ y, μ y ≠ 0 → ∀ p, p ∈ I → 2 * N * B ≤ V * (p * U y)) + (hlarge : ∀ y a q, q.Prime → q ∣ ∏ i, L y a i → V < q) : + Real.exp (-smoothGiantLogNormalizer P φ G) * + ‖∑ y, (μ y : ℂ) * ∑ p : P, (smoothGiantPrior P φ G p : ℂ) * + ∑ a, W y p a * movingRegularTransform (Sum.elim (Q y p) (L y a)) + (movingSumFactors (Q y p) (L y a) (gQ y p) (gL y a)) (D y) (v y a)‖ ^ 2 ≤ + (∑ y, μ y * (U y : ℝ) * ∑ p ∈ I, φ (Real.log p - G) * + (pivotDiagonal (fun a => ∏ i, L y a i) (v y) + (movingRegularCoefficient (L y) (gL y) (D y) (U y) (v y) (W y) p)).re) + + ‖∑ y, ((μ y * (U y : ℝ) : ℝ) : ℂ) * + ∑ s ∈ transferFrequencyRange V, ∑ a, ∑ b, + if validTransferredPivot I + (v y a * (∏ i, L y b i) - v y b * (∏ i, L y a i)) (s * U y) then + let p := reconstructedPivot + (v y a * (∏ i, L y b i) - v y b * (∏ i, L y a i)) (s * U y) + (φ (Real.log p - G) : ℂ) * W y p a * conj (W y p b) * + movingRegularTransform (Sum.elim (L y a) (L y b)) + (movingSumFactors (L y a) (L y b) (gL y a) (gL y b)) (D y) s + else 0‖ := by + let c := fun y => movingRegularCoefficient (L y) (gL y) (D y) (U y) (v y) (W y) + have hc (y : Y) (p : ℕ) (a : A) (h : c y p a ≠ 0) : W y p a ≠ 0 := by + intro hz + apply h + simp only [c, movingRegularCoefficient, hz, zero_mul] + have ht := smoothGiantPrior_transfer_on_prior P I hP hPI hI φ G hφ hpos μ hμ hμmass U hU + (fun y p => movingGuardedRow (Q y p) (gQ y p) (D y)) + (fun y p => by + simpa only [Nat.cast_mul] using + movingGuardedRow_energy (Q y p) (gQ y p) (D y) ((p : ℕ) * U y) + (hQprod y p) giant (S y p) (hgQ y p) (hregular y p) (hS y p) (hSp y p)) + (fun y a => ∏ i, L y a i) v c + (fun y p hp a h => (hsupport y p hp a (hc y p a h)).2.1) N B V + (fun y p hp a h => hv y p hp a (hc y p a h)) + (fun y hy p hp a h => hL y hy p hp a (hc y p a h)) hscale + have hsum : (∑ y, (μ y : ℂ) * ∑ p : P, (smoothGiantPrior P φ G p : ℂ) * + ∑ a, movingGuardedRow (Q y p) (gQ y p) (D y) + (positiveIntegerPivotKey ((p : ℕ) * U y) + (Nat.mul_pos (hP p p.property).pos (hU y)) (∏ i, L y a i) (v y a)) * c y p a) = + ∑ y, (μ y : ℂ) * ∑ p : P, (smoothGiantPrior P φ G p : ℂ) * + ∑ a, W y p a * movingRegularTransform (Sum.elim (Q y p) (L y a)) + (movingSumFactors (Q y p) (L y a) (gQ y p) (gL y a)) (D y) (v y a) := by + apply Finset.sum_congr rfl + intro y _ + congr 1 + apply Finset.sum_congr rfl + intro p _ + congr 1 + apply Finset.sum_congr rfl + intro a _ + by_cases hz : W y p a = 0 + · simp only [c, movingRegularCoefficient, hz, zero_mul, mul_zero] + · have hs := hrowSupport y p a hz + rw [moving_full_transform_guarded (Q y p) (L y a) (gQ y p) (gL y a) + (D y) ((p : ℕ) * U y) (hQprod y p) + (Nat.mul_pos (hP p p.property).pos (hU y)) (v y a) hs.1 hs.2 + (hsupport y p (hPI p.property) a hz).2.1] + dsimp only [c, movingRegularCoefficient] + ring + rw [hsum] at ht + convert ht using 1 + congr 1 + congr 1 + apply Finset.sum_congr rfl + intro y _ + congr 1 + dsimp only [c] + rw [movingGiantOffDiagonal_regular (L y) (gL y) (hgL y) I V (U y) (D y) + (v y) (fun p => φ (Real.log p - G)) (W y) (hsupport y) (hlarge y)] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + split_ifs + · congr 1 + congr 1 + funext i + cases i <;> rfl + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullTransformTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullTransformTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..bb18b10e05caa22ed35bb2e8053fd4c4db364b9d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingFullTransformTransfer.lean @@ -0,0 +1,156 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGuardedRow +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularOffDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSumFactors + +namespace OAI + +/-! # The original full Fourier amplitude through one giant-only step -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance fullTransferSum_neZero {J H : Type*} (Q : J → ℕ) (L : H → ℕ) + [∀ j, NeZero (Q j)] [∀ i, NeZero (L i)] (i : J ⊕ H) : + NeZero (Sum.elim Q L i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +/-- The row used by Cauchy is the actual extracted part of the full transform. +The support conditions are used only where the original coefficient is nonzero. -/ +theorem moving_full_transform_guarded {J H : Type*} [Fintype J] [Fintype H] + (Q : J → ℕ) (L : H → ℕ) [∀ j, Fact (Q j).Prime] [∀ i, Fact (L i).Prime] + (gQ : ∀ j, ZMod (Q j) → ℂ) (gL : ∀ i, ZMod (L i) → ℂ) + (D M : ℕ) (hM : (∏ j, Q j) = M) (hMpos : 0 < M) (v : ℤ) + (hQ : Pairwise (fun i j => (Q i).Coprime (Q j))) + (hD : ∀ j, D.Coprime (Q j)) (hL : (∏ i, L i).Coprime M) : + movingRegularTransform (Sum.elim Q L) + (movingSumFactors Q L gQ gL) D v = + movingGuardedRow Q gQ D (positiveIntegerPivotKey M hMpos (∏ i, L i) v) * + movingRegularTransform L gL (M * D) v := by + subst M + rw [movingGuardedRow_grouped Q gQ D (∏ i, L i) v hQ hD hL] + calc + _ = movingRegularTransform Q gQ (D * ∏ i, L i) v * + movingRegularTransform L gL (D * ∏ j, Q j) v := by + convert moving_regular_transform_split Q L gQ gL D v using 1 + congr 1 + funext i + cases i <;> rfl + _ = _ := by rw [Nat.mul_comm (∏ j, Q j) D] + +/-- One iteration for the genuine full Fourier transform. The row energy is +derived from the normalized compensation transforms, and the retained factors +are evaluated at the exact new frequency after the forced integer substitution. -/ +theorem smoothGiantPrior_full_transform_transfer + {Y A J H : Type*} [Fintype Y] [Fintype A] [Fintype J] [Fintype H] + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (hI : ∀ p ∈ I, 0 < p) + (φ : ℝ → ℝ) (G : ℝ) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass P φ G) + (μ : Y → ℝ) (hμ : ∀ y, 0 ≤ μ y) (hμmass : ∑ y, μ y = 1) + (U : Y → ℕ) (hU : ∀ y, 0 < U y) + (Q : Y → P → J → ℕ) [∀ y p j, Fact (Q y p j).Prime] + (gQ : ∀ y p j, ZMod (Q y p j) → ℂ) + (hQprod : ∀ y p, (∏ j, Q y p j) = (p : ℕ) * U y) + (giant : J) (S : ∀ y p j, Finset (ZMod (Q y p j))) + (hgQ : ∀ y p x, ‖gQ y p giant x‖ ≤ 1) + (hregular : ∀ y p j, j ≠ giant → gQ y p j = normalizedResidueTransform (S y p j)) + (hS : ∀ y p j, j ≠ giant → (S y p j).Nonempty) + (hSp : ∀ y p j, j ≠ giant → (S y p j).card < Q y p j) + (L : Y → A → H → ℕ) [∀ y a i, Fact (L y a i).Prime] + (gL : ∀ y a i, ZMod (L y a i) → ℂ) + (hgL : ∀ y a i x, gL y a i (-x) = conj (gL y a i x)) + (D : Y → ℕ) (v : Y → A → ℤ) (W : Y → ℕ → A → ℂ) + (hrowSupport : ∀ y (p : P) a, W y p a ≠ 0 → + Pairwise (fun i j => (Q y p i).Coprime (Q y p j)) ∧ + ∀ j, (D y).Coprime (Q y p j)) + (hsupport : ∀ y p, p ∈ I → ∀ a, W y p a ≠ 0 → + Pairwise (fun i j => (L y a i).Coprime (L y a j)) ∧ + (∏ i, L y a i).Coprime (p * U y) ∧ ∀ i, (D y).Coprime (L y a i)) + (N B V : ℕ) + (hv : ∀ y p, p ∈ I → ∀ a, W y p a ≠ 0 → (v y a).natAbs ≤ N) + (hL : ∀ y p, p ∈ I → ∀ a, W y p a ≠ 0 → (∏ i, L y a i) ≤ B) + (hscale : ∀ y, μ y ≠ 0 → ∀ p, p ∈ I → 2 * N * B ≤ V * (p * U y)) + (hlarge : ∀ y a q, q.Prime → q ∣ ∏ i, L y a i → V < q) : + Real.exp (-smoothGiantLogNormalizer P φ G) * + ‖∑ y, (μ y : ℂ) * ∑ p : P, (smoothGiantPrior P φ G p : ℂ) * + ∑ a, W y p a * movingRegularTransform (Sum.elim (Q y p) (L y a)) + (movingSumFactors (Q y p) (L y a) (gQ y p) (gL y a)) (D y) (v y a)‖ ^ 2 ≤ + (∑ y, μ y * (U y : ℝ) * ∑ p ∈ I, φ (Real.log p - G) * + (pivotDiagonal (fun a => ∏ i, L y a i) (v y) + (movingRegularCoefficient (L y) (gL y) (D y) (U y) (v y) (W y) p)).re) + + ‖∑ y, ((μ y * (U y : ℝ) : ℝ) : ℂ) * + ∑ s ∈ transferFrequencyRange V, ∑ a, ∑ b, + if validTransferredPivot I + (v y a * (∏ i, L y b i) - v y b * (∏ i, L y a i)) (s * U y) then + let p := reconstructedPivot + (v y a * (∏ i, L y b i) - v y b * (∏ i, L y a i)) (s * U y) + (φ (Real.log p - G) : ℂ) * W y p a * conj (W y p b) * + movingRegularTransform (Sum.elim (L y a) (L y b)) + (movingSumFactors (L y a) (L y b) (gL y a) (gL y b)) (D y) s + else 0‖ := by + let c := fun y => movingRegularCoefficient (L y) (gL y) (D y) (U y) (v y) (W y) + have hc (y : Y) (p : ℕ) (a : A) (h : c y p a ≠ 0) : W y p a ≠ 0 := by + intro hz + apply h + simp only [c, movingRegularCoefficient, hz, zero_mul] + have ht := smoothGiantPrior_transfer P I hP hPI hI φ G hφ hpos μ hμ hμmass U hU + (fun y p => movingGuardedRow (Q y p) (gQ y p) (D y)) + (fun y p => by + simpa only [Nat.cast_mul] using + movingGuardedRow_energy (Q y p) (gQ y p) (D y) ((p : ℕ) * U y) + (hQprod y p) giant (S y p) (hgQ y p) (hregular y p) (hS y p) (hSp y p)) + (fun y a => ∏ i, L y a i) v c + (fun y p hp a h => (hsupport y p hp a (hc y p a h)).2.1) N B V + (fun y p hp a h => hv y p hp a (hc y p a h)) + (fun y p hp a h => hL y p hp a (hc y p a h)) hscale + have hsum : (∑ y, (μ y : ℂ) * ∑ p : P, (smoothGiantPrior P φ G p : ℂ) * + ∑ a, movingGuardedRow (Q y p) (gQ y p) (D y) + (positiveIntegerPivotKey ((p : ℕ) * U y) + (Nat.mul_pos (hP p p.property).pos (hU y)) (∏ i, L y a i) (v y a)) * c y p a) = + ∑ y, (μ y : ℂ) * ∑ p : P, (smoothGiantPrior P φ G p : ℂ) * + ∑ a, W y p a * movingRegularTransform (Sum.elim (Q y p) (L y a)) + (movingSumFactors (Q y p) (L y a) (gQ y p) (gL y a)) (D y) (v y a) := by + apply Finset.sum_congr rfl + intro y _ + congr 1 + apply Finset.sum_congr rfl + intro p _ + congr 1 + apply Finset.sum_congr rfl + intro a _ + by_cases hz : W y p a = 0 + · simp only [c, movingRegularCoefficient, hz, zero_mul, mul_zero] + · have hs := hrowSupport y p a hz + rw [moving_full_transform_guarded (Q y p) (L y a) (gQ y p) (gL y a) + (D y) ((p : ℕ) * U y) (hQprod y p) + (Nat.mul_pos (hP p p.property).pos (hU y)) (v y a) hs.1 hs.2 + (hsupport y p (hPI p.property) a hz).2.1] + dsimp only [c, movingRegularCoefficient] + ring + rw [hsum] at ht + convert ht using 1 + congr 1 + congr 1 + apply Finset.sum_congr rfl + intro y _ + congr 1 + dsimp only [c] + rw [movingGiantOffDiagonal_regular (L y) (gL y) (hgL y) I V (U y) (D y) + (v y) (fun p => φ (Real.log p - G)) (W y) (hsupport y) (hlarge y)] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + split_ifs + · congr 1 + congr 1 + funext i + cases i <;> rfl + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantAmbientAmplitude.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantAmbientAmplitude.lean new file mode 100644 index 0000000000000000000000000000000000000000..b69b750ce571276ea5eb7f4ff80c6ecebda39320 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantAmbientAmplitude.lean @@ -0,0 +1,45 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateAmplitude +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantAmbientPrior + +namespace OAI + +/-! # Restricting the giant average to its full smooth cell -/ +namespace Ostmann +open scoped Classical BigOperators + +theorem smoothGiantPrior_ambient_complex_mean (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (φ : ℝ → ℝ) (G : ℝ) (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (hsub : smoothGiantPrimeRange G ⊆ P) (f : P → ℂ) : + (∑ p : P, (smoothGiantPrior P φ G p : ℂ) * f p) = + ∑ q : smoothGiantPrimeRange G, + (smoothGiantPrior (smoothGiantPrimeRange G) φ G q : ℂ) * f ⟨q, hsub q.property⟩ := by + apply Complex.ext + · simpa only [Complex.re_sum, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, + zero_mul, sub_zero] using smoothGiantPrior_ambient_mean P hP φ G hout hsub (fun p => (f p).re) + · simpa only [Complex.im_sum, Complex.mul_im, Complex.ofReal_re, Complex.ofReal_im, + zero_mul, add_zero] using smoothGiantPrior_ambient_mean P hP φ G hout hsub (fun p => (f p).im) + +theorem movingTemplatePrimeAmplitude_giant_ambient {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (ψ : ℝ → ℝ) (H : ℝ) (hout : ∀ x, 1 ≤ |x| → ψ x = 0) + (hsub : smoothGiantPrimeRange H ⊆ P) + (ν : MovingRegularSlot n r m → σ → ℝ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n r m + P (smoothGiantPrior P ψ H) ν greg ggiant favorable = + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n r m + (smoothGiantPrimeRange H) (smoothGiantPrior (smoothGiantPrimeRange H) ψ H) + ν greg ggiant favorable := by + unfold movingTemplatePrimeAmplitude + rw [smoothGiantPrior_ambient_complex_mean P hP ψ H hout hsub] + apply Finset.sum_congr rfl + intro XL _ + congr 1 + rw [smoothGiantPrior_ambient_complex_mean P hP ψ H hout hsub] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantAncestorValues.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantAncestorValues.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d6c04899ee5fd8ef263f3df461a98071b279de4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantAncestorValues.lean @@ -0,0 +1,123 @@ +import OAI.NumberTheory.Ostmann.Construction.ScheduledPreorderNodes +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotSystem +import OAI.NumberTheory.Ostmann.Construction.HistoryGiantSources + +namespace OAI + +/-! # Actual moving giants are the selected proper ancestor quotients + +The preorder pivot array is divided by its own sampled compensation product. +The current giants use exactly these quotients, rather than the composite +pivots that enter the generic transfer-history recursion. +-/ + +namespace Ostmann +open scoped Classical + +noncomputable def movingNodeGiant {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (node : ReconstructedTransferNode (MovingSlotState σ)) : ℕ := + node.pivot (movingSlotSystem value childBound pivotBound) / node.state.compensation value + +noncomputable def movingGiantArray {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (n : ℕ) (x : MovingSlotState σ) + (t : FrequencyTree ℤ n) (j : Fin (2 ^ n - 1)) : ℤ := + movingNodeGiant value childBound pivotBound + (transferNodeArray (movingSlotSystem value childBound pivotBound) n x t j) + +/-- Following a path updates the two giants with the actual quotient at each +proper prefix. The hypothesis just names these computed values. -/ +theorem movingNodeAtPath_giants {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (n : ℕ) (T : MovingSlotData σ n) + (t : FrequencyTree ℤ n) (XL XR : ℕ) (path : List Bool) (hp : path.length < n) + (d : ℕ) (p : ℕ → ℤ) + (hanc : ∀ k < path.length, p (d + k) = + (movingNodeGiant value childBound pivotBound + (transferNodeAtPath (movingSlotSystem value childBound pivotBound) n + ⟨n, T, XL, XR⟩ t (path.take k)) : ℤ)) : + let z := (transferNodeAtPath (movingSlotSystem value childBound pivotBound) n + ⟨n, T, XL, XR⟩ t path).state + ((z.leftGiant : ℤ), (z.rightGiant : ℤ)) = + evolveGiantValues p d (XL, XR) path := by + induction n generalizing XL XR path d with + | zero => simp at hp + | succ n ih => + cases T with + | node s CL CR u left right => + cases path with + | nil => rfl + | cons b path => + have hp' : path.length < n := by simpa using hp + let sys := movingSlotSystem value childBound pivotBound + let x : MovingSlotState σ := ⟨n + 1, .node s CL CR u left right, XL, XR⟩ + let Q := historyPivot sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + let g := Q / MovingSlotReversal.naturalProduct value u + have hg : p d = (g : ℤ) := by + simpa only [Nat.add_zero, List.take_zero, transferNodeAtPath, + movingNodeGiant, ReconstructedTransferNode.pivot, + MovingSlotState.compensation] using hanc 0 (by simp) + cases b + · change (((transferNodeAtPath sys n ⟨n, left, g, XL⟩ t.2.1 path).state.leftGiant : ℤ), + ((transferNodeAtPath sys n ⟨n, left, g, XL⟩ t.2.1 path).state.rightGiant : ℤ)) = _ + rw [evolveGiantValues, hg] + apply ih left t.2.1 g XL path hp' (d + 1) + intro k hk + have h := hanc (k + 1) (by simpa using Nat.add_lt_add_right hk 1) + simpa only [Nat.add_assoc, Nat.add_comm 1 k, List.take_succ_cons, + transferNodeAtPath, Bool.false_eq_true, ite_false, movingSlotSystem, + MovingSlotState.child, sys, x, g, Q, ite_true] using h + · change (((transferNodeAtPath sys n ⟨n, right, g, XR⟩ t.2.2 path).state.leftGiant : ℤ), + ((transferNodeAtPath sys n ⟨n, right, g, XR⟩ t.2.2 path).state.rightGiant : ℤ)) = _ + rw [evolveGiantValues, hg] + apply ih right t.2.2 g XR path hp' (d + 1) + intro k hk + have h := hanc (k + 1) (by simpa using Nat.add_lt_add_right hk 1) + simpa only [Nat.add_assoc, Nat.add_comm 1 k, List.take_succ_cons, + transferNodeAtPath, ite_true, movingSlotSystem, MovingSlotState.child, + sys, x, g, Q, Bool.false_eq_true, ite_false] using h + +/-- The source expression in the ancestor scheme evaluates to the actual +natural giant on each side of a preorder node. -/ +theorem movingGiantArray_sources {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (n : ℕ) (T : MovingSlotData σ n) + (t : FrequencyTree ℤ n) (XL XR : ℕ) (j : Fin (2 ^ n - 1)) : + let p := movingGiantArray value childBound pivotBound n ⟨n, T, XL, XR⟩ t + let z := (transferNodeArray (movingSlotSystem value childBound pivotBound) n + ⟨n, T, XL, XR⟩ t j).state + ((z.leftGiant : ℤ), (z.rightGiant : ℤ)) = + ((historyGiantSources XL XR (preorderNodePath n j)).1.nodeValue n j p + (historyGiantSources_known XL XR _).1, + (historyGiantSources XL XR (preorderNodePath n j)).2.nodeValue n j p + (historyGiantSources_known XL XR _).2) := by + dsimp only + rw [transferNodeArray_path] + let p := movingGiantArray value childBound pivotBound n ⟨n, T, XL, XR⟩ t + let q := fun k => if hk : k < (preorderNodePath n j).length then + p (ancestorNodeIndex n j ⟨k, hk⟩) else 0 + have h := movingNodeAtPath_giants value childBound pivotBound n T t XL XR + (preorderNodePath n j) (preorderNodePath_length n j) 0 q (by + intro k hk + simp only [Nat.zero_add, q, dite_eq_left hk, p, movingGiantArray, + transferNodeArray_path, ancestorNodeIndex_path]) + have heval := evolveGiantSources_eval q 0 (.fixed (XL : ℤ), .fixed (XR : ℤ)) + (preorderNodePath n j) + change _ = evolveGiantValues q 0 (XL, XR) (preorderNodePath n j) at heval + rw [← heval] at h + change _ = ((historyGiantSources XL XR (preorderNodePath n j)).1.eval q, + (historyGiantSources XL XR (preorderNodePath n j)).2.eval q) at h + rw [h] + have he (s : HistoryGiantSource) (hs : s.knownBefore (preorderNodePath n j).length) : + s.eval q = s.nodeValue n j p hs := by + cases s with + | fixed c => rfl + | ancestor i => + change (if hi : i < (preorderNodePath n j).length then + p (ancestorNodeIndex n j ⟨i, hi⟩) else 0) = _ + change i < (preorderNodePath n j).length at hs + rw [dite_eq_left hs] + rfl + exact Prod.ext (he _ (historyGiantSources_known XL XR _).1) + (he _ (historyGiantSources_known XL XR _).2) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantArchimedean.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantArchimedean.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba603f02f95e3c425ab00db7d9985d90737e3df9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantArchimedean.lean @@ -0,0 +1,142 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotSpectator +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOccurrenceUnits +import OAI.NumberTheory.Ostmann.Characters.NormalizedFourierProfile +import OAI.NumberTheory.Ostmann.Characters.TreeTupleProfiles + +namespace OAI + +/-! # The actual terminal moduli as quadratic functions of a top giant + +Small prime values are fixed here. Every reconstructed giant is linear in the +initial pair, and each terminal modulus is a product of two such linear forms. +The identification uses the integer support equations of the original sampler. +-/ + +namespace Ostmann +open scoped Classical + +noncomputable def MovingSlotReversal.realPivot {σ : Type*} + (s : MovingSlotReversal σ) (value : σ → ℕ) (XL XR : ℝ) : ℝ := + ((s.leftFrequency : ℝ) * (MovingSlotReversal.naturalProduct value s.rightSlots : ℝ) * XR - + (s.rightFrequency : ℝ) * (MovingSlotReversal.naturalProduct value s.leftSlots : ℝ) * XL) / + ((s.rootFrequency : ℝ) * (MovingSlotReversal.naturalProduct value s.compensationSlots : ℝ)) + +theorem MovingSlotReversal.realPivot_eq {σ : Type*} + (s : MovingSlotReversal σ) (value : σ → ℕ) (XL XR : ℕ) + (hs : s.rootFrequency ≠ 0) + (hu : MovingSlotReversal.naturalProduct value s.compensationSlots ≠ 0) + (h : s.IntegralAt value (XL, XR)) : + s.realPivot value XL XR = (s.naturalPivot value XL XR : ℝ) := by + have he := congrArg (fun z : ℤ => (z : ℝ)) h.2 + simp only [Int.cast_sub, Int.cast_mul, Int.cast_natCast, Nat.cast_mul] at he + unfold realPivot + apply (div_eq_iff (mul_ne_zero (Int.cast_ne_zero.mpr hs) (Nat.cast_ne_zero.mpr hu))).mpr + nlinarith only [he] + +noncomputable def MovingSlotReversal.pivotPolynomial {σ : Type*} + (s : MovingSlotReversal σ) (value : σ → ℕ) (XL XR : Polynomial ℝ) : Polynomial ℝ := + Polynomial.C (((s.rootFrequency : ℝ) * + (MovingSlotReversal.naturalProduct value s.compensationSlots : ℝ))⁻¹) * + (Polynomial.C ((s.leftFrequency : ℝ) * + (MovingSlotReversal.naturalProduct value s.rightSlots : ℝ)) * XR - + Polynomial.C ((s.rightFrequency : ℝ) * + (MovingSlotReversal.naturalProduct value s.leftSlots : ℝ)) * XL) + +theorem MovingSlotReversal.pivotPolynomial_eval {σ : Type*} + (s : MovingSlotReversal σ) (value : σ → ℕ) (XL XR : Polynomial ℝ) (z : ℝ) : + (s.pivotPolynomial value XL XR).eval z = s.realPivot value (XL.eval z) (XR.eval z) := by + simp only [pivotPolynomial, Polynomial.eval_mul, Polynomial.eval_sub, Polynomial.eval_C, + realPivot, div_eq_mul_inv] + ring + +theorem MovingSlotReversal.pivotPolynomial_degree {σ : Type*} + (s : MovingSlotReversal σ) (value : σ → ℕ) (XL XR : Polynomial ℝ) (d : ℕ) + (hL : XL.natDegree ≤ d) (hR : XR.natDegree ≤ d) : + (s.pivotPolynomial value XL XR).natDegree ≤ d := by + apply Polynomial.natDegree_mul_le.trans + simp only [Polynomial.natDegree_C, zero_add] + apply (Polynomial.natDegree_sub_le _ _).trans + apply max_le + · exact Polynomial.natDegree_mul_le.trans (by simpa only [Polynomial.natDegree_C, zero_add] using hR) + · exact Polynomial.natDegree_mul_le.trans (by simpa only [Polynomial.natDegree_C, zero_add] using hL) + +/-- The terminal integer moduli, with the same pivot divisions and child order +as the full recursive coefficient. -/ +def MovingSlotData.leafModuli {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → TreeLeafIndex n → ℕ + | _, .leaf _ regular, XL, XR, _ => XL * XR * MovingSlotReversal.naturalProduct value regular + | _, .node s CL CR u left right, XL, XR, i => + let p := (MovingSlotData.step s CL CR u left right false).naturalPivot value XL XR + match i with + | .inl i => left.leafModuli value p XL i + | .inr i => right.leafModuli value p XR i + +/-- Polynomial extension in one free top coordinate. Its coefficients may +contain reciprocals of the fixed frequency and compensation products. -/ +noncomputable def MovingSlotData.leafPolynomials {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → Polynomial ℝ → Polynomial ℝ → + TreeLeafIndex n → Polynomial ℝ + | _, .leaf _ regular, XL, XR, _ => + XL * XR * Polynomial.C (MovingSlotReversal.naturalProduct value regular : ℝ) + | _, .node s CL CR u left right, XL, XR, i => + let p := (MovingSlotData.step s CL CR u left right false).pivotPolynomial value XL XR + match i with + | .inl i => left.leafPolynomials value p XL i + | .inr i => right.leafPolynomials value p XR i + +theorem MovingSlotData.leafPolynomials_degree {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : Polynomial ℝ) (d : ℕ) + (hL : XL.natDegree ≤ d) (hR : XR.natDegree ≤ d) (i : TreeLeafIndex n) : + (T.leafPolynomials value XL XR i).natDegree ≤ 2 * d := by + induction T generalizing XL XR with + | leaf s regular => + apply Polynomial.natDegree_mul_le.trans + simp only [Polynomial.natDegree_C, add_zero] + exact Polynomial.natDegree_mul_le.trans (by omega) + | node s CL CR u left right ihL ihR => + have hp := (MovingSlotData.step s CL CR u left right false).pivotPolynomial_degree + value XL XR d hL hR + cases i with + | inl i => exact ihL _ _ hp hL i + | inr i => exact ihR _ _ hp hR i + +theorem MovingSlotReversal.naturalProduct_ne_zero {σ : Type*} + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (slots : List σ) : + naturalProduct value slots ≠ 0 := by + induction slots with + | nil => simp [naturalProduct] + | cons i slots ih => + simpa only [naturalProduct, List.map_cons, List.prod_cons] using mul_ne_zero (hvalue i) ih + +/-- Exact agreement on integer support; no approximation or extra +real-variable realization condition is assumed. -/ +theorem MovingSlotData.leafPolynomials_eval {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) {n : ℕ} (T : MovingSlotData σ n) + (hfreq : T.Frequencies (· ≠ 0)) (XL XR : ℕ) (hI : T.Integral value XL XR) + (L R : Polynomial ℝ) (z : ℝ) (hL : L.eval z = (XL : ℝ)) (hR : R.eval z = (XR : ℝ)) + (i : TreeLeafIndex n) : + (T.leafPolynomials value L R i).eval z = (T.leafModuli value XL XR i : ℝ) := by + induction T generalizing XL XR L R with + | leaf s regular => + simp only [leafPolynomials, leafModuli, Polynomial.eval_mul, Polynomial.eval_C, + hL, hR, Nat.cast_mul] + | node s CL CR u left right ihL ihR => + let step := MovingSlotData.step s CL CR u left right false + have hp : (step.pivotPolynomial value L R).eval z = (step.naturalPivot value XL XR : ℝ) := by + rw [MovingSlotReversal.pivotPolynomial_eval, hL, hR] + exact step.realPivot_eq value XL XR hfreq.1 + (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) hI.1 + cases i with + | inl i => exact ihL hfreq.2.1 _ _ hI.2.1 _ _ hp hL i + | inr i => exact ihR hfreq.2.2 _ _ hI.2.2 _ _ hp hR i + +/-- In particular each leaf is quadratic in either initial giant. -/ +theorem MovingSlotData.leftGiant_quadratic {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XR : ℝ) (i : TreeLeafIndex n) : + (T.leafPolynomials value Polynomial.X (Polynomial.C XR) i).natDegree ≤ 2 := by + simpa only [mul_one] using T.leafPolynomials_degree value Polynomial.X (Polynomial.C XR) 1 + (by simp) (by simp) i + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantFormulas.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantFormulas.lean new file mode 100644 index 0000000000000000000000000000000000000000..3409beb80fc18689f06560501b92b7106e1796fc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantFormulas.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNodeGuards + +namespace OAI + +/-! # Rational formulas retain the actual compensation division -/ + +namespace Ostmann +open scoped Classical + +noncomputable def MovingSlotReversal.giantFormula {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) + (hs : step.rootFrequency ≠ 0) + (hu : MovingSlotReversal.naturalProduct value step.compensationSlots ≠ 0) + (L R : HistoryFormula Bool) : HistoryFormula Bool := + .solve (.product L (.external (MovingSlotReversal.naturalProduct value step.leftSlots))) + (.product R (.external (MovingSlotReversal.naturalProduct value step.rightSlots))) + step.leftFrequency step.rightFrequency + (step.rootFrequency * (MovingSlotReversal.naturalProduct value step.compensationSlots : ℤ)) + (mul_ne_zero hs (Int.natCast_ne_zero.mpr hu)) + +/-- A supported integer reconstruction evaluates the rational giant formula +exactly. The sampled compensation product appears in its denominator. -/ +theorem MovingSlotReversal.giantFormula_value {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) + (hs : step.rootFrequency ≠ 0) + (hu : MovingSlotReversal.naturalProduct value step.compensationSlots ≠ 0) + (L R : HistoryFormula Bool) (a : Bool → ℤ) (XL XR : ℕ) + (hL : L.value (fun b => (a b : ℚ)) = (XL : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (XR : ℚ)) + (hI : step.IntegralAt value (XL, XR)) : + (step.giantFormula value hs hu L R).value (fun b => (a b : ℚ)) = + (step.naturalPivot value XL XR : ℚ) := by + have he := congrArg (fun z : ℤ => (z : ℚ)) hI.2 + simp only [Int.cast_sub, Int.cast_mul, Int.cast_natCast, Nat.cast_mul] at he + simp only [giantFormula, HistoryFormula.value_solve, HistoryFormula.value_product, + HistoryFormula.value_external, hL, hR, Int.cast_mul, Int.cast_natCast] + apply (div_eq_iff (mul_ne_zero (Int.cast_ne_zero.mpr hs) (Nat.cast_ne_zero.mpr hu))).mpr + nlinarith only [he] + +theorem MovingSlotReversal.giantFormula_integral {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) + (hs : step.rootFrequency ≠ 0) + (hu : MovingSlotReversal.naturalProduct value step.compensationSlots ≠ 0) + (L R : HistoryFormula Bool) (a : Bool → ℤ) (XL XR : ℕ) + (hL : L.value (fun b => (a b : ℚ)) = (XL : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (XR : ℚ)) + (hI : step.IntegralAt value (XL, XR)) : + (step.giantFormula value hs hu L R).IntegralAt a := by + refine ⟨(step.naturalPivot value XL XR : ℤ), ?_⟩ + simpa only [Int.cast_natCast] using step.giantFormula_value value hs hu L R a XL XR hL hR hI + +/-- The extra division by u is represented by an integer-polynomial residue +test. It is not discarded when the ordinary transfer guards are idealized. -/ +theorem rational_nat_div_integral_iff (P u : ℕ) (hu : u ≠ 0) : + (∃ z : ℤ, (P : ℚ) / u = (z : ℚ)) ↔ u ∣ P := by + constructor + · rintro ⟨z, hz⟩ + have he := (div_eq_iff (Nat.cast_ne_zero.mpr hu)).mp hz + have hi : (P : ℤ) = z * (u : ℤ) := by exact_mod_cast he + have hd : (u : ℤ) ∣ (P : ℤ) := ⟨z, by simpa only [mul_comm] using hi⟩ + exact Int.natCast_dvd_natCast.mp hd + · rintro ⟨z, rfl⟩ + refine ⟨(z : ℤ), ?_⟩ + simp only [Nat.cast_mul, Int.cast_natCast] + exact mul_div_cancel_left₀ (z : ℚ) (Nat.cast_ne_zero.mpr hu) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantPhase.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantPhase.lean new file mode 100644 index 0000000000000000000000000000000000000000..b181f2579c977fd183a670f88f059e49828ae92a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantPhase.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalStatistic +import OAI.NumberTheory.Ostmann.Construction.PhaseGiantTest + +namespace OAI + +/-! # The two original giant Fourier phases on a fixed product fibre -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The two cofactor phases before inserting the logarithmic coordinates. -/ +noncomputable def giantPairPhase (g : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (D H XL XR : ℕ) (s : ℤ) : ℂ := + (if favorable XL then complexUnitPhase + (g XL ((s : ZMod XL) * ((D * XR * H : ℕ) : ZMod XL)⁻¹)) else 0) * + (if favorable XR then complexUnitPhase + (g XR ((s : ZMod XR) * ((D * XL * H : ℕ) : ZMod XR)⁻¹)) else 0) + +/-- The two giant factors of Section 7.4, evaluated at their exact cofactors. +The definition also applies to the integer giant in a transfer diagonal. -/ +noncomputable def movingGiantPhase {σ B : Type*} {n : ℕ} + (value : σ → ℕ) (outside : List ℕ) (small bulk : TreeLeafTuple (List B) n) + (g : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (s : ℤ) (y : B → σ) (x z : ℝ) : ℂ := + giantPairPhase g favorable outside.prod + (MovingSlotReversal.naturalProduct (value ∘ y) + (flattenMovingSlots n small ++ flattenMovingSlots n bulk)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ s + +theorem movingGiantPhase_norm_le {σ B : Type*} {n : ℕ} + (value : σ → ℕ) (outside : List ℕ) (small bulk : TreeLeafTuple (List B) n) + (g : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (s : ℤ) (y : B → σ) (x z : ℝ) : + ‖movingGiantPhase value outside small bulk g favorable s y x z‖ ≤ 1 := by + unfold movingGiantPhase giantPairPhase + rw [norm_mul] + apply (mul_le_mul _ _ (norm_nonneg _) zero_le_one).trans_eq (one_mul 1) + all_goals split_ifs <;> first | exact complexUnitPhase_norm_le _ | simp + +theorem movingGiantPhase_selectedBulkSample {σ B : Type*} [Fintype B] + (value : σ → ℕ) (outside : List ℕ) (n m : ℕ) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (e : Equiv.Perm (TreeLeafIndex n × Fin m)) (y : B → σ) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (g : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (s : ℤ) (x z : ℝ) : + movingGiantPhase value outside small (bulkSlotLeaves n m slot) g favorable s + (selectedBulkSample slot e y) x z = + movingGiantPhase value outside small (bulkSlotLeaves n m slot) g favorable s y x z := by + unfold movingGiantPhase + rw [MovingSlotReversal.naturalProduct_selected_bulk value n m small slot e y hsmall] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantPolynomial.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantPolynomial.lean new file mode 100644 index 0000000000000000000000000000000000000000..054887ee446cbc74653064ae52d70ecafd6a3fd3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantPolynomial.lean @@ -0,0 +1,170 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantRows +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticHistoryLines + +namespace OAI + +/-! # Cleared line bounds for the source-ordered moving giant histories -/ + +namespace Ostmann +namespace PolynomialGiantRows + +variable {σ : Type*} + +theorem denominator_movingReverse (T : PolynomialGiantRows σ) (left : Bool) + (v w u : MvPolynomial σ ℤ) : + (T.movingReverse left v w u).denominator = T.denominator * u := by + cases left <;> rfl + +theorem usesOnly_movingReverse [DecidableEq σ] (T : PolynomialGiantRows σ) + (S : Finset σ) (hT : T.UsesOnly S) (left : Bool) (v w u : MvPolynomial σ ℤ) + (hv : v.vars ⊆ S) (hw : w.vars ⊆ S) (hu : u.vars ⊆ S) : + (T.movingReverse left v w u).UsesOnly S := by + have h := usesOnly_reverse T S hT left v w u hv hw hu + cases left + · exact h + · exact ⟨h.2.2.1, h.2.2.2.1, h.1, h.2.1, h.2.2.2.2⟩ + +theorem valueLE_movingReverse (T : PolynomialGiantRows σ) + (φ : MvPolynomial σ ℤ →+* ℝ) (left : Bool) (v w u : MvPolynomial σ ℤ) + (H L : ℝ) (hH : 0 ≤ H) (hL : 0 ≤ L) (hT : T.ValueLE φ H) + (hv : |φ v| ≤ L) (hw : |φ w| ≤ L) (hu : |φ u| ≤ L) : + (T.movingReverse left v w u).ValueLE φ (2 * L * H) := by + have h := valueLE_reverse T φ left v w u H L hH hL hT hv hw hu + cases left + · exact h + · exact ⟨h.2.2.1, h.2.2.2.1, h.1, h.2.1, h.2.2.2.2⟩ + +end PolynomialGiantRows + +noncomputable def movingPolynomialAncestors {σ : Type*} : + List (PolynomialReversal σ) → PolynomialGiantRows σ + | [] => PolynomialGiantRows.identity + | s :: steps => (movingPolynomialAncestors steps).movingReverse s.left s.v s.w s.u + +theorem movingPolynomialAncestors_denominator {σ K : Type*} [Field K] + (steps : List (PolynomialReversal σ)) (φ : MvPolynomial σ ℤ →+* K) + (h : ∀ s ∈ steps, φ s.u ≠ 0) : + φ (movingPolynomialAncestors steps).denominator ≠ 0 := by + induction steps with + | nil => simp [movingPolynomialAncestors, PolynomialGiantRows.identity] + | cons s steps ih => + rw [movingPolynomialAncestors, PolynomialGiantRows.denominator_movingReverse, map_mul] + exact mul_ne_zero (ih fun t ht => h t (by simp [ht])) (h s (by simp)) + +theorem movingPolynomialAncestors_det {σ K : Type*} [Field K] + (steps : List (PolynomialReversal σ)) (φ : MvPolynomial σ ℤ →+* K) + (h : ∀ s ∈ steps, φ s.v ≠ 0 ∧ φ s.w ≠ 0 ∧ φ s.u ≠ 0) : + IsUnit ((movingPolynomialAncestors steps).normalized φ).det := by + induction steps with + | nil => simp [movingPolynomialAncestors, PolynomialGiantRows.identity, + PolynomialGiantRows.normalized, GiantRows.identity, GiantRows.det] + | cons s steps ih => + have hs := h s (by simp) + have ht := ih (fun t ht => h t (by simp [ht])) + have hd := movingPolynomialAncestors_denominator steps φ + (fun t ht => (h t (by simp [ht])).2.2) + rw [movingPolynomialAncestors, PolynomialGiantRows.normalized_movingReverse _ φ + s.left s.v s.w s.u hd hs.1 hs.2.1 hs.2.2] + exact GiantRows.isUnit_det_movingReverse _ ht _ _ _ _ + +theorem movingPolynomialAncestors_degree {σ : Type*} + (steps : List (PolynomialReversal σ)) (d : ℕ) + (h : ∀ s ∈ steps, s.v.totalDegree ≤ d ∧ s.w.totalDegree ≤ d ∧ s.u.totalDegree ≤ d) : + (movingPolynomialAncestors steps).DegreeLE (steps.length * d) := by + induction steps with + | nil => simpa only [movingPolynomialAncestors, List.length_nil, Nat.zero_mul] using + (PolynomialGiantRows.degreeLE_identity (σ := σ)) + | cons s steps ih => + have hs := h s (by simp) + simpa only [movingPolynomialAncestors, List.length_cons, Nat.add_mul, one_mul] using + PolynomialGiantRows.degreeLE_movingReverse (movingPolynomialAncestors steps) + s.left s.v s.w s.u (steps.length * d) d (ih fun t ht => h t (by simp [ht])) + hs.1 hs.2.1 hs.2.2 + +theorem movingPolynomialAncestors_usesOnly {σ : Type*} [DecidableEq σ] + (steps : List (PolynomialReversal σ)) (S : Finset σ) + (h : ∀ s ∈ steps, s.v.vars ⊆ S ∧ s.w.vars ⊆ S ∧ s.u.vars ⊆ S) : + (movingPolynomialAncestors steps).UsesOnly S := by + induction steps with + | nil => exact PolynomialGiantRows.usesOnly_identity S + | cons s steps ih => + have hs := h s (by simp) + exact PolynomialGiantRows.usesOnly_movingReverse _ S + (ih fun t ht => h t (by simp [ht])) s.left s.v s.w s.u hs.1 hs.2.1 hs.2.2 + +theorem movingPolynomialAncestors_value {σ : Type*} + (steps : List (PolynomialReversal σ)) (φ : MvPolynomial σ ℤ →+* ℝ) + (L : ℝ) (hL : 0 ≤ L) + (h : ∀ s ∈ steps, |φ s.v| ≤ L ∧ |φ s.w| ≤ L ∧ |φ s.u| ≤ L) : + (movingPolynomialAncestors steps).ValueLE φ ((2 * L) ^ steps.length) := by + induction steps with + | nil => exact PolynomialGiantRows.valueLE_identity φ + | cons s steps ih => + have hs := h s (by simp) + have he : 2 * L * (2 * L) ^ steps.length = (2 * L) ^ (s :: steps).length := by + rw [List.length_cons, pow_succ] + ring + rw [← he] + exact PolynomialGiantRows.valueLE_movingReverse _ φ s.left s.v s.w s.u _ L + (pow_nonneg (by positivity) _) hL (ih fun t ht => h t (by simp [ht])) + hs.1 hs.2.1 hs.2.2 + +noncomputable def movingHistoryLine {σ : Type*} (steps : List (PolynomialReversal σ)) + (v w : MvPolynomial σ ℤ) : PolynomialGiantLine σ := + (movingPolynomialAncestors steps).numeratorLine v w + +/-- Nonvanishing needed before the current compensation prime is sampled. -/ +theorem movingHistoryLine_nonzero {σ K : Type*} [Field K] + (steps : List (PolynomialReversal σ)) (v w : MvPolynomial σ ℤ) + (φ : MvPolynomial σ ℤ →+* K) + (h : ∀ s ∈ steps, φ s.v ≠ 0 ∧ φ s.w ≠ 0 ∧ φ s.u ≠ 0) + (hv : φ v ≠ 0) (hw : φ w ≠ 0) : + φ (movingHistoryLine steps v w).a ≠ 0 ∨ φ (movingHistoryLine steps v w).b ≠ 0 := by + have hd := movingPolynomialAncestors_denominator steps φ (fun s hs => (h s hs).2.2) + have hdet := (movingPolynomialAncestors_det steps φ h).ne_zero + have hn := GiantRows.numerator_nonzero ((movingPolynomialAncestors steps).normalized φ) + hdet (Units.mk0 (φ v) hv) (Units.mk0 (φ w) hw) + have hn' : ((movingHistoryLine steps v w).normalized φ).1 ≠ 0 ∨ + ((movingHistoryLine steps v w).normalized φ).2 ≠ 0 := by + rw [movingHistoryLine, PolynomialGiantRows.normalized_numeratorLine _ v w φ hd] + simpa only [Units.val_mk0] using hn + have hz := (movingHistoryLine steps v w).normalized_zero_iff φ hd + exact hn'.imp (fun h h₀ => h (hz.1.mpr h₀)) (fun h h₀ => h (hz.2.mpr h₀)) + +/-- Concrete degree bound for the coefficient tests in the ancestor ordering. -/ +theorem movingHistoryLine_degree {σ : Type*} + (steps : List (PolynomialReversal σ)) (v w : MvPolynomial σ ℤ) + (d : ℕ) (hs : ∀ s ∈ steps, + s.v.totalDegree ≤ d ∧ s.w.totalDegree ≤ d ∧ s.u.totalDegree ≤ d) + (hv : v.totalDegree ≤ d) (hw : w.totalDegree ≤ d) : + (movingHistoryLine steps v w).a.totalDegree ≤ (steps.length + 1) * d ∧ + (movingHistoryLine steps v w).b.totalDegree ≤ (steps.length + 1) * d := by + simpa only [movingHistoryLine, Nat.add_mul, one_mul] using + PolynomialGiantRows.numeratorLine_degree_le (movingPolynomialAncestors steps) v w + (steps.length * d) d (movingPolynomialAncestors_degree steps d hs) hv hw + +theorem movingHistoryLine_value {σ : Type*} + (steps : List (PolynomialReversal σ)) (v w : MvPolynomial σ ℤ) + (φ : MvPolynomial σ ℤ →+* ℝ) (L : ℝ) (hL : 0 ≤ L) + (hs : ∀ s ∈ steps, |φ s.v| ≤ L ∧ |φ s.w| ≤ L ∧ |φ s.u| ≤ L) + (hv : |φ v| ≤ L) (hw : |φ w| ≤ L) : + |φ (movingHistoryLine steps v w).a| ≤ (2 * L) ^ (steps.length + 1) ∧ + |φ (movingHistoryLine steps v w).b| ≤ (2 * L) ^ (steps.length + 1) := by + have h := PolynomialGiantRows.numeratorLine_value_le (movingPolynomialAncestors steps) + v w φ ((2 * L) ^ steps.length) L hL (movingPolynomialAncestors_value steps φ L hL hs) hv hw + have he : 2 * L * (2 * L) ^ steps.length = (2 * L) ^ (steps.length + 1) := by + rw [pow_succ] + ring + simpa only [movingHistoryLine, he] using h + +theorem movingHistoryLine_vars_subset {σ : Type*} [DecidableEq σ] + (steps : List (PolynomialReversal σ)) (v w : MvPolynomial σ ℤ) (S : Finset σ) + (hs : ∀ s ∈ steps, s.v.vars ⊆ S ∧ s.w.vars ⊆ S ∧ s.u.vars ⊆ S) + (hv : v.vars ⊆ S) (hw : w.vars ⊆ S) : + (movingHistoryLine steps v w).a.vars ⊆ S ∧ (movingHistoryLine steps v w).b.vars ⊆ S := + PolynomialGiantRows.numeratorLine_vars_subset _ v w S + (movingPolynomialAncestors_usesOnly steps S hs) hv hw + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantRows.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantRows.lean new file mode 100644 index 0000000000000000000000000000000000000000..d048b0051c928ebd8e0ee5fc06e524fc4a32cff1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantRows.lean @@ -0,0 +1,124 @@ +import OAI.NumberTheory.Ostmann.Characters.PolynomialAncestorNonvanishing +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantTree + +namespace OAI + +/-! # Ordered coefficient rows for the moving-giant reversal + +In the manuscript's order both children put the inserted giant first. The +left child is therefore the exchanged version of the retained-first reversal. +This exchange preserves the nonvanishing determinant used in the line bounds. +-/ + +namespace Ostmann +namespace GiantRows + +variable {R : Type*} [CommRing R] + +def swap (T : GiantRows R) : GiantRows R := ⟨T.c, T.d, T.a, T.b⟩ + +@[simp] theorem eval_swap (T : GiantRows R) (x y : R) : + T.swap.eval x y = ((T.eval x y).2, (T.eval x y).1) := rfl + +theorem det_swap (T : GiantRows R) : T.swap.det = -T.det := by + simp only [swap, det] + ring + +/-- Both source children order their giants as `(new, retained)`. -/ +def movingReverse (T : GiantRows R) (left : Bool) (v w u : Rˣ) : GiantRows R := + if left then (T.reverse true v w u).swap else T.reverse false v w u + +theorem eval_movingReverse (T : GiantRows R) (left : Bool) (v w u : Rˣ) (x y : R) : + (T.movingReverse left v w u).eval x y = + ((u⁻¹ : Rˣ) * ((v : R) * (T.eval x y).2 - (w : R) * (T.eval x y).1), + if left then (T.eval x y).1 else (T.eval x y).2) := by + cases left <;> simp only [movingReverse, Bool.false_eq_true, ite_false, ite_true, + eval_swap, eval_reverse] + +theorem isUnit_det_movingReverse (T : GiantRows R) (hT : IsUnit T.det) + (left : Bool) (v w u : Rˣ) : IsUnit (T.movingReverse left v w u).det := by + cases left + · exact isUnit_det_reverse T hT false v w u + · change IsUnit (T.reverse true v w u).swap.det + rw [det_swap] + exact (isUnit_det_reverse T hT true v w u).neg + +/-- An exact integer node gives the actual child giant pair under reduction. -/ +theorem movingReverse_integer_node {q : ℕ} [Fact q.Prime] + (T : GiantRows (ZMod q)) (left : Bool) (v w u : (ZMod q)ˣ) + (x y : ZMod q) (XL XR p CL CR ML MR comp : ℕ) (s fv fw : ℤ) + (hpair : T.eval x y = ((XL : ZMod q), (XR : ZMod q))) + (hv : (v : ZMod q) = (fv : ZMod q) * ((CR * MR : ℕ) : ZMod q)) + (hw : (w : ZMod q) = (fw : ZMod q) * ((CL * ML : ℕ) : ZMod q)) + (hu : (u : ZMod q) = (s : ZMod q) * (comp : ZMod q)) + (hnode : fv * ((XR * CR * MR : ℕ) : ℤ) - + fw * ((XL * CL * ML : ℕ) : ℤ) = s * ((comp * p : ℕ) : ℤ)) : + (T.movingReverse left v w u).eval x y = + ((p : ZMod q), if left then (XL : ZMod q) else (XR : ZMod q)) := by + have he : (v : ZMod q) * XR - (w : ZMod q) * XL = (u : ZMod q) * p := by + have hc := congrArg (fun a : ℤ => (a : ZMod q)) hnode + simp only [Int.cast_sub, Int.cast_mul, Int.cast_natCast, Nat.cast_mul] at hc + rw [hv, hw, hu] + simp only [Nat.cast_mul] + convert hc using 1 <;> ring + rw [eval_movingReverse, hpair] + dsimp only + rw [he, Units.val_inv_eq_inv_val, ← mul_assoc, inv_mul_cancel₀ (Units.ne_zero u), one_mul] + +end GiantRows + +/-- The full path retains the same determinant invariant in the source order. -/ +def movingGiantAncestorRows {R : Type*} [CommRing R] : List (GiantReversal R) → GiantRows R + | [] => GiantRows.identity + | s :: steps => (movingGiantAncestorRows steps).movingReverse s.left s.v s.w s.u + +theorem movingGiantAncestorRows_isUnit_det {R : Type*} [CommRing R] + (steps : List (GiantReversal R)) : IsUnit (movingGiantAncestorRows steps).det := by + induction steps with + | nil => simp [movingGiantAncestorRows, GiantRows.identity, GiantRows.det] + | cons s steps ih => exact GiantRows.isUnit_det_movingReverse _ ih _ _ _ _ + +theorem movingGiantAncestorRows_numerator_nonzero {q : ℕ} [Fact q.Prime] + (steps : List (GiantReversal (ZMod q))) (v w : (ZMod q)ˣ) : + (v : ZMod q) * (movingGiantAncestorRows steps).c - + (w : ZMod q) * (movingGiantAncestorRows steps).a ≠ 0 ∨ + (v : ZMod q) * (movingGiantAncestorRows steps).d - + (w : ZMod q) * (movingGiantAncestorRows steps).b ≠ 0 := + GiantRows.numerator_nonzero _ (movingGiantAncestorRows_isUnit_det steps).ne_zero v w + +namespace PolynomialGiantRows + +variable {σ : Type*} + +noncomputable def swap (T : PolynomialGiantRows σ) : PolynomialGiantRows σ := + ⟨T.rows.swap, T.denominator⟩ + +noncomputable def movingReverse (T : PolynomialGiantRows σ) (left : Bool) + (v w u : MvPolynomial σ ℤ) : PolynomialGiantRows σ := + if left then (T.reverse true v w u).swap else T.reverse false v w u + +@[simp] theorem normalized_swap {K : Type*} [Field K] (T : PolynomialGiantRows σ) + (φ : MvPolynomial σ ℤ →+* K) : T.swap.normalized φ = (T.normalized φ).swap := rfl + +theorem normalized_movingReverse {K : Type*} [Field K] (T : PolynomialGiantRows σ) + (φ : MvPolynomial σ ℤ →+* K) (left : Bool) (v w u : MvPolynomial σ ℤ) + (hd : φ T.denominator ≠ 0) (hv : φ v ≠ 0) (hw : φ w ≠ 0) (hu : φ u ≠ 0) : + (T.movingReverse left v w u).normalized φ = + (T.normalized φ).movingReverse left (Units.mk0 (φ v) hv) (Units.mk0 (φ w) hw) + (Units.mk0 (φ u) hu) := by + cases left <;> simp only [movingReverse, GiantRows.movingReverse, Bool.false_eq_true, + ite_false, ite_true, normalized_swap, normalized_reverse T φ _ v w u hd hv hw hu] + +theorem degreeLE_movingReverse (T : PolynomialGiantRows σ) (left : Bool) + (v w u : MvPolynomial σ ℤ) (d e : ℕ) (hT : T.DegreeLE d) + (hv : v.totalDegree ≤ e) (hw : w.totalDegree ≤ e) (hu : u.totalDegree ≤ e) : + (T.movingReverse left v w u).DegreeLE (d + e) := by + have h := degreeLE_reverse T left v w u d e hT hv hw hu + cases left + · exact h + · exact ⟨h.2.2.1, h.2.2.2.1, h.1, h.2.1, h.2.2.2.2⟩ + +end PolynomialGiantRows +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantSamples.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantSamples.lean new file mode 100644 index 0000000000000000000000000000000000000000..5542623b6a4d193b354c00db8725c0a91bb895a9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantSamples.lean @@ -0,0 +1,140 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantTree +import OAI.NumberTheory.Ostmann.Construction.WordTransferFullPeriod + +namespace OAI + +/-! # Constructing the moving-giant tree from the sampled compensation slots + +Each reversing node samples four positions per leaf of either child. Their +products are inserted into both child regular lists. The constructor proves +the required product consistency; it does not ask for a pre-existing diagram. +-/ + +namespace Ostmann +open scoped BigOperators + +/-- The four actual compensation positions per child leaf at a reversal. -/ +inductive MovingGiantSamples : ℕ → Type + | leaf : MovingGiantSamples 0 + | node {n : ℕ} (samples : TreeLeafTuple (Fin 4 → ℕ) n) + (left right : MovingGiantSamples n) : MovingGiantSamples (n + 1) + +def compensationLeafProducts : (n : ℕ) → + TreeLeafTuple (Fin 4 → ℕ) n → TreeLeafTuple ℕ n + | 0, x => (∏ i : Fin 4, (show Fin 4 → ℕ from x) i : ℕ) + | n + 1, x => (compensationLeafProducts n x.1, compensationLeafProducts n x.2) + +def multiplySmallLeaves : (n : ℕ) → + TreeLeafTuple ℕ n → TreeLeafTuple ℕ n → TreeLeafTuple ℕ n + | 0, x, y => (show ℕ from x) * (show ℕ from y) + | n + 1, x, y => (multiplySmallLeaves n x.1 y.1, multiplySmallLeaves n x.2 y.2) + +theorem multiplySmallLeaves_product (n : ℕ) (x y : TreeLeafTuple ℕ n) : + treeLeafProduct n (multiplySmallLeaves n x y) = treeLeafProduct n x * treeLeafProduct n y := by + induction n with + | zero => rfl + | succ n ih => + simp only [multiplySmallLeaves, treeLeafProduct, ih] + ring + +def MovingGiantTree.castConstant {n C D : ℕ} (h : C = D) + (T : MovingGiantTree n C) : MovingGiantTree n D := h ▸ T + +@[simp] theorem MovingGiantTree.castConstant_frequency {n C D : ℕ} (h : C = D) + (T : MovingGiantTree n C) : (T.castConstant h).frequency = T.frequency := by + subst D + rfl + +@[simp] theorem MovingGiantTree.castConstant_units {n C D : ℕ} (h : C = D) + (T : MovingGiantTree n C) (q : ℕ) : (T.castConstant h).UnitsAt q ↔ T.UnitsAt q := by + subst D + rfl + +/-- `small` contains only the fixed regular factors at the top of this history. +Bulk values and the two moving giants do not occur in this constructor. -/ +def buildMovingGiantTree : (n : ℕ) → (t : FrequencyTree ℤ n) → + (small : TreeLeafTuple ℕ n) → MovingGiantSamples n → + MovingGiantTree n (treeLeafProduct n small) + | 0, t, small, .leaf => .leaf (frequencyRoot 0 t) (treeLeafProduct 0 small) + | n + 1, t, small, .node samples left right => + let u := compensationLeafProducts n samples + let L := buildMovingGiantTree n t.2.1 (multiplySmallLeaves n u small.1) left + let R := buildMovingGiantTree n t.2.2 (multiplySmallLeaves n u small.2) right + .node t.1 (treeLeafProduct n small.1) (treeLeafProduct n small.2) (treeLeafProduct n u) + (L.castConstant (multiplySmallLeaves_product n u small.1)) + (R.castConstant (multiplySmallLeaves_product n u small.2)) + +theorem buildMovingGiantTree_frequency (n : ℕ) (t : FrequencyTree ℤ n) + (small : TreeLeafTuple ℕ n) (samples : MovingGiantSamples n) : + (buildMovingGiantTree n t small samples).frequency = frequencyRoot n t := by + cases samples <;> rfl + +def movingGiantFrequencyUnits (q : ℕ) : (n : ℕ) → FrequencyTree ℤ n → Prop + | 0, t => ((frequencyRoot 0 t : ℤ) : ZMod q) ≠ 0 + | n + 1, t => (t.1 : ZMod q) ≠ 0 ∧ + movingGiantFrequencyUnits q n t.2.1 ∧ movingGiantFrequencyUnits q n t.2.2 + +def MovingGiantSamples.UnitsAt (q : ℕ) : {n : ℕ} → MovingGiantSamples n → Prop + | _, .leaf => True + | n + 1, .node samples left right => + ((treeLeafProduct n (compensationLeafProducts n samples) : ℕ) : ZMod q) ≠ 0 ∧ + left.UnitsAt q ∧ right.UnitsAt q + +/-- Unit conditions for the diagram follow from the actual sampled products +and original frequency bounds. They are independent of the bulk variables. -/ +theorem buildMovingGiantTree_units {q n : ℕ} [Fact q.Prime] (t : FrequencyTree ℤ n) + (small : TreeLeafTuple ℕ n) (samples : MovingGiantSamples n) + (hfreq : movingGiantFrequencyUnits q n t) + (hsmall : ((treeLeafProduct n small : ℕ) : ZMod q) ≠ 0) + (hsamples : samples.UnitsAt q) : + (buildMovingGiantTree n t small samples).UnitsAt q := by + induction samples with + | leaf => exact ⟨hfreq, hsmall⟩ + | @node n samples left right ihL ihR => + have hparts : ((treeLeafProduct n small.1 : ℕ) : ZMod q) ≠ 0 ∧ + ((treeLeafProduct n small.2 : ℕ) : ZMod q) ≠ 0 := by + simpa only [treeLeafProduct, Nat.cast_mul, mul_ne_zero_iff] using hsmall + refine ⟨hfreq.1, hparts.1, hparts.2, hsamples.1, ?_, ?_⟩ + · rw [MovingGiantTree.castConstant_units] + apply ihL _ _ hfreq.2.1 _ hsamples.2.1 + rw [multiplySmallLeaves_product, Nat.cast_mul] + exact mul_ne_zero hsamples.1 hparts.1 + · rw [MovingGiantTree.castConstant_units] + apply ihR _ _ hfreq.2.2 _ hsamples.2.2 + rw [multiplySmallLeaves_product, Nat.cast_mul] + exact mul_ne_zero hsamples.1 hparts.2 + +theorem movingGiantFrequencyUnits_of_bounds {q n : ℕ} [Fact q.Prime] + (t : FrequencyTree ℤ n) + (h : ∀ s ∈ allFrequencyList n t, s ≠ 0 ∧ s.natAbs < q) : + movingGiantFrequencyUnits q n t := by + induction n with + | zero => + have hs := h (frequencyRoot 0 t) (by simp [allFrequencyList, frequencyRoot]) + exact spectator_frequency_ne_zero _ hs.1 hs.2 + | succ n ih => + refine ⟨spectator_frequency_ne_zero _ (h t.1 (by simp [allFrequencyList])).1 + (h t.1 (by simp [allFrequencyList])).2, ?_, ?_⟩ + · apply ih t.2.1 + intro s hs + exact h s (List.mem_cons_of_mem _ (List.mem_append_left _ hs)) + · apply ih t.2.2 + intro s hs + exact h s (List.mem_cons_of_mem _ (List.mem_append_right _ hs)) + +def MovingGiantSamples.sampleCount : {n : ℕ} → MovingGiantSamples n → ℕ + | _, .leaf => 0 + | n + 1, .node _ left right => 4 * 2 ^ n + left.sampleCount + right.sampleCount + +/-- The literal internal sample count is the `O(k r)` count in Section 8.1. -/ +theorem MovingGiantSamples.sampleCount_eq {n : ℕ} (samples : MovingGiantSamples n) : + samples.sampleCount = 2 * n * 2 ^ n := by + induction samples with + | leaf => rfl + | @node n samples left right ihL ihR => + simp only [sampleCount, ihL, ihR, pow_succ] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantSpectator.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantSpectator.lean new file mode 100644 index 0000000000000000000000000000000000000000..8adcef9cc9779a391297409b01ea55c59131cd6b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantSpectator.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantTree +import OAI.NumberTheory.Ostmann.Construction.SpectatorProductNorm + +namespace OAI + +/-! # Fixed spectator diagrams for the integral moving-giant coefficient + +The support multiplier is allowed to include every original arithmetic and +smooth restriction. Only a nonzero multiplier requires integrality. Thus the +identification retains, rather than discards, the original support boundary. +-/ + +namespace Ostmann +open scoped Classical ComplexConjugate + +/-- The diagram is chosen before the bulk variables and support multiplier. -/ +theorem MovingGiantTree.exists_supported_diagram {q : ℕ} [Fact q.Prime] + {n C : ℕ} (T : MovingGiantTree n C) (hT : T.UnitsAt q) + (D : (ZMod q)ˣ) (XL XR : ℕ) (A B : (ZMod q)ˣ) + (hA : (XL : ZMod q) = A) (hB : (XR : ZMod q) = B) : + ∃ d : SpectatorDiagram q n, + d.D = D ∧ d.XL = A ∧ d.XR = B ∧ + d.conjugations = transferConjugations n false ∧ + ∀ (g : ZMod q → ℂ) (x : TreeLeafTuple ℕ n) + (y : TreeLeafTuple (ZMod q)ˣ n) (c : ℂ), + TreeNaturalLift n x y → (c ≠ 0 → T.Integral XL XR x) → + c * movingGiantAmplitude g D T XL XR x = c * d.value g y := by + obtain ⟨U, R, _, _, he⟩ := T.exists_residue_diagram hT + refine ⟨⟨D, U, R, A, B, transferConjugations n false⟩, + rfl, rfl, rfl, rfl, ?_⟩ + intro g x y c hxy hc + by_cases hc0 : c = 0 + · simp only [hc0, zero_mul] + · apply congrArg (fun z : ℂ => c * z) + exact he g D XL XR A B x y hA hB hxy (hc hc0) false + +/-- Two original integral histories have the paired factor in (8.5), with +fixed diagrams and a common support multiplier. -/ +theorem movingGiant_pair_diagrams {q : ℕ} [Fact q.Prime] + {n C₁ C₂ : ℕ} (T₁ : MovingGiantTree n C₁) (T₂ : MovingGiantTree n C₂) + (hT₁ : T₁.UnitsAt q) (hT₂ : T₂.UnitsAt q) + (D₁ D₂ : (ZMod q)ˣ) (XL₁ XR₁ XL₂ XR₂ : ℕ) + (A₁ B₁ A₂ B₂ : (ZMod q)ˣ) + (hA₁ : (XL₁ : ZMod q) = A₁) (hB₁ : (XR₁ : ZMod q) = B₁) + (hA₂ : (XL₂ : ZMod q) = A₂) (hB₂ : (XR₂ : ZMod q) = B₂) : + ∃ d₁ d₂ : SpectatorDiagram q n, + d₁.conjugations = transferConjugations n false ∧ + d₂.conjugations = transferConjugations n false ∧ + ∀ (g : ZMod q → ℂ) (x₁ x₂ : TreeLeafTuple ℕ n) + (y₁ y₂ : TreeLeafTuple (ZMod q)ˣ n) (c : ℂ), + TreeNaturalLift n x₁ y₁ → TreeNaturalLift n x₂ y₂ → + (c ≠ 0 → T₁.Integral XL₁ XR₁ x₁ ∧ T₂.Integral XL₂ XR₂ x₂) → + c * (movingGiantAmplitude g D₁ T₁ XL₁ XR₁ x₁ * + conj (movingGiantAmplitude g D₂ T₂ XL₂ XR₂ x₂)) = + c * (d₁.value g y₁ * conj (d₂.value g y₂)) := by + obtain ⟨U₁, R₁, _, _, he₁⟩ := T₁.exists_residue_diagram hT₁ + obtain ⟨U₂, R₂, _, _, he₂⟩ := T₂.exists_residue_diagram hT₂ + refine ⟨⟨D₁, U₁, R₁, A₁, B₁, transferConjugations n false⟩, + ⟨D₂, U₂, R₂, A₂, B₂, transferConjugations n false⟩, rfl, rfl, ?_⟩ + intro g x₁ x₂ y₁ y₂ c hx₁ hx₂ hc + by_cases hc0 : c = 0 + · simp only [hc0, zero_mul] + · obtain ⟨hI₁, hI₂⟩ := hc hc0 + have h₁ := he₁ g D₁ XL₁ XR₁ A₁ B₁ x₁ y₁ hA₁ hB₁ hx₁ hI₁ false + have h₂ := he₂ g D₂ XL₂ XR₂ A₂ B₂ x₂ y₂ hA₂ hB₂ hx₂ hI₂ false + simpa only [Bool.false_eq_true, ite_false, SpectatorDiagram.value] using + congrArg₂ (fun z w : ℂ => c * (z * conj w)) h₁ h₂ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantSupportedTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantSupportedTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b9ea456868d822b97b3f52e437deae760863748 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantSupportedTransfer.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeArithmeticTransfer + +namespace OAI + +/-! # The original giant-only transfer, including its exact diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- The entire Cauchy--Schwarz, positive-integer extension and forced-pivot +substitution. The inherited prime laws remain in `μ` and `c`; the integer +variable has no prime-specific transform attached to it. -/ +theorem moving_giant_transfer_on_prior {Y A : Type*} [Fintype Y] [Fintype A] + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (hI : ∀ p ∈ I, 0 < p) + (μ : Y → ℝ) (hμ : ∀ y, 0 ≤ μ y) (hμmass : ∑ y, μ y = 1) + (w : ℕ → ℝ) (hw : ∀ p ∈ I, 0 ≤ w p) (Z : ℝ) (hZ : 0 ≤ Z) + (hmass : ∑ p : P, Z * w p / (p : ℝ) = 1) + (U : Y → ℕ) (hU : ∀ y, 0 < U y) + (row : ∀ y, (p : P) → Fin ((p : ℕ) * U y) → ℂ) + (hrow : ∀ y p, (∑ t, ‖row y p t‖ ^ 2) ≤ (p : ℕ) * (U y : ℝ)) + (L : Y → A → ℕ) (v : Y → A → ℤ) (c : Y → ℕ → A → ℂ) + (hcoprime : ∀ y p, p ∈ I → ∀ a, c y p a ≠ 0 → (L y a).Coprime (p * U y)) + (N H V : ℕ) + (hv : ∀ y p, p ∈ I → ∀ a, c y p a ≠ 0 → (v y a).natAbs ≤ N) + (hL : ∀ y, μ y ≠ 0 → ∀ p, p ∈ I → ∀ a, c y p a ≠ 0 → L y a ≤ H) + (hscale : ∀ y, μ y ≠ 0 → ∀ p, p ∈ I → 2 * N * H ≤ V * (p * U y)) : + ‖∑ y, (μ y : ℂ) * ∑ p : P, ((Z * w p / (p : ℝ) : ℝ) : ℂ) * + ∑ a, row y p (positiveIntegerPivotKey _ + (Nat.mul_pos (hP p p.property).pos (hU y)) (L y a) (v y a)) * c y p a‖ ^ 2 ≤ + Z * ((∑ y, μ y * (U y : ℝ) * + ∑ p ∈ I, w p * (pivotDiagonal (L y) (v y) (c y p)).re) + + (∑ y, ((μ y * (U y : ℝ) : ℝ) : ℂ) * + movingGiantOffDiagonal I V (U y) (L y) (v y) w (c y)).re) := by + let B : ∀ y p, Fin (p * U y) → ℂ := fun y p => + if hp : 0 < p * U y then + groupedCoefficient (fun a => positiveIntegerPivotKey _ hp (L y a) (v y a)) (c y p) + else fun _ => 0 + have ht := moving_prime_row_transfer P I hP hPI μ hμ hμmass w hw Z hZ hmass U row B hrow + have hleft : (∑ y, (μ y : ℂ) * ∑ p : P, ((Z * w p / (p : ℝ) : ℝ) : ℂ) * + ∑ t, row y p t * B y p t) = + ∑ y, (μ y : ℂ) * ∑ p : P, ((Z * w p / (p : ℝ) : ℝ) : ℂ) * + ∑ a, row y p (positiveIntegerPivotKey _ + (Nat.mul_pos (hP p p.property).pos (hU y)) (L y a) (v y a)) * c y p a := by + apply Finset.sum_congr rfl + intro y _ + congr 1 + apply Finset.sum_congr rfl + intro p _ + congr 1 + simp only [B, dite_eq_left (Nat.mul_pos (hP p p.property).pos (hU y))] + exact (pivot_residue_grouping _ (row y p) (c y p)).symm + rw [hleft] at ht + apply ht.trans_eq + congr 1 + have hs (y : Y) (hy : μ y ≠ 0) : + (∑ p ∈ I, w p * ∑ t, ‖B y p t‖ ^ 2) = + (∑ p ∈ I, w p * (pivotDiagonal (L y) (v y) (c y p)).re) + + (movingGiantOffDiagonal I V (U y) (L y) (v y) w (c y)).re := by + have hsplit (p : ℕ) (hp : p ∈ I) : (∑ t, ‖B y p t‖ ^ 2) = + (pivotDiagonal (L y) (v y) (c y p)).re + + (pivotOffDiagonal (p * U y) (L y) (v y) (c y p)).re := by + have hpU := Nat.mul_pos (hI p hp) (hU y) + let : NeZero (p * U y) := ⟨hpU.ne'⟩ + simpa only [B, dite_eq_left hpU, positiveIntegerPivotKey] using + pivot_square_split_on_support (p * U y) (L y) (v y) (c y p) (hcoprime y p hp) + calc + _ = ∑ p ∈ I, w p * ((pivotDiagonal (L y) (v y) (c y p)).re + + (pivotOffDiagonal (p * U y) (L y) (v y) (c y p)).re) := by + apply Finset.sum_congr rfl + intro p hp + rw [hsplit p hp] + _ = (∑ p ∈ I, w p * (pivotDiagonal (L y) (v y) (c y p)).re) + + (∑ p ∈ I, (w p : ℂ) * pivotOffDiagonal (p * U y) (L y) (v y) (c y p)).re := by + simp only [mul_add, Finset.sum_add_distrib, Complex.re_sum, + Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero] + _ = _ := by rw [movingGiantOffDiagonal_eq I hI (U y) (hU y) N H V + (L y) (v y) w (c y) (hv y) (hL y hy) (hscale y hy)] + simp only [Complex.re_sum, Complex.mul_re, Complex.ofReal_re, + Complex.ofReal_im, zero_mul, sub_zero] + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro y _ + by_cases hy : μ y = 0 + · simp only [hy, zero_mul, zero_add] + · rw [hs y hy, mul_add] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf4d25c8fa73159d9c63780803fddb409f630962 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantTransfer.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeArithmeticTransfer + +namespace OAI + +/-! # The original giant-only transfer, including its exact diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- The entire Cauchy--Schwarz, positive-integer extension and forced-pivot +substitution. The inherited prime laws remain in `μ` and `c`; the integer +variable has no prime-specific transform attached to it. -/ +theorem moving_giant_transfer {Y A : Type*} [Fintype Y] [Fintype A] + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (hI : ∀ p ∈ I, 0 < p) + (μ : Y → ℝ) (hμ : ∀ y, 0 ≤ μ y) (hμmass : ∑ y, μ y = 1) + (w : ℕ → ℝ) (hw : ∀ p ∈ I, 0 ≤ w p) (Z : ℝ) (hZ : 0 ≤ Z) + (hmass : ∑ p : P, Z * w p / (p : ℝ) = 1) + (U : Y → ℕ) (hU : ∀ y, 0 < U y) + (row : ∀ y, (p : P) → Fin ((p : ℕ) * U y) → ℂ) + (hrow : ∀ y p, (∑ t, ‖row y p t‖ ^ 2) ≤ (p : ℕ) * (U y : ℝ)) + (L : Y → A → ℕ) (v : Y → A → ℤ) (c : Y → ℕ → A → ℂ) + (hcoprime : ∀ y p, p ∈ I → ∀ a, c y p a ≠ 0 → (L y a).Coprime (p * U y)) + (N H V : ℕ) + (hv : ∀ y p, p ∈ I → ∀ a, c y p a ≠ 0 → (v y a).natAbs ≤ N) + (hL : ∀ y p, p ∈ I → ∀ a, c y p a ≠ 0 → L y a ≤ H) + (hscale : ∀ y, μ y ≠ 0 → ∀ p, p ∈ I → 2 * N * H ≤ V * (p * U y)) : + ‖∑ y, (μ y : ℂ) * ∑ p : P, ((Z * w p / (p : ℝ) : ℝ) : ℂ) * + ∑ a, row y p (positiveIntegerPivotKey _ + (Nat.mul_pos (hP p p.property).pos (hU y)) (L y a) (v y a)) * c y p a‖ ^ 2 ≤ + Z * ((∑ y, μ y * (U y : ℝ) * + ∑ p ∈ I, w p * (pivotDiagonal (L y) (v y) (c y p)).re) + + (∑ y, ((μ y * (U y : ℝ) : ℝ) : ℂ) * + movingGiantOffDiagonal I V (U y) (L y) (v y) w (c y)).re) := by + let B : ∀ y p, Fin (p * U y) → ℂ := fun y p => + if hp : 0 < p * U y then + groupedCoefficient (fun a => positiveIntegerPivotKey _ hp (L y a) (v y a)) (c y p) + else fun _ => 0 + have ht := moving_prime_row_transfer P I hP hPI μ hμ hμmass w hw Z hZ hmass U row B hrow + have hleft : (∑ y, (μ y : ℂ) * ∑ p : P, ((Z * w p / (p : ℝ) : ℝ) : ℂ) * + ∑ t, row y p t * B y p t) = + ∑ y, (μ y : ℂ) * ∑ p : P, ((Z * w p / (p : ℝ) : ℝ) : ℂ) * + ∑ a, row y p (positiveIntegerPivotKey _ + (Nat.mul_pos (hP p p.property).pos (hU y)) (L y a) (v y a)) * c y p a := by + apply Finset.sum_congr rfl + intro y _ + congr 1 + apply Finset.sum_congr rfl + intro p _ + congr 1 + simp only [B, dite_eq_left (Nat.mul_pos (hP p p.property).pos (hU y))] + exact (pivot_residue_grouping _ (row y p) (c y p)).symm + rw [hleft] at ht + apply ht.trans_eq + congr 1 + have hs (y : Y) (hy : μ y ≠ 0) : + (∑ p ∈ I, w p * ∑ t, ‖B y p t‖ ^ 2) = + (∑ p ∈ I, w p * (pivotDiagonal (L y) (v y) (c y p)).re) + + (movingGiantOffDiagonal I V (U y) (L y) (v y) w (c y)).re := by + have hsplit (p : ℕ) (hp : p ∈ I) : (∑ t, ‖B y p t‖ ^ 2) = + (pivotDiagonal (L y) (v y) (c y p)).re + + (pivotOffDiagonal (p * U y) (L y) (v y) (c y p)).re := by + have hpU := Nat.mul_pos (hI p hp) (hU y) + let : NeZero (p * U y) := ⟨hpU.ne'⟩ + simpa only [B, dite_eq_left hpU, positiveIntegerPivotKey] using + pivot_square_split_on_support (p * U y) (L y) (v y) (c y p) (hcoprime y p hp) + calc + _ = ∑ p ∈ I, w p * ((pivotDiagonal (L y) (v y) (c y p)).re + + (pivotOffDiagonal (p * U y) (L y) (v y) (c y p)).re) := by + apply Finset.sum_congr rfl + intro p hp + rw [hsplit p hp] + _ = (∑ p ∈ I, w p * (pivotDiagonal (L y) (v y) (c y p)).re) + + (∑ p ∈ I, (w p : ℂ) * pivotOffDiagonal (p * U y) (L y) (v y) (c y p)).re := by + simp only [mul_add, Finset.sum_add_distrib, Complex.re_sum, + Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero] + _ = _ := by rw [movingGiantOffDiagonal_eq I hI (U y) (hU y) N H V + (L y) (v y) w (c y) (hv y) (hL y) (hscale y hy)] + simp only [Complex.re_sum, Complex.mul_re, Complex.ofReal_re, + Complex.ofReal_im, zero_mul, sub_zero] + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro y _ + by_cases hy : μ y = 0 + · simp only [hy, zero_mul, zero_add] + · rw [hs y hy, mul_add] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantTree.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..905e52c1879676099fe6ad888982aeb4d419da36 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGiantTree.lean @@ -0,0 +1,176 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticSpectatorNode +import OAI.NumberTheory.Ostmann.Construction.TransferConjugations +import OAI.NumberTheory.Ostmann.Tree.RationalTreeLeaves + +namespace OAI + +/-! # The moving-giant arithmetic in Section 8.1 + +The integer constants record actual products of regular small entries. At a +reversal, the sampled compensation product `u` is inserted into both children: +their constants are `u * CL` and `u * CR`. The pivot is reconstructed over the +integers first, and only its giant factor is passed to either child. +-/ + +namespace Ostmann +open scoped Classical ComplexConjugate + +inductive MovingGiantTree : ℕ → ℕ → Type + | leaf (s : ℤ) (C : ℕ) : MovingGiantTree 0 C + | node {n : ℕ} (s : ℤ) (CL CR u : ℕ) + (left : MovingGiantTree n (u * CL)) + (right : MovingGiantTree n (u * CR)) : MovingGiantTree (n + 1) (CL * CR) + +@[implicit_reducible] def MovingGiantTree.frequency : + {n C : ℕ} → MovingGiantTree n C → ℤ + | _, _, .leaf s _ => s + | _, _, .node s _ _ _ _ _ => s + +def movingGiantPivot (s v w : ℤ) (CL CR u XL XR ML MR : ℕ) : ℕ := + reconstructedPivot (v * ((XR * CR * MR : ℕ) : ℤ) - + w * ((XL * CL * ML : ℕ) : ℤ)) s / u + +/-- This is the exact division in (8.3), applied to a valid original node. -/ +theorem movingGiantPivot_of_node {State : Type*} + {sys : TransferHistorySystem State} {σ : State} {s v w : ℤ} {P : ℕ} + (h : ValidTransferNode sys σ s v w P) (CL CR u p XL XR ML MR : ℕ) + (hu : 0 < u) (hP : P = u * p) + (hL : sys.leftProduct σ = XL * CL * ML) + (hR : sys.rightProduct σ = XR * CR * MR) : + movingGiantPivot s v w CL CR u XL XR ML MR = p := by + unfold movingGiantPivot + rw [← hL, ← hR, reconstructedPivot_of_eq _ _ h.root_ne_zero P h.relation, hP] + exact Nat.mul_div_cancel_left p hu + +def MovingGiantTree.Integral : {n C : ℕ} → MovingGiantTree n C → + ℕ → ℕ → TreeLeafTuple ℕ n → Prop + | _, _, .leaf _ _, _, _, _ => True + | n + 1, _, .node s CL CR u left right, XL, XR, x => + let p := movingGiantPivot s left.frequency right.frequency CL CR u XL XR + (treeLeafProduct n x.1) (treeLeafProduct n x.2) + 0 < p ∧ + left.frequency * ((XR * CR * treeLeafProduct n x.2 : ℕ) : ℤ) - + right.frequency * ((XL * CL * treeLeafProduct n x.1 : ℕ) : ℤ) = + s * ((u * p : ℕ) : ℤ) ∧ + left.Integral p XL x.1 ∧ right.Integral p XR x.2 + +def MovingGiantTree.UnitsAt (q : ℕ) : {n C : ℕ} → MovingGiantTree n C → Prop + | _, _, .leaf s C => (s : ZMod q) ≠ 0 ∧ (C : ZMod q) ≠ 0 + | _, _, .node s CL CR u left right => + (s : ZMod q) ≠ 0 ∧ (CL : ZMod q) ≠ 0 ∧ (CR : ZMod q) ≠ 0 ∧ + (u : ZMod q) ≠ 0 ∧ left.UnitsAt q ∧ right.UnitsAt q + +def TreeNaturalLift {q : ℕ} : (n : ℕ) → + TreeLeafTuple ℕ n → TreeLeafTuple (ZMod q)ˣ n → Prop + | 0, x, y => ((show ℕ from x) : ZMod q) = (show (ZMod q)ˣ from y) + | n + 1, x, y => TreeNaturalLift n x.1 y.1 ∧ TreeNaturalLift n x.2 y.2 + +theorem TreeNaturalLift.product {q : ℕ} {n : ℕ} + {x : TreeLeafTuple ℕ n} {y : TreeLeafTuple (ZMod q)ˣ n} + (h : TreeNaturalLift n x y) : + ((treeLeafProduct n x : ℕ) : ZMod q) = (treeLeafProduct n y : (ZMod q)ˣ) := by + induction n with + | zero => exact h + | succ n ih => + simp only [treeLeafProduct, Nat.cast_mul, Units.val_mul] + rw [ih h.1, ih h.2] + +/-- Ordinary integral evaluation, including the inserted-giant zero convention. +All additional smooth and range factors can multiply this spectator factor. -/ +noncomputable def movingGiantAmplitude {q : ℕ} [Fact q.Prime] + (g : ZMod q → ℂ) (D : (ZMod q)ˣ) : + {n C : ℕ} → MovingGiantTree n C → ℕ → ℕ → TreeLeafTuple ℕ n → ℂ + | _, _, .leaf s C, XL, XR, x => + g ((s : ZMod q) / ((D : ZMod q) * ((XL * XR * C * treeLeafProduct 0 x : ℕ) : ZMod q))) + | n + 1, _, .node s CL CR u left right, XL, XR, x => + let p := movingGiantPivot s left.frequency right.frequency CL CR u XL XR + (treeLeafProduct n x.1) (treeLeafProduct n x.2) + if (p : ZMod q) = 0 then 0 else + movingGiantAmplitude g D left p XL x.1 * + conj (movingGiantAmplitude g D right p XR x.2) + +/-- Every integral moving-giant history has a rational diagram whose constants +and frequencies depend only on the fixed small data and frequency history. +They do not depend on the giant values or on the bulk leaf values. -/ +theorem MovingGiantTree.exists_residue_diagram {q : ℕ} [Fact q.Prime] + {n C : ℕ} (T : MovingGiantTree n C) (hT : T.UnitsAt q) : + ∃ (U : (ZMod q)ˣ) (R : RationalTreeData (ZMod q)ˣ n U), + (C : ZMod q) = U ∧ (T.frequency : ZMod q) = R.frequency ∧ + ∀ (g : ZMod q → ℂ) (D : (ZMod q)ˣ) (XL XR : ℕ) + (A B : (ZMod q)ˣ) (x : TreeLeafTuple ℕ n) (y : TreeLeafTuple (ZMod q)ˣ n), + (XL : ZMod q) = A → (XR : ZMod q) = B → TreeNaturalLift n x y → + T.Integral XL XR x → ∀ b : Bool, + (if b then conj (movingGiantAmplitude g D T XL XR x) + else movingGiantAmplitude g D T XL XR x) = + rationalTreeAmplitude g D R A B (transferConjugations n b) y := by + induction T with + | leaf s C => + let S : (ZMod q)ˣ := Units.mk0 (s : ZMod q) hT.1 + let U : (ZMod q)ˣ := Units.mk0 (C : ZMod q) hT.2 + refine ⟨U, .leaf S U, rfl, rfl, ?_⟩ + intro g D XL XR A B x y hA hB hxy _ b + change ((show ℕ from x) : ZMod q) = (show (ZMod q)ˣ from y) at hxy + have he : (s : ZMod q) / ((D : ZMod q) * ((XL * XR * C * treeLeafProduct 0 x : ℕ) : ZMod q)) = + (rationalTreeArgument S U D A B y : ZMod q) := by + simp only [Nat.cast_mul, hA, hB, show (C : ZMod q) = U from rfl, hxy, + rationalTreeArgument, Units.val_div_eq_div_val, Units.val_mul, treeLeafProduct] + congr 1 + ring + cases b <;> simp only [movingGiantAmplitude, he, rationalTreeAmplitude, + transferConjugations, Bool.false_eq_true, ↓reduceIte, Complex.star_def] + | @node n s CL CR u left right ihL ihR => + obtain ⟨hs, hCL, hCR, hu, hl, hr⟩ := hT + let S : (ZMod q)ˣ := Units.mk0 (s : ZMod q) hs + let A₀ : (ZMod q)ˣ := Units.mk0 (CL : ZMod q) hCL + let B₀ : (ZMod q)ˣ := Units.mk0 (CR : ZMod q) hCR + let U₀ : (ZMod q)ˣ := Units.mk0 (u : ZMod q) hu + obtain ⟨UL, L, hUL, hfL, hL⟩ := ihL hl + obtain ⟨UR, R, hUR, hfR, hR⟩ := ihR hr + have eL : UL = U₀ * A₀ := by + apply Units.ext + simpa only [U₀, A₀, Units.val_mul, Units.val_mk0, Nat.cast_mul] using hUL.symm + have eR : UR = U₀ * B₀ := by + apply Units.ext + simpa only [U₀, B₀, Units.val_mul, Units.val_mk0, Nat.cast_mul] using hUR.symm + subst UL + subst UR + refine ⟨A₀ * B₀, .node S A₀ B₀ U₀ L R, ?_, rfl, ?_⟩ + · simp only [Nat.cast_mul, Units.val_mul, Units.val_mk0, A₀, B₀] + intro g D XL XR A B x y hA hB hxy hI b + let p := movingGiantPivot s left.frequency right.frequency CL CR u XL XR + (treeLeafProduct n x.1) (treeLeafProduct n x.2) + have hrec : reconstructedEntry (S : ZMod q) L.frequency R.frequency U₀ + ((A * A₀ * treeLeafProduct n y.1 : (ZMod q)ˣ) : ZMod q) + ((B * B₀ * treeLeafProduct n y.2 : (ZMod q)ˣ) : ZMod q) = (p : ZMod q) := by + have he := congrArg (fun z : ℤ => (z : ZMod q)) hI.2.1 + simp only [Int.cast_sub, Int.cast_mul, Int.cast_natCast, Nat.cast_mul, + hA, hB, hxy.1.product, hxy.2.product, hfL, hfR] at he + unfold reconstructedEntry + apply (div_eq_iff (mul_ne_zero hs hu)).mpr + simpa only [Units.val_mul, Units.val_mk0, S, A₀, B₀, U₀, mul_assoc, + mul_comm, mul_left_comm] using he + by_cases hp : (p : ZMod q) = 0 + · cases b <;> simp only [movingGiantAmplitude, show + (movingGiantPivot s left.frequency right.frequency CL CR u XL XR + (treeLeafProduct n x.1) (treeLeafProduct n x.2) : ZMod q) = 0 from hp, + ↓reduceIte, map_zero, rationalTreeAmplitude, hrec, hp, Bool.false_eq_true, + dite_true] + · let V : (ZMod q)ˣ := Units.mk0 (p : ZMod q) hp + have hVL : (p : ZMod q) = V := rfl + have hleft := hL g D p XL V A x.1 y.1 hVL hA hxy.1 hI.2.2.1 b + have hright := hR g D p XR V B x.2 y.2 hVL hB hxy.2 hI.2.2.2 (!b) + have hV : Units.mk0 + (reconstructedEntry (S : ZMod q) L.frequency R.frequency U₀ + ((A * A₀ * treeLeafProduct n y.1 : (ZMod q)ˣ) : ZMod q) + ((B * B₀ * treeLeafProduct n y.2 : (ZMod q)ˣ) : ZMod q)) + (by rw [hrec]; exact hp) = V := Units.ext hrec + simp only [movingGiantAmplitude, show + (movingGiantPivot s left.frequency right.frequency CL CR u XL XR + (treeLeafProduct n x.1) (treeLeafProduct n x.2) : ZMod q) ≠ 0 from hp, + ↓reduceIte, rationalTreeAmplitude, transferConjugations] + rw [dite_eq_right (by rw [hrec]; exact hp), hV, ← hleft, ← hright] + cases b <;> simp [p] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGroupedBulkAverage.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGroupedBulkAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..71521ec57f59dbb0f29839c1aafd494431148dfe --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGroupedBulkAverage.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.GroupedBulkSymmetrization +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeIndex + +namespace OAI + +/-! # Averaging the regular bulk inside the full giant and frequency fibre -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem grouped_three_bulk_average {B A X S K : Type*} + [Fintype B] [Fintype A] [Fintype X] [Fintype S] + (n m : ℕ) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (ν : B → A → ℝ) (hν : ∀ j k, ν (slot j) = ν (slot k)) (ρ : X → ℝ) + (key : X → (B → A) → S → K) + (hkey : ∀ x s e y, key x (selectedBulkSample slot e y) s = key x y s) + (W : X → (B → A) → S → ℂ) (k : K) : + groupedCoefficient (fun a : X × ((B → A) × S) => key a.1 a.2.1 a.2.2) + (fun a => ((ρ a.1 * ∏ i, ν i (a.2.1 i) : ℝ) : ℂ) * + mixedBulkSymmetrize n m slot (fun _ y _ _ => W a.1 y a.2.2) 0 a.2.1 0 0) k = + groupedCoefficient (fun a : X × ((B → A) × S) => key a.1 a.2.1 a.2.2) + (fun a => ((ρ a.1 * ∏ i, ν i (a.2.1 i) : ℝ) : ℂ) * W a.1 a.2.1 a.2.2) k := by + unfold groupedCoefficient + simp only [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro x _ + rw [Finset.sum_comm, Finset.sum_comm (s := Finset.univ) (t := Finset.univ) + (f := fun y s => if key x y s = k then _ else 0)] + apply Finset.sum_congr rfl + intro s _ + have h := groupedCoefficient_bulk_average n m slot ν hν (fun y => key x y s) + (hkey x s) (fun y => W x y s) k + have hh := congrArg (fun z : ℂ => (ρ x : ℂ) * z) h + simpa only [groupedCoefficient, Complex.ofReal_mul, Finset.mul_sum, mul_ite, + mul_zero, mul_assoc] using hh + +theorem movingAmplitude_grouped_bulk_average + (P Pg : Finset ℕ) (n r m : ℕ) (V : ℕ → ℕ) + (ρ : Pg → ℝ) (ν : MovingRegularSlot n r m → P → ℝ) + (hν : ∀ j k : TreeLeafIndex n × Fin m, + ν (movingTemplateBulk n r m j) = ν (movingTemplateBulk n r m k)) + (W : MovingAmplitudeIndex P Pg n r m V → ℂ) (k : ℕ × ℕ × ℤ) : + groupedCoefficient + (fun a : MovingAmplitudeIndex P Pg n r m V => ((a.1 : ℕ), (∏ i, (a.2.1 i : ℕ)), a.2.2.val)) + (fun a => (movingAmplitudePrior Pg n r m V ρ ν a : ℂ) * + mixedBulkSymmetrize n m (movingTemplateBulk n r m) + (fun _ y _ _ => W (a.1, y, a.2.2)) 0 a.2.1 0 0) k = + groupedCoefficient + (fun a : MovingAmplitudeIndex P Pg n r m V => ((a.1 : ℕ), (∏ i, (a.2.1 i : ℕ)), a.2.2.val)) + (fun a => (movingAmplitudePrior Pg n r m V ρ ν a : ℂ) * W a) k := by + have hkey (x : Pg) (s : transferFrequencyRange (V n)) + (e : Equiv.Perm (TreeLeafIndex n × Fin m)) (y : MovingRegularSlot n r m → P) : + ((x : ℕ), (∏ i, (selectedBulkSample (A := P) (movingTemplateBulk n r m) e y i : ℕ)), s.val) = + ((x : ℕ), (∏ i, (y i : ℕ)), s.val) := by + exact Prod.ext rfl (Prod.ext + ((selectedBulkPerm (movingTemplateBulk n r m) e).symm.prod_comp (fun i => (y i : ℕ))) rfl) + have h := grouped_three_bulk_average + (B := MovingRegularSlot n r m) (A := P) (X := Pg) + (S := transferFrequencyRange (V n)) (K := ℕ × ℕ × ℤ) + n m (movingTemplateBulk n r m) ν hν ρ + (fun x y s => ((x : ℕ), (∏ i, (y i : ℕ)), s.val)) hkey + (fun x y s => W (x, y, s)) k + convert h using 1 <;> simp only [movingAmplitudePrior, groupedCoefficient, MovingAmplitudeIndex, finite_univ_canonical, Prod.eta] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGuardedDirectRecursion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGuardedDirectRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b5ea7b9d97aa4244cc278aaeeb0935d58d328a4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGuardedDirectRecursion.lean @@ -0,0 +1,139 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDirectRecursion + +namespace OAI + +/-! # The fully guarded sampled recursion with the explicit giant quotient -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original sample law and the two independent child sample trees are +retained. The inserted giant is exactly `(v H⁻ - w H⁺)/(s U)`, matching the +weighted integer off-diagonal, with every root support test still explicit. -/ +theorem movingSampledWeight_guarded_direct_node {σ : Type*} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ (n + 1)) + (small bulk : TreeLeafTuple (List σ) (n + 1)) (XL XR : ℕ) : + let E := movingCompensatedExtra value (movingOriginalNode value childBound pivotBound φ G) + movingSampledWeight value μ childBound pivotBound (movingGuardedLeaf value outside F) (movingGuardedExtra value outside E) (n + 1) t small bulk XL XR = + ∑ a : TreeLeafTuple (Fin 4 → σ) n, + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let x := movingRootState n t CL CR (flattenMovingSlots n u) XL XR + let U := x.compensation value + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let p := reconstructedPivot + (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) (t.1 * U) + (movingCompensationPrior (μ n) n a : ℂ) * + if movingLocalSupport value outside x ∧ + (ValidTransferNode (movingSlotSystem value childBound pivotBound) x t.1 v w (p * U) ∧ + 0 < U) then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) * + movingSampledWeight value μ childBound pivotBound (movingGuardedLeaf value outside F) (movingGuardedExtra value outside E) n t.2.1 + (appendMovingSlotLeaves n u small.1) bulk.1 p XL * + star (movingSampledWeight value μ childBound pivotBound (movingGuardedLeaf value outside F) (movingGuardedExtra value outside E) n t.2.2 + (appendMovingSlotLeaves n u small.2) bulk.2 p XR) + else 0 := by + intro E + rw [movingSampledWeight_node] + apply Finset.sum_congr rfl + intro a _ + dsimp only + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let x := movingRootState n t CL CR (flattenMovingSlots n u) XL XR + let U := x.compensation value + let sys := movingSlotSystem value childBound pivotBound + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let P := historyPivot sys x t.1 v w + let p := reconstructedPivot (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) (t.1 * U) + have hbase := movingSampleRootFactor_reconstructed value childBound pivotBound φ G n t + CL CR (flattenMovingSlots n u) XL XR + dsimp only at hbase + simp only [← Complex.ofReal_mul] at hbase + have hguard := movingSampleRootFactor_guarded value outside childBound pivotBound E n t + CL CR (flattenMovingSlots n u) XL XR + rw [hbase] at hguard + change movingSampleRootFactor value childBound pivotBound + (movingGuardedExtra value outside E) n t CL CR (flattenMovingSlots n u) XL XR = + (if movingLocalSupport value outside x then + (if ValidTransferNode sys x t.1 v w (p * U) ∧ 0 < U then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) else 0) else 0) at hguard + have hroot : movingSampleRootFactor value childBound pivotBound + (movingGuardedExtra value outside E) n t CL CR (flattenMovingSlots n u) XL XR = + if movingLocalSupport value outside x ∧ + (ValidTransferNode sys x t.1 v w (p * U) ∧ 0 < U) then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) else 0 := by + rw [hguard] + by_cases hl : movingLocalSupport value outside x + · simp only [hl, true_and, ite_true] + · simp only [hl, false_and, ite_false] + change (movingCompensationPrior (μ n) n a : ℂ) * + movingSampleRootFactor value childBound pivotBound (movingGuardedExtra value outside E) n t CL CR + (flattenMovingSlots n u) XL XR * + movingSampledWeight value μ childBound pivotBound (movingGuardedLeaf value outside F) (movingGuardedExtra value outside E) n t.2.1 + (appendMovingSlotLeaves n u small.1) bulk.1 (P / U) XL * + star (movingSampledWeight value μ childBound pivotBound (movingGuardedLeaf value outside F) (movingGuardedExtra value outside E) n t.2.2 + (appendMovingSlotLeaves n u small.2) bulk.2 (P / U) XR) = + (movingCompensationPrior (μ n) n a : ℂ) * + (if movingLocalSupport value outside x ∧ + (ValidTransferNode sys x t.1 v w (p * U) ∧ 0 < U) then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) * + movingSampledWeight value μ childBound pivotBound (movingGuardedLeaf value outside F) (movingGuardedExtra value outside E) n t.2.1 + (appendMovingSlotLeaves n u small.1) bulk.1 p XL * + star (movingSampledWeight value μ childBound pivotBound (movingGuardedLeaf value outside F) (movingGuardedExtra value outside E) n t.2.2 + (appendMovingSlotLeaves n u small.2) bulk.2 p XR) + else 0) + rw [hroot] + by_cases h : movingLocalSupport value outside x ∧ + (ValidTransferNode sys x t.1 v w (p * U) ∧ 0 < U) + · have hP : P = p * U := h.2.1.historyPivot_eq + have hp : P / U = p := by rw [hP, Nat.mul_div_left _ h.2.2] + rw [ite_eq_left h, ite_eq_left h, hp] + ring + · rw [ite_eq_right h, ite_eq_right h] + simp only [mul_zero, zero_mul] + +/-- The same exact recurrence for the fully supported coefficient used by +the arithmetic comparison. -/ +theorem movingSupportedSampledWeight_direct_node {σ : Type*} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ (n + 1)) + (small bulk : TreeLeafTuple (List σ) (n + 1)) (XL XR : ℕ) : + let E := movingOriginalNode value childBound pivotBound φ G + movingSupportedSampledWeight value outside μ childBound pivotBound F E (n + 1) t small bulk XL XR = + ∑ a : TreeLeafTuple (Fin 4 → σ) n, + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let x := movingRootState n t CL CR (flattenMovingSlots n u) XL XR + let U := x.compensation value + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let p := reconstructedPivot + (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) (t.1 * U) + (movingCompensationPrior (μ n) n a : ℂ) * + if movingLocalSupport value outside x ∧ + (ValidTransferNode (movingSlotSystem value childBound pivotBound) x t.1 v w (p * U) ∧ + 0 < U) then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) * + movingSupportedSampledWeight value outside μ childBound pivotBound F E n t.2.1 + (appendMovingSlotLeaves n u small.1) bulk.1 p XL * + star (movingSupportedSampledWeight value outside μ childBound pivotBound F E n t.2.2 + (appendMovingSlotLeaves n u small.2) bulk.2 p XR) + else 0 := by + dsimp only + simpa only [movingSupportedSampledWeight, movingLocalExtra_compensated, + movingOriginalNode_local] using + movingSampledWeight_guarded_direct_node value outside μ childBound pivotBound F φ G + n t small bulk XL XR + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGuardedRow.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGuardedRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..51b14196562898f6a1079917f43d50d5da49ea01 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingGuardedRow.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeRowNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularTransfer + +namespace OAI + +/-! # The extracted row with the original support indicators -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingGuardedRow {J : Type*} [Fintype J] + (q : J → ℕ) (g : ∀ j, ZMod (q j) → ℂ) (D : ℕ) {M : ℕ} (t : Fin M) : ℂ := + if Pairwise (fun i j => (q i).Coprime (q j)) ∧ (∀ j, D.Coprime (q j)) then + ∏ j, g j ((t.val : ZMod (q j)) * ((D * tupleCofactor q j : ℕ) : ZMod (q j))⁻¹) + else 0 + +/-- Invalid compensation vectors stay in the original sample space with +zero row. No conditioning or renormalization of that sample law is used. -/ +theorem movingGuardedRow_energy {J : Type*} [Fintype J] + (q : J → ℕ) [∀ j, Fact (q j).Prime] + (g : ∀ j, ZMod (q j) → ℂ) (D M : ℕ) (hM : (∏ j, q j) = M) + (giant : J) (S : ∀ j, Finset (ZMod (q j))) + (hg : ∀ x, ‖g giant x‖ ≤ 1) + (hregular : ∀ j, j ≠ giant → g j = normalizedResidueTransform (S j)) + (hS : ∀ j, j ≠ giant → (S j).Nonempty) + (hSp : ∀ j, j ≠ giant → (S j).card < q j) : + (∑ t : Fin M, ‖movingGuardedRow q g D t‖ ^ 2) ≤ M := by + by_cases h : Pairwise (fun i j => (q i).Coprime (q j)) ∧ (∀ j, D.Coprime (q j)) + · let : NeZero (∏ j, q j) := ⟨(Finset.prod_pos (fun j _ => (Fact.out : (q j).Prime).pos)).ne'⟩ + have he := moving_compensation_fourier_row_energy q h.1 giant g S hg hregular hS hSp D h.2 + rw [hM] at he + simpa only [movingGuardedRow, ite_eq_left h, div_eq_mul_inv] using he + · simp only [movingGuardedRow, ite_eq_right h, norm_zero, zero_pow (by decide : 2 ≠ 0), + Finset.sum_const_zero, Nat.cast_nonneg] + +/-- On support this is exactly the current transform at the grouped key. -/ +theorem movingGuardedRow_grouped {J : Type*} [Fintype J] + (q : J → ℕ) [∀ j, Fact (q j).Prime] + (g : ∀ j, ZMod (q j) → ℂ) (D H : ℕ) (v : ℤ) + (hc : Pairwise (fun i j => (q i).Coprime (q j))) (hD : ∀ j, D.Coprime (q j)) + (hH : H.Coprime (∏ j, q j)) : + movingGuardedRow q g D (positiveIntegerPivotKey (∏ j, q j) + (Finset.prod_pos (fun j _ => (Fact.out : (q j).Prime).pos)) H v) = + movingRegularTransform q g (D * H) v := by + rw [movingGuardedRow, ite_eq_left ⟨hc, hD⟩] + have he := moving_regular_transform_grouped_key q g H D v hH + simpa only [movingRegularTransform, Int.cast_natCast] using he + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicCounterpart.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicCounterpart.lean new file mode 100644 index 0000000000000000000000000000000000000000..3e4daa295915dcfae48a6636390913184c011dd7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicCounterpart.lean @@ -0,0 +1,47 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateHarmonicDiagonal + +namespace OAI + +/-! # The numerical counterpart cost for the actual harmonic diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original giant range and terminal bulk cutoff supply the two +exponential denominators in the harmonic product-fibre bound. -/ +theorem moving_harmonic_counterpart_le (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (cg Gmin cb : ℝ) + (X : ℕ) (y : MovingRegularSlot n r m → ℕ) + (hX : Real.exp Gmin ≤ (X : ℝ)) + (hy : Real.exp ((2 ^ n : ℕ) * (cb - 1)) ≤ ((∏ i, y i : ℕ) : ℝ)) : + (Real.exp cg / X) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, y i : ℕ) : ℝ)⁻¹ ≤ + Real.exp (cg - Gmin - (2 ^ n : ℕ) * (cb - 1)) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) := by + let K := ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) + have hK : 0 ≤ K := mul_nonneg (Nat.cast_nonneg _) + (Finset.prod_nonneg (fun i _ => inv_nonneg.mpr + (Finset.sum_nonneg (fun q _ => inv_nonneg.mpr (Nat.cast_nonneg q))))) + have hp : 0 < Real.exp Gmin * Real.exp ((2 ^ n : ℕ) * (cb - 1)) := by positivity + have hden : Real.exp Gmin * Real.exp ((2 ^ n : ℕ) * (cb - 1)) ≤ + (X : ℝ) * ((∏ i, y i : ℕ) : ℝ) := + mul_le_mul hX hy (Real.exp_nonneg _) (Nat.cast_nonneg _) + calc + _ = (Real.exp cg / ((X : ℝ) * ((∏ i, y i : ℕ) : ℝ))) * K := by + dsimp only [K] + simp only [div_eq_mul_inv, mul_inv_rev] + ring + _ ≤ (Real.exp cg / (Real.exp Gmin * Real.exp ((2 ^ n : ℕ) * (cb - 1)))) * K := + mul_le_mul_of_nonneg_right (div_le_div_of_nonneg_left (Real.exp_nonneg _) hp hden) hK + _ = _ := by + rw [← Real.exp_add, ← Real.exp_sub] + rw [show cg - (Gmin + (2 ^ n : ℕ) * (cb - 1)) = + cg - Gmin - (2 ^ n : ℕ) * (cb - 1) by ring] + dsimp only [K] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..a09a2250ae05a4d9a19ff08bbb7915e8ea4591fd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicDiagonal.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOneGiantDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicKeyMass + +namespace OAI + +/-! # The single-giant diagonal with its original harmonic mass -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Distinctness is forced by the coefficient, rather than imposed on the +sampling law. The harmonic fibre estimate therefore applies without changing +either the original diagonal or its single-branch energy. -/ +theorem movingOneGiant_harmonic_diagonal_le {A I : Type*} [Fintype A] [Fintype I] + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (Q : I → Finset ℕ) + (X : A → ℕ) (hX : ∀ a, (X a).Prime) + (y : A → I → P) (v : A → ℤ) (μ : A → ℝ) (W : A → ℂ) + (hμ : ∀ a, 0 ≤ μ a) (g : ℕ → ℝ) (hg : ∀ q, 0 ≤ g q) + (hrow : ∀ a b, X a = X b → y a = y b → v a = v b → a = b) + (hpoint : ∀ a, μ a ≤ g (X a) * ∏ i, primeSubsetPrior P (Q i) (y a i)) + (hinj : ∀ a, (μ a : ℂ) * W a ≠ 0 → Function.Injective (y a)) + (hv : ∀ a, (μ a : ℂ) * W a ≠ 0 → v a ≠ 0) + (hvg : ∀ a, (μ a : ℂ) * W a ≠ 0 → (v a).natAbs < X a) + (hvr : ∀ a, (μ a : ℂ) * W a ≠ 0 → ∀ i, (v a).natAbs < (y a i : ℕ)) + (hsep : ∀ a b, (μ a : ℂ) * W a ≠ 0 → (μ b : ℂ) * W b ≠ 0 → + ∀ i, X a ≠ (y b i : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (D : ℕ) : + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let _ : ∀ a i, Fact (y a i : ℕ).Prime := fun a i => ⟨hP _ (y a i).property⟩ + let θ := fun k : ℕ × ℕ × ℤ => g k.1 * ((Fintype.card I).factorial : ℝ) * + (∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * (k.2.1 : ℝ)⁻¹ + (pivotDiagonal (fun a => X a * ∏ i, (y a i : ℕ)) v + (fun a => (μ a : ℂ) * W a * + movingRegularTransform (movingOneGiantModuli (X a) (fun i => (y a i : ℕ))) + (movingOneGiantFactors (X a) (fun i => (y a i : ℕ)) greg ggiant favorable) D (v a))).re ≤ + ∑ a, μ a * θ (X a, (∏ i, (y a i : ℕ)), v a) * + ‖W a * primeProductTransform greg (D * X a) (∏ i, (y a i : ℕ)) (v a)‖ ^ 2 := by + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let _ : ∀ a i, Fact (y a i : ℕ).Prime := fun a i => ⟨hP _ (y a i).property⟩ + let μ' := fun a => if Function.Injective (y a) then μ a else 0 + let θ := fun k : ℕ × ℕ × ℤ => g k.1 * ((Fintype.card I).factorial : ℝ) * + (∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * (k.2.1 : ℝ)⁻¹ + have hμ' a : 0 ≤ μ' a := by + dsimp only [μ'] + split_ifs + · exact hμ a + · exact le_rfl + have he a : (μ' a : ℂ) * W a = (μ a : ℂ) * W a := by + by_cases hi : Function.Injective (y a) + · simp only [μ', ite_eq_left hi] + · have hz : (μ a : ℂ) * W a = 0 := by + by_contra h + exact hi (hinj a h) + simp only [μ', ite_eq_right hi, Complex.ofReal_zero, zero_mul, hz] + have hmass k : (∑ a, if (X a, (∏ i, (y a i : ℕ)), v a) = k then μ' a else 0) ≤ θ k := by + apply indexed_harmonic_key_mass P hP Q X y v μ' g hg hrow + · intro a ha + by_contra hi + simp only [μ', ite_eq_right hi, ne_eq, not_true_eq_false] at ha + · intro a _ + by_cases hi : Function.Injective (y a) + · simpa only [μ', ite_eq_left hi] using hpoint a + · simp only [μ', ite_eq_right hi] + exact mul_nonneg (hg _) (Finset.prod_nonneg + (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + have ht := movingOneGiant_weighted_pivot_diagonal_le X (fun a i => (y a i : ℕ)) + greg ggiant favorable D v μ' W θ hμ' + (fun a ha i j hij => hinj a (by simpa only [he] using ha) (Subtype.ext hij)) + (fun a ha => hv a (by simpa only [he] using ha)) + (fun a ha => hvg a (by simpa only [he] using ha)) + (fun a ha => hvr a (by simpa only [he] using ha)) + (fun a b ha hb => hsep a b (by simpa only [he] using ha) (by simpa only [he] using hb)) hmass + simp only [he] at ht + convert ht using 1 + apply Finset.sum_congr rfl + intro a _ + by_cases hi : Function.Injective (y a) + · simp only [μ', ite_eq_left hi, θ] + · have hz : (μ a : ℂ) * W a = 0 := by + by_contra h + exact hi (hinj a h) + rcases mul_eq_zero.mp hz with hm | hW + · have hm' : μ a = 0 := by exact_mod_cast hm + simp only [μ', ite_eq_right hi, hm', zero_mul] + · simp only [μ', ite_eq_right hi, hW, zero_mul, norm_zero, ne_eq, + OfNat.ofNat_ne_zero, not_false_eq_true, zero_pow, mul_zero] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicGroupedEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicGroupedEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..460852ad3f655243bbd5f34eedf4bd3955d5e60e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicGroupedEnergy.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicDiagonal + +namespace OAI + +/-! # Grouping and bulk averaging precede the harmonic Cauchy estimate -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingOneGiant_harmonic_grouped_diagonal_le {A I : Type*} [Fintype A] [Fintype I] + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (Q : I → Finset ℕ) + (X : A → ℕ) (hX : ∀ a, (X a).Prime) + (y : A → I → P) (v : A → ℤ) (μ : A → ℝ) (W Wnew : A → ℂ) + (hμ : ∀ a, 0 ≤ μ a) (g : ℕ → ℝ) (hg : ∀ q, 0 ≤ g q) + (hrow : ∀ a b, X a = X b → y a = y b → v a = v b → a = b) + (hpoint : ∀ a, μ a ≤ g (X a) * ∏ i, primeSubsetPrior P (Q i) (y a i)) + (hinj : ∀ a, (μ a : ℂ) * W a ≠ 0 → Function.Injective (y a)) + (hv : ∀ a, (μ a : ℂ) * W a ≠ 0 → v a ≠ 0) + (hvg : ∀ a, (μ a : ℂ) * W a ≠ 0 → (v a).natAbs < X a) + (hvr : ∀ a, (μ a : ℂ) * W a ≠ 0 → ∀ i, (v a).natAbs < (y a i : ℕ)) + (hsep : ∀ a b, (μ a : ℂ) * W a ≠ 0 → (μ b : ℂ) * W b ≠ 0 → + ∀ i, X a ≠ (y b i : ℕ)) + (hgroup : ∀ k : ℕ × ℕ × ℤ, + groupedCoefficient (fun a => (X a, (∏ i, (y a i : ℕ)), v a)) + (fun a => (μ a : ℂ) * W a) k = + groupedCoefficient (fun a => (X a, (∏ i, (y a i : ℕ)), v a)) + (fun a => (μ a : ℂ) * Wnew a) k) + (hnewinj : ∀ a, (μ a : ℂ) * Wnew a ≠ 0 → Function.Injective (y a)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (D : ℕ) : + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let _ : ∀ a i, Fact (y a i : ℕ).Prime := fun a i => ⟨hP _ (y a i).property⟩ + let θ := fun k : ℕ × ℕ × ℤ => g k.1 * ((Fintype.card I).factorial : ℝ) * + (∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * (k.2.1 : ℝ)⁻¹ + (pivotDiagonal (fun a => X a * ∏ i, (y a i : ℕ)) v + (fun a => (μ a : ℂ) * W a * + movingRegularTransform (movingOneGiantModuli (X a) (fun i => (y a i : ℕ))) + (movingOneGiantFactors (X a) (fun i => (y a i : ℕ)) greg ggiant favorable) D (v a))).re ≤ + ∑ a, μ a * θ (X a, (∏ i, (y a i : ℕ)), v a) * + ‖Wnew a * primeProductTransform greg (D * X a) (∏ i, (y a i : ℕ)) (v a)‖ ^ 2 := by + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let _ : ∀ a i, Fact (y a i : ℕ).Prime := fun a i => ⟨hP _ (y a i).property⟩ + let μ' := fun a => if Function.Injective (y a) then μ a else 0 + let θ := fun k : ℕ × ℕ × ℤ => g k.1 * ((Fintype.card I).factorial : ℝ) * + (∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * (k.2.1 : ℝ)⁻¹ + have hμ' a : 0 ≤ μ' a := by + dsimp only [μ'] + split_ifs + · exact hμ a + · exact le_rfl + have he a : (μ' a : ℂ) * Wnew a = (μ a : ℂ) * Wnew a := by + by_cases hi : Function.Injective (y a) + · simp only [μ', ite_eq_left hi] + · have hz : (μ a : ℂ) * Wnew a = 0 := by + by_contra h + exact hi (hnewinj a h) + simp only [μ', ite_eq_right hi, Complex.ofReal_zero, zero_mul, hz] + have hmass k : (∑ a, if (X a, (∏ i, (y a i : ℕ)), v a) = k then μ' a else 0) ≤ θ k := by + apply indexed_harmonic_key_mass P hP Q X y v μ' g hg hrow + · intro a ha + by_contra hi + simp only [μ', ite_eq_right hi, ne_eq, not_true_eq_false] at ha + · intro a _ + by_cases hi : Function.Injective (y a) + · simpa only [μ', ite_eq_left hi] using hpoint a + · simp only [μ', ite_eq_right hi] + exact mul_nonneg (hg _) (Finset.prod_nonneg + (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + have hd := movingOneGiant_pivot_diagonal_le X (fun a i => (y a i : ℕ)) + greg ggiant favorable D v (fun a => (μ a : ℂ) * W a) + (fun a ha i j hij => hinj a ha (Subtype.ext hij)) hv hvg hvr hsep + have ht := finite_grouped_weighted_energy_le + (fun a => (X a, (∏ i, (y a i : ℕ)), v a)) μ' Wnew + (fun k => primeProductTransform greg (D * k.1) k.2.1 k.2.2) θ hμ' hmass + have hgroup' (k : ℕ × ℕ × ℤ) : + groupedCoefficient (fun a => (X a, (∏ i, (y a i : ℕ)), v a)) + (fun a => (μ a : ℂ) * W a) k = + groupedCoefficient (fun a => (X a, (∏ i, (y a i : ℕ)), v a)) + (fun a => (μ' a : ℂ) * Wnew a) k := by + rw [hgroup k] + simp only [he] + simp only [hgroup'] at hd + have hfinal := hd.trans ht + convert hfinal using 1 + apply Finset.sum_congr rfl + intro a _ + by_cases hi : Function.Injective (y a) + · simp only [μ', ite_eq_left hi, θ] + · have hz : (μ a : ℂ) * Wnew a = 0 := by + by_contra h + exact hi (hnewinj a h) + rcases mul_eq_zero.mp hz with hm | hW + · have hm' : μ a = 0 := by exact_mod_cast hm + simp only [μ', ite_eq_right hi, hm', zero_mul] + · simp only [μ', ite_eq_right hi, hW, zero_mul, norm_zero, ne_eq, + OfNat.ofNat_ne_zero, not_false_eq_true, zero_pow, mul_zero] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicKeyMass.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicKeyMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..9b501882a9780dffc417bcef0d3bb8d950139d76 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicKeyMass.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicProductFiber + +namespace OAI + +/-! # Original harmonic mass of a giant/product/frequency fibre -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- On a fixed giant and frequency, the regular tuple determines the row. +Zero rows are discarded exactly; the other rows retain their original mass. -/ +theorem indexed_harmonic_key_mass {A I : Type*} [Fintype A] [Fintype I] + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (Q : I → Finset ℕ) + (X : A → ℕ) (y : A → I → P) (v : A → ℤ) (μ : A → ℝ) + (g : ℕ → ℝ) (hg : ∀ q, 0 ≤ g q) + (hrow : ∀ a b, X a = X b → y a = y b → v a = v b → a = b) + (hinj : ∀ a, μ a ≠ 0 → Function.Injective (y a)) + (hpoint : ∀ a, μ a ≠ 0 → + μ a ≤ g (X a) * ∏ i, primeSubsetPrior P (Q i) (y a i)) + (k : ℕ × ℕ × ℤ) : + (∑ a, if (X a, (∏ i, (y a i : ℕ)), v a) = k then μ a else 0) ≤ + g k.1 * ((Fintype.card I).factorial : ℝ) * + (∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * (k.2.1 : ℝ)⁻¹ := by + let S := Finset.univ.filter (fun a => + (X a, (∏ i, (y a i : ℕ)), v a) = k ∧ μ a ≠ 0) + let T := (Finset.univ : Finset (I → P)).filter + (fun z : I → P => Function.Injective z) + let U := T.filter (fun z : I → P => (∏ i, (z i : ℕ)) = k.2.1) + have hs : (∑ a, if (X a, (∏ i, (y a i : ℕ)), v a) = k then μ a else 0) = + ∑ a ∈ S, μ a := by + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro a _ + by_cases hk : (X a, (∏ i, (y a i : ℕ)), v a) = k <;> + by_cases hm : μ a = 0 <;> simp [hk, hm] + have hkey a (ha : a ∈ S) : + X a = k.1 ∧ (∏ i, (y a i : ℕ)) = k.2.1 ∧ v a = k.2.2 := by + have h := (Finset.mem_filter.mp ha).2.1 + simpa only [Prod.ext_iff] using h + have hm a (ha : a ∈ S) : μ a ≠ 0 := (Finset.mem_filter.mp ha).2.2 + have hmap : Set.InjOn y S := by + intro a ha b hb hab + exact hrow a b ((hkey a ha).1.trans (hkey b hb).1.symm) hab + ((hkey a ha).2.2.trans (hkey b hb).2.2.symm) + have hmem : Set.MapsTo y S U := by + intro a ha + exact Finset.mem_filter.mpr ⟨Finset.mem_filter.mpr + ⟨Finset.mem_univ _, hinj a (hm a ha)⟩, (hkey a ha).2.1⟩ + calc + _ = ∑ a ∈ S, μ a := hs + _ ≤ ∑ z ∈ U, g k.1 * ∏ i, primeSubsetPrior P (Q i) (z i) := by + apply Finset.sum_le_sum_of_injOn y hmap (by + intro z hz + obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hz + exact hmem ha) + · intro a ha + simpa only [(hkey a ha).1] using hpoint a (hm a ha) + · intro z _ _ + exact mul_nonneg (hg _) (Finset.prod_nonneg + (fun i _ => primeSubsetPrior_nonneg P (Q i) (z i))) + _ = g k.1 * ∑ z ∈ U, ∏ i, primeSubsetPrior P (Q i) (z i) := by + rw [Finset.mul_sum] + _ ≤ g k.1 * (((Fintype.card I).factorial : ℝ) * + (∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * (k.2.1 : ℝ)⁻¹) := by + apply mul_le_mul_of_nonneg_left _ (hg _) + exact indexed_harmonic_distinct_product_mass P hP Q T + (fun z hz => (Finset.mem_filter.mp hz).2) k.2.1 + _ = _ := by ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicMassBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicMassBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..6076cc94ed0262a83197df5ad88c9fed5d2435d5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicMassBudget.lean @@ -0,0 +1,94 @@ +import Mathlib.Data.Nat.Choose.Bounds +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularTemplate +import OAI.NumberTheory.Ostmann.Construction.BadMatchingHarmonicBudget + +namespace OAI + +/-! # The full factorial cost with the original bulk harmonic masses -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingRegular_inverse_mass_bound (n s m : ℕ) + (mass : MovingRegularSlot n s m → ℝ) (L C : ℝ) (hL : 0 < L) + (hsmall : ∀ j : TreeLeafIndex n × Fin s, Real.exp (-C * L) ≤ mass (j.1, .inl j.2)) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, L ≤ mass (j.1, .inr j.2)) : + (∏ i, (mass i)⁻¹) ≤ + (L⁻¹) ^ (2 ^ n * m) * Real.exp (C * L * (2 ^ n * s : ℕ)) := by + have hpoint (j : TreeLeafIndex n) (i : Fin s ⊕ Fin m) : + (mass (j, i))⁻¹ ≤ Sum.elim (fun _ => Real.exp (C * L)) (fun _ => L⁻¹) i := by + cases i with + | inl i => + have h := one_div_le_one_div_of_le (Real.exp_pos (-C * L)) (hsmall (j, i)) + simpa only [Sum.elim_inl, one_div, show -C * L = -(C * L) by ring, Real.exp_neg, inv_inv] using h + | inr i => simpa only [Sum.elim_inr, one_div] using one_div_le_one_div_of_le hL (hbulk (j, i)) + have hnonneg (i : MovingRegularSlot n s m) : 0 ≤ (mass i)⁻¹ := by + rcases i with ⟨j, i | i⟩ + · exact inv_nonneg.mpr ((Real.exp_pos _).le.trans (hsmall (j, i))) + · exact inv_nonneg.mpr (hL.le.trans (hbulk (j, i))) + apply (Finset.prod_le_prod₀ (fun i _ => hnonneg i) (fun i _ => hpoint i.1 i.2)).trans_eq + rw [Fintype.prod_prod_type] + simp only [Fintype.prod_sum_type, Sum.elim_inl, Sum.elim_inr, Finset.prod_const, + Finset.card_univ, Fintype.card_fin, card_treeLeafIndex] + rw [mul_pow, ← pow_mul, ← pow_mul, ← Real.exp_nat_mul] + push_cast + rw [show (s : ℝ) * 2 ^ n * (C * L) = C * L * (2 ^ n * s) by ring] + ring + +theorem factorial_split_upper (N S : ℕ) : + ((N + S).factorial : ℝ) ≤ 2 ^ (N + S) * (N.factorial : ℝ) * (S.factorial : ℝ) := by + have h := Nat.mul_le_mul_right (S.factorial) + (Nat.mul_le_mul_right (N.factorial) (Nat.choose_le_two_pow (N + S) N)) + have hf : (N + S).choose N * N.factorial * S.factorial = (N + S).factorial := by + simpa only [Nat.add_sub_cancel_left] using + Nat.choose_mul_factorial_mul_factorial (Nat.le_add_right N S) + rw [hf] at h + exact_mod_cast h + +theorem movingRegular_factorial_harmonic_bound (n s m : ℕ) + (mass : MovingRegularSlot n s m → ℝ) (L z C : ℝ) (hL : 0 < L) (hz : 0 < z) + (hm : (m : ℝ) ≤ z * L) + (hsmall : ∀ j : TreeLeafIndex n × Fin s, Real.exp (-C * L) ≤ mass (j.1, .inl j.2)) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, L ≤ mass (j.1, .inr j.2)) : + ((Fintype.card (MovingRegularSlot n s m)).factorial : ℝ) * (∏ i, (mass i)⁻¹) ≤ + (2 : ℝ) ^ (2 ^ n * s) * ((2 ^ n * s).factorial : ℝ) * + Real.exp (C * L * (2 ^ n * s : ℕ)) * + Real.exp ((Real.log 2 + Real.log z + Real.log (2 ^ n : ℕ)) * (2 ^ n * m : ℕ)) := by + have hf := factorial_split_upper (2 ^ n * m) (2 ^ n * s) + have hp := movingRegular_inverse_mass_bound n s m mass L C hL hsmall hbulk + have hnorm := factorial_harmonic_entropy 1 (2 ^ n * m) L ((2 ^ n : ℕ) * z) hL + (mul_pos (by positivity) hz) (by + push_cast + nlinarith [mul_le_mul_of_nonneg_left hm (show (0 : ℝ) ≤ 2 ^ n by positivity)]) + simp only [pow_one, one_mul] at hnorm + have hp0 : 0 ≤ ∏ i, (mass i)⁻¹ := by + apply Finset.prod_nonneg + rintro ⟨j, i | i⟩ _ + · exact inv_nonneg.mpr ((Real.exp_pos _).le.trans (hsmall (j, i))) + · exact inv_nonneg.mpr (hL.le.trans (hbulk (j, i))) + rw [movingRegularSlot_card, Nat.mul_add, Nat.add_comm (2 ^ n * s)] + calc + _ ≤ (2 ^ (2 ^ n * m + 2 ^ n * s) * ((2 ^ n * m).factorial : ℝ) * + ((2 ^ n * s).factorial : ℝ)) * + ((L⁻¹) ^ (2 ^ n * m) * Real.exp (C * L * (2 ^ n * s : ℕ))) := + mul_le_mul hf hp hp0 (by positivity) + _ = (2 ^ (2 ^ n * s) * ((2 ^ n * s).factorial : ℝ) * + Real.exp (C * L * (2 ^ n * s : ℕ))) * + (2 ^ (2 ^ n * m) * (((2 ^ n * m).factorial : ℝ) * (L⁻¹) ^ (2 ^ n * m))) := by + rw [pow_add] + ring + _ ≤ (2 ^ (2 ^ n * s) * ((2 ^ n * s).factorial : ℝ) * + Real.exp (C * L * (2 ^ n * s : ℕ))) * + (2 ^ (2 ^ n * m) * Real.exp (Real.log ((2 ^ n : ℕ) * z) * (2 ^ n * m : ℕ))) := by + gcongr + _ = _ := by + rw [Real.log_mul (by positivity : ((2 ^ n : ℕ) : ℝ) ≠ 0) hz.ne'] + have ht : (2 : ℝ) ^ (2 ^ n * m) = Real.exp ((2 ^ n * m : ℕ) * Real.log 2) := by + rw [Real.exp_nat_mul, Real.exp_log (by norm_num : (0 : ℝ) < 2)] + rw [ht, ← Real.exp_add] + congr 2 + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicProductFiber.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicProductFiber.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d95439898ccd181e24b38e1bc5d1cd485563a57 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicProductFiber.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.Ostmann.Characters.PivotProductPrior +import OAI.NumberTheory.Ostmann.Construction.PrimeProductMatching + +namespace OAI + +/-! # Harmonic product fibres on the actual regular-slot index type -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem card_indexed_distinct_prime_product_fiber {I : Type*} [Fintype I] + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (M : ℕ) : + ((Finset.univ : Finset (I → P)).filter + (fun x : I → P => Function.Injective x ∧ (∏ i, (x i : ℕ)) = M)).card ≤ + (Fintype.card I).factorial := by + let S := (Finset.univ : Finset (I → P)).filter + (fun x : I → P => Function.Injective x ∧ (∏ i, (x i : ℕ)) = M) + by_cases hS : S.Nonempty + · obtain ⟨x, hx⟩ := hS + have hx' := (Finset.mem_filter.mp hx).2 + have hex (y : S) : ∃ e : Equiv.Perm I, ∀ i, (x i : ℕ) = (y.val (e i) : ℕ) := by + have hy := (Finset.mem_filter.mp y.property).2 + obtain ⟨e, he, _⟩ := prime_product_matching_exists_unique + (fun i => (x i : ℕ)) (fun i => (y.val i : ℕ)) + (fun i => hP _ (x i).property) (fun i => hP _ (y.val i).property) + (fun i j h => hx'.1 (Subtype.ext h)) + (fun i j h => hy.1 (Subtype.ext h)) (hx'.2.trans hy.2.symm) + exact ⟨e, he⟩ + let f : S → Equiv.Perm I := fun y => Classical.choose (hex y) + have hf (y : S) (i : I) : (x i : ℕ) = (y.val (f y i) : ℕ) := + Classical.choose_spec (hex y) i + have hinj : Function.Injective f := by + intro y z he + apply Subtype.ext + funext j + obtain ⟨i, rfl⟩ := (f y).surjective j + apply Subtype.ext + rw [← hf y i, he] + exact hf z i + have hc := Fintype.card_le_of_injective f hinj + simpa only [S, Fintype.card_coe, Fintype.card_perm] using hc + · change S.card ≤ _ + rw [Finset.not_nonempty_iff_eq_empty.mp hS, Finset.card_empty] + exact Nat.zero_le _ + +theorem indexed_harmonic_product_point_bound {I : Type*} [Fintype I] + (P : Finset ℕ) (Q : I → Finset ℕ) (x : I → P) : + (∏ i, primeSubsetPrior P (Q i) (x i)) ≤ + (∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * (∏ i, (x i : ℝ))⁻¹ := by + have hi (i : I) : primeSubsetPrior P (Q i) (x i) ≤ + (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹ * (x i : ℝ)⁻¹ := by + unfold primeSubsetPrior + split_ifs + · rw [div_eq_mul_inv, mul_comm] + · positivity + have h : (∏ i, primeSubsetPrior P (Q i) (x i)) ≤ + ∏ i, ((∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹ * (x i : ℝ)⁻¹) := + Finset.prod_le_prod₀ (fun i _ => primeSubsetPrior_nonneg P (Q i) (x i)) + (fun i _ => hi i) + simpa only [Finset.prod_mul_distrib, Finset.prod_inv_distrib] using h + +/-- Reindexing the regular roles changes neither the original harmonic +normalizers nor the factorial cost of a distinct-prime product fibre. -/ +theorem indexed_harmonic_distinct_product_mass {I : Type*} [Fintype I] + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (Q : I → Finset ℕ) + (S : Finset (I → P)) (hS : ∀ x ∈ S, Function.Injective x) (M : ℕ) : + (∑ x ∈ S.filter (fun x : I → P => (∏ i, (x i : ℕ)) = M), + (∏ i, primeSubsetPrior P (Q i) (x i))) ≤ + ((Fintype.card I).factorial : ℝ) * + (∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * (M : ℝ)⁻¹ := by + let T := S.filter (fun x : I → P => (∏ i, (x i : ℕ)) = M) + have hc : T.card ≤ (Fintype.card I).factorial := by + apply (Finset.card_le_card (show T ⊆ (Finset.univ : Finset (I → P)).filter + (fun x : I → P => Function.Injective x ∧ (∏ i, (x i : ℕ)) = M) from ?_)).trans + (card_indexed_distinct_prime_product_fiber P hP M) + intro x hx + obtain ⟨hxS, hxM⟩ := Finset.mem_filter.mp hx + exact Finset.mem_filter.mpr ⟨Finset.mem_univ x, hS x hxS, hxM⟩ + calc + _ ≤ ∑ _x ∈ T, (∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * (M : ℝ)⁻¹ := by + apply Finset.sum_le_sum + intro x hx + have he : (∏ i, (x i : ℝ)) = (M : ℝ) := by + exact_mod_cast (Finset.mem_filter.mp hx).2 + simpa only [he] using indexed_harmonic_product_point_bound P Q x + _ = (T.card : ℝ) * ((∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * (M : ℝ)⁻¹) := by + simp only [Finset.sum_const, nsmul_eq_mul] + _ ≤ _ := by + have hc' : (T.card : ℝ) ≤ (Fintype.card I).factorial := by exact_mod_cast hc + calc + _ ≤ ((Fintype.card I).factorial : ℝ) * + ((∏ i, (∑ p ∈ Q i, (p : ℝ)⁻¹)⁻¹) * (M : ℝ)⁻¹) := + mul_le_mul_of_nonneg_right hc' (by positivity) + _ = _ := by ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicScale.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..b720fcc228980babd3c2fda1d00f1f6a47707f58 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicScale.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBadHarmonicScale + +namespace OAI + +/-! # The full counterpart normalization grows only exponentially in bulk size -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +theorem eventual_moving_harmonic_scale (n s k : ℕ) (hk : 0 < k) + (C a ε : ℝ) (ha : 0 < a) (hε : 0 < ε) + (hbudget : 4 * C * s ≤ ε * (k : ℝ) ^ 4) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ mass : MovingRegularSlot n s m → ℝ, + (∀ j : TreeLeafIndex n × Fin s, Real.exp (-C * L) ≤ mass (j.1, .inl j.2)) → + (∀ j : TreeLeafIndex n × Fin m, a * L ≤ mass (j.1, .inr j.2)) → + ((Fintype.card (MovingRegularSlot n s m)).factorial : ℝ) * (∏ i, (mass i)⁻¹) ≤ + Real.exp ((Real.log 2 + Real.log ((k : ℝ) ^ 4 / a) + + Real.log (2 ^ n : ℕ) + ε) * (2 ^ n * m : ℕ)) := by + filter_upwards [eventual_moving_nonbulk_cost n s k hk C ε hε hbudget, + eventually_gt_atTop (0 : ℝ)] with L hcost hL + dsimp only + intro mass hsmall hbulk + have hscale : (spectatorBulkCount k L : ℝ) ≤ ((k : ℝ) ^ 4 / a) * (a * L) := by + convert spectatorBulkCount_upper k L hL.le using 1; field_simp + have hid : -(C / a) * (a * L) = -C * L := by field_simp + have he := movingRegular_factorial_harmonic_bound n s (spectatorBulkCount k L) mass + (a * L) ((k : ℝ) ^ 4 / a) (C / a) (mul_pos ha hL) (by positivity) hscale + (by simpa only [hid] using hsmall) hbulk + have hid' : (C / a) * (a * L) = C * L := by field_simp + rw [hid'] at he + have hA : (1 : ℝ) ≤ (((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) := by + exact_mod_cast (Nat.one_le_iff_ne_zero.mpr (by positivity : + (2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) ≠ 0)) + have hpre : (2 : ℝ) ^ (2 ^ n * s) * ((2 ^ n * s).factorial : ℝ) * + Real.exp (C * L * (2 ^ n * s : ℕ)) ≤ + movingNonbulkCost n s * Real.exp (C * L * (2 ^ n * s : ℕ)) := by + have hh := mul_le_mul_of_nonneg_right hA (show 0 ≤ + (2 : ℝ) ^ (2 ^ n * s) * ((2 ^ n * s).factorial : ℝ) * + Real.exp (C * L * (2 ^ n * s : ℕ)) by positivity) + simpa only [movingNonbulkCost, one_mul, mul_assoc] using hh + apply he.trans + apply (mul_le_mul_of_nonneg_right (hpre.trans hcost) (Real.exp_nonneg _)).trans_eq + rw [← Real.exp_add] + congr 1 + push_cast + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..1315ea473f707bd879bc49a6bcd63991ddc1b0da --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHarmonicSupport.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Construction.SupportedPrimePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPriorSupport + +namespace OAI + +/-! # Concrete support conditions for the original harmonic role priors -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem harmonic_product_mem {N : ℕ} (P : Finset ℕ) + (Q : Fin (N + 1) → Finset ℕ) (x : Fin (N + 1) → P) + (hx : productPrior (fun i => primeSubsetPrior P (Q i)) x ≠ 0) : + ∀ i, (x i : ℕ) ∈ Q i := by + intro i + exact primeSubsetPrior_support P (Q i) (x i) + ((Finset.prod_ne_zero_iff.mp hx) i (Finset.mem_univ i)) + +theorem harmonic_product_distinct_levels {N : ℕ} (P : Finset ℕ) + (Q : Fin (N + 1) → Finset ℕ) (tier : Fin (N + 1) → ℕ) + (hQ : ∀ i j, tier i ≠ tier j → Disjoint (Q i) (Q j)) + (x : Fin (N + 1) → P) + (hx : productPrior (fun i => primeSubsetPrior P (Q i)) x ≠ 0) : + ∀ i j, tier i ≠ tier j → (x i : ℕ) ≠ (x j : ℕ) := by + intro i j hij heq + have hm := harmonic_product_mem P Q x hx + exact Finset.disjoint_left.mp (hQ i j hij) (hm i) (heq ▸ hm j) + +/-- The original internal samples lie strictly below the external tier. +Thus the same disjoint shell choice supplies the cross-coordinate condition. -/ +theorem harmonic_product_external_internal {B C : Type*} {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hB : ∀ b, n ≤ tierB b) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (P : Finset ℕ) (Q : Fin (N + 1) → Finset ℕ) + (hQ : ∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + Disjoint (Q i) (Q j)) (x : Fin (N + 1) → P) + (hx : productPrior (fun i => primeSubsetPrior P (Q i)) x ≠ 0) : + ∀ b c, (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ) := by + intro b c + apply harmonic_product_distinct_levels P Q (fun i => (Sum.elim tierB tierC) (e i)) hQ x hx + simp only [Equiv.apply_symm_apply, Sum.elim_inl, Sum.elim_inr] + have hc : tierC c < n := by + have ht := htier (rep c).val + rw [(rep c).property] at ht + exact ht.trans_lt (movingSampleTier_lt (rep c).val.2) + have hb := hB b + omega + +/-- A nonzero original frequency smaller than an internal prime remains +nonzero modulo that prime. -/ +theorem intCast_ne_zero_of_natAbs_lt (q : ℕ) (s : ℤ) (hs : s ≠ 0) + (hqs : s.natAbs < q) : (s : ZMod q) ≠ 0 := by + intro hz + have hd : q ∣ s.natAbs := by + have hh := (ZMod.intCast_zmod_eq_zero_iff_dvd s q).mp hz + exact_mod_cast Int.natAbs_dvd_natAbs.mpr hh + exact (not_le_of_gt hqs) (Nat.le_of_dvd (Int.natAbs_pos.mpr hs) hd) + +theorem harmonic_product_frequency_units {N : ℕ} (P : Finset ℕ) + (Q : Fin (N + 1) → Finset ℕ) (x : Fin (N + 1) → P) + (hx : productPrior (fun i => primeSubsetPrior P (Q i)) x ≠ 0) + (i : Fin (N + 1)) (s : ℤ) (hs : s ≠ 0) + (hQ : ∀ q ∈ Q i, s.natAbs < q) : (s : ZMod (x i : ℕ)) ≠ 0 := + intCast_ne_zero_of_natAbs_lt _ s hs (hQ _ (harmonic_product_mem P Q x hx i)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHistoryUniqueness.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHistoryUniqueness.lean new file mode 100644 index 0000000000000000000000000000000000000000..455f9bea5334253e2602a64e55dd991cec9d52c8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingHistoryUniqueness.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyCoefficient + +namespace OAI + +/-! # Rigidity of the actual moving-giant histories at fixed samples -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Frequencies stored in the slot data do not enter the products, bounds, +or child slots in the rigidity predicate. They may be replaced by one fixed +template before comparing two histories. -/ +theorem movingValidHistory_build_iff {σ : Type*} + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) (n : ℕ) + (t u v : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (a : MovingSampleSlots σ n) (XL XR : ℕ) : + ValidTransferHistory (movingSlotSystem value childBound pivotBound) n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ v ↔ + ValidTransferHistory (movingSlotSystem value childBound pivotBound) n + ⟨n, buildMovingSlotData n u small bulk a, XL, XR⟩ v := by + induction a generalizing XL XR with + | leaf => rfl + | @node n a l r ihL ihR => + let U := movingCompensationSlots n a + let sys := movingSlotSystem value childBound pivotBound + let x : MovingSlotState σ := ⟨n + 1, buildMovingSlotData (n + 1) t small bulk (.node a l r), XL, XR⟩ + change (∃ P, ValidTransferNode sys x v.1 (frequencyRoot n v.2.1) (frequencyRoot n v.2.2) P ∧ + ValidTransferHistory sys n + ⟨n, buildMovingSlotData n t.2.1 (appendMovingSlotLeaves n U small.1) bulk.1 l, + P / MovingSlotReversal.naturalProduct value (flattenMovingSlots n U), XL⟩ v.2.1 ∧ + ValidTransferHistory sys n + ⟨n, buildMovingSlotData n t.2.2 (appendMovingSlotLeaves n U small.2) bulk.2 r, + P / MovingSlotReversal.naturalProduct value (flattenMovingSlots n U), XR⟩ v.2.2) ↔ _ + have hn (P : ℕ) : ValidTransferNode sys x v.1 (frequencyRoot n v.2.1) (frequencyRoot n v.2.2) P ↔ + ValidTransferNode sys + ⟨n + 1, buildMovingSlotData (n + 1) u small bulk (.node a l r), XL, XR⟩ + v.1 (frequencyRoot n v.2.1) (frequencyRoot n v.2.2) P := by + constructor <;> intro h <;> exact + ⟨h.root_ne_zero, h.root_unit, h.relation, h.pivot_pos, h.pivot_bound, + h.left_bound, h.right_bound, h.range_gap, h.pivot_unit⟩ + constructor + · rintro ⟨P, hP, hL, hR⟩ + exact ⟨P, (hn P).mp hP, + (ihL t.2.1 u.2.1 v.2.1 (appendMovingSlotLeaves n U small.1) bulk.1 _ XL).mp hL, + (ihR t.2.2 u.2.2 v.2.2 (appendMovingSlotLeaves n U small.2) bulk.2 _ XR).mp hR⟩ + · rintro ⟨P, hP, hL, hR⟩ + exact ⟨P, (hn P).mpr hP, + (ihL t.2.1 u.2.1 v.2.1 (appendMovingSlotLeaves n U small.1) bulk.1 _ XL).mpr hL, + (ihR t.2.2 u.2.2 v.2.2 (appendMovingSlotLeaves n U small.2) bulk.2 _ XR).mpr hR⟩ + +/-- Original support forces a unique full frequency history when all actual +internal samples, top primes and the root frequency have been fixed. -/ +theorem movingRecursiveWeight_history_unique {σ : Type*} + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t u : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (a : MovingSampleSlots σ n) (XL XR : ℕ) + (ht : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound E) n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ t ≠ 0) + (hu : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound E) n + ⟨n, buildMovingSlotData n u small bulk a, XL, XR⟩ u ≠ 0) + (hroot : frequencyRoot n t = frequencyRoot n u) : t = u := by + have htv := recursiveTransferWeight_nonzero_valid _ _ _ _ _ _ ht + have huv := recursiveTransferWeight_nonzero_valid _ _ _ _ _ _ hu + have huv' := (movingValidHistory_build_iff value childBound pivotBound n u t u small bulk a XL XR).mp huv + exact validTransferHistory_unique _ n _ t u htv huv' hroot + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIndexedCellLower.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIndexedCellLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6abd6b38ef614bf26b4450a519624ea9e40d632 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIndexedCellLower.lean @@ -0,0 +1,39 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRoundedCellSums +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularTemplate + +namespace OAI + +/-! # The selected cell endpoints in the actual indexed regular template -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingCellLower (n : ℕ) (centers : List ℝ) + (i : TreeLeafIndex n × Fin centers.length) : ℝ := centers.get i.2 - 1 + +theorem movingCellLower_sum (n : ℕ) (centers : List ℝ) : + (∑ i, movingCellLower n centers i) = + (2 ^ n : ℕ) * (centers.map (fun c => c - 1)).sum := by + have hs : (∑ i : Fin centers.length, (centers.get i - 1)) = + (centers.map (fun c => c - 1)).sum := by + have he : List.ofFn (fun i : Fin centers.length => centers.get i - 1) = + centers.map (fun c => c - 1) := by + change List.ofFn ((fun c : ℝ => c - 1) ∘ centers.get) = _ + rw [← List.map_ofFn, List.ofFn_get] + simpa only [List.sum_ofFn] using congrArg List.sum he + simp only [movingCellLower, Fintype.sum_prod_type] + change (∑ _j : TreeLeafIndex n, (∑ i : Fin centers.length, (centers.get i - 1))) = _ + simp_rw [hs] + simp only [Finset.sum_const, Finset.card_univ, card_treeLeafIndex, nsmul_eq_mul] + +theorem movingCellLower_prime_bound (n : ℕ) (centers : List ℝ) + (i : TreeLeafIndex n × Fin centers.length) (q : ℕ) + (h : centers.get i.2 ≤ Real.log (q : ℝ)) (hq : 0 < q) : + Real.exp (movingCellLower n centers i) ≤ (q : ℝ) := by + apply (Real.le_log_iff_exp_le (by exact_mod_cast hq)).mp + dsimp only [movingCellLower] + linarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIndexedLineSystem.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIndexedLineSystem.lean new file mode 100644 index 0000000000000000000000000000000000000000..447e248573377fbadd92440d37a44468ef5965b5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIndexedLineSystem.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRepresentativeLineSystem +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleSizes + +namespace OAI + +/-! # A fixed finite index for every representative's actual line system -/ + +namespace Ostmann +open scoped Classical BigOperators + +abbrev MovingPairOccurrenceIndex {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) := Σ side : Bool, Fin (T side).occurrences.length + +theorem movingPairOccurrenceIndex_card {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) : + Fintype.card (MovingPairOccurrenceIndex T) = 2 * (2 ^ n - 1) := by + simp only [MovingPairOccurrenceIndex, Fintype.card_sigma, Fintype.card_fin, + Fintype.sum_bool, MovingSlotData.occurrences_length] + omega + +/-- Indices outside a representative's system repeat its selected base row. +Thus every representative uses the same finite index without changing any test. -/ +noncomputable def movingRepresentativeIndex {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (rep : σ) (base : MovingPairRepresentativeOccurrences T rep) + (o : MovingPairOccurrenceIndex T) : MovingPairRepresentativeOccurrences T rep := + if h : rep ∈ ((T o.1).occurrences.get o.2).current.compensationSlots then + ⟨o.1, ⟨o.2, h⟩⟩ else base + +theorem movingRepresentativeIndex_surjective {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (rep : σ) (base : MovingPairRepresentativeOccurrences T rep) : + Function.Surjective (movingRepresentativeIndex T rep base) := by + intro j + refine ⟨⟨j.1, j.2.val⟩, ?_⟩ + simp only [movingRepresentativeIndex, dite_eq_left j.2.property] + +noncomputable def movingIndexedOccurrence {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (rep : σ) (base : MovingPairRepresentativeOccurrences T rep) + (o : MovingPairOccurrenceIndex T) : MovingSlotOccurrence σ := + let j := movingRepresentativeIndex T rep base o + (T j.1).occurrences.get j.2.val + +noncomputable def movingIndexedLine {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (rep : σ) (base : MovingPairRepresentativeOccurrences T rep) + (o : MovingPairOccurrenceIndex T) : PolynomialGiantLine σ := + movingSlotLine (movingIndexedOccurrence T rep base o).path + (movingIndexedOccurrence T rep base o).current + +theorem movingIndexedOccurrence_absent {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (tier : σ → ℕ) (hlevels : ∀ side, (T side).Levels tier) + (rep : σ) (base : MovingPairRepresentativeOccurrences T rep) (o : MovingPairOccurrenceIndex T) : + (∀ s ∈ (movingIndexedOccurrence T rep base o).path, + rep ∉ s.leftSlots ∧ rep ∉ s.rightSlots ∧ rep ∉ s.compensationSlots) ∧ + rep ∉ (movingIndexedOccurrence T rep base o).current.leftSlots ∧ + rep ∉ (movingIndexedOccurrence T rep base o).current.rightSlots := by + let j := movingRepresentativeIndex T rep base o + let t := (T j.1).occurrences.get j.2.val + have ht : t ∈ (T j.1).occurrences := List.get_mem _ _ + have hbound := (T j.1).occurrence_bounds tier (hlevels j.1) t ht + have hrep := (T j.1).occurrence_compensation_level tier (hlevels j.1) t ht rep j.2.property + exact t.absent_of_level tier hbound.2.2 rep hrep + +theorem movingIndexedOccurrence_path_length {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (tier : σ → ℕ) (hlevels : ∀ side, (T side).Levels tier) + (rep : σ) (base : MovingPairRepresentativeOccurrences T rep) (o : MovingPairOccurrenceIndex T) : + (movingIndexedOccurrence T rep base o).path.length ≤ n := by + let j := movingRepresentativeIndex T rep base o + have h := (T j.1).occurrence_bounds tier (hlevels j.1) + ((T j.1).occurrences.get j.2.val) (List.get_mem _ _) + exact (Nat.le_add_left _ _).trans h.2.1 + +theorem movingIndexedOccurrence_units {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (hlevels : ∀ side, (T side).Levels tier) + (rep : σ) (base : MovingPairRepresentativeOccurrences T rep) + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod (value rep)) ≠ 0)) + (o : MovingPairOccurrenceIndex T) : + let φ := MovingSlotReversal.naturalReduction (value rep) value + let t := movingIndexedOccurrence T rep base o + (∀ s ∈ t.path, φ s.polynomial.v ≠ 0 ∧ φ s.polynomial.w ≠ 0 ∧ φ s.polynomial.u ≠ 0) ∧ + φ t.current.polynomial.v ≠ 0 ∧ φ t.current.polynomial.w ≠ 0 := by + let j := movingRepresentativeIndex T rep base o + let t := (T j.1).occurrences.get j.2.val + have ht : t ∈ (T j.1).occurrences := List.get_mem _ _ + exact (T j.1).occurrence_units_of_prime_types tier value hprime hdisjoint (hlevels j.1) + t ht rep ((T j.1).occurrence_compensation_level tier (hlevels j.1) t ht rep j.2.property) + (hf j.1) + +theorem movingIndexedOccurrence_size {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (d : ℕ) (F : ℝ) + (hsize : ∀ side, (T side).SizeLE d) + (hfreq : ∀ side, (T side).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (rep : σ) (base : MovingPairRepresentativeOccurrences T rep) (o : MovingPairOccurrenceIndex T) : + (∀ s ∈ (movingIndexedOccurrence T rep base o).path, s.lengthLE d ∧ s.frequencyLE F) ∧ + (movingIndexedOccurrence T rep base o).current.lengthLE d ∧ + (movingIndexedOccurrence T rep base o).current.frequencyLE F := by + let j := movingRepresentativeIndex T rep base o + let t := (T j.1).occurrences.get j.2.val + have ht : t ∈ (T j.1).occurrences := List.get_mem _ _ + have hs := (T j.1).occurrence_size (hsize j.1) t ht + have hf := (T j.1).occurrence_frequencies _ (hfreq j.1) t ht + exact ⟨fun s h => ⟨hs.2 s h, hf.2 s h⟩, hs.1, hf.1⟩ + +theorem movingInternalBaseProbability_indexed {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (rep : σ) + [Fact (value rep).Prime] (hunique : ∀ i, value i = value rep → i = rep) + (base : MovingPairRepresentativeOccurrences T rep) : + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).a) + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).b) = + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingIndexedLine T rep base j).a) + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingIndexedLine T rep base j).b) := by + rw [movingInternalBaseProbability_representative value T rep hunique] + have he (x y : ZMod (value rep)) : + (∀ j : MovingPairRepresentativeOccurrences T rep, + let φ := MovingSlotReversal.naturalReduction (value rep) value + let L := movingRepresentativeLine T rep j + φ L.a * x + φ L.b * y = 0) ↔ + (∀ o : MovingPairOccurrenceIndex T, + let φ := MovingSlotReversal.naturalReduction (value rep) value + let L := movingIndexedLine T rep base o + φ L.a * x + φ L.b * y = 0) := + (movingRepresentativeIndex_surjective T rep base).forall + unfold internalLineProbability + simp only [ite_true, ← Nat.card_eq_fintype_card] + apply congrArg (fun k : ℕ => (k : ℝ) / Nat.card (ZMod (value rep) × (ZMod (value rep))ˣ)) + exact Nat.card_congr (Equiv.subtypeEquivRight + (fun z : ZMod (value rep) × (ZMod (value rep))ˣ => he z.1 z.2)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIndexedProbability.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIndexedProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1ee14ebe37ce5187e8fa582d23c03bab3456110 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIndexedProbability.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingIndexedLineSystem + +namespace OAI + +/-! # Normalizing the fixed occurrence system for the small-prime comparison -/ + +namespace Ostmann +open scoped Classical + +theorem externalLineProbability_normalized {σ J : Type*} {p : ℕ} [Fact p.Prime] + (L : J → PolynomialGiantLine σ) (φ : MvPolynomial σ ℤ →+* ZMod p) + (hd : ∀ j, φ (L j).denominator ≠ 0) : + internalLineProbability true (fun j => φ (L j).a) (fun j => φ (L j).b) = + internalLineProbability true (fun j => ((L j).normalized φ).1) + (fun j => ((L j).normalized φ).2) := by + have he (x y : ZMod p) : (∀ j, φ (L j).a * x + φ (L j).b * y = 0) ↔ + (∀ j, ((L j).normalized φ).1 * x + ((L j).normalized φ).2 * y = 0) := by + apply forall_congr' + intro j + simp only [PolynomialGiantLine.normalized] + rw [div_mul_eq_mul_div, div_mul_eq_mul_div, ← add_div, div_eq_zero_iff, or_iff_left (hd j)] + unfold internalLineProbability + simp only [ite_true, ← Nat.card_eq_fintype_card] + apply congrArg (fun k : ℕ => (k : ℝ) / Nat.card (ZMod p × (ZMod p)ˣ)) + exact Nat.card_congr (Equiv.subtypeEquivRight (fun z : ZMod p × (ZMod p)ˣ => he z.1 z.2)) + +theorem movingIndexedLine_denominator_ne_zero {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (hlevels : ∀ side, (T side).Levels tier) + (rep : σ) (base : MovingPairRepresentativeOccurrences T rep) + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod (value rep)) ≠ 0)) + (o : MovingPairOccurrenceIndex T) : + MovingSlotReversal.naturalReduction (value rep) value + (movingIndexedLine T rep base o).denominator ≠ 0 := by + let : Fact (value rep).Prime := ⟨hprime rep⟩ + have hu := movingIndexedOccurrence_units T tier value hprime hdisjoint hlevels rep base hf o + change MovingSlotReversal.naturalReduction (value rep) value + (movingPolynomialAncestors + ((movingIndexedOccurrence T rep base o).path.map MovingSlotReversal.polynomial)).denominator ≠ 0 + apply movingPolynomialAncestors_denominator + ((movingIndexedOccurrence T rep base o).path.map MovingSlotReversal.polynomial) + (MovingSlotReversal.naturalReduction (value rep) value) + intro s hs + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs + exact (hu.1 t ht).2.2 + +theorem movingInternalBaseProbability_indexed_normalized {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (hlevels : ∀ side, (T side).Levels tier) + (rep : σ) [Fact (value rep).Prime] (base : MovingPairRepresentativeOccurrences T rep) + (hunique : ∀ i, value i = value rep → i = rep) + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod (value rep)) ≠ 0)) : + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).a) + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).b) = + internalLineProbability true + (fun j => ((movingIndexedLine T rep base j).normalized + (MovingSlotReversal.naturalReduction (value rep) value)).1) + (fun j => ((movingIndexedLine T rep base j).normalized + (MovingSlotReversal.naturalReduction (value rep) value)).2) := by + rw [movingInternalBaseProbability_indexed value T rep hunique base] + exact externalLineProbability_normalized (movingIndexedLine T rep base) + (MovingSlotReversal.naturalReduction (value rep) value) + (movingIndexedLine_denominator_ne_zero T tier value hprime hdisjoint hlevels rep base hf) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInitialCoefficient.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInitialCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7d88bb9b8b441d6c84cfa64929ae48e1fc6d9cb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInitialCoefficient.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalSampleExpansion + +namespace OAI + +/-! # The literal level-zero coefficient and its original cutoff -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingFrequencyCoefficient_levelZero_sample (σ : Type) [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (s : ℤ) (small bulk : List σ) (XL XR : ℕ) : + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G 0 s + small bulk XL XR = + movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) 0 s small bulk XL XR := by + unfold movingFrequencyCoefficient + change (∑ t : Unit, _) = _ + rw [Finset.univ_unique, Finset.sum_singleton] + rfl + +theorem movingFrequencyCoefficient_levelZero (σ : Type) [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (s : ℤ) (small bulk : List σ) (XL XR : ℕ) : + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G 0 s + small bulk XL XR = + movingGuardedLeaf value outside F ⟨0, .leaf s (small ++ bulk), XL, XR⟩ s := by + unfold movingFrequencyCoefficient + change (∑ t : Unit, _) = _ + rw [Finset.univ_unique, Finset.sum_singleton] + unfold movingSupportedSampledWeight movingSampledWeight + rw [← (movingSampleZeroEquiv σ).sum_comp] + rw [Finset.univ_unique, Finset.sum_singleton] + simp [movingSampleZeroEquiv, movingSamplesPrior, recursiveTransferWeight, + buildMovingSlotData, frequencyRoot, flattenMovingSlots, movingRootedFrequencyTree] + +theorem movingFrequencyCoefficient_levelZero_support (σ : Type) [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (s : ℤ) (small bulk : List σ) (XL XR : ℕ) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G 0 s + small bulk XL XR ≠ 0) : + F ⟨0, .leaf s (small ++ bulk), XL, XR⟩ s ≠ 0 := by + rw [movingFrequencyCoefficient_levelZero] at h + unfold movingGuardedLeaf at h + split_ifs at h + · exact h + · exact (h rfl).elim + +theorem movingOriginalLeaf_window {σ I : Type*} + (value : σ → ℕ) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (x : MovingSlotState σ) (s : ℤ) + (h : movingOriginalLeaf value q F g Dq S ψ X lo hi x s ≠ 0) : + (movingSlotModulus value x : ℝ) / X ∈ Set.Icc lo hi := by + have hw : movingWindowLeaf value X lo hi (movingDataLeaf F) x s ≠ 0 := + left_ne_zero_of_mul (left_ne_zero_of_mul h) + unfold movingWindowLeaf at hw + split_ifs at hw with hc + · exact hc + · exact (hw rfl).elim + +theorem movingFrequencyCoefficient_initial_window {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hX : 0 < X) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (s : ℤ) (small bulk : List σ) (XL XR : ℕ) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G 0 s small bulk XL XR ≠ 0) : + X * lo ≤ (XL * XR * MovingSlotReversal.naturalProduct value (small ++ bulk) : ℕ) ∧ + ((XL * XR * MovingSlotReversal.naturalProduct value (small ++ bulk) : ℕ) : ℝ) ≤ X * hi := by + have hw := movingOriginalLeaf_window value q F g Dq S ψ X lo hi + ⟨0, .leaf s (small ++ bulk), XL, XR⟩ s + (movingFrequencyCoefficient_levelZero_support σ value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G s small bulk XL XR h) + change lo ≤ _ / X ∧ _ / X ≤ hi at hw + constructor + · have ht := (le_div_iff₀ hX).mp hw.1 + simpa only [movingSlotModulus, mul_comm] using ht + · have ht := (div_le_iff₀ hX).mp hw.2 + simpa only [movingSlotModulus, mul_comm] using ht + +/-- At the first step the original terminal window bounds the retained +product after the extracted giant and compensation product are removed. -/ +theorem movingFrequencyCoefficient_initial_retained_bound {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi lower : ℝ) (hX : 0 < X) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (s : ℤ) + (comp small bulk : List σ) (p XR H : ℕ) + (hp : 0 < p) (hcomp : 0 < MovingSlotReversal.naturalProduct value comp) + (hlower : lower ≤ (p * MovingSlotReversal.naturalProduct value comp : ℕ)) + (hcap : X * hi ≤ lower * H) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G 0 s (comp ++ small) bulk p XR ≠ 0) : + XR * MovingSlotReversal.naturalProduct value (small ++ bulk) ≤ H := by + have hu := (movingFrequencyCoefficient_initial_window value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi hX φ G s (comp ++ small) bulk p XR h).2 + have hproduct : p * XR * MovingSlotReversal.naturalProduct value ((comp ++ small) ++ bulk) = + (p * MovingSlotReversal.naturalProduct value comp) * + (XR * MovingSlotReversal.naturalProduct value (small ++ bulk)) := by + simp only [MovingSlotReversal.naturalProduct, List.map_append, List.prod_append] + ring + rw [hproduct, Nat.cast_mul] at hu + have htot := hu.trans (hcap.trans (mul_le_mul_of_nonneg_right hlower (Nat.cast_nonneg H))) + have hpositive : (0 : ℝ) < (p * MovingSlotReversal.naturalProduct value comp : ℕ) := by + exact_mod_cast Nat.mul_pos hp hcomp + exact_mod_cast (mul_le_mul_iff_right₀ hpositive).mp htot + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInitialDiagonalAll.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInitialDiagonalAll.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c653bf705b212362fe59e4da0564ed5f903905f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInitialDiagonalAll.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedInitialEarlyDecay +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedInitialDiagonalDecay + +namespace OAI + +/-! # A uniform diagonal formula for every used finite depth -/ +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_initial_diagonal_all + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n < k) + (A Wwin Bφ Dφ c K εdiag Bs BD Bz B : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (hBs : 0 ≤ Bs) (hBD0 : 0 ≤ BD) (hBz : 9 ≤ Bz) + (hmassBudget : 4 * (K + 1) * r ≤ (k : ℝ) ^ 4) + (hBD : Bs + 2 * B + + (Real.log 2 - Real.log (1 / 16000 : ℝ) + 5 / 4 + 1 + Real.log 12 + 1 + εdiag) + 6 ≤ BD) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, ∀ b : ℕ, spectatorBulkCount k L = b + b → + let m := b + b + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot n r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (d rinit : ℕ) (sl sr : Fin d → primes) (fallback : primes) + (childBound pivotBound V : ℕ → ℕ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot n r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd btop : ℝ) (lower : TreeLeafIndex n × Fin r → ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let H := G (n + 1) + let slot := movingTemplateBulk n r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + 4 + r + 4 * n = rinit + rinit → + Monotone V → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V n : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Δ ≤ spectatorBaseGap Bs ((k : ℝ) ^ 4) m → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, n ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot n (4 + r) m) + 4 * n * 2 ^ n) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j ≤ n → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V n ≤ primeLo → V n < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ n, (q : ℝ) ≤ Real.exp btop) → + (∀ x, φ x ≤ 1) → + (∀ j : TreeLeafIndex n × Fin r, ∀ q : primes, + (q : ℕ) ∈ Qν (j.1, .inl j.2) → Real.exp (lower j) ≤ (q : ℝ)) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → V n < (q : ℕ)) → + (∀ q : smoothGiantPrimeRange H, smoothGiantPrior (smoothGiantPrimeRange H) φ H q ≠ 0 → + ∀ j (z : primes), (z : ℕ) ∈ Qν j → (q : ℕ) ≠ (z : ℕ)) → + (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + 1 + + ((2 ^ n * 4 : ℕ) : ℝ) * btop - + ((∑ j, lower j) + (2 ^ n : ℕ) * (2 * cb - 2)) ≤ + -spectatorStepGap BD Bz ((k : ℝ) ^ 4) (2 ^ n : ℕ) m) → + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d rinit cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G n r m (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + (smoothGiantPrior (smoothGiantPrimeRange H) φ H) + (fun i => primeSubsetPrior primes (Qν i)) (normalizedResidueFamily setsReg) ggiant favorable ≤ + Real.exp (-(2 * B + 3) * (2 ^ n : ℕ) * m) := by + by_cases hnsmall : n ≤ 1 + · have hearly := P.moving_selected_initial_early_diagonal_decay C hM ψ n r k hk hn hnsmall + A Wwin Bφ Dφ c K εdiag Bs BD Bz B hA hWwin hBφ hDφ hc hK hεdiag hdepth + hBs hBD0 hBz hmassBudget hBD + refine ⟨1, by norm_num, le_rfl, 3, le_rfl, ?_⟩ + filter_upwards [hearly] with L hearly + intro b hsize + dsimp only at hearly ⊢ + intro tierB primes hprimes _ d rinit sl sr fallback childBound pivotBound V outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg cb cd btop lower ggiant favorable + hlen hV hcard hVn hV0 hΔ hΔupper hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb hφ1 hlower hvr hsep hgap + exact hearly b hsize tierB primes hprimes d rinit sl sr fallback childBound pivotBound V + outside p Dq sets primeLo cutoff tier X Δ hi btop φ G global Qμ Qν setsReg cb cd + lower ggiant favorable hlen hV hcard hVn hV0 hΔ hΔupper hhi hwindow hH hB + (lt_of_lt_of_le zero_lt_one hm) hp hsets hsetsp hpupper hφpos hφ hlip hφout hShell + hdel hout hν hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hsetsReg hb hφ1 hlower hvr hgap + · obtain ⟨j, rfl⟩ : ∃ j, n = j + 2 := ⟨n - 2, by omega⟩ + exact P.moving_selected_initial_diagonal_decay C hM ψ j r k hk + (by omega) A Wwin Bφ Dφ c K εdiag Bs BD Bz B hA hWwin hBφ hDφ hc hK hεdiag + hdepth Dlog hDlog hloglip hBs hBD0 hBz hmassBudget hBD + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInitialDiagonalUniform.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInitialDiagonalUniform.lean new file mode 100644 index 0000000000000000000000000000000000000000..303959c1332eeb7051c06b31abe3cec1360c438e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInitialDiagonalUniform.lean @@ -0,0 +1,145 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInitialDiagonalAll + +namespace OAI + +/-! # One smallness parameter and prime cutoff for every used diagonal -/ +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_initial_diagonal_uniform + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (k : ℕ) (r : Fin k → ℕ) (hk : 0 < k) + (A Wwin Bφ Dφ c K εdiag Bs BD Bz B : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (hBs : 0 ≤ Bs) (hBD0 : 0 ≤ BD) (hBz : 9 ≤ Bz) + (hmassBudget : ∀ i, 4 * (K + 1) * r i ≤ (k : ℝ) ^ 4) + (hBD : Bs + 2 * B + + (Real.log 2 - Real.log (1 / 16000 : ℝ) + 5 / 4 + 1 + Real.log 12 + 1 + εdiag) + 6 ≤ BD) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, ∀ depth : Fin k, ∀ b : ℕ, spectatorBulkCount k L = b + b → + let m := b + b + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot depth.val (r depth) m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (d rinit : ℕ) (sl sr : Fin d → primes) (fallback : primes) + (childBound pivotBound V : ℕ → ℕ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot depth.val (r depth) m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd btop : ℝ) (lower : TreeLeafIndex depth.val × Fin (r depth) → ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let H := G (depth.val + 1) + let slot := movingTemplateBulk depth.val (r depth) m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V depth.val)).erase 0 + 4 + (r depth) + 4 * depth.val = rinit + rinit → + Monotone V → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V depth.val : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Δ ≤ spectatorBaseGap Bs ((k : ℝ) ^ 4) m → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, depth.val ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot depth.val (4 + (r depth)) m) + 4 * depth.val * 2 ^ depth.val) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j ≤ depth.val → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V depth.val ≤ primeLo → V depth.val < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ depth.val, (q : ℝ) ≤ Real.exp btop) → + (∀ x, φ x ≤ 1) → + (∀ j : TreeLeafIndex depth.val × Fin (r depth), ∀ q : primes, + (q : ℕ) ∈ Qν (j.1, .inl j.2) → Real.exp (lower j) ≤ (q : ℝ)) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → V depth.val < (q : ℕ)) → + (∀ q : smoothGiantPrimeRange H, smoothGiantPrior (smoothGiantPrimeRange H) φ H q ≠ 0 → + ∀ j (z : primes), (z : ℕ) ∈ Qν j → (q : ℕ) ≠ (z : ℕ)) → + (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + 1 + + ((2 ^ depth.val * 4 : ℕ) : ℝ) * btop - + ((∑ j, lower j) + (2 ^ depth.val : ℕ) * (2 * cb - 2)) ≤ + -spectatorStepGap BD Bz ((k : ℝ) ^ 4) (2 ^ depth.val : ℕ) m) → + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d rinit cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G depth.val (r depth) m (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + (smoothGiantPrior (smoothGiantPrimeRange H) φ H) + (fun i => primeSubsetPrior primes (Qν i)) (normalizedResidueFamily setsReg) ggiant favorable ≤ + Real.exp (-(2 * B + 3) * (2 ^ depth.val : ℕ) * m) := by + let : Nonempty (Fin k) := ⟨⟨0, hk⟩⟩ + have hdata (i : Fin k) := P.moving_selected_initial_diagonal_all C hM ψ i.val (r i) k hk i.isLt + A Wwin Bφ Dφ c K εdiag Bs BD Bz B hA hWwin hBφ hDφ hc hK hεdiag hdepth + Dlog hDlog hloglip hBs hBD0 hBz (hmassBudget i) hBD + choose eps heps heps1 cutoff hcut hL using hdata + let ε := Finset.univ.inf' Finset.univ_nonempty eps + let p₀ := Finset.univ.sup cutoff + have hε : 0 < ε := by + apply (Finset.lt_inf'_iff Finset.univ_nonempty).mpr + intro i _ + exact heps i + have hεi (i : Fin k) : ε ≤ eps i := Finset.inf'_le eps (Finset.mem_univ i) + have hpc (i : Fin k) : cutoff i ≤ p₀ := Finset.le_sup (Finset.mem_univ i) + refine ⟨ε, hε, (hεi ⟨0, hk⟩).trans (heps1 _), p₀, + (hcut ⟨0, hk⟩).trans (hpc _), ?_⟩ + filter_upwards [eventually_all.mpr hL] with L hL + intro depth b hsize + have hi := hL depth b hsize + dsimp only at hi ⊢ + intro tierB primes hprimes _ d rinit sl sr fallback childBound pivotBound V outside p _ Dq sets β + primeLo cutoff tier X Δ hiWin φ G global Qμ Qν setsReg cb cd btop lower ggiant favorable + hlen hV hcard hVn hV0 hΔ hΔupper hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb hφ1 hlower hvr hsep hgap + exact hi tierB primes hprimes d rinit sl sr fallback childBound pivotBound V outside p Dq sets β + primeLo cutoff tier X Δ hiWin φ G global Qμ Qν setsReg cb cd btop lower ggiant favorable + hlen hV hcard hVn hV0 hΔ hΔupper hhi hwindow hH hB + hm (fun j => (hpc depth).trans (hp j)) hsets hsetsp hpupper hdlo hdhi + (fun j => (hβ j).trans (hεi depth)) hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb hφ1 hlower hvr hsep hgap + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerCells.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..47877b31b09b014d4ff7e15fc6808f4d01f5e31b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerCells.lean @@ -0,0 +1,135 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.RootCellIntegerComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCells + +namespace OAI + +/-! # The literal moving arithmetic and spectator weights for integer giants -/ + +namespace Ostmann +open scoped BigOperators Classical +open MeasureTheory + +theorem complexIntegerInterval_congr (q a : ℕ) (u v G : ℝ) (w g : ℝ → ℂ) + (h : ∀ n ∈ Finset.Ioc ⌊Real.exp u⌋₊ ⌊Real.exp v⌋₊, + Nat.ModEq q n a → w (Real.log n) = g (Real.log n)) : + complexIntegerInterval q a u v G w = complexIntegerInterval q a u v G g := by + unfold complexIntegerInterval + apply Finset.sum_congr rfl + intro n hn + by_cases hc : Nat.ModEq q n a + · rw [h n hn hc] + · simp only [integerResidueAtom, ite_eq_right hc, Complex.ofReal_zero, mul_zero] + +theorem movingSupportedIntegerInterval_cells {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M : ℕ) + (S : Finset ℝ) (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hS : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ S) + (w : ℕ → ℂ) + (hw : ∀ XL YL, T.ArithmeticSupport value childBound pivotBound XL XR → + T.ArithmeticSupport value childBound pivotBound YL XR → + (XL : ℤ) ≡ (YL : ℤ) [ZMOD M] → + rootCellCode S (XL : ℝ) = rootCellCode S (YL : ℝ) → w XL = w YL) + (u v G : ℝ) (f : ℝ → ℂ) : + complexIntegerInterval M a u v G (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + w ⌊Real.exp y⌋₊) * f y) = + complexIntegerInterval M a u v G (fun y => + movingSupportedCellValue value childBound pivotBound T XR a M S w + (rootCellCode S (Real.exp y)) * f y) := by + apply complexIntegerInterval_congr + intro p hp hpa + have hp0 : (0 : ℝ) < p := by + have : 0 < p := lt_of_le_of_lt (Nat.zero_le _) (Finset.mem_Ioc.mp hp).1 + exact_mod_cast this + rw [Real.exp_log hp0, Nat.floor_natCast] + rw [movingSupportedCellValue_eq value hvalue childBound pivotBound T hf XR a M S hM hS + w hw p (Int.natCast_modEq_iff.mpr hpa)] + +theorem moving_supported_integer_comparison {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hM0 : 0 < M) (u v G : ℝ) (huv : u ≤ v) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) (S : Finset ℝ) + (hS : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ S) + (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (w : ℕ → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hwB : ∀ XL, T.ArithmeticSupport value childBound pivotBound XL XR → ‖w XL‖ ≤ B) + (hw : ∀ XL YL, T.ArithmeticSupport value childBound pivotBound XL XR → + T.ArithmeticSupport value childBound pivotBound YL XR → + (XL : ℤ) ≡ (YL : ℤ) [ZMOD M] → + rootCellCode S (XL : ℝ) = rootCellCode S (YL : ℝ) → w XL = w YL) : + ∃ (s : ℕ → ℝ) (N : ℕ) (d : ℕ → ℂ), + Monotone s ∧ s 0 = u ∧ s N = v ∧ N ≤ S.card + 1 ∧ (∀ j, ‖d j‖ ≤ B) ∧ + ‖complexIntegerInterval M a u v G (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + w ⌊Real.exp y⌋₊) * smoothPolynomialWeight F (Real.exp y)) - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + d j * smoothPolynomialWeight F (Real.exp y) * (integerLogDensity M G y : ℂ)‖ ≤ + 4 * ((S.card + 1 : ℕ) : ℝ) * B * smoothPolynomialBudget F * Real.exp (-G) := by + obtain ⟨s, N, d, hs, hs0, hsN, hN, hd, herr⟩ := root_cell_integer_comparison hM0 u v G huv F S hroots + (movingSupportedCellValue value childBound pivotBound T XR a M S w) B hB + (movingSupportedCellValue_norm value childBound pivotBound T XR a M S w B hB hwB) + refine ⟨s, N, d, hs, hs0, hsN, hN, hd, ?_⟩ + rw [movingSupportedIntegerInterval_cells value hvalue childBound pivotBound T hf XR a M S hM hS w hw] + exact herr + +theorem moving_spectator_integer_comparison {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (B : I → ℝ) (hB : ∀ i ∈ S, 0 ≤ B i) (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hM0 : 0 < M) (u v G : ℝ) (huv : u ≤ v) {k : ℕ} (F : Fin k → ClippedPolynomialFactor) : + ∃ (s : ℕ → ℝ) (N : ℕ) (d : ℕ → ℂ), + Monotone s ∧ s 0 = u ∧ s N = v ∧ + N ≤ (movingTopRootCuts value hvalue childBound pivotBound T hf XR).card + + (∑ i, (F i).polynomial.derivative.natDegree) + 1 ∧ + (∀ j, ‖d j‖ ≤ ∏ i ∈ S, B i ^ (2 ^ n)) ∧ + ‖complexIntegerInterval M a u v G (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + ∏ i ∈ S, movingSlotSpectator value (g i) (D i) T ⌊Real.exp y⌋₊ XR) * + smoothPolynomialWeight F (Real.exp y)) - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + d j * smoothPolynomialWeight F (Real.exp y) * (integerLogDensity M G y : ℂ)‖ ≤ + 4 * (((movingTopRootCuts value hvalue childBound pivotBound T hf XR).card + + (∑ i, (F i).polynomial.derivative.natDegree) + 1 : ℕ) : ℝ) * + (∏ i ∈ S, B i ^ (2 ^ n)) * smoothPolynomialBudget F * Real.exp (-G) := by + let roots := movingPrimeRootCuts value hvalue childBound pivotBound T hf XR F + let w := fun XL => ∏ i ∈ S, movingSlotSpectator value (g i) (D i) T XL XR + have hS : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ roots := + Finset.subset_union_left + have hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ roots := by + intro i r hr + exact Finset.mem_union_right _ (Finset.mem_biUnion.mpr + ⟨i, Finset.mem_univ _, Multiset.mem_toFinset.mpr hr⟩) + have hprod : 0 ≤ ∏ i ∈ S, B i ^ (2 ^ n) := by + apply Finset.prod_nonneg + intro i hi + exact pow_nonneg (hB i hi) _ + have hw : ∀ XL YL, T.ArithmeticSupport value childBound pivotBound XL XR → + T.ArithmeticSupport value childBound pivotBound YL XR → + (XL : ℤ) ≡ (YL : ℤ) [ZMOD M] → + rootCellCode roots (XL : ℝ) = rootCellCode roots (YL : ℝ) → w XL = w YL := by + intro XL YL hX hY hres _ + exact movingSpectatorProduct_modEq q value hvalue g D S T hf M XL XR YL hMq + (hX.integral value hvalue childBound pivotBound T XL XR) + (hY.integral value hvalue childBound pivotBound T YL XR) hres + obtain ⟨s, N, d, hs, hs0, hsN, hN, hd, herr⟩ := root_cell_integer_comparison hM0 u v G huv F + roots hroots (movingSupportedCellValue value childBound pivotBound T XR a M roots w) + (∏ i ∈ S, B i ^ (2 ^ n)) hprod + (movingSupportedCellValue_norm value childBound pivotBound T XR a M roots w _ hprod + (fun XL _ => movingSpectatorProduct_norm q value g D S B hB hg T XL XR)) + have hcard := Nat.add_le_add_right (movingPrimeRootCuts_card value hvalue childBound pivotBound T hf XR F) 1 + refine ⟨s, N, d, hs, hs0, hsN, hN.trans hcard, hd, ?_⟩ + rw [movingSupportedIntegerInterval_cells value hvalue childBound pivotBound T hf XR a M roots hM hS w hw] + apply herr.trans + gcongr + exact smoothPolynomialBudget_nonneg F + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerKernelRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerKernelRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d776b0bacf9dfd0aabe2f74807ad68a969753fb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerKernelRate.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelRates + +namespace OAI + +/-! # Uniform integer comparison for a literal moving-kernel slice -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical SchwartzMap + +theorem moving_integer_error_rate (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ J A : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → + A ≤ Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + 2 * (movingKernelRootBudget n : ℝ) * A * Real.exp (-J) ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [weighted_giant_atom_rate C d, + constant_mul_double_exp_le (2 * (movingKernelRootBudget n : ℝ)) 1 + (13 / 1000) (125 / 10000) (by positivity) (by norm_num) (by norm_num) (by norm_num)] + with L hA hK + intro J A hJ hbudget + calc + _ = 2 * (movingKernelRootBudget n : ℝ) * (A * Real.exp (-J)) := by ring + _ ≤ 2 * (movingKernelRootBudget n : ℝ) * Real.exp (-Real.exp ((13 / 1000 : ℝ) * L)) := + mul_le_mul_of_nonneg_left (hA J A hJ hbudget) (by positivity) + _ ≤ _ := by simpa only [one_mul, neg_mul] using hK + +theorem moving_kernel_integer_rate {σ : Type*} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (coord : Bool) (fixed : ℝ) + (q a : ℕ), 0 < q → ∀ u v J : ℝ, u ≤ v → + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → ∀ c : ℂ, + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let W := movingSmoothPolynomialFactors value T + (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + 2 * ‖c‖ * smoothPolynomialBudget W ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + ‖complexIntegerInterval q a u v J (fun y => c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) - + ∫ y in Set.Ioc u v, (c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) * + (integerLogDensity q J y : ℂ)‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [moving_integer_error_rate n C d] with L hL + intro value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + coord fixed q a hq u v J huv hJ c + dsimp only + intro hbudget + apply (moving_kernel_integer_bound value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip hout coord fixed q a hq u v J huv c).trans + convert hL J _ hJ hbudget using 1; ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerPairRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerPairRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..be2e4e61f21f559b8ea9322849fec334a8621789 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerPairRate.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPairRates + +namespace OAI + +/-! # Uniform integer comparison for a literal moving-kernel slice -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical SchwartzMap + +theorem moving_pair_integer_error_rate (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ J A : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → + A ≤ Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + 4 * (movingKernelRootBudget n : ℝ) * A * Real.exp (-J) ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [weighted_giant_atom_rate C d, + constant_mul_double_exp_le (4 * (movingKernelRootBudget n : ℝ)) 1 + (13 / 1000) (125 / 10000) (by positivity) (by norm_num) (by norm_num) (by norm_num)] + with L hA hK + intro J A hJ hbudget + calc + _ = 4 * (movingKernelRootBudget n : ℝ) * (A * Real.exp (-J)) := by ring + _ ≤ 4 * (movingKernelRootBudget n : ℝ) * Real.exp (-Real.exp ((13 / 1000 : ℝ) * L)) := + mul_le_mul_of_nonneg_left (hA J A hJ hbudget) (by positivity) + _ ≤ _ := by simpa only [one_mul, neg_mul] using hK + +theorem moving_kernelPair_integer_rate {σ : Type*} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (coord : Bool) (fixed : ℝ) + (q a : ℕ), 0 < q → ∀ u v J : ℝ, u ≤ v → + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → ∀ c : ℂ, + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := pairedPolynomialFactors + (movingSmoothPolynomialFactors value (T false) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (movingSmoothPolynomialFactors value (T true) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + 2 * ‖c‖ * smoothPolynomialBudget W ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + ‖complexIntegerInterval q a u v J (fun y => c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) - + ∫ y in Set.Ioc u v, (c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) * + (integerLogDensity q J y : ℂ)‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [moving_pair_integer_error_rate n C d] with L hL + intro value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + coord fixed q a hq u v J huv hJ c + dsimp only + intro hbudget + apply (moving_kernelPair_integer_bound value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip hout coord fixed q a hq u v J huv c).trans + convert hL J _ hJ hbudget using 1 + push_cast + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerRanges.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerRanges.lean new file mode 100644 index 0000000000000000000000000000000000000000..c594d1f7e8a476d22abd57a0e40c6f95ccfaaf6e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegerRanges.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCutoffReserve + +namespace OAI + +/-! # Rounded integer ranges for the actual moving-giant cutoffs -/ + +namespace Ostmann +open Filter +open scoped BigOperators + +theorem movingCutoffExponent_ge_reserve (Bs BD Bz z m : ℝ) (n : ℕ) + (hBs : 0 ≤ Bs) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) (hz : 1 ≤ z) (hm : 0 ≤ m) : + (2 : ℝ) ^ n * Real.sqrt (4 * m) ≤ movingCutoffExponent Bs BD Bz z m n := by + have hlogz := Real.log_nonneg hz + have hs : 0 ≤ ∑ j ∈ Finset.range n, spectatorStepGap BD Bz z ((2 : ℝ) ^ j) m := by + apply Finset.sum_nonneg + intro j _ + have hl := Real.log_nonneg (one_le_pow₀ (by norm_num : (1 : ℝ) ≤ 2) : 1 ≤ (2 : ℝ) ^ j) + unfold spectatorStepGap + positivity + have hb : 0 ≤ spectatorBaseGap Bs z m := by unfold spectatorBaseGap; positivity + unfold movingCutoffExponent + linarith + +/-- The same concrete floor cutoffs give both strict determinant rigidity +and the next-frequency bound, simultaneously at every transfer depth. -/ +theorem eventually_moving_integer_ranges (Bs BD Bz z C : ℝ) + (hBs : 0 ≤ Bs) (hBD : Bs + 1 ≤ BD) (hBz : 8 ≤ Bz) (hz : 1 ≤ z) : + ∀ᶠ m : ℝ in atTop, ∀ n : ℕ, ∀ T : ℝ, ∀ M R : ℕ, + Real.exp (T - C) ≤ M → + Real.exp (T + spectatorStepGap BD Bz z ((2 : ℝ) ^ n) m - C) ≤ R → + 2 * naturalProductCap (T + C) * movingNaturalCutoff Bs BD Bz z m n < R ∧ + 2 * movingNaturalCutoff Bs BD Bz z m n * + naturalProductCap (T + spectatorStepGap BD Bz z ((2 : ℝ) ^ n) m + C) ≤ + movingNaturalCutoff Bs BD Bz z m (n + 1) * M := by + filter_upwards [eventually_ge_atTop (64 : ℝ), + eventually_gt_atTop ((20 / 3 : ℝ) * (Real.log 2 + 2 * C)), + Real.tendsto_sqrt_atTop.eventually (eventually_gt_atTop (Real.log 4 + 2 * C))] + with m hm hlinear hsqrt + intro n T M R hM hR + have hm0 : 0 ≤ m := by linarith + have hr : 1 ≤ (2 : ℝ) ^ n := one_le_pow₀ (by norm_num) + have hdiag := movingCutoff_diagonal_reserve Bs BD Bz z m hBD hBz hz hm n + have hgap : Real.log 2 + 2 * C < + spectatorStepGap BD Bz z ((2 : ℝ) ^ n) m - movingCutoffExponent Bs BD Bz z m n := by + nlinarith [mul_le_mul_of_nonneg_right hr hm0] + have hs4 : Real.sqrt m ≤ Real.sqrt (4 * m) := Real.sqrt_le_sqrt (by linarith) + have hnext : Real.log 4 + 2 * C < + movingCutoffExponent Bs BD Bz z m (n + 1) - + (movingCutoffExponent Bs BD Bz z m n + spectatorStepGap BD Bz z ((2 : ℝ) ^ n) m) := by + rw [movingCutoff_frequency_reserve] + nlinarith [Real.sqrt_nonneg (4 * m)] + have hlog2 : Real.log 2 ≤ movingCutoffExponent Bs BD Bz z m (n + 1) := by + have he := movingCutoffExponent_ge_reserve Bs BD Bz z m (n + 1) hBs + (by linarith) (by linarith) hz hm0 + have hr' : 1 ≤ (2 : ℝ) ^ (n + 1) := one_le_pow₀ (by norm_num) + have hroot : 1 ≤ Real.sqrt (4 * m) := Real.le_sqrt_of_sq_le (by nlinarith) + have hl := Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2) + nlinarith [Real.sqrt_nonneg (4 * m)] + have hfloor (a : ℝ) : (naturalProductCap a : ℝ) ≤ Real.exp a := + Nat.floor_le (Real.exp_pos _).le + have hV : (movingNaturalCutoff Bs BD Bz z m n : ℝ) ≤ + Real.exp (movingCutoffExponent Bs BD Bz z m n) := Nat.floor_le (Real.exp_pos _).le + have hVnext := (natural_exp_cutoff_bounds (movingCutoffExponent Bs BD Bz z m (n + 1)) hlog2).2.2 + constructor + · exact transfer_integer_rigidity_gap _ _ R T _ _ C (hfloor _) hV hR hgap + · exact transfer_integer_frequency_cutoff M _ _ _ T _ _ _ C hM (hfloor _) hV hVnext + (by linarith) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegralFrequencySplit.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegralFrequencySplit.lean new file mode 100644 index 0000000000000000000000000000000000000000..86ba5a3b406e87e2a49c192aca01e4693ee8c0f6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingIntegralFrequencySplit.lean @@ -0,0 +1,149 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeLineGate + +namespace OAI + +/-! # Exact frequency and internal-prime splitting before real restrictions + +All divisions here are integer divisions. Positivity is deliberately left to +the existing real gate. The equivalence recovers integer divisibility from +the two disjoint residue blocks, including at every descendant node. +-/ + +namespace Ostmann +open scoped Classical + +def MovingSlotReversal.SignedIntegralAt {σ : Type*} (s : MovingSlotReversal σ) + (value : σ → ℕ) (x y : ℤ) : Prop := + s.signedNumerator value x y = + s.rootFrequency * (naturalProduct value s.compensationSlots : ℤ) * s.signedPivot value x y + +def MovingSlotData.SignedIntegral {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → Prop + | _, .leaf _ _, _, _ => True + | _, .node s CL CR U left right, x, y => + let step := MovingSlotData.step s CL CR U left right false + let p := step.signedPivot value x y + step.SignedIntegralAt value x y ∧ left.SignedIntegral value p x ∧ right.SignedIntegral value p y + +def movingSignedFrequencyUnits {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → Prop + | _, T@(.leaf _ _), x, y => movingFrequencyLocalUnits T x y + | _, T@(.node s CL CR U left right), x, y => + let p := (MovingSlotData.step s CL CR U left right false).signedPivot value x y + movingFrequencyLocalUnits T x y ∧ + movingSignedFrequencyUnits value left p x ∧ movingSignedFrequencyUnits value right p y + +theorem movingSignedFrequencyUnits_auxiliary {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (x y : ℤ) : + movingSignedFrequencyUnits value T x y ↔ movingSignedAuxiliaryUnits value [] T x y := by + induction T generalizing x y with + | leaf => simp only [movingSignedFrequencyUnits, movingSignedAuxiliaryUnits, + movingFrequencyLocalUnits, movingAuxiliaryLocalUnits, List.prod_nil, Nat.cast_one, + isCoprime_one_right, and_true] + | node s CL CR U left right ihL ihR => + simp only [movingSignedFrequencyUnits, movingSignedAuxiliaryUnits, + movingFrequencyLocalUnits, movingAuxiliaryLocalUnits, List.prod_nil, Nat.cast_one, + isCoprime_one_right, and_true, ihL, ihR] + +theorem MovingSlotReversal.frequencyPivot_signed_modEq {σ : Type*} + (s : MovingSlotReversal σ) (value : σ → ℕ) (R : ℤ) (k : ℕ) + (hs : s.rootFrequency ≠ 0) + (hu : IsCoprime (naturalProduct value s.compensationSlots : ℤ) R) + (x y : ℤ) (hI : s.SignedIntegralAt value x y) : + s.frequencyPivot value R k x y ≡ s.signedPivot value x y [ZMOD R ^ k] := by + unfold frequencyPivot + rw [show s.signedNumerator value x y = s.rootFrequency * + ((naturalProduct value s.compensationSlots : ℤ) * s.signedPivot value x y) by + simpa only [SignedIntegralAt, mul_assoc] using hI] + rw [Int.mul_ediv_cancel_left _ hs] + simpa only [one_mul, mul_assoc, mul_comm, mul_left_comm] using + (coprime_bezout_inverse_modEq _ R hu k).mul_right (s.signedPivot value x y) + +theorem pairwise_coprime_list_prod_int_dvd_iff (U : List ℕ) + (hU : U.Pairwise Nat.Coprime) (N : ℤ) : + (U.prod : ℤ) ∣ N ↔ ∀ b ∈ U, (b : ℤ) ∣ N := by + simp only [Int.natCast_dvd, pairwise_coprime_list_prod_dvd_iff U hU] + +theorem MovingSlotReversal.signedIntegral_of_prime_lines {σ : Type*} + (s : MovingSlotReversal σ) (value : σ → ℕ) (R : ℤ) + (hsR : s.rootFrequency ∣ R) + (hu : IsCoprime (naturalProduct value s.compensationSlots : ℤ) R) + (hp : (s.compensationSlots.map value).Pairwise Nat.Coprime) (x y : ℤ) + (hs : s.rootFrequency ∣ s.signedNumerator value x y) + (hlines : ∀ i ∈ s.compensationSlots, (value i : ℤ) ∣ s.signedNumerator value x y) : + s.SignedIntegralAt value x y := by + have hU : (naturalProduct value s.compensationSlots : ℤ) ∣ s.signedNumerator value x y := by + apply (pairwise_coprime_list_prod_int_dvd_iff _ hp _).mpr + intro b hb + obtain ⟨i, hi, rfl⟩ := List.mem_map.mp hb + exact hlines i hi + have hc : IsCoprime s.rootFrequency (naturalProduct value s.compensationSlots : ℤ) := + (hu.of_isCoprime_of_dvd_right hsR).symm + have hd := hc.mul_dvd hs hU + exact (Int.mul_ediv_cancel' hd).symm + +/-- The frequency block and the simultaneous prime lines give precisely +the original signed integer recursion with its subtree-frequency unit tests. +This is an equivalence on every top pair, before the real support is imposed. -/ +theorem moving_frequency_internal_split {σ : Type*} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) (R : ℤ) + (hsmall : ∀ i, IsCoprime (value i : ℤ) R) + {n : ℕ} (T : MovingSlotData σ n) (hlevels : T.Levels tier) + (hf : T.Frequencies (· ≠ 0)) + (hfmod : ∀ i, T.Frequencies (fun f => (f : ZMod (value i)) ≠ 0)) + (hR : T.frequencyProduct ∣ R) (hdistinct : T.CompensationDistinct value) (x y : ℤ) : + movingFrequencyGate value R T x y ∧ movingPrimeLineSupport value T x y ↔ + T.SignedIntegral value x y ∧ movingSignedFrequencyUnits value T x y := by + induction T generalizing x y with + | leaf s C => + simp only [movingFrequencyGate, MovingSlotData.SignedIntegral, movingSignedFrequencyUnits, + movingPrimeLineSupport, MovingSlotData.occurrences, List.not_mem_nil, + IsEmpty.forall_iff, implies_true, and_true, true_and] + | @node n s CL CR U left right ihL ihR => + let step := MovingSlotData.step s CL CR U left right false + let p := step.signedPivot value x y + let r := step.frequencyPivot value R (n + 1) x y + have hd := MovingSlotData.frequencyProduct_node_dvd s CL CR U left right R hR + have hU : IsCoprime (MovingSlotReversal.naturalProduct value U : ℤ) R := + movingNaturalProduct_coprime value U R (fun i _ => hsmall i) + have hstep (hI : step.SignedIntegralAt value x y) : + movingFrequencyGate value R left r x ↔ movingFrequencyGate value R left p x := by + exact movingFrequencyGate_modEq value R left hf.2.1 hd.2.1 r x p x + (step.frequencyPivot_signed_modEq value R (n + 1) hf.1 hU x y hI) (Int.ModEq.refl _) + have hstepR (hI : step.SignedIntegralAt value x y) : + movingFrequencyGate value R right r y ↔ movingFrequencyGate value R right p y := by + exact movingFrequencyGate_modEq value R right hf.2.2 hd.2.2 r y p y + (step.frequencyPivot_signed_modEq value R (n + 1) hf.1 hU x y hI) (Int.ModEq.refl _) + have hline (hI : step.SignedIntegralAt value x y) := + movingPrimeLineSupport_node_of_levels tier value hprime hdisjoint s CL CR U left right + hlevels hfmod x y p hI + have hl := ihL hlevels.2.2.2.1 hf.2.1 (fun i => (hfmod i).2.1) hd.2.1 hdistinct.2.1 p x + have hr := ihR hlevels.2.2.2.2 hf.2.2 (fun i => (hfmod i).2.2) hd.2.2 hdistinct.2.2 p y + constructor + · rintro ⟨hfreq, hlines⟩ + have hroot := movingPrimeLineSupport_root value s CL CR U left right x y hlines + have hI : step.SignedIntegralAt value x y := + step.signedIntegral_of_prime_lines value R hd.1 hU hdistinct.1 x y hfreq.2.1 hroot + have hlines' := (hline hI).mp hlines + have hL := hl.mp ⟨(hstep hI).mp hfreq.2.2.1, hlines'.2.1⟩ + have hR := hr.mp ⟨(hstepR hI).mp hfreq.2.2.2, hlines'.2.2⟩ + exact ⟨⟨hI, hL.1, hR.1⟩, hfreq.1, hL.2, hR.2⟩ + · rintro ⟨⟨hI, hIL, hIR⟩, hunit, hUL, hUR⟩ + have hL := hl.mpr ⟨hIL, hUL⟩ + have hR := hr.mpr ⟨hIR, hUR⟩ + have hdiv : s ∣ step.signedNumerator value x y := + ⟨_, by simpa only [MovingSlotReversal.SignedIntegralAt, step, + MovingSlotData.step, mul_assoc] using hI⟩ + have hroot : ∀ i ∈ U, (value i : ℤ) ∣ step.signedNumerator value x y := by + intro i hi + have hp : value i ∣ MovingSlotReversal.naturalProduct value U := + List.dvd_prod (List.mem_map.mpr ⟨i, hi, rfl⟩) + rw [hI] + exact dvd_mul_of_dvd_left (dvd_mul_of_dvd_right (Int.natCast_dvd_natCast.mpr hp) _) _ + exact ⟨⟨hunit, hdiv, (hstep hI).mpr hL.1, (hstepR hI).mpr hR.1⟩, + (hline hI).mpr ⟨hroot, hL.2, hR.2⟩⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalAverageError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalAverageError.lean new file mode 100644 index 0000000000000000000000000000000000000000..743e3b763c842204f01d2bfb883ff7ff68c92454 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalAverageError.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalFiber +import OAI.NumberTheory.Ostmann.Construction.ExternalSquareCoordinates + +namespace OAI + +/-! # The relative square error in the original local Haar average -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingInternalPairFactor_fiber_norm_le {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] + (x₀ y₀ : ZMod p) (v : SquareLiftPairs p x₀ y₀) : + ‖movingInternalPairFactor value T p v.1.val v.2.val‖ ≤ + ‖movingInternalBaseFactor value T p x₀ y₀‖ := by + rw [movingInternalPairFactor_fiber, norm_mul] + apply mul_le_of_le_one_right (norm_nonneg _) + split_ifs <;> norm_num + +theorem movingInternalPairFactor_normalized_fiber_norm_le {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] + (x₀ y₀ : ZMod p) : + ‖((p : ℂ) ^ 2)⁻¹ * + (∑ v : SquareLiftPairs p x₀ y₀, movingInternalPairFactor value T p v.1.val v.2.val)‖ ≤ + ‖movingInternalBaseFactor value T p x₀ y₀‖ := by + have hp : (p : ℝ) ^ 2 ≠ 0 := pow_ne_zero _ (by exact_mod_cast (Fact.out : p.Prime).ne_zero) + rw [norm_mul, norm_inv, norm_pow, Complex.norm_natCast] + calc + _ ≤ ((p : ℝ) ^ 2)⁻¹ * ∑ _v : SquareLiftPairs p x₀ y₀, + ‖movingInternalBaseFactor value T p x₀ y₀‖ := by + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (sq_nonneg _)) + exact (norm_sum_le _ _).trans (Finset.sum_le_sum fun v _ => + movingInternalPairFactor_fiber_norm_le value T p x₀ y₀ v) + _ = _ := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, + squareLiftPairs_card, Nat.cast_pow] + rw [← mul_assoc, inv_mul_cancel₀ hp, one_mul] + +theorem movingInternalPairFactor_normalized_fiber_error {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) [Fact p.Prime] + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) + (x₀ y₀ : ZMod p) (hy : y₀ ≠ 0) : + ‖((p : ℂ) ^ 2)⁻¹ * + (∑ v : SquareLiftPairs p x₀ y₀, movingInternalPairFactor value T p v.1.1 v.2.1) - + movingInternalBaseFactor value T p x₀ y₀‖ ≤ + (2 * (2 ^ n - 1 : ℕ) / (p : ℝ)) * ‖movingInternalBaseFactor value T p x₀ y₀‖ := by + let A := ∀ j : MovingPrimeOccurrences value T p, + let φ := MovingSlotReversal.naturalReduction p value + let L := movingPrimeOccurrenceLine value T p j + φ L.a * x₀ + φ L.b * y₀ = 0 + by_cases h : A + · have hval : movingInternalBaseFactor value T p x₀ y₀ = 1 := ite_eq_left h + have hb := movingInternalPairFactor_fiber_error tier value hprime hdisjoint T hlevels p hf x₀ y₀ hy h + have hp : (p : ℂ) ^ 2 ≠ 0 := pow_ne_zero _ (by exact_mod_cast (Fact.out : p.Prime).ne_zero) + have he (z : ℂ) : ((p : ℂ) ^ 2)⁻¹ * z - 1 = ((p : ℂ) ^ 2)⁻¹ * (z - (p : ℂ) ^ 2) := by + rw [mul_sub, inv_mul_cancel₀ hp] + rw [hval, norm_one, mul_one, he, norm_mul, norm_inv, norm_pow, Complex.norm_natCast] + exact hb + · have hval : movingInternalBaseFactor value T p x₀ y₀ = 0 := ite_eq_right h + have hz (v : SquareLiftPairs p x₀ y₀) : movingInternalPairFactor value T p v.1.1 v.2.1 = 0 := by + rw [movingInternalPairFactor_fiber, hval, zero_mul] + simp only [hz, Finset.sum_const_zero, mul_zero, hval, sub_self, norm_zero, le_refl] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalBaseAverage.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalBaseAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..a17599e1a3df7dca4f8b779b4306b36e23ca6ef1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalBaseAverage.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeOccurrences +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticLineIntegration + +namespace OAI + +/-! # Actual internal-prime averages after removing their square exclusions -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingInternalBaseFactor {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) + (x y : ZMod p) : ℂ := + if ∀ j : MovingPrimeOccurrences value T p, + let φ := MovingSlotReversal.naturalReduction p value + let L := movingPrimeOccurrenceLine value T p j + φ L.a * x + φ L.b * y = 0 then 1 else 0 + +/-- The field average is the exact simultaneous line probability for all +occurrences of the prime in both original histories. -/ +theorem movingInternalBaseFactor_average {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : + (Fintype.card (ZMod p × (ZMod p)ˣ) : ℂ)⁻¹ * + (∑ z : ZMod p × (ZMod p)ˣ, movingInternalBaseFactor value T p z.1 z.2) = + (internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) : ℂ) := by + classical + let P := fun z : ZMod p × (ZMod p)ˣ => ∀ j : MovingPrimeOccurrences value T p, + let φ := MovingSlotReversal.naturalReduction p value + let L := movingPrimeOccurrenceLine value T p j + φ L.a * z.1 + φ L.b * z.2 = 0 + have hs : (∑ z : ZMod p × (ZMod p)ˣ, movingInternalBaseFactor value T p z.1 z.2) = + (Fintype.card {z : ZMod p × (ZMod p)ˣ // P z} : ℂ) := by + rw [Fintype.card_subtype] + simp only [movingInternalBaseFactor, P, ← Finset.sum_filter, Finset.sum_const, + nsmul_eq_mul, mul_one] + dsimp only [P] at hs + rw [hs] + simp only [internalLineProbability, ite_true, Complex.ofReal_div, Complex.ofReal_natCast] + rw [mul_comm, ← div_eq_mul_inv] + simp only [← Nat.card_eq_fintype_card] + +/-- All rows and all cleared denominators in this line probability come from +the actual moving trees. Thus the polynomial flags used later are exact. -/ +theorem movingInternalBaseProbability_eq_flags {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) [Fact p.Prime] + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) + (base : MovingPrimeOccurrences value T p) : + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) = + internalLineFlagWeight true p (fun s => arithmeticTestFlag + (MovingSlotReversal.naturalReduction p value + (lineTestPolynomials (movingPrimeOccurrenceLine value T p) base s) = 0)) := by + classical + let φ := MovingSlotReversal.naturalReduction p value + let L := movingPrimeOccurrenceLine value T p + have hd := movingPrimeOccurrenceLine_denominator_ne_zero tier value hprime hdisjoint T hlevels p hf + have hr := movingPrimeOccurrenceLine_nonzero tier value hprime hdisjoint T hlevels p hf base + have he (x y : ZMod p) : (∀ j, φ (L j).a * x + φ (L j).b * y = 0) ↔ + (∀ j, ((L j).normalized φ).1 * x + ((L j).normalized φ).2 * y = 0) := by + apply forall_congr' + intro j + simp only [PolynomialGiantLine.normalized] + rw [div_mul_eq_mul_div, div_mul_eq_mul_div, ← add_div, div_eq_zero_iff, or_iff_left (hd j)] + have hc := Nat.card_congr (Equiv.subtypeEquivRight + (fun z : ZMod p × (ZMod p)ˣ => he z.1 z.2)) + have hr' : ((L base).normalized φ).1 ≠ 0 ∨ ((L base).normalized φ).2 ≠ 0 := by + have hz := (L base).normalized_zero_iff φ (hd base) + exact hr.imp (fun h h0 => h (hz.1.mp h0)) (fun h h0 => h (hz.2.mp h0)) + have hext := external_lineSystem_integral_eq_flags L base φ hd hr' + unfold internalLineProbability + simp only [ite_true, ← Nat.card_eq_fintype_card] + simp only [← Nat.card_eq_fintype_card] at hext + change (Nat.card {z : ZMod p × (ZMod p)ˣ // + ∀ j, φ (L j).a * z.1 + φ (L j).b * z.2 = 0} : ℝ) / + Nat.card (ZMod p × (ZMod p)ˣ) = _ + rw [hc] + exact hext + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalErrorRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalErrorRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..f7092355ddead9d61534527a9798d9cbecd0a16e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalErrorRate.lean @@ -0,0 +1,201 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticErrorRates +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCostRate + +namespace OAI + +/-! # The actual internal arithmetic error at the source's prime scales -/ + +namespace Ostmann +open Filter + +noncomputable def movingInternalArithmeticError (n c d : ℕ) (F U α β V : ℝ) : ℝ := + ((2 * (2 ^ n - 1 : ℕ)) * c * Real.exp (-V)) + + 2 * ((c * (2 + 2 * (2 ^ n - 1)) : ℕ) : ℝ) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β) + +/-- The logarithm of the polynomial height, before the prime-divisor count. +Only the sampled-coordinate lower cutoff will divide this expression. -/ +theorem moving_internal_log_height (n d : ℕ) (F U C D L : ℝ) + (hF : 1 ≤ F) (hU : 1 ≤ U) (hC : 0 ≤ C) (hD : 0 ≤ D) (hL : 1 ≤ L) + (hfreq : Real.log F ≤ C * L) (hdegree : (d : ℝ) ≤ D * L) + (hvalue : Real.log U ≤ Real.exp ((12 / 1000 : ℝ) * L)) : + Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) ≤ + (1 + 2 * ((n : ℝ) + 1) * (1 + C + D)) * L * + Real.exp ((12 / 1000 : ℝ) * L) := by + have hF0 : 0 < F := lt_of_lt_of_le (by norm_num) hF + have hU0 : 0 < U := lt_of_lt_of_le (by norm_num) hU + have hexp : 1 ≤ Real.exp ((12 / 1000 : ℝ) * L) := + Real.one_le_exp_iff.mpr (by linarith) + have heq : Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) = + Real.log 2 + 2 * ((n : ℝ) + 1) * + (Real.log 2 + Real.log F + (d : ℝ) * Real.log U) := by + rw [Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) (by positivity), Real.log_pow, + Real.log_pow, Real.log_mul (by norm_num : (2 : ℝ) ≠ 0) (by positivity), + Real.log_mul hF0.ne' (pow_ne_zero _ hU0.ne'), Real.log_pow] + push_cast + ring + have hlog2 : Real.log 2 ≤ 1 := by + linarith [Real.log_le_sub_one_of_pos (show (0 : ℝ) < 2 by norm_num)] + have hd : (d : ℝ) * Real.log U ≤ D * L * Real.exp ((12 / 1000 : ℝ) * L) := + mul_le_mul hdegree hvalue (Real.log_nonneg hU) (by positivity) + have hCL : C * L ≤ C * L * Real.exp ((12 / 1000 : ℝ) * L) := + le_mul_of_one_le_right (by positivity) hexp + have hunit : 1 ≤ L * Real.exp ((12 / 1000 : ℝ) * L) := + one_le_mul_of_one_le_of_one_le hL hexp + have hinn : Real.log 2 + Real.log F + (d : ℝ) * Real.log U ≤ + (1 + C + D) * L * Real.exp ((12 / 1000 : ℝ) * L) := by + nlinarith + rw [heq] + have hm := mul_le_mul_of_nonneg_left hinn + (show 0 ≤ 2 * ((n : ℝ) + 1) by positivity) + nlinarith + +/-- The source's three internal errors have a common exponential saving. +The prime-divisor term is evaluated with the internal-prime cutoff. -/ +theorem moving_internal_error_small (n c : ℕ) (C D E : ℝ) + (hC : 0 ≤ C) (hD : 0 ≤ D) (hE : 0 ≤ E) : + ∀ᶠ L : ℝ in atTop, ∀ (d : ℕ) (F U α β : ℝ), + 1 ≤ F → 1 ≤ U → 0 ≤ α → + α ≤ Real.exp (E * L - Real.exp ((39 / 10000 : ℝ) * L)) → 0 ≤ β → + Real.log F ≤ C * L → (d : ℝ) ≤ D * L → + Real.log U ≤ Real.exp ((12 / 1000 : ℝ) * L) → + β ≤ Real.exp (E * L - Real.exp ((1 / 100 : ℝ) * L)) → + movingInternalArithmeticError n c d F U α β (Real.exp ((1 / 100 : ℝ) * L)) ≤ + Real.exp (-((1 / 2 : ℝ) * Real.exp ((39 / 10000 : ℝ) * L))) := by + let K : ℝ := 1 + 2 * ((n : ℝ) + 1) * (1 + C + D) + let a : ℝ := (2 * (2 ^ n - 1 : ℕ)) * c + let b : ℝ := 2 * (c * (2 + 2 * (2 ^ n - 1)) : ℕ) + let H : ℝ := a + b * (2 * ((n : ℝ) + 1) * D + K) + have hK : 0 ≤ K := by dsimp only [K]; positivity + have ha : 0 ≤ a := by dsimp only [a]; positivity + have hb : 0 ≤ b := by dsimp only [b]; positivity + have hH : 0 ≤ H := by dsimp only [H]; positivity + have hrate := arithmetic_exponent_absorption 0 (39 / 10000) 0 + (H + E + 12 / 1000) (1 / 2) 1 + (by norm_num) (by norm_num) (by norm_num) (by norm_num) + filter_upwards [hrate, eventually_ge_atTop (1 : ℝ)] with L hrate hL + intro d F U α β hF hU hα0 hα hβ hfreq hdegree hvalue hβbound + have hheight := moving_internal_log_height n d F U C D L hF hU hC hD hL hfreq hdegree hvalue + have hV : 1 ≤ Real.exp ((1 / 100 : ℝ) * L) := + Real.one_le_exp_iff.mpr (by linarith) + have hheight0 : 0 ≤ Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) := by + apply Real.log_nonneg + have hbase : 1 ≤ 2 * (F * U ^ d) := by + have := one_le_mul_of_one_le_of_one_le hF (one_le_pow₀ hU (n := d)) + linarith + have := one_le_pow₀ (one_le_pow₀ hbase (n := n + 1)) (n := 2) + linarith + have hquot : Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / + Real.exp ((1 / 100 : ℝ) * L) ≤ K * L * Real.exp ((12 / 1000 : ℝ) * L) := + (div_le_self hheight0 hV).trans hheight + have hdeg : ((2 * ((n + 1) * d) : ℕ) : ℝ) ≤ 2 * ((n : ℝ) + 1) * D * L := by + push_cast + have hh := mul_le_mul_of_nonneg_left hdegree (show 0 ≤ 2 * ((n : ℝ) + 1) by positivity) + nlinarith + have hsave : Real.exp ((39 / 10000 : ℝ) * L) ≤ Real.exp ((1 / 100 : ℝ) * L) := + Real.exp_le_exp.mpr (by linarith) + have hβcommon : β ≤ Real.exp (E * L - Real.exp ((39 / 10000 : ℝ) * L)) := + hβbound.trans (Real.exp_le_exp.mpr (by linarith)) + have hexp : 1 ≤ Real.exp ((12 / 1000 : ℝ) * L) := + Real.one_le_exp_iff.mpr (by linarith) + have hunit : 1 ≤ L * Real.exp ((12 / 1000 : ℝ) * L) := + one_le_mul_of_one_le_of_one_le hL hexp + have he0 : 0 ≤ E * L := mul_nonneg hE (by linarith) + have he : Real.exp (-Real.exp ((1 / 100 : ℝ) * L)) ≤ + Real.exp (E * L - Real.exp ((39 / 10000 : ℝ) * L)) := + Real.exp_le_exp.mpr (by linarith) + have hterms : + a * Real.exp (-Real.exp ((1 / 100 : ℝ) * L)) + + b * (((2 * ((n + 1) * d) : ℕ) : ℝ) * α + + Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / + Real.exp ((1 / 100 : ℝ) * L) * β) ≤ + H * L * Real.exp ((12 / 1000 : ℝ) * L) * + Real.exp (E * L - Real.exp ((39 / 10000 : ℝ) * L)) := by + have hdeg' : 2 * ((n : ℝ) + 1) * D * L ≤ + 2 * ((n : ℝ) + 1) * D * L * Real.exp ((12 / 1000 : ℝ) * L) := + le_mul_of_one_le_right (by positivity) hexp + have hαterm := mul_le_mul hdeg hα hα0 (by positivity) + have hβterm := mul_le_mul hquot hβcommon hβ (by positivity) + have hsum := add_le_add hαterm hβterm + have hsum' : + ((2 * ((n + 1) * d) : ℕ) : ℝ) * α + + Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / + Real.exp ((1 / 100 : ℝ) * L) * β ≤ + (2 * ((n : ℝ) + 1) * D * L + K * L * Real.exp ((12 / 1000 : ℝ) * L)) * + Real.exp (E * L - Real.exp ((39 / 10000 : ℝ) * L)) := + hsum.trans_eq (by ring) + have hbm := mul_le_mul_of_nonneg_left + (hsum'.trans (mul_le_mul_of_nonneg_right (add_le_add hdeg' le_rfl) (Real.exp_nonneg _))) hb + have ham := mul_le_mul_of_nonneg_left he ha + have ha' := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hunit ha) + (Real.exp_nonneg (E * L - Real.exp ((39 / 10000 : ℝ) * L))) + simp only [mul_one] at ha' + exact (add_le_add (ham.trans ha') hbm).trans_eq (by dsimp only [H]; ring) + change a * _ + b * _ ≤ _ + apply hterms.trans + have hpref : H * L ≤ Real.exp (H * L) := by + linarith [Real.add_one_le_exp (H * L)] + have hh := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right hpref (Real.exp_nonneg ((12 / 1000 : ℝ) * L))) + (Real.exp_nonneg (E * L - Real.exp ((39 / 10000 : ℝ) * L))) + apply hh.trans + simp only [← Real.exp_add] + apply Real.exp_le_exp.mpr + simp only [pow_one, zero_mul, Real.exp_zero, mul_one] at hrate + have : (H + E + 12 / 1000) * L ≤ (1 / 2 : ℝ) * Real.exp ((39 / 10000 : ℝ) * L) := by + have hc : 0 ≤ (H + E + 12 / 1000) * L := by positivity + nlinarith + linarith + +/-- Summing equality patterns and paying the true pointwise kernel/spectator +cost still leaves the stated internal-prime error. -/ +theorem moving_internal_error_with_cost (n c : ℕ) (C D E Cprior B : ℝ) + (hC : 0 ≤ C) (hD : 0 ≤ D) (hE : 0 ≤ E) (hCprior : 1 ≤ Cprior) (_hB : 0 ≤ B) : + ∀ᶠ L : ℝ in atTop, ∀ (d : ℕ) (F U α β : ℝ), + 1 ≤ F → 1 ≤ U → 0 ≤ α → + α ≤ Real.exp (E * L - Real.exp ((39 / 10000 : ℝ) * L)) → 0 ≤ β → + Real.log F ≤ C * L → (d : ℝ) ≤ D * L → + Real.log U ≤ Real.exp ((12 / 1000 : ℝ) * L) → + β ≤ Real.exp (E * L - Real.exp ((1 / 100 : ℝ) * L)) → + ((2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) * + (max 2 (Real.exp (Cprior * L))) ^ (4 * n * 2 ^ n)) * + Real.exp (B * L ^ 2 + B * L * Real.exp ((1 / 1000 : ℝ) * L)) * + movingInternalArithmeticError n c d F U α β (Real.exp ((1 / 100 : ℝ) * L)) ≤ + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + let J : ℝ := ((4 * n * 2 ^ n) ^ 2 + 4 * n * 2 ^ n : ℕ) + let B' := B + J * Cprior + filter_upwards [moving_internal_error_small n c C D E hC hD hE, + arithmetic_error_absorption (1 / 1000) (39 / 10000) (2 / 1000) B' (1 / 2) 2 + (by norm_num) (by norm_num) (by norm_num) (by norm_num), + eventually_ge_atTop (1 : ℝ)] with L hsmall hcost hL + intro d F U α β hF hU hα0 hα hβ hfreq hdegree hvalue hβbound + have hJ : 0 ≤ J := by positivity + have hJL : J * Cprior * L ≤ J * Cprior * L ^ 2 := by + have hC0 : 0 ≤ Cprior := by linarith + exact mul_le_mul_of_nonneg_left (by nlinarith : L ≤ L ^ 2) (mul_nonneg hJ hC0) + have hrest : B * L * Real.exp ((1 / 1000 : ℝ) * L) ≤ + B' * L * Real.exp ((1 / 1000 : ℝ) * L) := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg _) + dsimp only [B'] + nlinarith [mul_nonneg hJ (show 0 ≤ Cprior by linarith)] + have hbudget : + ((2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) * + (max 2 (Real.exp (Cprior * L))) ^ (4 * n * 2 ^ n)) * + Real.exp (B * L ^ 2 + B * L * Real.exp ((1 / 1000 : ℝ) * L)) ≤ + Real.exp (B' * L ^ 2 + B' * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + apply (mul_le_mul_of_nonneg_right + (movingPattern_total_cost_le_exp n Cprior L hCprior hL) (Real.exp_nonneg _)).trans + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + dsimp only [B'] + nlinarith + have hs := hsmall d F U α β hF hU hα0 hα hβ hfreq hdegree hvalue hβbound + exact ((mul_le_mul_of_nonneg_left hs (by positivity)).trans + (mul_le_mul_of_nonneg_right hbudget (Real.exp_nonneg _))).trans + (by simpa only [neg_mul] using hcost) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalFiber.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalFiber.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1958afc967a71129b59ee96016fac893ca731fe --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalFiber.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairSquareLoss +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalBaseAverage +import OAI.NumberTheory.Ostmann.Construction.ExternalSquareFibers + +namespace OAI + +/-! # Relative local square loss above the actual simultaneous line system -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingInternalPairFactor_fiber {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) + (x₀ y₀ : ZMod p) (v : SquareLiftPairs p x₀ y₀) : + movingInternalPairFactor value T p v.1.1 v.2.1 = + movingInternalBaseFactor value T p x₀ y₀ * + (if ∀ j : MovingPrimeOccurrences value T p, + let φ := MovingSlotReversal.naturalReduction (p ^ 2) value + let L := movingPrimeOccurrenceLine value T p j + φ L.a * v.1.1 + φ L.b * v.2.1 ≠ 0 then 1 else 0) := by + let A := ∀ j : MovingPrimeOccurrences value T p, + let φ := MovingSlotReversal.naturalReduction p value + let L := movingPrimeOccurrenceLine value T p j + φ L.a * x₀ + φ L.b * y₀ = 0 + let B := ∀ j : MovingPrimeOccurrences value T p, + let φ := MovingSlotReversal.naturalReduction (p ^ 2) value + let L := movingPrimeOccurrenceLine value T p j + φ L.a * v.1.1 + φ L.b * v.2.1 ≠ 0 + have hs : (∀ side, movingInternalLocalSupport value (T side) p v.1.1 v.2.1) ↔ A ∧ B := by + rw [movingInternalLocalSupport_occurrences] + simp only [map_add, map_mul, naturalReduction_square, v.1.property, v.2.property] + exact forall_and + change (if ∀ side, movingInternalLocalSupport value (T side) p v.1.1 v.2.1 then 1 else 0) = + (if A then 1 else 0) * (if B then 1 else 0) + by_cases ha : A + · by_cases hb : B + · simp only [ite_eq_left (hs.mpr ⟨ha, hb⟩), ite_eq_left ha, ite_eq_left hb, mul_one] + · simp only [ite_eq_right (fun h => hb (hs.mp h).2), ite_eq_left ha, ite_eq_right hb, mul_zero] + · simp only [ite_eq_right (fun h => ha (hs.mp h).1), ite_eq_right ha, zero_mul] + +/-- The square loss is relative to the base line event. The number of +forbidden zero lifts is bounded by the number of nodes in the two histories. -/ +theorem movingInternalPairFactor_fiber_error {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) [Fact p.Prime] + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) + (x₀ y₀ : ZMod p) (hy : y₀ ≠ 0) + (hbase : ∀ j : MovingPrimeOccurrences value T p, + let φ := MovingSlotReversal.naturalReduction p value + let L := movingPrimeOccurrenceLine value T p j + φ L.a * x₀ + φ L.b * y₀ = 0) : + ((p : ℝ) ^ 2)⁻¹ * + ‖(∑ v : SquareLiftPairs p x₀ y₀, movingInternalPairFactor value T p v.1.1 v.2.1) - + (p : ℂ) ^ 2‖ ≤ 2 * (2 ^ n - 1 : ℕ) / (p : ℝ) := by + let J := MovingPrimeOccurrences value T p + let φ := MovingSlotReversal.naturalReduction (p ^ 2) value + let L := movingPrimeOccurrenceLine value T p + let bad := fun v : SquareLiftPairs p x₀ y₀ => ∃ j : J, φ (L j).a * v.1.1 + φ (L j).b * v.2.1 = 0 + have hr (j : J) : squareReduction p (φ (L j).a) ≠ 0 ∨ squareReduction p (φ (L j).b) ≠ 0 := by + simp only [φ, naturalReduction_square] + exact movingPrimeOccurrenceLine_nonzero tier value hprime hdisjoint T hlevels p hf j + have hlocal := square_lift_nonzero_rows_removed_mass_le + (fun j : J => φ (L j).a) (fun j : J => φ (L j).b) x₀ y₀ hy hr + (by simpa only [φ, naturalReduction_square] using hbase) + (fun _ => (1 : ℂ)) 1 (by norm_num) (by simp) + have hid (v : SquareLiftPairs p x₀ y₀) : + movingInternalPairFactor value T p v.1.1 v.2.1 - 1 = -(if bad v then 1 else 0) := by + rw [movingInternalPairFactor_on_fiber value T p x₀ y₀ hbase] + change (if ∀ j : J, φ (L j).a * v.1.1 + φ (L j).b * v.2.1 ≠ 0 then 1 else 0) - 1 = + -(if bad v then 1 else 0) + by_cases h : bad v + · have hn : ¬ ∀ j : J, φ (L j).a * v.1.1 + φ (L j).b * v.2.1 ≠ 0 := by + obtain ⟨j, hj⟩ := h + exact fun hall => hall j hj + simp only [ite_eq_right hn, ite_eq_left h, zero_sub] + · have hg : ∀ j : J, φ (L j).a * v.1.1 + φ (L j).b * v.2.1 ≠ 0 := not_exists.mp h + simp only [ite_eq_left hg, ite_eq_right h, sub_self, neg_zero] + have hsum : (∑ v : SquareLiftPairs p x₀ y₀, movingInternalPairFactor value T p v.1.1 v.2.1) - + (p : ℂ) ^ 2 = -(∑ v ∈ Finset.univ.filter bad, (1 : ℂ)) := by + calc + _ = ∑ v : SquareLiftPairs p x₀ y₀, (movingInternalPairFactor value T p v.1.1 v.2.1 - 1) := by + rw [Finset.sum_sub_distrib] + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one, squareLiftPairs_card, Nat.cast_pow] + _ = ∑ v : SquareLiftPairs p x₀ y₀, -(if bad v then 1 else 0) := Finset.sum_congr rfl (fun v _ => hid v) + _ = _ := by rw [Finset.sum_neg_distrib, Finset.sum_filter] + rw [hsum, norm_neg] + have hbound : (Fintype.card J : ℝ) / p ≤ 2 * (2 ^ n - 1 : ℕ) / (p : ℝ) := by + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact_mod_cast movingPrimeOccurrences_card value T p + have he : ((p : ℝ) ^ 2)⁻¹ * ‖∑ v ∈ Finset.univ.filter bad, (1 : ℂ)‖ ≤ + (Fintype.card J : ℝ) / p := by + simpa only [bad, φ, L, J, one_mul, div_eq_mul_inv, mul_comm] using hlocal + exact he.trans hbound + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalHaarError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalHaarError.lean new file mode 100644 index 0000000000000000000000000000000000000000..e14f09b06622588fc13621a635d44358c0c0b6ae --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalHaarError.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalAverageError + +namespace OAI + +/-! # Averaging the relative square loss under the original mixed Haar law -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingInternalPairFactor_haar_norm_le {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : + ‖(Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + (∑ z : ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ, movingInternalPairFactor value T p z.1 z.2)‖ ≤ + (Fintype.card (ZMod p × (ZMod p)ˣ) : ℝ)⁻¹ * + ∑ z : ZMod p × (ZMod p)ˣ, ‖movingInternalBaseFactor value T p z.1 z.2‖ := by + rw [externalSquare_raw_average p (movingInternalPairFactor value T p), norm_mul, + norm_inv, Complex.norm_natCast] + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (Nat.cast_nonneg _)) + exact (norm_sum_le _ _).trans (Finset.sum_le_sum fun z _ => + movingInternalPairFactor_normalized_fiber_norm_le value T p z.1 z.2) + +theorem movingInternalPairFactor_haar_error {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) [Fact p.Prime] + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) : + ‖(Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + (∑ z : ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ, movingInternalPairFactor value T p z.1 z.2) - + (Fintype.card (ZMod p × (ZMod p)ˣ) : ℂ)⁻¹ * + (∑ z : ZMod p × (ZMod p)ˣ, movingInternalBaseFactor value T p z.1 z.2)‖ ≤ + (2 * (2 ^ n - 1 : ℕ) / (p : ℝ)) * + ((Fintype.card (ZMod p × (ZMod p)ˣ) : ℝ)⁻¹ * + ∑ z : ZMod p × (ZMod p)ˣ, ‖movingInternalBaseFactor value T p z.1 z.2‖) := by + let c : ℂ := (Fintype.card (ZMod p × (ZMod p)ˣ) : ℂ)⁻¹ + let w : ℝ := (Fintype.card (ZMod p × (ZMod p)ˣ) : ℝ)⁻¹ + let K : ℝ := 2 * (2 ^ n - 1 : ℕ) / (p : ℝ) + let H := fun z : ZMod p × (ZMod p)ˣ => ((p : ℂ) ^ 2)⁻¹ * + ∑ v : SquareLiftPairs p z.1 (z.2 : ZMod p), movingInternalPairFactor value T p v.1.1 v.2.1 + let G := fun z : ZMod p × (ZMod p)ˣ => movingInternalBaseFactor value T p z.1 z.2 + have havg : (Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + (∑ z : ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ, movingInternalPairFactor value T p z.1 z.2) = + c * ∑ z, H z := by + exact externalSquare_raw_average p (movingInternalPairFactor value T p) + have he (z : ZMod p × (ZMod p)ˣ) : ‖H z - G z‖ ≤ K * ‖G z‖ := + movingInternalPairFactor_normalized_fiber_error tier value hprime hdisjoint T hlevels p hf + z.1 z.2 (Units.ne_zero z.2) + have hc : ‖c‖ = w := by simp only [c, w, norm_inv, Complex.norm_natCast] + have hw : 0 ≤ w := inv_nonneg.mpr (Nat.cast_nonneg _) + rw [havg] + change ‖c * (∑ z, H z) - c * (∑ z, G z)‖ ≤ K * (w * ∑ z, ‖G z‖) + rw [← mul_sub, ← Finset.sum_sub_distrib, norm_mul, hc] + calc + w * ‖∑ z, (H z - G z)‖ ≤ w * ∑ z, ‖H z - G z‖ := + mul_le_mul_of_nonneg_left (norm_sum_le _ _) hw + _ ≤ w * ∑ z, K * ‖G z‖ := + mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun z _ => he z) hw + _ = _ := by rw [← Finset.mul_sum]; ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalLocalFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalLocalFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad93324da325fa6ae839c93d847b7e9deb46af71 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalLocalFactor.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedPair + +namespace OAI + +/-! # Actual internal-prime factors before averaging -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- All occurrences of a fixed internal prime impose their line modulo `p` +and exclude its zero lift modulo `p²`. Repeated occurrences remain simultaneous. -/ +noncomputable def movingInternalLocalSupport {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (p : ℕ) (x y : ZMod (p ^ 2)) : Prop := + ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, value i = p → + let φ := MovingSlotReversal.naturalReduction (p ^ 2) value + let z := φ (movingSlotLine o.path o.current).a * x + + φ (movingSlotLine o.path o.current).b * y + squareReduction p z = 0 ∧ z ≠ 0 + +theorem movingInternalLocalSupport_iff {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (P : Finset ℕ) + (hcover : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, value i ∈ P) + (x y : ℤ) : + (∀ p ∈ P, movingInternalLocalSupport value T p x y) ↔ + movingPrimeLineSupport value T x y ∧ movingSquareLineSupport value T x y := by + have he (p : ℕ) (o : MovingSlotOccurrence σ) : + squareReduction p + (MovingSlotReversal.naturalReduction (p ^ 2) value (movingSlotLine o.path o.current).a * + (x : ZMod (p ^ 2)) + + MovingSlotReversal.naturalReduction (p ^ 2) value (movingSlotLine o.path o.current).b * + (y : ZMod (p ^ 2))) = + MovingSlotReversal.naturalReduction p value (movingSlotLine o.path o.current).a * + (x : ZMod p) + + MovingSlotReversal.naturalReduction p value (movingSlotLine o.path o.current).b * + (y : ZMod p) := by + simp + constructor + · intro h + constructor + · intro o ho i hi + have hz := (h (value i) (hcover o ho i hi) o ho i hi rfl).1 + dsimp only at hz ⊢ + rw [he] at hz + exact hz + · intro o ho i hi + exact (h (value i) (hcover o ho i hi) o ho i hi rfl).2 + · rintro ⟨hline, hsquare⟩ p _ o ho i hi rfl + exact ⟨by simpa only [he] using hline o ho i hi, hsquare o ho i hi⟩ + +noncomputable def movingInternalPairFactor {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (p : ℕ) + (x y : ZMod (p ^ 2)) : ℂ := + if ∀ side, movingInternalLocalSupport value (T side) p x y then 1 else 0 + +theorem movingInternalPairFactor_product {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (P : Finset ℕ) + (hcover : ∀ side, ∀ o ∈ (T side).occurrences, + ∀ i ∈ o.current.compensationSlots, value i ∈ P) (x y : ℤ) : + (∏ p ∈ P, movingInternalPairFactor value T p x y) = + if ∀ side, movingPrimeLineSupport value (T side) x y ∧ + movingSquareLineSupport value (T side) x y then 1 else 0 := by + have hiff : (∀ p ∈ P, ∀ side, movingInternalLocalSupport value (T side) p x y) ↔ + ∀ side, movingPrimeLineSupport value (T side) x y ∧ + movingSquareLineSupport value (T side) x y := by + constructor + · intro h side + exact (movingInternalLocalSupport_iff value (T side) P (hcover side) x y).mp + (fun p hp => h p hp side) + · intro h p hp side + exact (movingInternalLocalSupport_iff value (T side) P (hcover side) x y).mpr + (h side) p hp + by_cases h : ∀ p ∈ P, ∀ side, movingInternalLocalSupport value (T side) p x y + · rw [ite_eq_left (hiff.mp h)] + apply Finset.prod_eq_one + intro p hp + exact ite_eq_left (h p hp) + · rw [ite_eq_right (fun hn => h (hiff.mpr hn))] + obtain ⟨p, hp, hn⟩ := not_forall₂.mp h + exact Finset.prod_eq_zero hp (ite_eq_right hn) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalProbabilityError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalProbabilityError.lean new file mode 100644 index 0000000000000000000000000000000000000000..854741862a5f2287919233f76474fe2d625eeafe --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalProbabilityError.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalHaarError + +namespace OAI + +/-! # The square error retains the one-over-prime line factor -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The base coefficient is a nonnegative indicator, so its absolute average +is exactly its simultaneous line probability. -/ +theorem movingInternalBaseFactor_norm_average {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : + (Fintype.card (ZMod p × (ZMod p)ˣ) : ℝ)⁻¹ * + (∑ z : ZMod p × (ZMod p)ˣ, ‖movingInternalBaseFactor value T p z.1 z.2‖) = + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) := by + have he (z : ZMod p × (ZMod p)ˣ) : + (movingInternalBaseFactor value T p z.1 z.2).re = + ‖movingInternalBaseFactor value T p z.1 z.2‖ := by + unfold movingInternalBaseFactor + split_ifs <;> simp + have h := congrArg Complex.re (movingInternalBaseFactor_average value T p) + simpa only [← Complex.ofReal_natCast, ← Complex.ofReal_inv, Complex.mul_re, + Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero, Complex.re_sum, he] using h + +theorem movingInternalPairFactor_probability_error {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) [Fact p.Prime] + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) : + let prob := internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) + ‖(Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + (∑ z : ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ, movingInternalPairFactor value T p z.1 z.2) - + (prob : ℂ)‖ ≤ (2 * (2 ^ n - 1 : ℕ) / (p : ℝ)) * prob := by + have h := movingInternalPairFactor_haar_error tier value hprime hdisjoint T hlevels p hf + rw [movingInternalBaseFactor_average, movingInternalBaseFactor_norm_average] at h + exact h + +theorem movingInternalPairFactor_probability_norm_le {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : + ‖(Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + (∑ z : ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ, movingInternalPairFactor value T p z.1 z.2)‖ ≤ + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) := by + have h := movingInternalPairFactor_haar_norm_le value T p + rwa [movingInternalBaseFactor_norm_average] at h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalProductError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalProductError.lean new file mode 100644 index 0000000000000000000000000000000000000000..61316b411be54c41a58c9b23520ba47c7ca276c5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingInternalProductError.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalProbabilityError +import OAI.NumberTheory.Ostmann.Preliminaries.FiniteRelativeProductError + +namespace OAI + +/-! # Simultaneous square removal with the full internal-prime scale -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingInternalHaarAverage {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : ℂ := + (Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + ∑ z : ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ, movingInternalPairFactor value T p z.1 z.2 + +noncomputable def movingInternalLineProbability {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : ℝ := + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) + +theorem movingInternalLineProbability_nonneg {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : + 0 ≤ movingInternalLineProbability value T p := internalLineProbability_nonneg _ _ _ + +theorem movingInternalLineProbability_le_inv {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) [Fact p.Prime] + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) + (base : MovingPrimeOccurrences value T p) : + movingInternalLineProbability value T p ≤ (p : ℝ)⁻¹ := by + unfold movingInternalLineProbability + rw [movingInternalBaseProbability_eq_flags tier value hprime hdisjoint T hlevels p hf base] + unfold internalLineFlagWeight internalLineScalar + simp only [ite_true] + split_ifs + · rfl + · exact inv_nonneg.mpr (Nat.cast_nonneg _) + +/-- The simultaneous replacement is relative to the complete product of line +probabilities, including the factor from every distinct internal prime. -/ +theorem movingInternalProduct_error {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (P : Finset ℕ) [∀ p : P, Fact p.val.Prime] + (hf : ∀ p : P, ∀ side, (T side).Frequencies (fun s => (s : ZMod p.val) ≠ 0)) : + ‖(∏ p : P, movingInternalHaarAverage value T p.val) - + ∏ p : P, (movingInternalLineProbability value T p.val : ℂ)‖ ≤ + (2 * (2 ^ n - 1 : ℕ) * ∑ p : P, (p.val : ℝ)⁻¹) * + ∏ p : P, movingInternalLineProbability value T p.val := by + have h := finite_relative_product_error (Finset.univ : Finset P) + (fun p => movingInternalHaarAverage value T p.val) + (fun p => (movingInternalLineProbability value T p.val : ℂ)) + (fun p => movingInternalLineProbability value T p.val) + (fun p => 2 * (2 ^ n - 1 : ℕ) / (p.val : ℝ)) + (fun p _ => movingInternalLineProbability_nonneg value T p.val) + (fun p _ => div_nonneg (mul_nonneg (by norm_num) (Nat.cast_nonneg _)) (Nat.cast_nonneg _)) + (fun p _ => movingInternalPairFactor_probability_norm_le value T p.val) + (fun p _ => by rw [Complex.norm_real, Real.norm_of_nonneg + (movingInternalLineProbability_nonneg value T p.val)]) + (fun p _ => movingInternalPairFactor_probability_error tier value hprime hdisjoint T hlevels p.val (hf p)) + simpa only [div_eq_mul_inv, ← Finset.mul_sum] using h + +/-- The external coefficient may grow with the sampled internal primes. Only +its product with the actual line probabilities needs to be bounded. -/ +theorem movingInternalProduct_weighted_error {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (P : Finset ℕ) [∀ p : P, Fact p.val.Prime] + (hf : ∀ p : P, ∀ side, (T side).Frequencies (fun s => (s : ZMod p.val) ≠ 0)) + (W : ℂ) (B : ℝ) + (hW : ‖W‖ * (∏ p : P, movingInternalLineProbability value T p.val) ≤ B) : + ‖W * ((∏ p : P, movingInternalHaarAverage value T p.val) - + ∏ p : P, (movingInternalLineProbability value T p.val : ℂ))‖ ≤ + B * (2 * (2 ^ n - 1 : ℕ) * ∑ p : P, (p.val : ℝ)⁻¹) := by + have hK : 0 ≤ 2 * (2 ^ n - 1 : ℕ) * ∑ p : P, (p.val : ℝ)⁻¹ := by positivity + rw [norm_mul] + apply (mul_le_mul_of_nonneg_left + (movingInternalProduct_error tier value hprime hdisjoint T hlevels P hf) (norm_nonneg W)).trans + calc + _ = (‖W‖ * (∏ p : P, movingInternalLineProbability value T p.val)) * + (2 * (2 ^ n - 1 : ℕ) * ∑ p : P, (p.val : ℝ)⁻¹) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_right hW hK + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointGiantRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointGiantRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..a16771321fa567f51ba21fe1d41cf4845d1f130d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointGiantRate.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelTransport + +namespace OAI + +/-! # Joint prime-giant idealization of the literal moving kernel -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +/-- Both original prime sums are replaced jointly. The Page factors remain +inside their actual measures and the threshold is uniform in the small data. -/ +theorem PublishedProgressionInput.moving_joint_prime_rate (P : PublishedProgressionInput) + {σ : Type*} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), T.Frequencies (fun s => |(s : ℝ)| ≤ V) → + ∀ Q q a b : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → a.Coprime q → b.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + ∀ c : ℂ, + 2 * ‖c‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + ‖complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂primeGiantMeasure P Q q a u v‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) * + (reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) + 2) := by + filter_upwards [P.moving_kernel_prime_rate (σ := σ) n C d, eventually_ge_atTop (0 : ℝ)] with L hL hL0 + intro value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q a b hQ hq hqQ ha hb hlog u v r s hu huv hshort hr hrs hrshort c hbudget + dsimp only + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let H := fun x y => c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + let μ := primeGiantMeasure P Q q a u v + let ν := primeGiantMeasure P Q q b r s + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hu1 : 1 ≤ u := (Real.one_le_exp (by positivity)).trans hu + have hr1 : 1 ≤ r := (Real.one_le_exp (by positivity)).trans hr + have : IsFiniteMeasure μ := finite_primeGiantMeasure P Q q a u v (by linarith) + have : IsFiniteMeasure ν := finite_primeGiantMeasure P Q q b r s (by linarith) + have hsmall (coord : Bool) (fixed : ℝ) : + 2 * ‖c‖ * smoothPolynomialBudget (movingSmoothPolynomialFactors value T + (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip) ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + exact (mul_le_mul_of_nonneg_left + (movingSmoothPolynomialFactors_budget value T _ _ ψ X lo hi V hlo hhi hV + φ G B D hB hD hφ hlip) (by positivity)).trans hbudget + have hleft (y : ℝ) : ‖complexPrimeInterval q a u v (fun x => H x y) - ∫ x, H x y ∂μ‖ ≤ err := by + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + false (Real.exp y) Q q a hQ hq hqQ ha hlog u v hu huv hshort c (hsmall false (Real.exp y)) + rw [primeGiantMeasure_integral P Q q a u v (by linarith)] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hright (x : ℝ) : ‖complexPrimeInterval q b r s (H x) - ∫ y, H x y ∂ν‖ ≤ err := by + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + true (Real.exp x) Q q b hQ hq hqQ hb hlog r s hr hrs hrshort c (hsmall true (Real.exp x)) + rw [primeGiantMeasure_integral P Q q b r s (by linarith)] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hpair := moving_kernel_pair_transport value T nodes ψ X lo hi hlo hhi φ G B D + hB hD hφ hlip hout c q a b u v r s μ ν err err hleft hright + have hmass : μ.real Set.univ ≤ 2 := primeGiantMeasure_mass_le_two P Q q a hq u v hu1 huv hshort + apply hpair.trans + have hmul := mul_le_mul_of_nonneg_left hmass (Real.exp_pos (-Real.exp ((125 / 10000 : ℝ) * L))).le + dsimp only [err] at * + nlinarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointMixedPairRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointMixedPairRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..77823517a0acf5c329a8bea564f3ec1c1be7f6c2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointMixedPairRate.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPairTransport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPairRates +import OAI.NumberTheory.Ostmann.Arithmetic.MovingIntegerPairRate + +namespace OAI + +/-! # Joint prime-giant idealization of the literal moving kernel -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +/-- Both original prime sums are replaced jointly. The Page factors remain +inside their actual measures and the threshold is uniform in the small data. -/ +theorem PublishedProgressionInput.moving_joint_kernelPair_mixed_rate (P : PublishedProgressionInput) + {σ : Type*} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q a b : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → b.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + ∀ c : ℂ, + 2 * ‖c‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂integerGiantMeasure q J u v‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) * + (reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) + Real.exp (v - J)) := by + filter_upwards [P.moving_kernelPair_prime_rate (σ := σ) n C d, + moving_kernelPair_integer_rate (σ := σ) n C d, eventually_ge_atTop (0 : ℝ)] with L hL hI hL0 + intro value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q a b hQ hq hqQ hb hlog u v r s J hJ huv hshort hr hrs hrshort c hbudget + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let H := fun x y => c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + let μ := integerGiantMeasure q J u v + let ν := primeGiantMeasure P Q q b r s + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hr1 : 1 ≤ r := (Real.one_le_exp (by positivity)).trans hr + have : IsFiniteMeasure μ := finite_integerGiantMeasure q J u v + have : IsFiniteMeasure ν := finite_primeGiantMeasure P Q q b r s (by linarith) + have hsmall (coord : Bool) (fixed : ℝ) : + 2 * ‖c‖ * smoothPolynomialBudget (pairedPolynomialFactors + (movingSmoothPolynomialFactors value (T false) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (movingSmoothPolynomialFactors value (T true) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip)) ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + exact (mul_le_mul_of_nonneg_left + (movingPairedSmoothPolynomialFactors_budget value T _ _ ψ X lo hi V hlo hhi hV + φ G B D hB hD hφ hlip) (by positivity)).trans hbudget + have hleft (y : ℝ) : ‖complexIntegerInterval q a u v J (fun x => H x y) - ∫ x, H x y ∂μ‖ ≤ err := by + have h := hI value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + false (Real.exp y) q a (by omega) u v J huv hJ c (hsmall false (Real.exp y)) + rw [integerGiantMeasure_integral q J u v] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hright (x : ℝ) : ‖complexPrimeInterval q b r s (H x) - ∫ y, H x y ∂ν‖ ≤ err := by + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + true (Real.exp x) Q q b hQ hq hqQ hb hlog r s hr hrs hrshort c (hsmall true (Real.exp x)) + rw [primeGiantMeasure_integral P Q q b r s (by linarith)] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hpair := moving_kernelPair_mixed_transport value T nodes ψ X lo hi hlo hhi φ G B D + hB hD hφ hlip hout c q a b u v r s J μ ν err err hleft hright + have hmass : μ.real Set.univ ≤ Real.exp (v - J) := + integerGiantMeasure_mass_le q (by omega) J u v huv hshort + apply hpair.trans + have hmul := mul_le_mul_of_nonneg_left hmass (Real.exp_pos (-Real.exp ((125 / 10000 : ℝ) * L))).le + dsimp only [err] at * + nlinarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointMixedRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointMixedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..12f4b9db998fe079bf420e7827c18f0c37c74d53 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointMixedRate.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelTransport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingIntegerKernelRate + +namespace OAI + +/-! # Joint integer–prime idealization of the literal moving kernel -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +/-- The original integer and prime sums are replaced jointly. The Page factors remain +inside their actual measures and the threshold is uniform in the small data. -/ +theorem PublishedProgressionInput.moving_joint_mixed_rate (P : PublishedProgressionInput) + {σ : Type*} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), T.Frequencies (fun s => |(s : ℝ)| ≤ V) → + ∀ Q q a b : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → b.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + ∀ c : ℂ, + 2 * ‖c‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + ‖complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂integerGiantMeasure q J u v‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) * + (reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) + Real.exp (v - J)) := by + filter_upwards [P.moving_kernel_prime_rate (σ := σ) n C d, + moving_kernel_integer_rate (σ := σ) n C d, eventually_ge_atTop (0 : ℝ)] with L hL hI hL0 + intro value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q a b hQ hq hqQ hb hlog u v r s J hJ huv hshort hr hrs hrshort c hbudget + dsimp only + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let H := fun x y => c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + let μ := integerGiantMeasure q J u v + let ν := primeGiantMeasure P Q q b r s + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hr1 : 1 ≤ r := (Real.one_le_exp (by positivity)).trans hr + have : IsFiniteMeasure μ := finite_integerGiantMeasure q J u v + have : IsFiniteMeasure ν := finite_primeGiantMeasure P Q q b r s (by linarith) + have hsmall (coord : Bool) (fixed : ℝ) : + 2 * ‖c‖ * smoothPolynomialBudget (movingSmoothPolynomialFactors value T + (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip) ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + exact (mul_le_mul_of_nonneg_left + (movingSmoothPolynomialFactors_budget value T _ _ ψ X lo hi V hlo hhi hV + φ G B D hB hD hφ hlip) (by positivity)).trans hbudget + have hleft (y : ℝ) : ‖complexIntegerInterval q a u v J (fun x => H x y) - ∫ x, H x y ∂μ‖ ≤ err := by + have h := hI value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + false (Real.exp y) q a (by omega) u v J huv hJ c (hsmall false (Real.exp y)) + rw [integerGiantMeasure_integral q J u v] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hright (x : ℝ) : ‖complexPrimeInterval q b r s (H x) - ∫ y, H x y ∂ν‖ ≤ err := by + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + true (Real.exp x) Q q b hQ hq hqQ hb hlog r s hr hrs hrshort c (hsmall true (Real.exp x)) + rw [primeGiantMeasure_integral P Q q b r s (by linarith)] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hpair := moving_kernel_mixed_transport value T nodes ψ X lo hi hlo hhi φ G B D + hB hD hφ hlip hout c q a b u v r s J μ ν err err hleft hright + have hmass : μ.real Set.univ ≤ Real.exp (v - J) := + integerGiantMeasure_mass_le q (by omega) J u v huv hshort + apply hpair.trans + have hmul := mul_le_mul_of_nonneg_left hmass (Real.exp_pos (-Real.exp ((125 / 10000 : ℝ) * L))).le + dsimp only [err] at * + nlinarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointPairRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointPairRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7bef24722885c62a8129e17642219456ce2e7d3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointPairRate.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPairTransport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPairRates + +namespace OAI + +/-! # Joint prime-giant idealization of the literal moving kernel -/ + +namespace Ostmann +universe u v +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +/-- Both original prime sums are replaced jointly. The Page factors remain +inside their actual measures and the threshold is uniform in the small data. -/ +theorem PublishedProgressionInput.moving_joint_kernelPair_prime_rate_uniform (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q a b : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → a.Coprime q → b.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + ∀ c : ℂ, + 2 * ‖c‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂primeGiantMeasure P Q q a u v‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) * + (reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) + 2) := by + filter_upwards [P.moving_kernelPair_prime_rate_uniform n C d, eventually_ge_atTop (0 : ℝ)] with L hL hL0 + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q a b hQ hq hqQ ha hb hlog u v r s hu huv hshort hr hrs hrshort c hbudget + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let H := fun x y => c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + let μ := primeGiantMeasure P Q q a u v + let ν := primeGiantMeasure P Q q b r s + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hu1 : 1 ≤ u := (Real.one_le_exp (by positivity)).trans hu + have hr1 : 1 ≤ r := (Real.one_le_exp (by positivity)).trans hr + have : IsFiniteMeasure μ := finite_primeGiantMeasure P Q q a u v (by linarith) + have : IsFiniteMeasure ν := finite_primeGiantMeasure P Q q b r s (by linarith) + have hsmall (coord : Bool) (fixed : ℝ) : + 2 * ‖c‖ * smoothPolynomialBudget (pairedPolynomialFactors + (movingSmoothPolynomialFactors value (T false) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (movingSmoothPolynomialFactors value (T true) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip)) ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + exact (mul_le_mul_of_nonneg_left + (movingPairedSmoothPolynomialFactors_budget value T _ _ ψ X lo hi V hlo hhi hV + φ G B D hB hD hφ hlip) (by positivity)).trans hbudget + have hleft (y : ℝ) : ‖complexPrimeInterval q a u v (fun x => H x y) - ∫ x, H x y ∂μ‖ ≤ err := by + have h := hL σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + false (Real.exp y) Q q a hQ hq hqQ ha hlog u v hu huv hshort c (hsmall false (Real.exp y)) + rw [primeGiantMeasure_integral P Q q a u v (by linarith)] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hright (x : ℝ) : ‖complexPrimeInterval q b r s (H x) - ∫ y, H x y ∂ν‖ ≤ err := by + have h := hL σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + true (Real.exp x) Q q b hQ hq hqQ hb hlog r s hr hrs hrshort c (hsmall true (Real.exp x)) + rw [primeGiantMeasure_integral P Q q b r s (by linarith)] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hpair := moving_kernelPair_pair_transport value T nodes ψ X lo hi hlo hhi φ G B D + hB hD hφ hlip hout c q a b u v r s μ ν err err hleft hright + have hmass : μ.real Set.univ ≤ 2 := primeGiantMeasure_mass_le_two P Q q a hq u v hu1 huv hshort + apply hpair.trans + have hmul := mul_le_mul_of_nonneg_left hmass (Real.exp_pos (-Real.exp ((125 / 10000 : ℝ) * L))).le + dsimp only [err] at * + nlinarith + +theorem PublishedProgressionInput.moving_joint_kernelPair_prime_rate (P : PublishedProgressionInput) + {σ : Type u} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q a b : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → a.Coprime q → b.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + ∀ c : ℂ, + 2 * ‖c‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂primeGiantMeasure P Q q a u v‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) * + (reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) + 2) := by + filter_upwards [P.moving_joint_kernelPair_prime_rate_uniform n C d] with L hL + exact hL σ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointSquareLoss.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointSquareLoss.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a8bcdc682f7dbd5c1be118c4a640604347de340 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingJointSquareLoss.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRepresentativeSquares +import OAI.NumberTheory.Ostmann.Arithmetic.JointSquareLiftExclusions + +namespace OAI + +/-! # Joint square-exclusion estimate for the actual moving-tree rows -/ + +namespace Ostmann +open scoped BigOperators Classical + +theorem moving_joint_square_loss {σ I : Type*} [Fintype I] [DecidableEq I] + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + {n : ℕ} (T : MovingSlotData σ n) (hlevels : T.Levels tier) (rep : I → σ) + (hf : ∀ i, T.Frequencies (fun s => (s : ZMod (value (rep i))) ≠ 0)) + (x₀ y₀ : ∀ i, ZMod (value (rep i))) (hy : ∀ i, y₀ i ≠ 0) + (hbase : ∀ i (j : MovingRepresentativeOccurrences T (rep i)), + let o := T.occurrences.get j.val + let φ := MovingSlotReversal.naturalReduction (value (rep i)) value + φ (movingSlotLine o.path o.current).a * x₀ i + + φ (movingSlotLine o.path o.current).b * y₀ i = 0) + (F : (∀ i, SquareLiftPairs (value (rep i)) (x₀ i) (y₀ i)) → ℂ) + (B : ℝ) (hB : 0 ≤ B) (hF : ∀ x, ‖F x‖ ≤ B) : + let _ : ∀ i, Fact (value (rep i)).Prime := fun i => ⟨hprime (rep i)⟩ + let φ := fun i => MovingSlotReversal.naturalReduction (value (rep i) ^ 2) value + (Fintype.card (∀ i, SquareLiftPairs (value (rep i)) (x₀ i) (y₀ i)) : ℝ)⁻¹ * + ‖(∑ x, if ∀ i (j : MovingRepresentativeOccurrences T (rep i)), + let o := T.occurrences.get j.val + φ i (movingSlotLine o.path o.current).a * (x i).1.1 + + φ i (movingSlotLine o.path o.current).b * (x i).2.1 ≠ 0 then F x else 0) - + ∑ x, F x‖ ≤ + 2 * B * (2 ^ n - 1 : ℕ) * ∑ i, (value (rep i) : ℝ)⁻¹ := by + let : ∀ i, Fact (value (rep i)).Prime := fun i => ⟨hprime (rep i)⟩ + let J := fun i => MovingRepresentativeOccurrences T (rep i) + let line := fun i (j : J i) => + let o := T.occurrences.get j.val + movingSlotLine o.path o.current + let φ := fun i => MovingSlotReversal.naturalReduction (value (rep i) ^ 2) value + have hu (i : I) (j : J i) := + T.occurrence_units_of_prime_types tier value hprime hdisjoint hlevels + (T.occurrences.get j.val) (List.get_mem _ _) (rep i) + (T.occurrence_compensation_level tier hlevels _ (List.get_mem _ _) (rep i) j.property) (hf i) + have hrow (i : I) (j : J i) : + squareReduction (value (rep i)) (φ i (line i j).a) ≠ 0 ∨ + squareReduction (value (rep i)) (φ i (line i j).b) ≠ 0 := by + simp only [φ, naturalReduction_square] + apply movingHistoryLine_nonzero + · intro s hs + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs + exact (hu i j).1 t ht + · exact (hu i j).2.1 + · exact (hu i j).2.2 + have hb := joint_square_lift_removed_mass_le (fun i => value (rep i)) J + (fun i j => φ i (line i j).a) (fun i j => φ i (line i j).b) x₀ y₀ hy hrow + (by simpa only [φ, naturalReduction_square] using hbase) F B hB hF + refine hb.trans ?_ + calc + 2 * B * ∑ i, (Fintype.card (J i) : ℝ) / value (rep i) ≤ + 2 * B * ∑ i, (2 ^ n - 1 : ℕ) / (value (rep i) : ℝ) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply Finset.sum_le_sum + intro i _ + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact_mod_cast movingRepresentativeOccurrences_card T (rep i) + _ = _ := by simp only [div_eq_mul_inv, ← Finset.mul_sum]; ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelPair.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..fcd17ff9c8aaca3765531ce1b10017e862872501 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelPair.lean @@ -0,0 +1,128 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelRates + +namespace OAI + +/-! # The literal product of the two histories in a diagonal comparison -/ + +namespace Ostmann +open MeasureTheory +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +noncomputable def movingRealKernelPair {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) (L R : ℝ) : ℂ := + movingRealKernel value (T false) (nodes false) ψ X lo hi hlo hhi φ G L R * + conj (movingRealKernel value (T true) (nodes true) ψ X lo hi hlo hhi φ G L R) + +theorem pairedPolynomialFactors_roots {n m : ℕ} + (F : Fin n → ClippedPolynomialFactor) (G : Fin m → ClippedPolynomialFactor) + (S U : Finset ℝ) + (hS : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (hU : ∀ i r, r ∈ (G i).polynomial.derivative.roots → r ∈ U) : + ∀ i r, r ∈ ((pairedPolynomialFactors F G) i).polynomial.derivative.roots → r ∈ S ∪ U := by + intro i r + refine Fin.addCases ?_ ?_ i + · intro j hr + simp only [pairedPolynomialFactors, Fin.append_left] at hr + exact Finset.mem_union_left _ (hS j r hr) + · intro j hr + simp only [pairedPolynomialFactors, Fin.append_right, ClippedPolynomialFactor.conjugate] at hr + exact Finset.mem_union_right _ (hU j r hr) + +theorem movingPairedSmoothPolynomialFactors_budget {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) : + smoothPolynomialBudget (pairedPolynomialFactors + (movingSmoothPolynomialFactors value (T false) L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (movingSmoothPolynomialFactors value (T true) L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip)) ≤ + (movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 := by + rw [pairedPolynomialFactors_budget, pow_two] + have h0 := movingSmoothPolynomialFactors_budget value (T false) L R ψ X lo hi V hlo hhi + (hV false) φ G B D hB hD hφ hlip + have h1 := movingSmoothPolynomialFactors_budget value (T true) L R ψ X lo hi V hlo hhi + (hV true) φ G B D hB hD hφ hlip + exact mul_le_mul h0 h1 (smoothPolynomialBudget_nonneg _) ((smoothPolynomialBudget_nonneg _).trans h0) + +theorem movingRealKernelPair_norm {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B : ℝ) (hB : 0 ≤ B) (hφ : ∀ x, |φ x| ≤ B) (L R : ℝ) : + ‖movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G L R‖ ≤ + ((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) ^ 2 := by + rw [movingRealKernelPair, norm_mul, Complex.norm_conj, pow_two] + exact mul_le_mul + (movingRealKernel_norm value (T false) (nodes false) ψ X lo hi hlo hhi φ G B hB hφ L R) + (movingRealKernel_norm value (T true) (nodes true) ψ X lo hi hlo hhi φ G B hB hφ L R) + (norm_nonneg _) (by positivity) + +theorem measurable_movingRealKernelPair {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (hout : ∀ x, 1 ≤ |x| → φ x = 0) : + Measurable (fun z : ℝ × ℝ => movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G z.1 z.2) := by + have h0 := measurable_movingRealKernel value (T false) (nodes false) ψ X lo hi hlo hhi φ G + B D hB hD hφ hlip hout + have h1 := measurable_movingRealKernel value (T true) (nodes true) ψ X lo hi hlo hhi φ G + B D hB hD hφ hlip hout + exact h0.mul (Complex.continuous_conj.measurable.comp h1) + +theorem movingRealKernelPair_slice_polynomial {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (coord : Bool) (fixed z : ℝ) : + let W := fun b => movingSmoothPolynomialFactors value (T b) + (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed z false) (movingRealPair coord fixed z true) = + (movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair coord fixed z) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair coord fixed z))) * + smoothPolynomialWeight (pairedPolynomialFactors (W false) (W true)) z := by + dsimp only + rw [movingRealKernelPair, + movingRealKernel_slice_polynomial value (T false) (nodes false) ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip hout, + movingRealKernel_slice_polynomial value (T true) (nodes true) ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip hout, + pairedPolynomialFactors_weight, map_mul] + ring + +theorem movingRealKernelPair_slice_root_data {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (coord : Bool) (fixed : ℝ) : + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := fun b => movingSmoothPolynomialFactors value (T b) + (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + ∃ S : Finset ℝ, S.card + 1 ≤ 2 * movingKernelRootBudget n ∧ + (∀ i r, r ∈ ((pairedPolynomialFactors (W false) (W true)) i).polynomial.derivative.roots → r ∈ S) ∧ + (∀ x y, rootCellCode S x = rootCellCode S y → + (movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair coord fixed x) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair coord fixed x))) = + (movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair coord fixed y) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair coord fixed y)))) := by + dsimp only + obtain ⟨S, hS, hSr, hSc⟩ := movingRealKernel_slice_root_data value hvalue childBound pivotBound + (T false) (hf false) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip coord fixed + obtain ⟨U, hU, hUr, hUc⟩ := movingRealKernel_slice_root_data value hvalue childBound pivotBound + (T true) (hf true) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip coord fixed + refine ⟨S ∪ U, ?_, pairedPolynomialFactors_roots _ _ S U hSr hUr, ?_⟩ + · have hc := Finset.card_union_le S U + unfold movingKernelRootBudget + omega + · intro x y hc + rw [hSc x y (rootCellCode_eq_of_subset S (S ∪ U) Finset.subset_union_left x y hc), + hUc x y (rootCellCode_eq_of_subset U (S ∪ U) Finset.subset_union_right x y hc)] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelPairRates.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelPairRates.lean new file mode 100644 index 0000000000000000000000000000000000000000..ddc662dda7cf3aabea2dedead7132a7c53064d95 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelPairRates.lean @@ -0,0 +1,169 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPair + +namespace OAI + +/-! # Uniform prime and integer comparisons for either real giant slice -/ + +namespace Ostmann +universe u v +open Filter MeasureTheory +open scoped Classical BigOperators ComplexConjugate SchwartzMap + +/-- The threshold depends on the fixed depth and numerical budget, not the +small-prime data, residue class, or other real giant. -/ +theorem PublishedProgressionInput.moving_kernelPair_prime_rate_uniform (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (coord : Bool) (fixed : ℝ) + (Q q a : ℕ), 2 ≤ Q → 1 ≤ q → q ≤ Q → a.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v : ℝ, Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + ∀ c : ℂ, + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := pairedPolynomialFactors + (movingSmoothPolynomialFactors value (T false) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (movingSmoothPolynomialFactors value (T true) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + 2 * ‖c‖ * smoothPolynomialBudget W ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + ‖complexPrimeInterval q a u v (fun y => c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) - + ∫ y in Set.Ioc u v, (c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [P.root_integral_prime_rate C d (2 * movingKernelRootBudget n)] with L hL + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + coord fixed Q q a hQ hq hqQ ha hlog u v hu huv hshort c + dsimp only + intro hbudget + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := pairedPolynomialFactors + (movingSmoothPolynomialFactors value (T false) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (movingSmoothPolynomialFactors value (T true) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + let gate := fun x => movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair coord fixed x) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair coord fixed x)) + let w := fun x => c * gate x + obtain ⟨S, hS, hroots, hconst⟩ := movingRealKernelPair_slice_root_data value hvalue childBound pivotBound + T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip coord fixed + have hw (x : ℝ) : ‖w x‖ ≤ ‖c‖ := by + change ‖c * _‖ ≤ ‖c‖ + rw [norm_mul] + simpa only [mul_one] using mul_le_mul_of_nonneg_left + (show ‖gate x‖ ≤ 1 from by + dsimp only [gate] + rw [norm_mul, Complex.norm_conj] + exact (mul_le_mul + (movingRealGateWeight_norm value (T false) (nodes false) X lo hi _) + (movingRealGateWeight_norm value (T true) (nodes true) X lo hi _) + (norm_nonneg _) (by norm_num)).trans_eq (one_mul 1)) (norm_nonneg c) + have hc (x y : ℝ) (hcode : rootCellCode S x = rootCellCode S y) : w x = w y := + congrArg (c * ·) (hconst x y hcode) + have he (z : ℝ) : w z * smoothPolynomialWeight W z = + c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed z false) (movingRealPair coord fixed z true) := by + rw [movingRealKernelPair_slice_polynomial value T nodes ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout] + dsimp only [w, W, gate] + ring + have h := hL Q q a hQ hq hqQ ha hlog u v hu huv hshort _ W S + hS hroots w ‖c‖ (norm_nonneg _) hw hc hbudget + simpa only [he] using h + +theorem PublishedProgressionInput.moving_kernelPair_prime_rate (P : PublishedProgressionInput) + {σ : Type u} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (coord : Bool) (fixed : ℝ) + (Q q a : ℕ), 2 ≤ Q → 1 ≤ q → q ≤ Q → a.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v : ℝ, Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + ∀ c : ℂ, + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := pairedPolynomialFactors + (movingSmoothPolynomialFactors value (T false) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (movingSmoothPolynomialFactors value (T true) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + 2 * ‖c‖ * smoothPolynomialBudget W ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + ‖complexPrimeInterval q a u v (fun y => c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) - + ∫ y in Set.Ioc u v, (c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [P.moving_kernelPair_prime_rate_uniform n C d] with L hL + exact hL σ + +theorem moving_kernelPair_integer_bound {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (coord : Bool) (fixed : ℝ) + (q a : ℕ) (hq : 0 < q) (u v J : ℝ) (huv : u ≤ v) (c : ℂ) : + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := pairedPolynomialFactors + (movingSmoothPolynomialFactors value (T false) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (movingSmoothPolynomialFactors value (T true) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + ‖complexIntegerInterval q a u v J (fun y => c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) - + ∫ y in Set.Ioc u v, (c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) * + (integerLogDensity q J y : ℂ)‖ ≤ + 4 * ((2 * movingKernelRootBudget n : ℕ) : ℝ) * ‖c‖ * smoothPolynomialBudget W * Real.exp (-J) := by + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := pairedPolynomialFactors + (movingSmoothPolynomialFactors value (T false) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (movingSmoothPolynomialFactors value (T true) (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + let gate := fun x => movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair coord fixed x) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair coord fixed x)) + let w := fun x => c * gate x + obtain ⟨S, hS, hroots, hconst⟩ := movingRealKernelPair_slice_root_data value hvalue childBound pivotBound + T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip coord fixed + have hw (x : ℝ) : ‖w x‖ ≤ ‖c‖ := by + change ‖c * _‖ ≤ ‖c‖ + rw [norm_mul] + simpa only [mul_one] using mul_le_mul_of_nonneg_left + (show ‖gate x‖ ≤ 1 from by + dsimp only [gate] + rw [norm_mul, Complex.norm_conj] + exact (mul_le_mul + (movingRealGateWeight_norm value (T false) (nodes false) X lo hi _) + (movingRealGateWeight_norm value (T true) (nodes true) X lo hi _) + (norm_nonneg _) (by norm_num)).trans_eq (one_mul 1)) (norm_nonneg c) + have hc (x y : ℝ) (hcode : rootCellCode S x = rootCellCode S y) : w x = w y := + congrArg (c * ·) (hconst x y hcode) + have he (z : ℝ) : w z * smoothPolynomialWeight W z = + c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed z false) (movingRealPair coord fixed z true) := by + rw [movingRealKernelPair_slice_polynomial value T nodes ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout] + dsimp only [w, W, gate] + ring + have h := root_integral_integer_bound q a hq u v J huv W S hroots w ‖c‖ (norm_nonneg _) hw hc + simp only [he] at h + apply h.trans + have hK : ((S.card + 1 : ℕ) : ℝ) ≤ 2 * movingKernelRootBudget n := by + exact_mod_cast hS + gcongr + exact smoothPolynomialBudget_nonneg W + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelPairTransport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelPairTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..df08a3ff87052c2b63af8dd7a7038828fcc0dc1c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelPairTransport.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelTransport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPair + +namespace OAI + +namespace Ostmann +open MeasureTheory +open scoped Classical SchwartzMap + +theorem moving_kernelPair_pair_transport {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (c : ℂ) (q a b : ℕ) (u v r s : ℝ) (μ ν : Measure ℝ) + [IsFiniteMeasure μ] [IsFiniteMeasure ν] (δ ε : ℝ) + (hleft : ∀ y, ‖complexPrimeInterval q a u v (fun x => + c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)) - + ∫ x, c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂μ‖ ≤ δ) + (hright : ∀ x, ‖complexPrimeInterval q b r s (fun y => + c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)) - + ∫ y, c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂ν‖ ≤ ε) : + ‖complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂ν ∂μ‖ ≤ + δ * reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) + ε * μ.real Set.univ := by + let H := fun x y => c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + have hbase := measurable_movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G B D + hB hD hφ hlip hout + have hmeas : Measurable (Function.uncurry H) := + measurable_exp_pair_mul (movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G) hbase c + have hnorm (x y : ℝ) : ‖H x y‖ ≤ ‖c‖ * + ((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) ^ 2 := by + dsimp only [H] + rw [norm_mul] + exact mul_le_mul_of_nonneg_left + (movingRealKernelPair_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ _ _) (norm_nonneg _) + exact prime_pair_integral_transport q a b u v r s μ ν H hmeas _ hnorm δ ε hleft hright + +theorem moving_kernelPair_mixed_transport {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (c : ℂ) (q a b : ℕ) (u v r s J : ℝ) (μ ν : Measure ℝ) + [IsFiniteMeasure μ] [IsFiniteMeasure ν] (δ ε : ℝ) + (hleft : ∀ y, ‖complexIntegerInterval q a u v J (fun x => + c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)) - + ∫ x, c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂μ‖ ≤ δ) + (hright : ∀ x, ‖complexPrimeInterval q b r s (fun y => + c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)) - + ∫ y, c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂ν‖ ≤ ε) : + ‖complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂ν ∂μ‖ ≤ + δ * reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) + ε * μ.real Set.univ := by + let H := fun x y => c * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + have hbase := measurable_movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G B D + hB hD hφ hlip hout + have hmeas : Measurable (Function.uncurry H) := + measurable_exp_pair_mul (movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G) hbase c + have hnorm (x y : ℝ) : ‖H x y‖ ≤ ‖c‖ * + ((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) ^ 2 := by + dsimp only [H] + rw [norm_mul] + exact mul_le_mul_of_nonneg_left + (movingRealKernelPair_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ _ _) (norm_nonneg _) + exact mixed_pair_integral_transport q a b u v r s J μ ν H hmeas _ hnorm δ ε hleft hright + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelRates.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelRates.lean new file mode 100644 index 0000000000000000000000000000000000000000..4af6c6fd57394436b8036bcad1928ff0327d36ae --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelRates.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelSlices + +namespace OAI + +/-! # Uniform prime and integer comparisons for either real giant slice -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +def movingKernelRootBudget (n : ℕ) : ℕ := + (2 ^ n - 1) * (3 * (7 * 2 ^ n)) + 5 * 2 ^ n + 1 + +/-- The threshold depends on the fixed depth and numerical budget, not the +small-prime data, residue class, or other real giant. -/ +theorem PublishedProgressionInput.moving_kernel_prime_rate (P : PublishedProgressionInput) + {σ : Type*} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (coord : Bool) (fixed : ℝ) + (Q q a : ℕ), 2 ≤ Q → 1 ≤ q → q ≤ Q → a.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v : ℝ, Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + ∀ c : ℂ, + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let W := movingSmoothPolynomialFactors value T + (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + 2 * ‖c‖ * smoothPolynomialBudget W ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + ‖complexPrimeInterval q a u v (fun y => c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) - + ∫ y in Set.Ioc u v, (c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [P.root_integral_prime_rate C d (movingKernelRootBudget n)] with L hL + intro value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + coord fixed Q q a hQ hq hqQ ha hlog u v hu huv hshort c + dsimp only + intro hbudget + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let W := movingSmoothPolynomialFactors value T (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + let w := fun x => c * movingRealGateWeight value T nodes X lo hi (movingRealPair coord fixed x) + obtain ⟨S, hS, hroots, hconst⟩ := movingRealKernel_slice_root_data value hvalue childBound pivotBound + T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip coord fixed + have hw (x : ℝ) : ‖w x‖ ≤ ‖c‖ := by + change ‖c * _‖ ≤ ‖c‖ + rw [norm_mul] + simpa only [mul_one] using mul_le_mul_of_nonneg_left + (movingRealGateWeight_norm value T nodes X lo hi _) (norm_nonneg c) + have hc (x y : ℝ) (hcode : rootCellCode S x = rootCellCode S y) : w x = w y := + congrArg (c * ·) (hconst x y hcode) + have he (z : ℝ) : w z * smoothPolynomialWeight W z = + c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed z false) (movingRealPair coord fixed z true) := by + rw [movingRealKernel_slice_polynomial value T nodes ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout] + dsimp only [w, W] + ring + have h := hL Q q a hQ hq hqQ ha hlog u v hu huv hshort _ W S + (by unfold movingKernelRootBudget; omega) hroots w ‖c‖ (norm_nonneg _) hw hc hbudget + simpa only [he] using h + +theorem moving_kernel_integer_bound {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (coord : Bool) (fixed : ℝ) + (q a : ℕ) (hq : 0 < q) (u v J : ℝ) (huv : u ≤ v) (c : ℂ) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let W := movingSmoothPolynomialFactors value T + (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + ‖complexIntegerInterval q a u v J (fun y => c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) - + ∫ y in Set.Ioc u v, (c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) * + (integerLogDensity q J y : ℂ)‖ ≤ + 4 * (movingKernelRootBudget n : ℝ) * ‖c‖ * smoothPolynomialBudget W * Real.exp (-J) := by + dsimp only + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let W := movingSmoothPolynomialFactors value T (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + let w := fun x => c * movingRealGateWeight value T nodes X lo hi (movingRealPair coord fixed x) + obtain ⟨S, hS, hroots, hconst⟩ := movingRealKernel_slice_root_data value hvalue childBound pivotBound + T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip coord fixed + have hw (x : ℝ) : ‖w x‖ ≤ ‖c‖ := by + change ‖c * _‖ ≤ ‖c‖ + rw [norm_mul] + simpa only [mul_one] using mul_le_mul_of_nonneg_left + (movingRealGateWeight_norm value T nodes X lo hi _) (norm_nonneg c) + have hc (x y : ℝ) (hcode : rootCellCode S x = rootCellCode S y) : w x = w y := + congrArg (c * ·) (hconst x y hcode) + have he (z : ℝ) : w z * smoothPolynomialWeight W z = + c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed z false) (movingRealPair coord fixed z true) := by + rw [movingRealKernel_slice_polynomial value T nodes ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout] + dsimp only [w, W] + ring + have h := root_integral_integer_bound q a hq u v J huv W S hroots w ‖c‖ (norm_nonneg _) hw hc + simp only [he] at h + apply h.trans + have hK : ((S.card + 1 : ℕ) : ℝ) ≤ movingKernelRootBudget n := by + exact_mod_cast (show S.card + 1 ≤ movingKernelRootBudget n by unfold movingKernelRootBudget; omega) + gcongr + exact smoothPolynomialBudget_nonneg W + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelSlices.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelSlices.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5309936b6dfe2d61b55e00195ac990a3a50e01b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelSlices.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRealKernel +import OAI.NumberTheory.Ostmann.Arithmetic.RootIntegralRates + +namespace OAI + +/-! # Concrete polynomial data for either slice of the two-giant kernel -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingSmoothPolynomialFactors_root_data {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) + (hL : L.natDegree ≤ 1) (hR : R.natDegree ≤ 1) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) : + ∃ S : Finset ℝ, S.card ≤ 2 ^ n ∧ ∀ i r, + r ∈ ((movingSmoothPolynomialFactors value T L R ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip i).polynomial.derivative).roots → r ∈ S := by + let F := movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi + let S := polynomialRootCuts (fun i => (F i).polynomial.derivative) + have hdeg (i : Fin (2 ^ n)) : (F i).polynomial.derivative.natDegree ≤ 1 := by + have h := movingFourierPolynomialFactors_degree value T L R ψ X lo hi hlo hhi hL hR i + change (F i).polynomial.natDegree ≤ 2 at h + exact (Polynomial.natDegree_derivative_le _).trans (by omega) + refine ⟨S, ?_, ?_⟩ + · exact (polynomialRootCuts_card _).trans (by + calc + _ ≤ ∑ _i : Fin (2 ^ n), 1 := Finset.sum_le_sum (fun i _ => hdeg i) + _ = _ := by simp) + · intro i r + refine Fin.addCases ?_ ?_ i + · intro j hr + simp only [movingSmoothPolynomialFactors, Fin.append_left] at hr + exact Finset.mem_biUnion.mpr ⟨j, Finset.mem_univ _, Multiset.mem_toFinset.mpr hr⟩ + · intro j + simp only [movingSmoothPolynomialFactors, Fin.append_right] + rw [movingNodeCutoffFactors_no_derivative_roots value T L R hL hR φ G B D hB hD hφ hlip j] + simp + +theorem movingRealKernel_slice_polynomial {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (coord : Bool) (fixed z : ℝ) : + movingRealKernel value T nodes ψ X lo hi hlo hhi φ G + (movingRealPair coord fixed z false) (movingRealPair coord fixed z true) = + movingRealGateWeight value T nodes X lo hi (movingRealPair coord fixed z) * + smoothPolynomialWeight (movingSmoothPolynomialFactors value T + (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) z := by + rw [movingSmoothPolynomialFactors_real value T _ _ ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout, + (movingCoordinate_eval coord fixed z).1, (movingCoordinate_eval coord fixed z).2] + unfold movingRealKernel + congr 2 + funext b + cases coord <;> cases b <;> rfl + +/-- The root count is uniform in both real coordinate values and all fixed +small primes. This is the certificate used by the joint giant comparison. -/ +theorem movingRealKernel_slice_root_data {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (coord : Bool) (fixed : ℝ) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let W := movingSmoothPolynomialFactors value T + (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + ∃ S : Finset ℝ, + S.card ≤ (2 ^ n - 1) * (3 * (7 * 2 ^ n)) + 5 * 2 ^ n ∧ + (∀ i r, r ∈ (W i).polynomial.derivative.roots → r ∈ S) ∧ + (∀ x y, rootCellCode S x = rootCellCode S y → + movingRealGateWeight value T nodes X lo hi (movingRealPair coord fixed x) = + movingRealGateWeight value T nodes X lo hi (movingRealPair coord fixed y)) := by + dsimp only + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + obtain ⟨S, hS, hroot⟩ := movingSmoothPolynomialFactors_root_data value T + (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + (by cases coord <;> simp [movingCoordinateLeft]) + (by cases coord <;> simp [movingCoordinateRight]) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + refine ⟨movingRealRootCuts value T nodes X lo hi coord fixed ∪ S, ?_, ?_, ?_⟩ + · have ha := movingRealRootCuts_card value hvalue childBound pivotBound T hf X lo hi coord fixed + exact (Finset.card_union_le _ _).trans (by dsimp only [nodes]; omega) + · intro i r hr + exact Finset.mem_union_right _ (hroot i r hr) + · intro x y hcode + exact movingRealGateWeight_rootCell value T nodes X lo hi coord fixed x y _ + Finset.subset_union_left hcode + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelTransport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelTransport.lean new file mode 100644 index 0000000000000000000000000000000000000000..087cb5cd98cec28c810a7a388f1f67ee49d3b300 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingKernelTransport.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.Ostmann.Construction.GiantDiscreteTransport + +namespace OAI + +/-! # Measure transport for the concrete bounded moving kernel -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical SchwartzMap + +theorem measurable_exp_pair_mul (K : ℝ → ℝ → ℂ) + (hK : Measurable (Function.uncurry K)) (c : ℂ) : + Measurable (Function.uncurry (fun x y => c * K (Real.exp x) (Real.exp y))) := by + have he : Measurable (fun z : ℝ × ℝ => (Real.exp z.1, Real.exp z.2)) := + (Real.continuous_exp.comp continuous_fst).measurable.prodMk + (Real.continuous_exp.comp continuous_snd).measurable + exact measurable_const.mul (hK.comp he) + +theorem moving_kernel_pair_transport {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (c : ℂ) (q a b : ℕ) (u v r s : ℝ) (μ ν : Measure ℝ) + [IsFiniteMeasure μ] [IsFiniteMeasure ν] (δ ε : ℝ) + (hleft : ∀ y, ‖complexPrimeInterval q a u v (fun x => + c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)) - + ∫ x, c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂μ‖ ≤ δ) + (hright : ∀ x, ‖complexPrimeInterval q b r s (fun y => + c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)) - + ∫ y, c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂ν‖ ≤ ε) : + ‖complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂ν ∂μ‖ ≤ + δ * reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) + ε * μ.real Set.univ := by + let H := fun x y => c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + have hbase := measurable_movingRealKernel value T nodes ψ X lo hi hlo hhi φ G B D + hB hD hφ hlip hout + have hmeas : Measurable (Function.uncurry H) := + measurable_exp_pair_mul (movingRealKernel value T nodes ψ X lo hi hlo hhi φ G) hbase c + have hnorm (x y : ℝ) : ‖H x y‖ ≤ ‖c‖ * + ((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) := by + dsimp only [H] + rw [norm_mul] + exact mul_le_mul_of_nonneg_left + (movingRealKernel_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ _ _) (norm_nonneg _) + exact prime_pair_integral_transport q a b u v r s μ ν H hmeas _ hnorm δ ε hleft hright + +theorem moving_kernel_mixed_transport {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (c : ℂ) (q a b : ℕ) (u v r s J : ℝ) (μ ν : Measure ℝ) + [IsFiniteMeasure μ] [IsFiniteMeasure ν] (δ ε : ℝ) + (hleft : ∀ y, ‖complexIntegerInterval q a u v J (fun x => + c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)) - + ∫ x, c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂μ‖ ≤ δ) + (hright : ∀ x, ‖complexPrimeInterval q b r s (fun y => + c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)) - + ∫ y, c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂ν‖ ≤ ε) : + ‖complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) ∂ν ∂μ‖ ≤ + δ * reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) + ε * μ.real Set.univ := by + let H := fun x y => c * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + have hbase := measurable_movingRealKernel value T nodes ψ X lo hi hlo hhi φ G B D + hB hD hφ hlip hout + have hmeas : Measurable (Function.uncurry H) := + measurable_exp_pair_mul (movingRealKernel value T nodes ψ X lo hi hlo hhi φ G) hbase c + have hnorm (x y : ℝ) : ‖H x y‖ ≤ ‖c‖ * + ((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) := by + dsimp only [H] + rw [norm_mul] + exact mul_le_mul_of_nonneg_left + (movingRealKernel_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ _ _) (norm_nonneg _) + exact mixed_pair_integral_transport q a b u v r s J μ ν H hmeas _ hnorm δ ε hleft hright + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLeafAmplitude.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLeafAmplitude.lean new file mode 100644 index 0000000000000000000000000000000000000000..834db68dad29cc79ebd09a1aac05b34afc73b57a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLeafAmplitude.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingScalarWindows +import OAI.NumberTheory.Ostmann.Tree.PairedFrequencyProjection +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticFrequencyTree + +namespace OAI + +/-! # The scalar leaf weights retain the actual frequency cutoff -/ + +namespace Ostmann +open scoped Classical + +theorem movingDataWeight_unit_leaf_bound {σ : Type*} + (F : {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) (V : ℕ) + (hF : ∀ s regular, ‖F (.leaf s regular) s‖ ≤ if s.natAbs ≤ V then 1 else 0) + (S : Finset ℤ) (n : ℕ) (t : FrequencyTree S n) + (small bulk : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) : + ‖movingDataWeight F (fun _ _ _ _ => 1) + (buildMovingSlotData n (frequencyTreeMap Subtype.val n t) small bulk a)‖ ≤ + frequencyLeafWeight (singleFrequencyLeaf S V) n t := by + induction a with + | leaf => exact hF _ _ + | @node n u l r ihL ihR => + simp only [buildMovingSlotData, frequencyTreeMap, movingDataWeight, + Complex.ofReal_one, one_mul, norm_mul, norm_star, frequencyLeafWeight] + exact mul_le_mul (ihL _ _ _) (ihR _ _ _) (norm_nonneg _) + (frequencyLeafWeight_nonneg _ (fun _ => by unfold singleFrequencyLeaf; split_ifs <;> norm_num) _ _) + +/-- Removing the explicit compensation multipliers leaves a scalar amplitude +of norm at most one whenever the actual leaf coefficients have that bound. -/ +theorem movingDataWeight_unit_norm_le_one {σ : Type*} + (F : {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (hF : ∀ s regular, ‖F (.leaf s regular) s‖ ≤ 1) + {n : ℕ} (T : MovingSlotData σ n) : + ‖movingDataWeight F (fun _ _ _ _ => 1) T‖ ≤ 1 := by + induction T with + | leaf s regular => exact hF s regular + | node s CL CR U l r ihL ihR => + simp only [movingDataWeight, Complex.ofReal_one, one_mul, norm_mul, norm_star] + exact (mul_le_mul ihL ihR (norm_nonneg _) (by norm_num)).trans_eq (one_mul 1) + +theorem frequencyLeafWeight_pair_projection (S : Finset ℤ) (V n : ℕ) + (t : FrequencyTree (S × S) n) : + frequencyLeafWeight (singleFrequencyLeaf S V) n (frequencyPairProjection S n false t) * + frequencyLeafWeight (singleFrequencyLeaf S V) n (frequencyPairProjection S n true t) = + frequencyLeafWeight (pairedFrequencyLeaf S V) n t := by + induction n with + | zero => + change (if (t.1 : ℤ).natAbs ≤ V then (1 : ℝ) else 0) * + (if (t.2 : ℤ).natAbs ≤ V then 1 else 0) = _ + unfold frequencyLeafWeight pairedFrequencyLeaf + split_ifs <;> simp_all + | succ n ih => + change + (frequencyLeafWeight (singleFrequencyLeaf S V) n (frequencyPairProjection S n false t.2.1) * + frequencyLeafWeight (singleFrequencyLeaf S V) n (frequencyPairProjection S n false t.2.2)) * + (frequencyLeafWeight (singleFrequencyLeaf S V) n (frequencyPairProjection S n true t.2.1) * + frequencyLeafWeight (singleFrequencyLeaf S V) n (frequencyPairProjection S n true t.2.2)) = _ * _ + rw [show ∀ a b c d : ℝ, (a * b) * (c * d) = (a * c) * (b * d) by intros; ring] + rw [ih t.2.1, ih t.2.2] + +theorem movingDataWeight_pair_unit_leaf_bound {σ : Type*} + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) (V : ℕ) + (hF : ∀ b s regular, ‖F b (.leaf s regular) s‖ ≤ if s.natAbs ≤ V then 1 else 0) + (S : Finset ℤ) (n : ℕ) (t : FrequencyTree (S × S) n) + (small : Bool → TreeLeafTuple (List σ) n) (bulk : TreeLeafTuple (List σ) n) + (a : Bool → MovingSampleSlots σ n) : + let T := fun b => buildMovingSlotData n + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t)) (small b) bulk (a b) + ‖movingDataWeight (F false) (fun _ _ _ _ => 1) (T false)‖ * + ‖movingDataWeight (F true) (fun _ _ _ _ => 1) (T true)‖ ≤ + frequencyLeafWeight (pairedFrequencyLeaf S V) n t := by + intro T + rw [← frequencyLeafWeight_pair_projection] + exact mul_le_mul (movingDataWeight_unit_leaf_bound (F false) V (hF false) S n _ _ bulk _) + (movingDataWeight_unit_leaf_bound (F true) V (hF true) S n _ _ bulk _) (norm_nonneg _) + (frequencyLeafWeight_nonneg _ (fun _ => by unfold singleFrequencyLeaf; split_ifs <;> norm_num) _ _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLeafPermutation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLeafPermutation.lean new file mode 100644 index 0000000000000000000000000000000000000000..13abee09528cb858f9cad08e4f396f3b24ac3ac7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLeafPermutation.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInitialCoefficient + +namespace OAI + +/-! # Reordering the regular primes in an original terminal leaf -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingLocalSupport_leaf_perm {A : Type*} (value : A → ℕ) + (outside : List ℕ) (L R : List A) (h : L.Perm R) (s : ℤ) (XL XR : ℕ) : + movingLocalSupport value outside ⟨0, .leaf s L, XL, XR⟩ ↔ + movingLocalSupport value outside ⟨0, .leaf s R, XL, XR⟩ := by + have hp : MovingSlotReversal.naturalProduct value L = + MovingSlotReversal.naturalProduct value R := (h.map value).prod_eq + have hpair := (((h.map value).cons XR).cons XL).append_right outside + have he : (XL :: XR :: L.map value ++ outside).Pairwise Nat.Coprime ↔ + (XL :: XR :: R.map value ++ outside).Pairwise Nat.Coprime := + hpair.pairwise_iff (fun h => h.symm) + simp only [movingLocalSupport, MovingSlotData.currentSlots, MovingSlotData.regularSlots, + movingLocalGiantUnits, MovingSlotData.frequencyProduct, List.cons_append, hp] + exact and_congr_left (fun _ => by simpa only [List.cons_append] using he) + +theorem movingOriginalLeaf_constant_leaf_perm {A I : Type*} (value : A → ℕ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (L R : List A) (h : L.Perm R) (s : ℤ) (XL XR : ℕ) : + movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi ⟨0, .leaf s L, XL, XR⟩ s = + movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi ⟨0, .leaf s R, XL, XR⟩ s := by + have hp : MovingSlotReversal.naturalProduct value L = + MovingSlotReversal.naturalProduct value R := (h.map value).prod_eq + simp only [movingOriginalLeaf, movingWindowLeaf, movingDataLeaf, movingFourierLeaf, + movingSlotModulus, spectatorHistoryLeaf, hp] + rfl + +theorem movingFrequencyCoefficient_zero_small_perm {A I : Type} [Fintype A] + (value : A → ℕ) (outside : List ℕ) (μ : ℕ → A → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (L R bulk : List A) (h : L.Perm R) (s : ℤ) (XL XR : ℕ) : + movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G 0 s L bulk XL XR = + movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G 0 s R bulk XL XR := by + rw [movingFrequencyCoefficient_levelZero, movingFrequencyCoefficient_levelZero] + unfold movingGuardedLeaf + rw [movingLocalSupport_leaf_perm value outside (L ++ bulk) (R ++ bulk) (h.append_right bulk)] + rw [movingOriginalLeaf_constant_leaf_perm value q f g Dq S ψ X lo hi + (L ++ bulk) (R ++ bulk) (h.append_right bulk)] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..fd6e097058b07080437f57809d7a23a845d3742b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineComparison.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantPolynomial +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticLineComparison + +namespace OAI + +/-! # Original-prior comparison for the moving-giant occurrence lines -/ + +namespace Ostmann +open scoped BigOperators Classical + +/-- No degree or height of an occurrence line is assumed: both are inherited +from its actual path of reversals. The same applies to its nonzero row. -/ +theorem moving_line_probability_comparison {A J : Type*} [Fintype A] [Fintype J] + {n : ℕ} (value : A → ℤ) (hinj : Function.Injective value) + (steps : J → List (PolynomialReversal (Fin n))) + (v w : J → MvPolynomial (Fin n) ℤ) (i : J) (external : Bool) + (k d : ℕ) (hlen : ∀ j, (steps j).length ≤ k) + (hdegree : ∀ j, (∀ s ∈ steps j, + s.v.totalDegree ≤ d ∧ s.w.totalDegree ≤ d ∧ s.u.totalDegree ≤ d) ∧ + (v j).totalDegree ≤ d ∧ (w j).totalDegree ≤ d) + (K : ℝ) (hK : 1 ≤ K) + (hheight : ∀ (x : Fin n → A) j, + let φ := MvPolynomial.eval₂Hom (Int.castRingHom ℝ) (fun a => (value (x a) : ℝ)) + (∀ s ∈ steps j, |φ s.v| ≤ K ∧ |φ s.w| ≤ K ∧ |φ s.u| ≤ K) ∧ + |φ (v j)| ≤ K ∧ |φ (w j)| ≤ K) + (μ : Fin n → A → ℝ) (hμ : ∀ j a, 0 ≤ μ j a) + (hmass : ∀ j, ∑ a, μ j a = 1) + (α : ℝ) (hα : 0 ≤ α) (hmax : ∀ j a, μ j a ≤ α) + (P : Finset ℕ) (hprime : ∀ p ∈ P, p.Prime) + (ν : ℕ → ℝ) (hν : ∀ p ∈ P, 0 ≤ ν p) (hνmass : ∑ p ∈ P, ν p = 1) + (β V : ℝ) (hβ : 0 ≤ β) (hV : 0 < V) + (hνmax : ∀ p ∈ P, ν p ≤ β) (hsize : ∀ p ∈ P, V ≤ Real.log (p : ℝ)) + (hunits : ∀ (x : Fin n → A) (p : P) j, + let φ := integerLineReduction value x p + (∀ s ∈ steps j, φ s.v ≠ 0 ∧ φ s.w ≠ 0 ∧ φ s.u ≠ 0) ∧ + φ (v j) ≠ 0 ∧ φ (w j) ≠ 0) + (F : (Fin n → A) → ℕ → ℂ) (B : ℝ) (hB : 0 ≤ B) (hF : ∀ x p, ‖F x p‖ ≤ B) : + let L := fun j => movingHistoryLine (steps j) (v j) (w j) + ‖∑ x, ∑ p : P, ((productPrior μ x * ν p : ℝ) : ℂ) * F x p * + ((sampledLineProbability value L external P hprime x p : ℂ) - + (internalLineFlagWeight external p + (fun s => arithmeticTestFlag (lineTestPolynomials L i s = 0)) : ℂ))‖ ≤ + 2 * B * (2 + Fintype.card J) * + ((2 * ((k + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * K) ^ (k + 1)) ^ 2) / V) * β) := by + let L := fun j => movingHistoryLine (steps j) (v j) (w j) + let H := (2 * K) ^ (k + 1) + have hK0 : 0 ≤ K := by linarith + have hH : 1 ≤ H := one_le_pow₀ (by linarith) + have hlineDegree (j : J) : (L j).a.totalDegree ≤ (k + 1) * d ∧ + (L j).b.totalDegree ≤ (k + 1) * d := by + have hj := movingHistoryLine_degree (steps j) (v j) (w j) d + (hdegree j).1 (hdegree j).2.1 (hdegree j).2.2 + have hb : ((steps j).length + 1) * d ≤ (k + 1) * d := + Nat.mul_le_mul_right d (Nat.add_le_add_right (hlen j) 1) + exact ⟨hj.1.trans hb, hj.2.trans hb⟩ + have hlineHeight (x : Fin n → A) (j : J) : + let φ := MvPolynomial.eval₂Hom (Int.castRingHom ℝ) (fun a => (value (x a) : ℝ)) + |φ (L j).a| ≤ H ∧ |φ (L j).b| ≤ H := by + have hj := movingHistoryLine_value (steps j) (v j) (w j) _ K hK0 + (hheight x j).1 (hheight x j).2.1 (hheight x j).2.2 + have hb : (2 * K) ^ ((steps j).length + 1) ≤ H := by + apply pow_le_pow_right₀ (by linarith : 1 ≤ 2 * K) + exact Nat.add_le_add_right (hlen j) 1 + exact ⟨hj.1.trans hb, hj.2.trans hb⟩ + have htestHeight (s : Bool ⊕ J) (x : Fin n → A) : + |(integerTestValue value (lineTestPolynomials L i s) x : ℝ)| ≤ 2 * H ^ 2 := by + rw [integerTestValue_real_cast] + exact lineTestPolynomials_value_le L i _ H hH (hlineHeight x) s + have hHfull : 1 ≤ 2 * H ^ 2 := by nlinarith [sq_nonneg H] + have hden (x : Fin n → A) (p : P) (j : J) : + integerLineReduction value x p (L j).denominator ≠ 0 := by + let : Fact (p.val.Prime) := ⟨hprime _ p.property⟩ + exact movingPolynomialAncestors_denominator (steps j) _ + (fun s hs => ((hunits x p j).1 s hs).2.2) + have hrow (x : Fin n → A) (p : P) : + integerLineReduction value x p (L i).a ≠ 0 ∨ + integerLineReduction value x p (L i).b ≠ 0 := by + let : Fact (p.val.Prime) := ⟨hprime _ p.property⟩ + exact movingHistoryLine_nonzero (steps i) (v i) (w i) _ + (hunits x p i).1 (hunits x p i).2.1 (hunits x p i).2.2 + have hcomp := sampled_line_probability_comparison_le value hinj L i external μ hμ hmass + α hα hmax P hprime ν hν hνmass β V (2 * H ^ 2) hβ hV hHfull hνmax hsize + htestHeight hden hrow F B hB hF + apply hcomp.trans + have hterm (s : Bool ⊕ J) : + ((lineTestPolynomials L i s).totalDegree : ℝ) * α + + (Real.log (2 * H ^ 2) / V) * β ≤ + ((2 * ((k + 1) * d) : ℕ) : ℝ) * α + (Real.log (2 * H ^ 2) / V) * β := by + have hd : ((lineTestPolynomials L i s).totalDegree : ℝ) ≤ + ((2 * ((k + 1) * d) : ℕ) : ℝ) := by + exact_mod_cast lineTestPolynomials_degree_le L i ((k + 1) * d) hlineDegree s + exact add_le_add (mul_le_mul_of_nonneg_right hd hα) le_rfl + have hsum := Finset.sum_le_sum (s := Finset.univ) (fun s _ => hterm s) + apply (mul_le_mul_of_nonneg_left hsum (mul_nonneg (by norm_num) hB)).trans_eq + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_sum, Fintype.card_bool, + nsmul_eq_mul, Nat.cast_add, Nat.cast_ofNat, H] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineComposition.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineComposition.lean new file mode 100644 index 0000000000000000000000000000000000000000..da12e64251744d4a98e183628b6fab7bf3cc2269 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineComposition.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyResidues + +namespace OAI + +/-! # Composition of the cleared occurrence lines + +The identity works before any descendant division. It lets the current +internal-prime congruence establish integrality inductively, without assuming +the conclusion for the rest of the path. +-/ + +namespace Ostmann +open scoped Classical + +noncomputable def PolynomialGiantRows.evalNumerator {σ R : Type*} [CommRing R] + (T : PolynomialGiantRows σ) (φ : MvPolynomial σ ℤ →+* R) (x y : R) : R × R := + (φ T.rows.a * x + φ T.rows.b * y, φ T.rows.c * x + φ T.rows.d * y) + +theorem PolynomialGiantRows.evalNumerator_movingReverse {σ R : Type*} [CommRing R] + (T : PolynomialGiantRows σ) (φ : MvPolynomial σ ℤ →+* R) + (left : Bool) (v w u : MvPolynomial σ ℤ) (x y : R) : + (T.movingReverse left v w u).evalNumerator φ x y = + (φ v * (T.evalNumerator φ x y).2 - φ w * (T.evalNumerator φ x y).1, + φ u * (if left then (T.evalNumerator φ x y).1 else (T.evalNumerator φ x y).2)) := by + cases left <;> apply Prod.ext <;> + simp only [evalNumerator, movingReverse, reverse, swap, GiantRows.swap, + Bool.false_eq_true, ite_false, ite_true, map_mul, map_sub] <;> ring + +theorem movingPolynomialAncestors_append_eval {σ R : Type*} [CommRing R] + (φ : MvPolynomial σ ℤ →+* R) (a b : List (PolynomialReversal σ)) (x y : R) : + (movingPolynomialAncestors (a ++ b)).evalNumerator φ x y = + (movingPolynomialAncestors a).evalNumerator φ + ((movingPolynomialAncestors b).evalNumerator φ x y).1 + ((movingPolynomialAncestors b).evalNumerator φ x y).2 := by + induction a with + | nil => simp [movingPolynomialAncestors, PolynomialGiantRows.evalNumerator, + PolynomialGiantRows.identity, GiantRows.identity] + | cons s a ih => + simp only [List.cons_append, movingPolynomialAncestors, + PolynomialGiantRows.evalNumerator_movingReverse, ih] + +theorem PolynomialGiantRows.evalNumerator_smul {σ R : Type*} [CommRing R] + (T : PolynomialGiantRows σ) (φ : MvPolynomial σ ℤ →+* R) (c x y : R) : + T.evalNumerator φ (c * x) (c * y) = + (c * (T.evalNumerator φ x y).1, c * (T.evalNumerator φ x y).2) := by + apply Prod.ext <;> simp only [evalNumerator] <;> ring + +theorem movingSlotLine_eval {σ R : Type*} [CommRing R] + (φ : MvPolynomial σ ℤ →+* R) (path : List (MovingSlotReversal σ)) + (s : MovingSlotReversal σ) (x y : R) : + φ (movingSlotLine path s).a * x + φ (movingSlotLine path s).b * y = + φ s.polynomial.v * ((movingPolynomialAncestors + (path.map MovingSlotReversal.polynomial)).evalNumerator φ x y).2 - + φ s.polynomial.w * ((movingPolynomialAncestors + (path.map MovingSlotReversal.polynomial)).evalNumerator φ x y).1 := by + simp only [movingSlotLine, movingHistoryLine, PolynomialGiantRows.numeratorLine, + PolynomialGiantRows.evalNumerator, map_mul, map_sub] + ring + +/-- A root division multiplies every descendant cleared line by its root +denominator. No integrality of the descendant path is needed. -/ +theorem movingSlotLine_append_singleton {σ R : Type*} [CommRing R] + (φ : MvPolynomial σ ℤ →+* R) (path : List (MovingSlotReversal σ)) + (current root : MovingSlotReversal σ) (x y p : R) + (hroot : φ root.polynomial.v * y - φ root.polynomial.w * x = φ root.polynomial.u * p) : + φ (movingSlotLine (path ++ [root]) current).a * x + + φ (movingSlotLine (path ++ [root]) current).b * y = + φ root.polynomial.u * (φ (movingSlotLine path current).a * p + + φ (movingSlotLine path current).b * (if root.left then x else y)) := by + rw [movingSlotLine_eval, movingSlotLine_eval, List.map_append, + movingPolynomialAncestors_append_eval] + have he : (movingPolynomialAncestors ([root].map MovingSlotReversal.polynomial)).evalNumerator φ x y = + (φ root.polynomial.u * p, φ root.polynomial.u * (if root.left then x else y)) := by + rw [List.map_cons, List.map_nil, movingPolynomialAncestors, + PolynomialGiantRows.evalNumerator_movingReverse] + simp only [MovingSlotReversal.polynomial] at hroot + simp only [movingPolynomialAncestors, PolynomialGiantRows.evalNumerator, + PolynomialGiantRows.identity, GiantRows.identity, map_one, map_zero, + one_mul, zero_mul, add_zero, zero_add, MovingSlotReversal.polynomial, hroot] + rw [he, PolynomialGiantRows.evalNumerator_smul] + simp only + ring + +theorem movingSlotLine_append_singleton_zero_iff {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (path : List (MovingSlotReversal σ)) + (current root : MovingSlotReversal σ) (x y p : ℤ) + (hroot : root.signedNumerator value x y = + root.rootFrequency * (MovingSlotReversal.naturalProduct value root.compensationSlots : ℤ) * p) + (hu : MovingSlotReversal.naturalReduction q value root.polynomial.u ≠ 0) : + let φ := MovingSlotReversal.naturalReduction q value + φ (movingSlotLine (path ++ [root]) current).a * (x : ZMod q) + + φ (movingSlotLine (path ++ [root]) current).b * (y : ZMod q) = 0 ↔ + φ (movingSlotLine path current).a * (p : ZMod q) + + φ (movingSlotLine path current).b * ((if root.left then x else y : ℤ) : ZMod q) = 0 := by + have hc := congrArg (fun z : ℤ => (z : ZMod q)) hroot + simp only [MovingSlotReversal.signedNumerator, Int.cast_sub, Int.cast_mul, + Int.cast_natCast] at hc + have hh : MovingSlotReversal.naturalReduction q value root.polynomial.v * (y : ZMod q) - + MovingSlotReversal.naturalReduction q value root.polynomial.w * (x : ZMod q) = + MovingSlotReversal.naturalReduction q value root.polynomial.u * (p : ZMod q) := by + simp only [MovingSlotReversal.naturalReduction, MovingSlotReversal.polynomial, + MovingSlotReversal.coefficient_nat_eval] + linear_combination hc + have he := movingSlotLine_append_singleton (MovingSlotReversal.naturalReduction q value) + path current root (x : ZMod q) (y : ZMod q) (p : ZMod q) hh + dsimp only + rw [he, mul_eq_zero, or_iff_right hu] + cases root.left <;> rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineIntegration.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineIntegration.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0c0ac5777bd628306cc8d25219ebc0bce3eb996 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineIntegration.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotLines + +namespace OAI + +/-! # Integrating the actual moving-giant line systems on their full support -/ + +namespace Ostmann +open scoped BigOperators Classical + +noncomputable def movingSlotLineProbability {A J : Type*} {n : ℕ} + (value : A → ℤ) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (path : J → List (MovingSlotReversal (Fin n))) + (current : J → MovingSlotReversal (Fin n)) (external : Bool) + (x : Fin n → A) (a : A) : ℝ := + let _ : Fact (prime a).Prime := ⟨hprime a⟩ + let φ := integerLineReduction value x (prime a) + internalLineProbability external + (fun j => ((movingSlotLine (path j) (current j)).normalized φ).1) + (fun j => ((movingSlotLine (path j) (current j)).normalized φ).2) + +theorem movingSlotLineProbability_eq_flags {A J : Type*} {n : ℕ} + (value : A → ℤ) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (path : J → List (MovingSlotReversal (Fin n))) + (current : J → MovingSlotReversal (Fin n)) (base : J) (external : Bool) + (x : Fin n → A) (a : A) + (hpath : ∀ j s, s ∈ path j → + let φ := integerLineReduction value x (prime a) + φ s.polynomial.v ≠ 0 ∧ φ s.polynomial.w ≠ 0 ∧ φ s.polynomial.u ≠ 0) + (hcurrent : let φ := integerLineReduction value x (prime a) + φ (current base).polynomial.v ≠ 0 ∧ φ (current base).polynomial.w ≠ 0) : + movingSlotLineProbability value prime hprime path current external x a = + internalLineFlagWeight external (prime a) (fun s => arithmeticTestFlag + (prime a ∣ (integerTestValue value + (lineTestPolynomials (fun j => movingSlotLine (path j) (current j)) base s) x).natAbs)) := by + let : Fact (prime a).Prime := ⟨hprime a⟩ + let φ := integerLineReduction value x (prime a) + have hsteps (j : J) : ∀ s ∈ (path j).map MovingSlotReversal.polynomial, + φ s.v ≠ 0 ∧ φ s.w ≠ 0 ∧ φ s.u ≠ 0 := by + intro s hs + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs + exact hpath j t ht + have hd (j : J) : φ (movingSlotLine (path j) (current j)).denominator ≠ 0 := + movingPolynomialAncestors_denominator _ φ (fun s hs => (hsteps j s hs).2.2) + have hr := movingHistoryLine_nonzero _ _ _ φ (hsteps base) hcurrent.1 hcurrent.2 + have hz := (movingSlotLine (path base) (current base)).normalized_zero_iff φ (hd base) + have hr' : ((movingSlotLine (path base) (current base)).normalized φ).1 ≠ 0 ∨ + ((movingSlotLine (path base) (current base)).normalized φ).2 ≠ 0 := + hr.imp (fun h h₀ => h (hz.1.mp h₀)) (fun h h₀ => h (hz.2.mp h₀)) + unfold movingSlotLineProbability + rw [internalLineProbability_eq_flags external _ base φ hd hr'] + change internalLineFlagWeight external (prime a) (fun s => arithmeticTestFlag + (MvPolynomial.eval₂Hom (Int.castRingHom (ZMod (prime a))) + (fun i => (value (x i) : ZMod (prime a))) + (lineTestPolynomials (fun j => movingSlotLine (path j) (current j)) base s) = 0)) = _ + rw [line_divisibility_flags_eq] + +theorem internalLineFlagWeight_le_scalar {J : Type*} (external : Bool) (p : ℕ) + (flags : Bool ⊕ J → Bool) : + internalLineFlagWeight external p flags ≤ internalLineScalar external p := by + unfold internalLineFlagWeight + split_ifs + · rfl + · exact internalLineScalar_nonneg external p + +/-- The remaining weight may be large. Its bound is imposed only after the +one-over-prime line scalars have been included, exactly as in (8.20). -/ +theorem line_product_multiplier_bound {A J O : Type*} [Fintype J] + (prime : A → ℕ) (external : J → Bool) (representative : J → A) + (weight : ℂ) (B : ℝ) + (h : ‖weight‖ * ∏ j, internalLineScalar (external j) (prime (representative j)) ≤ B) + (flags : J × (Bool ⊕ O) → Bool) : + ‖weight * ∏ j, (internalLineFlagWeight (external j) (prime (representative j)) + (fun s => flags (j, s)) : ℂ)‖ ≤ B := by + rw [norm_mul, norm_prod] + have he (j : J) : ‖(internalLineFlagWeight (external j) (prime (representative j)) + (fun s => flags (j, s)) : ℂ)‖ = + internalLineFlagWeight (external j) (prime (representative j)) (fun s => flags (j, s)) := by + rw [Complex.norm_real, Real.norm_of_nonneg (internalLineFlagWeight_nonneg _ _ _)] + simp_rw [he] + apply le_trans _ h + apply mul_le_mul_of_nonneg_left _ (norm_nonneg weight) + exact Finset.prod_le_prod₀ (fun _ _ => internalLineFlagWeight_nonneg _ _ _) + (fun _ _ => internalLineFlagWeight_le_scalar _ _ _) + +/-- On the original full support the actual line counts can be inserted into +the same signed expression. No line identity is requested on rejected samples. -/ +theorem moving_line_product_on_support {A J O : Type*} [Fintype J] {n : ℕ} + (value : A → ℤ) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (path : J → O → List (MovingSlotReversal (Fin n))) + (current : J → O → MovingSlotReversal (Fin n)) (base : J → O) + (external : J → Bool) (representative : J → A) (x : Fin n → A) (weight : ℂ) + (hpath : weight ≠ 0 → ∀ j o s, s ∈ path j o → + let φ := integerLineReduction value x (prime (representative j)) + φ s.polynomial.v ≠ 0 ∧ φ s.polynomial.w ≠ 0 ∧ φ s.polynomial.u ≠ 0) + (hcurrent : weight ≠ 0 → ∀ j, + let φ := integerLineReduction value x (prime (representative j)) + φ (current j (base j)).polynomial.v ≠ 0 ∧ φ (current j (base j)).polynomial.w ≠ 0) : + weight * ∏ j, (movingSlotLineProbability value prime hprime (path j) (current j) + (external j) x (representative j) : ℂ) = + weight * ∏ j, (internalLineFlagWeight (external j) (prime (representative j)) + (fun s => arithmeticTestFlag (prime (representative j) ∣ + (integerTestValue value (lineTestPolynomials + (fun o => movingSlotLine (path j o) (current j o)) (base j) s) x).natAbs)) : ℂ) := by + by_cases hw : weight = 0 + · simp only [hw, zero_mul] + · congr 1 + apply Finset.prod_congr rfl + intro j _ + exact congrArg (fun r : ℝ => (r : ℂ)) + (movingSlotLineProbability_eq_flags value prime hprime (path j) (current j) (base j) + (external j) x (representative j) (hpath hw j) (hcurrent hw j)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineProductComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineProductComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..e963928ab88f09956c788e234e66051342e8333c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLineProductComparison.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingLineIntegration + +namespace OAI + +/-! # Signed joint arithmetic comparison with the actual line integrals -/ + +namespace Ostmann +open scoped BigOperators Classical + +/-- This replaces the actual simultaneous line probabilities, under the +original product law, by their symbolic rank and feasibility flags. The +support may contain any further arithmetic and smooth restrictions. -/ +theorem moving_slot_line_product_comparison {A J O : Type*} + [Fintype A] [Nonempty A] [Fintype J] [Fintype O] {n : ℕ} + (value : A → ℤ) (hinj : Function.Injective value) + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (path : J → O → List (MovingSlotReversal (Fin (n + 1)))) + (current : J → O → MovingSlotReversal (Fin (n + 1))) + (base : J → O) (coordinate : J → Fin (n + 1)) (external : J → Bool) + (k d : ℕ) (F T : ℝ) (hF : 1 ≤ F) (hT : 1 ≤ T) + (hlen : ∀ j o, (path j o).length ≤ k) + (hd : ∀ j o, (∀ s ∈ path j o, s.lengthLE d ∧ s.frequencyLE F) ∧ + (current j o).lengthLE d ∧ (current j o).frequencyLE F) + (habsent : ∀ j o, + (∀ s ∈ path j o, coordinate j ∉ s.leftSlots ∧ coordinate j ∉ s.rightSlots ∧ + coordinate j ∉ s.compensationSlots) ∧ + coordinate j ∉ (current j o).leftSlots ∧ coordinate j ∉ (current j o).rightSlots) + (hvalues : ∀ a, |(value a : ℝ)| ≤ T) + (μ : Fin (n + 1) → A → ℝ) (hμ : ∀ i a, 0 ≤ μ i a) + (hmass : ∀ i, ∑ a, μ i a = 1) + (α β V : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hmax : ∀ i a, μ i a ≤ α) (hpmax : ∀ j a, μ (coordinate j) a ≤ β) + (hsize : ∀ j a, μ (coordinate j) a ≠ 0 → V ≤ Real.log (prime a : ℝ)) + (weight : (Fin (n + 1) → A) → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hweight : ∀ x, ‖weight x‖ * + ∏ j, internalLineScalar (external j) (prime (x (coordinate j))) ≤ B) + (hpath : ∀ x, weight x ≠ 0 → ∀ j o s, s ∈ path j o → + let φ := integerLineReduction value x (prime (x (coordinate j))) + φ s.polynomial.v ≠ 0 ∧ φ s.polynomial.w ≠ 0 ∧ φ s.polynomial.u ≠ 0) + (hcurrent : ∀ x, weight x ≠ 0 → ∀ j, + let φ := integerLineReduction value x (prime (x (coordinate j))) + φ (current j (base j)).polynomial.v ≠ 0 ∧ φ (current j (base j)).polynomial.w ≠ 0) : + ‖∑ x, (productPrior μ x : ℂ) * weight x * + ((∏ j, (movingSlotLineProbability value prime hprime (path j) (current j) + (external j) x (x (coordinate j)) : ℂ)) - + ∏ j, (internalLineFlagWeight (external j) (prime (x (coordinate j))) + (fun s => arithmeticTestFlag (lineTestPolynomials + (fun o => movingSlotLine (path j o) (current j o)) (base j) s = 0)) : ℂ))‖ ≤ + 2 * B * (Fintype.card J * (2 + Fintype.card O)) * + ((2 * ((k + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * T ^ d)) ^ (k + 1)) ^ 2) / V) * β) := by + let Ψ := fun (x : Fin (n + 1) → A) (flags : J × (Bool ⊕ O) → Bool) => + weight x * ∏ j, (internalLineFlagWeight (external j) (prime (x (coordinate j))) + (fun s => flags (j, s)) : ℂ) + have hΨ (x : Fin (n + 1) → A) (flags : J × (Bool ⊕ O) → Bool) : ‖Ψ x flags‖ ≤ B := + line_product_multiplier_bound prime external (fun j => x (coordinate j)) (weight x) B + (hweight x) flags + have h := moving_slot_joint_symbolic_comparison value hinj prime hpInj hprime + path current base coordinate k d F T hF hT hlen hd habsent hvalues μ hμ hmass + α β V hα hβ hV hmax hpmax hsize Ψ B hB hΨ + have he (x : Fin (n + 1) → A) := moving_line_product_on_support value prime hprime + path current base external (fun j => x (coordinate j)) x (weight x) (hpath x) (hcurrent x) + convert h using 1 + congr 1 + apply Finset.sum_congr rfl + intro x _ + dsimp only [Ψ] + rw [mul_sub, mul_assoc, he, ← mul_sub] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLivePrimeDivisors.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLivePrimeDivisors.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d8fcdafead0dd15513468ace1ba3a2dc65d3aa0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLivePrimeDivisors.lean @@ -0,0 +1,33 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingConstructedLiveProductStep + +namespace OAI + +/-! # Frequency separation from the live original prime priors -/ +namespace Ostmann +open scoped Classical BigOperators + +theorem live_prime_product_divisor_large {I P : Type*} [Fintype I] + (value : P → ℕ) (hvalue : ∀ p, (value p).Prime) + (ν : I → P → ℝ) (V : ℕ) + (hlive : ∀ i p, ν i p ≠ 0 → V < value p) + (y : I → P) (hy : (∏ i, ν i (y i)) ≠ 0) + (q : ℕ) (hq : q.Prime) (hd : q ∣ ∏ i, value (y i)) : V < q := by + obtain ⟨i, _, hi⟩ := (hq.prime.dvd_finsetProd_iff _).mp hd + have he : q = value (y i) := (Nat.dvd_prime (hvalue _)).mp hi |>.resolve_left hq.ne_one + rw [he] + exact hlive i (y i) (Finset.prod_ne_zero_iff.mp hy i (Finset.mem_univ _)) + +theorem live_giant_product_divisor_large {I P : Type*} [Fintype I] + (value : P → ℕ) (hvalue : ∀ p, (value p).Prime) + (ν : I → P → ℝ) (V X : ℕ) (hX : X.Prime) (hXV : V < X) + (hlive : ∀ i p, ν i p ≠ 0 → V < value p) + (y : I → P) (hy : (∏ i, ν i (y i)) ≠ 0) + (q : ℕ) (hq : q.Prime) (hd : q ∣ X * ∏ i, value (y i)) : V < q := by + rcases hq.dvd_mul.mp hd with hd | hd + · have he : q = X := (Nat.dvd_prime hX).mp hd |>.resolve_left hq.ne_one + exact he ▸ hXV + · exact live_prime_product_divisor_large value hvalue ν V hlive y hy q hq hd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLogLeaves.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLogLeaves.lean new file mode 100644 index 0000000000000000000000000000000000000000..108fc499fc0380d36382dafacdfd6e9759846695 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLogLeaves.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPivotDerivative + +namespace OAI + +/-! # Logarithmic derivatives of the actual terminal moving moduli -/ + +namespace Ostmann + +noncomputable def MovingSlotData.realLeafModuli {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℝ → ℝ → TreeLeafIndex n → ℝ + | _, .leaf _ regular, L, R, _ => L * R * MovingSlotReversal.naturalProduct value regular + | _, .node s CL CR u left right, L, R, i => + let p := (MovingSlotData.step s CL CR u left right false).realPivot value L R + match i with + | .inl i => left.realLeafModuli value p L i + | .inr i => right.realLeafModuli value p R i + +/-- The quantitative cancellation test at every actual internal node. -/ +def MovingSlotData.PivotControl {σ : Type*} (value : σ → ℕ) (A : ℝ) : + {n : ℕ} → MovingSlotData σ n → ℝ → ℝ → Prop + | _, .leaf _ _, _, _ => True + | _, .node s CL CR u left right, L, R => + let step := MovingSlotData.step s CL CR u left right false + let p := step.realPivot value L R + 0 < p ∧ + |(left.frequency : ℝ) * (MovingSlotReversal.naturalProduct value CR : ℝ) * R| + + |(right.frequency : ℝ) * (MovingSlotReversal.naturalProduct value CL : ℝ) * L| ≤ + A * |(s : ℝ) * (MovingSlotReversal.naturalProduct value u : ℝ)| * p ∧ + left.PivotControl value A p L ∧ right.PivotControl value A p R + +theorem positive_product_relative_derivative (X Y C dX dY D : ℝ) + (hX : 0 ≤ X) (hY : 0 ≤ Y) (hC : 0 ≤ C) + (hDX : |dX| ≤ D * X) (hDY : |dY| ≤ D * Y) : + |(dX * Y + X * dY) * C| ≤ 2 * D * (X * Y * C) := by + rw [abs_mul, abs_of_nonneg hC] + calc + _ ≤ (|dX * Y| + |X * dY|) * C := + mul_le_mul_of_nonneg_right (abs_add_le _ _) hC + _ = (|dX| * Y + X * |dY|) * C := by + rw [abs_mul, abs_mul, abs_of_nonneg hX, abs_of_nonneg hY] + _ ≤ (D * X * Y + X * (D * Y)) * C := by gcongr + _ = _ := by ring + +/-- Each leaf modulus has logarithmic derivative at most `2*A^depth*D`. +The depth, rather than the number of leaves, controls the amplification. -/ +theorem MovingSlotData.realLeafModuli_derivative {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (A D : ℝ) (hA : 1 ≤ A) (hD : 0 ≤ D) + {L R : ℝ → ℝ} {x dL dR : ℝ} (hL : HasDerivAt L dL x) (hR : HasDerivAt R dR x) + (hL0 : 0 < L x) (hR0 : 0 < R x) (hdL : |dL| ≤ D * L x) (hdR : |dR| ≤ D * R x) + (hcontrol : T.PivotControl value A (L x) (R x)) (i : TreeLeafIndex n) : + ∃ dM : ℝ, + HasDerivAt (fun z => T.realLeafModuli value (L z) (R z) i) dM x ∧ + 0 < T.realLeafModuli value (L x) (R x) i ∧ + |dM| ≤ 2 * A ^ n * D * T.realLeafModuli value (L x) (R x) i := by + induction T generalizing D L R dL dR with + | leaf s regular => + let C : ℝ := MovingSlotReversal.naturalProduct value regular + have hC : 0 < C := by + dsimp only [C] + exact_mod_cast Nat.pos_of_ne_zero (MovingSlotReversal.naturalProduct_ne_zero value hvalue regular) + refine ⟨(dL * R x + L x * dR) * C, (hL.mul hR).mul_const C, ?_, ?_⟩ + · change 0 < L x * R x * C + positivity + · simpa only [realLeafModuli, pow_zero, mul_one, mul_assoc] using + positive_product_relative_derivative (L x) (R x) C dL dR D hL0.le hR0.le hC.le hdL hdR + | @node n s CL CR u left right ihL ihR => + let step := MovingSlotData.step s CL CR u left right false + let P : ℝ → ℝ := fun z => step.realPivot value (L z) (R z) + let dP := step.realPivot value dL dR + have hp : HasDerivAt P dP x := step.realPivot_hasDerivAt value hL hR + have hp0 : 0 < P x := hcontrol.1 + have hdP : |dP| ≤ (A * D) * P x := + moving_pivot_relative_derivative _ _ _ (L x) (R x) dL dR (P x) A D + (mul_ne_zero (Int.cast_ne_zero.mpr hf.1) + (Nat.cast_ne_zero.mpr (MovingSlotReversal.naturalProduct_ne_zero value hvalue u))) + hL0.le hR0.le hD hdL hdR hcontrol.2.1 + have hAD : 0 ≤ A * D := mul_nonneg (by linarith) hD + have hDAD : D ≤ A * D := by simpa only [one_mul] using mul_le_mul_of_nonneg_right hA hD + have hdL' : |dL| ≤ (A * D) * L x := hdL.trans (mul_le_mul_of_nonneg_right hDAD hL0.le) + have hdR' : |dR| ≤ (A * D) * R x := hdR.trans (mul_le_mul_of_nonneg_right hDAD hR0.le) + cases i with + | inl i => + obtain ⟨dM, hM, hM0, hdM⟩ := ihL hf.2.1 (A * D) hAD hp hL hp0 hL0 hdP hdL' hcontrol.2.2.1 i + refine ⟨dM, hM, hM0, ?_⟩ + change |dM| ≤ 2 * A ^ (n + 1) * D * left.realLeafModuli value (P x) (L x) i + convert hdM using 1; ring + | inr i => + obtain ⟨dM, hM, hM0, hdM⟩ := ihR hf.2.2 (A * D) hAD hp hR hp0 hR0 hdP hdR' hcontrol.2.2.2 i + refine ⟨dM, hM, hM0, ?_⟩ + change |dM| ≤ 2 * A ^ (n + 1) * D * right.realLeafModuli value (P x) (R x) i + convert hdM using 1; ring + +/-- In logarithmic coordinates the derivative bound no longer contains the +large leaf modulus. This is the quantity needed for smooth cutoffs. -/ +theorem MovingSlotData.log_realLeafModuli_derivative {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (A D : ℝ) (hA : 1 ≤ A) (hD : 0 ≤ D) + {L R : ℝ → ℝ} {x dL dR : ℝ} (hL : HasDerivAt L dL x) (hR : HasDerivAt R dR x) + (hL0 : 0 < L x) (hR0 : 0 < R x) (hdL : |dL| ≤ D * L x) (hdR : |dR| ≤ D * R x) + (hcontrol : T.PivotControl value A (L x) (R x)) (i : TreeLeafIndex n) : + ∃ d : ℝ, HasDerivAt (fun z => Real.log (T.realLeafModuli value (L z) (R z) i)) d x ∧ + |d| ≤ 2 * A ^ n * D := by + obtain ⟨dM, hM, hM0, hdM⟩ := T.realLeafModuli_derivative value hvalue hf A D hA hD + hL hR hL0 hR0 hdL hdR hcontrol i + refine ⟨_, hM.log (ne_of_gt hM0), ?_⟩ + rw [abs_div, abs_of_pos hM0] + exact (div_le_iff₀ hM0).mpr hdM + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLogPrimeAverage.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLogPrimeAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..dccf197e47c3b25362d8b74e743320f38a4ed75b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingLogPrimeAverage.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkLogWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeFrequencyAverage + +namespace OAI + +/-! # Terminal log weights through the two giant Page averages -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +section +variable {σ : Type*} (value tier : σ → ℕ) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) + (F : Bool → {d : ℕ} → MovingSlotData σ d → ℤ → ℂ) + (E : Bool → {d : ℕ} → MovingSlotData σ d → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) (R : ℤ) + +theorem movingFrequencyPairFactor_bulk_log (x y : ℤ) : + movingFrequencyPairFactor value outside + (fun b {_} T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F b T s) + E T nodes R x y = + ((movingBulkTreeLogWeight value tier k outside cb cd (T false) : ℂ) * + star (movingBulkTreeLogWeight value tier k outside cb cd (T true) : ℂ)) * + movingFrequencyPairFactor value outside F E T nodes R x y := by + unfold movingFrequencyPairFactor + split_ifs + · rw [movingDataWeight_bulk_log, movingDataWeight_bulk_log] + simp only [map_mul, Complex.star_def] + ring + · exact (mul_zero _).symm + +/-- Both Page corrections are unchanged. The original logarithmic weights +are constants only with respect to the two giant residue variables. -/ +theorem movingFrequencyPrimeAverage_bulk_log (r : ℕ) [NeZero r] + (P : PublishedProgressionInput) (Q : ℕ) (x y : ℝ) : + movingFrequencyPrimeAverage value outside + (fun b {_} T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F b T s) + E T nodes R r P Q x y = + ((movingBulkTreeLogWeight value tier k outside cb cd (T false) : ℂ) * + star (movingBulkTreeLogWeight value tier k outside cb cd (T true) : ℂ)) * + movingFrequencyPrimeAverage value outside F E T nodes R r P Q x y := by + unfold movingFrequencyPrimeAverage + simp_rw [movingFrequencyPairFactor_bulk_log] + unfold correctedPrimePairAverage + simp only [Finset.mul_sum] + apply Finset.sum_congr rfl + intro z _ + ring + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedBulkAction.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedBulkAction.lean new file mode 100644 index 0000000000000000000000000000000000000000..b70d1150c40ba916b0e12355fea537c567ee0449 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedBulkAction.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateExternalMultiplier +import OAI.NumberTheory.Ostmann.Construction.SelectedBulkPermutation + +namespace OAI + +/-! # The compensation mask is invariant under every bulk reassignment -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem selectedBulkPerm_active {B J : Type*} (slot : J ↪ B) + (active : B → Bool) (hactive : ∀ j, active (slot j) = true) + (e : Equiv.Perm J) (i : B) : active (selectedBulkPerm slot e i) = active i := by + obtain ⟨j, rfl⟩ := (selectedIndexEquiv slot).surjective i + cases j with + | inl j => simp only [selectedIndexEquiv_inl, selectedBulkPerm_bulk, hactive] + | inr j => + change active (selectedBulkPerm slot e j.val) = active j.val + rw [selectedBulkPerm_nonbulk slot e j.val j.property] + +theorem movingTemplateExternalMultiplier_bulk_action + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n r m : ℕ) + (active : MovingRegularSlot n r m → Bool) + (hactive : ∀ j, active (movingTemplateBulk n r m j) = true) + (outside : List ℕ) (greg : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) (φ : ℝ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) + (e : Equiv.Perm (TreeLeafIndex n × Fin m)) (x : MovingRegularSlot n r m → P) (z y : ℝ) : + movingTemplateExternalMultiplier P hP n r m active outside greg s φ Jleft Jright diagonal + (selectedBulkSample (movingTemplateBulk n r m) e x) z y = + movingTemplateExternalMultiplier P hP n r m active outside greg s φ Jleft Jright diagonal x z y := by + let E := (selectedBulkPerm (movingTemplateBulk n r m) e).symm + let q := fun i => (x i : ℕ) + let _ : ∀ i, Fact (q i).Prime := fun i => ⟨hP _ (x i).property⟩ + let _ : ∀ i, Fact (q (E i)).Prime := fun i => ⟨hP _ (x (E i)).property⟩ + have ha : (fun i => active (E i)) = active := by + funext i + exact selectedBulkPerm_active (movingTemplateBulk n r m) active hactive e.symm i + have h := naturalRegularMultiplier_equiv E q (fun i => hP _ (x i).property) active greg + outside.prod ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ s + dsimp only at h + rw [ha] at h + unfold movingTemplateExternalMultiplier + dsimp only + exact congrArg (fun a : ℝ => + (giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ : ℂ) * a) h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedEnergyIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedEnergyIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f7f8174fb8b0a0c08f094964739a4f1e5ad5cd9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedEnergyIntegral.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMaskedTemplateEnergy +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantMixedInterval + +namespace OAI + +/-! # The masked energy with its exact integer and harmonic-prime scales -/ + +namespace Ostmann +open scoped Classical BigOperators + +private theorem masked_energy_fubini {S A X T : Type} + [Fintype S] [Fintype A] [Fintype X] + (I : Finset T) (M : A → ℂ) (w : T → ℂ) (ρ : X → ℂ) + (F : S → A → T → X → ℂ) : + (∑ a, M a * ∑ p ∈ I, w p * ∑ x, ρ x * ∑ s, F s a p x) = + ∑ s, ∑ a, M a * ∑ x, ρ x * ∑ p ∈ I, w p * F s a p x := by + simp only [Finset.mul_sum] + conv_lhs => + arg 2 + ext a + arg 2 + ext p + rw [Finset.sum_comm] + conv_lhs => + arg 2 + ext a + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro a _ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro p _ + ring + +theorem movingMaskedTemplateEnergy_interval + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (center : ℝ) : + let H := G (n + 1) + let Pg := smoothGiantPrimeRange H + let I := Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊ + let ν := movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i)) + (movingMaskedTemplateEnergy P Pg I hP outside μ childBound pivotBound V F φ G n r m Q greg + (fun _ => 1) : ℂ) = + (Real.exp (smoothGiantLogNormalizer Pg φ H + center) : ℂ) * + mixedExternalAverage ν (V n) (H - 1) (H + 1) (H - 1) (H + 1) center + (fun s x z y => (φ (z - H) : ℂ) * (φ (y - H) : ℂ) * + (movingMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G n r m greg + x ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ s : ℝ)) := by + intro H Pg I ν + have h := smoothGiant_mixed_external_interval ν (V n) φ H H center hout + (fun s x p q => (movingMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G + n r m greg x p q s : ℝ)) + apply Eq.trans _ h + unfold movingMaskedTemplateEnergy + simp only [one_mul, Complex.ofReal_sum, Complex.ofReal_mul] + have hf := masked_energy_fubini (S := transferFrequencyRange (V n)) + (A := MovingRegularSlot n (4 + r) m → P) (X := Pg) (T := ℕ) I + (fun x => ((∏ i, ν i (x i) : ℝ) : ℂ)) + (fun p => (φ (Real.log p - H) : ℂ)) + (fun q : Pg => (smoothGiantPrior Pg φ H q : ℂ)) + (fun s x p q => (movingMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G + n r m greg x p q s.val : ℝ)) + convert hf using 1 + simp only [Pg, I, finite_univ_canonical] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedMultiplierReindex.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedMultiplierReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..feb1d8de2d04d44c1f460aad41825875b538bb9a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedMultiplierReindex.lean @@ -0,0 +1,31 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredMultiplier + +namespace OAI + +/-! # Reindexing the complete masked cofactor multiplier -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem naturalRegularMultiplier_equiv {I J : Type*} [Fintype I] [Fintype J] + (e : I ≃ J) (p : J → ℕ) (hp : ∀ j, (p j).Prime) (active : J → Bool) + (g : ∀ q : ℕ, ZMod q → ℂ) (D XL XR : ℕ) (s : ℤ) : + let _ : ∀ j, Fact (p j).Prime := fun j => ⟨hp j⟩ + let _ : ∀ i, Fact (p (e i)).Prime := fun i => ⟨hp (e i)⟩ + naturalRegularMultiplier (fun i => p (e i)) (fun i => active (e i)) s + (fun i => ((D * tupleCofactor (fun j => p (e j)) i : ℕ) : ZMod (p (e i)))) + (fun i => g (p (e i))) XL XR = + naturalRegularMultiplier p active s + (fun i => ((D * tupleCofactor p i : ℕ) : ZMod (p i))) + (fun i => g (p i)) XL XR := by + dsimp only + let _ : ∀ j, Fact (p j).Prime := fun j => ⟨hp j⟩ + let _ : ∀ i, Fact (p (e i)).Prime := fun i => ⟨hp (e i)⟩ + rw [naturalRegularMultiplier_eq_transform_norm, naturalRegularMultiplier_eq_transform_norm] + exact congrArg (fun z : ℂ => ‖z‖ ^ 2) + (movingRegularTransform_equiv e p (fun j z => if active j then g (p j) z else 1) + (D * XL * XR) s) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedOriginalIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedOriginalIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..19f0b9cfcb670b68fc4105e5cef35625788aa474 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedOriginalIntegral.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMaskedEnergyIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateExternalMultiplier +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedDiagonalEnergy + +namespace OAI + +/-! # The mixed integral of the actual masked coefficient square -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingMaskedTemplateKernel_original_integral {I : Type} + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (outside : List ℕ) (μ : ℕ → P → ℝ) (n r m : ℕ) + (ν : MovingRegularSlot n (4 + r) m → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (H : ℝ) (u v a b center : ℝ) : + mixedExternalAverage ν (V n) u v a b center + (fun s x z y => (φ (z - H) : ℂ) * (φ (y - H) : ℂ) * + (movingMaskedTemplateKernel P hP outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val q (fun _ => f) g Dq S ψ X lo hi) φ G n r m greg + x ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ s : ℝ)) = + movingWeightedDiagonalEnergy q Subtype.val outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n (movingTemplateSmall n (4 + r) m) + (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m)) + (fun s => movingTemplateExternalMultiplier P hP n (4 + r) m + (movingRestoredActive n r m) outside greg s φ H H false) u v a b center := by + unfold mixedExternalAverage movingWeightedDiagonalEnergy + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro x _ + congr 1 + unfold complexPrimeInterval + apply Finset.sum_congr rfl + intro Xg hXg + split_ifs + · congr 1 + unfold complexIntegerInterval + apply Finset.sum_congr rfl + intro piv hpiv + congr 1 + have hp : (0 : ℝ) < piv := by + exact_mod_cast (Nat.zero_le _).trans_lt (Finset.mem_Ioc.mp hpiv).1 + have hq : (0 : ℝ) < Xg := by + exact_mod_cast (Nat.zero_le _).trans_lt (Finset.mem_Ioc.mp hXg).1 + simp only [Real.exp_log hp, Real.exp_log hq, Nat.floor_natCast, + movingMaskedTemplateKernel, movingTemplateExternalMultiplier, + movingTemplateCoefficient, giantOuterWeight, positiveLogCutoff, + ite_eq_left hp, ite_eq_left hq, Bool.false_eq_true, ite_false, mul_one, Complex.ofReal_mul, Complex.ofReal_pow] + ring + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedTemplateEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedTemplateEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff58652a301e2fdb349a946271482a20e6b8c1e3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMaskedTemplateEnergy.lean @@ -0,0 +1,163 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeHarmonicCost + +namespace OAI + +/-! # The one-branch energy with its actual compensation mask -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingRestoredCompensationProduct {A : Type*} (value : A → ℕ) + (n r m : ℕ) (x : MovingRegularSlot n (4 + r) m → A) : ℕ := + ∏ i : TreeLeafIndex n × Fin 4, value (x (movingReverseTemplate n r m (.inl i))) + +@[simp] theorem movingRestoredCompensationProduct_restore {A : Type*} (value : A → ℕ) + (n r m : ℕ) (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) : + movingRestoredCompensationProduct value n r m (movingRestoreSample n r m u y) = + ∏ i, value (u i) := by + simp only [movingRestoredCompensationProduct, movingRestoreSample, + Function.comp_apply, Equiv.symm_apply_apply, Sum.elim_inl] + +noncomputable def movingMaskedTemplateKernel + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (x : MovingRegularSlot n (4 + r) m → P) (p X : ℕ) (s : ℤ) : ℝ := + let q := fun i => (x i : ℕ) + let _ : ∀ i, Fact (q i).Prime := fun i => ⟨hP _ (x i).property⟩ + ‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n (4 + r) m s x p X‖ ^ 2 * + naturalRegularMultiplier q (movingRestoredActive n r m) s + (fun i => ((outside.prod * tupleCofactor q i : ℕ) : ZMod (q i))) + (fun i => greg (q i)) p X + +theorem movingMaskedTemplateKernel_restore + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (u : TreeLeafIndex n × Fin 4 → P) (y : MovingRegularSlot n r m → P) + (p X : ℕ) (s : ℤ) : + movingMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G n r m greg + (movingRestoreSample n r m u y) p X s = + ‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n (4 + r) m s (movingRestoreSample n r m u y) p X * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * X) + (∏ i, (y i : ℕ)) s‖ ^ 2 := by + have he := movingTemplateCoefficient_restored_multiplier Subtype.val + (fun a : P => hP _ a.property) outside μ childBound pivotBound V F φ G n r m s u y p X greg + dsimp only at he + unfold movingMaskedTemplateKernel + dsimp only + convert he using 1 + congr 3 + ac_rfl + +noncomputable def movingMaskedTemplateEnergy + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (greg : ∀ q : ℕ, ZMod q → ℂ) + (weight : (MovingRegularSlot n (4 + r) m → P) → ℝ) : ℝ := + ∑ x : MovingRegularSlot n (4 + r) m → P, + (∏ i, movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i)) i (x i)) * + (weight x * ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + ∑ X : Pg, smoothGiantPrior Pg φ (G (n + 1)) X * + ∑ s : transferFrequencyRange (V n), + movingMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G n r m + greg x p X s.val) + +theorem movingMaskedTemplateKernel_nonneg + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (x : MovingRegularSlot n (4 + r) m → P) (p X : ℕ) (s : ℤ) : + 0 ≤ movingMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G n r m greg x p X s := by + unfold movingMaskedTemplateKernel + dsimp only + apply mul_nonneg (sq_nonneg _) + unfold naturalRegularMultiplier + apply Finset.prod_nonneg + intro i _ + split <;> positivity + +/-- A bound on the original support suffices: no support is conditioned into +or removed from the independent restored law. -/ +theorem movingMaskedTemplateEnergy_weight_le + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hφ : ∀ t, 0 ≤ φ t) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (greg : ∀ q : ℕ, ZMod q → ℂ) + (weight : (MovingRegularSlot n (4 + r) m → P) → ℝ) (B : ℝ) + (hweight : ∀ x, (∏ i, movingTemplateRestoredPrior n r m (μ n) + (fun i => primeSubsetPrior P (Q i)) i (x i)) ≠ 0 → weight x ≤ B) : + movingMaskedTemplateEnergy P Pg I hP outside μ childBound pivotBound V F φ G n r m Q greg weight ≤ + B * movingMaskedTemplateEnergy P Pg I hP outside μ childBound pivotBound V F φ G n r m Q greg (fun _ => 1) := by + unfold movingMaskedTemplateEnergy + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro x _ + let mass := ∏ i, movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i)) i (x i) + have hm : 0 ≤ mass := by + apply Finset.prod_nonneg + intro i _ + unfold movingTemplateRestoredPrior + cases he : (movingReverseTemplate n r m).symm i with + | inl j => exact hμ n (x i) + | inr j => exact primeSubsetPrior_nonneg P (Q j) (x i) + by_cases hz : mass = 0 + · change mass * _ ≤ B * (mass * _) + simp only [hz, zero_mul, mul_zero, le_refl] + have hE : 0 ≤ ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + ∑ X : Pg, smoothGiantPrior Pg φ (G (n + 1)) X * + ∑ s : transferFrequencyRange (V n), + movingMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G n r m greg x p X s.val := by + apply Finset.sum_nonneg + intro p _ + apply mul_nonneg (hφ _) + apply Finset.sum_nonneg + intro X _ + apply mul_nonneg (smoothGiantPrior_nonneg Pg φ (G (n + 1)) hφ X) + exact Finset.sum_nonneg (fun s _ => movingMaskedTemplateKernel_nonneg P hP outside μ + childBound pivotBound V F φ G n r m greg x p X s.val) + have ht := mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_right (hweight x hz) hE) hm + convert ht using 1 + ring + +/-- The compensation product is bounded using only the support of the same +original prior. All four draws at every leaf are counted. -/ +theorem movingRestoredCompensationProduct_le_exp + (P : Finset ℕ) (μ : P → ℝ) (n r m : ℕ) + (ν : MovingRegularSlot n r m → P → ℝ) (b : ℝ) + (hb : ∀ a, μ a ≠ 0 → (a : ℝ) ≤ Real.exp b) + (x : MovingRegularSlot n (4 + r) m → P) + (hx : (∏ i, movingTemplateRestoredPrior n r m μ ν i (x i)) ≠ 0) : + (movingRestoredCompensationProduct Subtype.val n r m x : ℝ) ≤ + Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * b) := by + have hm (i : TreeLeafIndex n × Fin 4) : + μ (x (movingReverseTemplate n r m (.inl i))) ≠ 0 := by + have h := Finset.prod_ne_zero_iff.mp hx (movingReverseTemplate n r m (.inl i)) + (Finset.mem_univ _) + simpa only [movingTemplateRestoredPrior, Equiv.symm_apply_apply, Sum.elim_inl] using h + calc + (movingRestoredCompensationProduct Subtype.val n r m x : ℝ) = + ∏ i : TreeLeafIndex n × Fin 4, (x (movingReverseTemplate n r m (.inl i)) : ℝ) := by + simp only [movingRestoredCompensationProduct, Nat.cast_prod] + _ ≤ ∏ _i : TreeLeafIndex n × Fin 4, Real.exp b := by + apply Finset.prod_le_prod₀ + · intro i _ + exact Nat.cast_nonneg _ + · intro i _ + exact hb _ (hm i) + _ = Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * b) := by + rw [Finset.prod_const, Finset.card_univ, Fintype.card_prod, card_treeLeafIndex, + Fintype.card_fin, ← Real.exp_nat_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedCorrelationPatterns.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedCorrelationPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d604195602b00b10706e1c12c445cc1a229e742 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedCorrelationPatterns.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalMatchedCorrelation + +namespace OAI + +/-! # The complete diagonal energy is controlled by its signed pattern means -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalMatchedCorrelation_pattern_bound {B : Type} [Fintype B] + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (outside : List ℕ) + (n m : ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) (hV : Monotone V) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n + (fun i => Quotient.mk'' i) + (movingOriginalPatternMatchedObservable (e s) (trees t) small slot perm (fun i => Quotient.mk'' i) + primes hprimes p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun _ => true) (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside childBound pivotBound + ψ X lo hi φ G Jleft Jright diagonal u v r w center) x + ‖movingOriginalMatchedCorrelation p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f g Dq Finset.univ ψ X lo hi φ G n small + (movingPatternBulkLeaves n m slot perm) greg Jleft Jright diagonal u v r w center‖ ≤ + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ∑ s : Setoid (Bool × MovingSampleIndex n), ‖term t s‖ := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let M := fun a b : FrequencyTree ℤ n => + movingOriginalMatchedMean p (fun q : primes => (q : ℕ)) outside μ ν childBound pivotBound + f g Dq Finset.univ ψ X lo hi φ G n (fun side => if side then b else a) + small (movingPatternBulkLeaves n m slot perm) greg (frequencyRoot n a) Jleft Jright diagonal u v r w center + have hzL (a : ScheduledFrequencyIndex V n) (t : FrequencyTree ℤ n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M (scheduledFrequencyHistory V n a) t = 0 := + movingOriginalMatchedMean_zero_frequency p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f hf g Dq Finset.univ ψ X lo hi φ G n _ small + (movingPatternBulkLeaves n m slot perm) greg _ Jleft Jright diagonal u v r w center false ha + have hzR (t : FrequencyTree ℤ n) (a : ScheduledFrequencyIndex V n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M t (scheduledFrequencyHistory V n a) = 0 := + movingOriginalMatchedMean_zero_frequency p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f hf g Dq Finset.univ ψ X lo hi φ G n _ small + (movingPatternBulkLeaves n m slot perm) greg _ Jleft Jright diagonal u v r w center true ha + have hs := same_root_scheduled_pair_sum_le V n + (fun a b => ‖M (scheduledFrequencyHistory V n a) (scheduledFrequencyHistory V n b)‖) + (fun _ _ => norm_nonneg _) + have hh (a : transferFrequencyRange (V n)) (b : MovingDescendantFrequencyIndex V n) : + scheduledFrequencyHistory V n ((scheduledFrequencyRootEquiv V n).symm (a, b)) = + movingRootedFrequencyTree V n a.val b := by + rw [scheduledFrequencyRootEquiv_history, Equiv.apply_symm_apply] + simp_rw [hh] at hs + have he := paired_scheduled_history_sum_le V hV n (fun a b => ‖M a b‖) + (fun _ _ => norm_nonneg _) (fun a t ha => by rw [hzL a t ha, norm_zero]) + (fun t a ha => by rw [hzR t a ha, norm_zero]) + rw [movingOriginalMatchedCorrelation_eq] + apply le_trans _ (hs.trans (he.trans ?_)) + · apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro a _ + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro b _ + have hb := norm_sum_le (Finset.univ : Finset (MovingDescendantFrequencyIndex V n)) + (fun c => movingOriginalMatchedMean p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f g Dq Finset.univ ψ X lo hi φ G n + (fun side => if side then movingRootedFrequencyTree V n a.val c + else movingRootedFrequencyTree V n a.val b) + small (movingPatternBulkLeaves n m slot perm) greg a.val Jleft Jright diagonal u v r w center) + simpa only [M, frequencyRoot_movingRootedFrequencyTree] using hb + · apply Finset.sum_le_sum + intro t _ + let trees := fun side => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + have hpatterns := movingOriginalMatchedMean_finite_patterns trees small slot perm primes hprimes + p μ ν g Dq greg (frequencyRoot n (trees false)) f outside childBound pivotBound + ψ X lo hi φ G Jleft Jright diagonal u v r w center N e + have htrees : (fun side => if side then trees true else trees false) = trees := by + funext side + cases side <;> rfl + dsimp only at hpatterns + conv_lhs at hpatterns => rw [← htrees] + change M (trees false) (trees true) = _ at hpatterns + split_ifs + · rw [hpatterns] + exact norm_sum_le _ _ + · exact Finset.sum_nonneg (fun _ _ => norm_nonneg _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedCorrelationRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedCorrelationRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..a050fedbfef110f40f2e02111391c1c81ffab52c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedCorrelationRate.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMatchedCorrelationPatterns +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticGoodPatternRate + +namespace OAI + +/-! # Full original matched correlation from the signed pattern budget -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalMatchedCorrelation_pattern_rate + (ψ : 𝓢(ℝ, ℂ)) (n k : ℕ) (hk : 0 < k) + (Cfreq Cprior gain : ℝ) (hCfreq : 0 ≤ Cfreq) (hCprior : 1 ≤ Cprior) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B : Type) [Fintype B] + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (X Δ hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (greg : ∀ q : ℕ, ZMod q → ℂ) (outside : List ℕ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s), + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let err := Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n + (fun i => Quotient.mk'' i) + (movingOriginalPatternMatchedObservable (e s) (trees t) small slot perm + (fun i => Quotient.mk'' i) primes hprimes p g Dq + (movingPatternRegularSlots (e s) n m small slot).get (fun _ => true) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside + childBound pivotBound ψ X (Real.exp Δ) hi φ G Jleft Jright diagonal u v r w center) x + Monotone V → f 0 = 0 → + (Sfreq.card : ℝ) ≤ Real.exp (Cfreq * m) → + (∀ s t, ‖term t s‖ ≤ + ((2 : ℝ) ^ Fintype.card (Quotient s) * + (Real.exp (Cprior * L)) ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) * + (Real.exp (-goodPatternGain n Cprior Cfreq gain * m) + err)) → + ‖movingOriginalMatchedCorrelation p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f g Dq Finset.univ ψ X (Real.exp Δ) hi φ G n small + (movingPatternBulkLeaves n m slot perm) greg Jleft Jright diagonal u v r w center‖ ≤ + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + filter_upwards [arithmetic_good_pattern_rate n k hk Cprior Cfreq gain hCprior hCfreq] with L hrate + dsimp only at hrate ⊢ + intro B _ primes hprimes p _ μ ν childBound pivotBound V f g Dq X Δ hi φ G + small slot perm greg outside Jleft Jright diagonal u v r w center N e + let m := spectatorBulkCount k L + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n (fun i => Quotient.mk'' i) + (movingOriginalPatternMatchedObservable (e s) (trees t) small slot perm (fun i => Quotient.mk'' i) + primes hprimes p g Dq (movingPatternRegularSlots (e s) n m small slot).get (fun _ => true) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside childBound pivotBound + ψ X (Real.exp Δ) hi φ G Jleft Jright diagonal u v r w center) x + intro hV hf hcard hterm + have hsum := hrate Sfreq hcard (fun s t => (‖term t s‖ : ℂ)) (by + intro s t + rw [Complex.norm_real, Real.norm_of_nonneg (norm_nonneg _)] + simpa only [add_assoc] using hterm s t) + have hnonneg : 0 ≤ ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ‖term t s‖ := by positivity + simp only [← Complex.ofReal_sum, Complex.norm_real, Real.norm_of_nonneg hnonneg] at hsum + have hactual := movingOriginalMatchedCorrelation_pattern_bound primes hprimes outside n + (spectatorBulkCount k L) p μ ν childBound pivotBound V f hf g Dq ψ X (Real.exp Δ) + hi φ G small slot perm greg Jleft Jright diagonal u v r w center hV N e + apply hactual.trans + rw [Finset.sum_comm] + exact hsum + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedExteriorWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedExteriorWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..f40d461243142551d0112653270b5957afe1cd75 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedExteriorWeight.lean @@ -0,0 +1,30 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedMatchedRelabel + +namespace OAI + +/-! # Constants in the original matched-history exterior factor -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingWeightedMatchedKernel_mul {σ I B : Type*} {n : ℕ} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (bulk : Bool → TreeLeafTuple (List B) n) + (weight : (B → σ) → ℂ) (W : (B → σ) → ℝ → ℝ → ℂ) + (u v r w center : ℝ) (y : B → σ) + (a : MovingSampleSlots σ n × MovingSampleSlots σ n) : + movingWeightedMatchedKernel q value outside childBound pivotBound f g Dq S ψ X lo hi φ G + t small bulk (fun y x z => weight y * W y x z) u v r w center y a = + weight y * movingWeightedMatchedKernel q value outside childBound pivotBound f g Dq S + ψ X lo hi φ G t small bulk W u v r w center y a := by + unfold movingWeightedMatchedKernel + simp_rw [mul_left_comm _ (weight y), complexIntegerInterval_const_mul, + complexPrimeInterval_const_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedRegularProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedRegularProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff9398cb253bec6090f1393f054765bbf8c75738 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMatchedRegularProduct.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularMultiplierIdentity +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularCollisionSupport + +namespace OAI + +/-! # The genuine common-product factor on the entire original sample space -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalSupportedOuterPair_matched_regular_product {B C I : Type*} [Fintype I] + {N n m : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) (value : Fin (N + 1) → ℕ) + (hprime : ∀ i, (value i).Prime) (outside : List ℕ) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (gspec : ∀ i, ZMod (p i) → ℂ) (Dq : Bool → ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) + (childBound pivotBound : ℕ → ℕ) + (F : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (E : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (XL XR : ℕ) : + let slots := movingPatternRegularSlots e n m small slot + let q := fun i : Fin slots.length => value (slots.get i) + let : ∀ i, Fact (q i).Prime := fun _ => ⟨hprime _⟩ + let T := movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern + let W := movingOriginalSupportedOuterPair p value outside childBound pivotBound F E gspec Dq + Finset.univ ψ X lo hi φ G Jleft Jright diagonal T t XL XR + W * (naturalRegularMultiplier q (fun _ => true) s + (fun i => (movingRegularOther value outside slots i : ZMod (q i))) + (fun i => greg (q i)) XL XR : ℂ) = + W * (‖primeProductTransform greg (outside.prod * XL * XR) + (MovingSlotReversal.naturalProduct value slots) s‖ ^ 2 : ℝ) := by + dsimp only + let T := movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern + let slots := movingPatternRegularSlots e n m small slot + let : ∀ i : Fin slots.length, Fact (value (slots.get i)).Prime := fun _ => ⟨hprime _⟩ + by_cases hgood : movingRegularOutsidePairwise value outside (T false) + · rw [movingPattern_regular_multiplier_eq_primeProduct e t small slot pattern value hprime + outside greg s XL XR hgood] + · have hbad : ¬ ∀ b, movingRegularOutsidePairwise value outside (T b) := fun h => hgood (h false) + have hz := movingOriginalSupportedOuterPair_zero_of_not_regular p value outside childBound + pivotBound F E gspec Dq Finset.univ ψ X lo hi φ G Jleft Jright diagonal T t hbad XL XR + change _ * _ = _ * _ + rw [hz, zero_mul, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMixedResidueRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMixedResidueRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..350d444355243b73875d3af1824671a21f72f110 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingMixedResidueRate.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingJointMixedRate +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePairResidues +import OAI.NumberTheory.Ostmann.Construction.GiantResidueSumBound + +namespace OAI + +/-! # Simultaneous giant idealization summed over every integer–unit residue pair -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_mixed_residue_sum_rate (P : PublishedProgressionInput) + {σ : Type*} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), T.Frequencies (fun s => |(s : ℝ)| ≤ V) → + ∀ Q q : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + (∀ a ∈ Finset.range q, ∀ b ∈ reducedResidues q, + 2 * ‖c a b‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + ‖(∑ b ∈ reducedResidues q, ∑ a ∈ Finset.range q, + complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c a b * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)))) - + (∑ b ∈ reducedResidues q, ∑ a ∈ Finset.range q, + ∫ x, ∫ y, c a b * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂integerGiantMeasure q J u v)‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_joint_mixed_rate (σ := σ) n C d, + giant_residue_sum_error_rate (2 * Real.exp 1) (by positivity)] with L hL hR + intro value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q hQ hq hqQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog c hbudget + dsimp only + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hm (b : ℕ) : reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) ≤ Real.exp 1 := + (reciprocalPrimeInterval_le_exp q b r s).trans (Real.exp_le_exp.mpr (by linarith)) + have hpoint (b : ℕ) (hb : b ∈ reducedResidues q) (a : ℕ) (ha : a ∈ Finset.range q) : + ‖complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c a b * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c a b * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂integerGiantMeasure q J u v‖ ≤ err * (2 * Real.exp 1) := by + exact (hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q a b hQ hq hqQ (Finset.mem_filter.mp hb).2 hlog + u v r s J hJ huv hshort hr hrs hrshort (c a b) (hbudget a ha b hb)).trans + (mul_le_mul_of_nonneg_left (by + have hmass : Real.exp (v - J) ≤ Real.exp 1 := Real.exp_le_exp.mpr (by linarith) + linarith [hm b]) (Real.exp_pos _).le) + apply (finite_pair_comparison (reducedResidues q) (Finset.range q) _ _ _ hpoint).trans + have hc : ((reducedResidues q).card : ℝ) ≤ q := Nat.cast_le.mpr (reducedResidues_card_le q) + calc + _ ≤ (q : ℝ) * q * (err * (2 * Real.exp 1)) := by + simp only [Finset.card_range] + gcongr + _ = (q : ℝ) ^ 2 * (2 * Real.exp 1) * err := by ring + _ ≤ _ := hR q (by omega) hqlog + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingModularSpectator.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingModularSpectator.lean new file mode 100644 index 0000000000000000000000000000000000000000..1081ca68e8c67051a2233e810d292f76b29555f3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingModularSpectator.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyFormulaGate + +namespace OAI + +/-! # Spectator evaluation without internal primes in the period + +At a spectator prime the entire reversal denominator is a unit. The field +recursion therefore depends only on the two spectator residues, even though +the original recursion used integer division by compensation products. +-/ + +namespace Ostmann +open scoped Classical + +noncomputable def MovingSlotReversal.modularPivot {σ : Type*} (step : MovingSlotReversal σ) + (value : σ → ℕ) (q : ℕ) [Fact q.Prime] (x y : ZMod q) : ZMod q := + ((step.leftFrequency : ZMod q) * (y * MovingSlotReversal.naturalProduct value step.rightSlots) - + (step.rightFrequency : ZMod q) * (x * MovingSlotReversal.naturalProduct value step.leftSlots)) / + ((step.rootFrequency : ZMod q) * MovingSlotReversal.naturalProduct value step.compensationSlots) + +def MovingSlotData.ModularDenominators {σ : Type*} (value : σ → ℕ) (q : ℕ) : + {n : ℕ} → MovingSlotData σ n → Prop + | _, .leaf _ _ => True + | _, .node s _ _ U left right => + (s : ZMod q) ≠ 0 ∧ (MovingSlotReversal.naturalProduct value U : ZMod q) ≠ 0 ∧ + left.ModularDenominators value q ∧ right.ModularDenominators value q + +theorem MovingSlotData.modularDenominators_of_units {σ : Type*} + (value : σ → ℕ) (q : ℕ) [Fact q.Prime] (hvalue : ∀ i, (value i : ZMod q) ≠ 0) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (fun s => (s : ZMod q) ≠ 0)) : + T.ModularDenominators value q := by + induction T with + | leaf => trivial + | node s CL CR U left right ihL ihR => + refine ⟨hf.1, ?_, ihL hf.2.1, ihR hf.2.2⟩ + have hp : (U.map fun i => (value i : ZMod q)).prod ≠ 0 := by + apply List.prod_ne_zero + intro hz + obtain ⟨i, _, hi⟩ := List.mem_map.mp hz + exact hvalue i hi + simpa only [MovingSlotReversal.naturalProduct, Nat.cast_list_prod, + List.map_map, Function.comp_def] using hp + +theorem MovingSlotReversal.modularPivot_of_signedIntegral {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) (q : ℕ) [Fact q.Prime] + (hs : (step.rootFrequency : ZMod q) ≠ 0) + (hu : (MovingSlotReversal.naturalProduct value step.compensationSlots : ZMod q) ≠ 0) + (x y : ℤ) (hI : step.SignedIntegralAt value x y) : + step.modularPivot value q x y = (step.signedPivot value x y : ZMod q) := by + have he := congrArg (fun z : ℤ => (z : ZMod q)) hI + simp only [MovingSlotReversal.signedNumerator, + Int.cast_sub, Int.cast_mul, Int.cast_natCast] at he + unfold modularPivot + apply (div_eq_iff (mul_ne_zero hs hu)).mpr + linear_combination he + +noncomputable def movingModularSpectator {σ : Type*} (value : σ → ℕ) + (q : ℕ) [Fact q.Prime] (g : ZMod q → ℂ) (D : (ZMod q)ˣ) : + {n : ℕ} → MovingSlotData σ n → ZMod q → ZMod q → ℂ + | _, .leaf s regular, x, y => + g ((s : ZMod q) / ((D : ZMod q) * (x * y * MovingSlotReversal.naturalProduct value regular))) + | _, .node s CL CR U left right, x, y => + let p := (MovingSlotData.step s CL CR U left right false).modularPivot value q x y + if p = 0 then 0 else + movingModularSpectator value q g D left p x * star (movingModularSpectator value q g D right p y) + +theorem movingSignedSpectator_eq_modular {σ : Type*} (value : σ → ℕ) + (q : ℕ) [Fact q.Prime] (g : ZMod q → ℂ) (D : (ZMod q)ˣ) + {n : ℕ} (T : MovingSlotData σ n) (hden : T.ModularDenominators value q) + (x y : ℤ) (hI : T.SignedIntegral value x y) : + movingSignedSpectator value g D T x y = movingModularSpectator value q g D T x y := by + induction T generalizing x y with + | leaf => simp only [movingSignedSpectator, movingModularSpectator, Int.cast_mul, Int.cast_natCast] + | node s CL CR U left right ihL ihR => + simp only [movingSignedSpectator, movingModularSpectator, + (MovingSlotData.step s CL CR U left right false).modularPivot_of_signedIntegral + value q hden.1 hden.2.1 x y hI.1] + split_ifs + · rfl + · rw [ihL hden.2.2.1 _ _ hI.2.1, ihR hden.2.2.2 _ _ hI.2.2] + +theorem movingModularSpectator_norm {σ : Type*} (value : σ → ℕ) + (q : ℕ) [Fact q.Prime] (g : ZMod q → ℂ) (D : (ZMod q)ˣ) + (B : ℝ) (hB : 0 ≤ B) (hg : ∀ z, ‖g z‖ ≤ B) + {n : ℕ} (T : MovingSlotData σ n) (x y : ZMod q) : + ‖movingModularSpectator value q g D T x y‖ ≤ B ^ (2 ^ n) := by + induction T generalizing x y with + | leaf => simpa only [movingModularSpectator, pow_zero, pow_one] using hg _ + | @node n s CL CR U left right ihL ihR => + rw [movingModularSpectator] + split_ifs + · simpa only [norm_zero] using pow_nonneg hB (2 ^ (n + 1)) + · rw [norm_mul, norm_star] + calc + _ ≤ B ^ (2 ^ n) * B ^ (2 ^ n) := + mul_le_mul (ihL _ _) (ihR _ _) (norm_nonneg _) (pow_nonneg hB _) + _ = B ^ (2 ^ (n + 1)) := by rw [← pow_add, pow_succ]; congr 1; omega + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingModulusAssembly.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingModulusAssembly.lean new file mode 100644 index 0000000000000000000000000000000000000000..ade5405a14a9c985e1aedbabc44fab7de5d26511 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingModulusAssembly.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModulus +import OAI.NumberTheory.Ostmann.Construction.SpectatorBulkScale + +namespace OAI + +/-! # All CRT size conditions for the concrete pair frequency modulus -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +/-- A single eventual cutoff works for every actual history, frequency +choice and spectator list in the prescribed ranges. -/ +theorem moving_pair_modulus_range (n k : ℕ) (A a : ℝ) (hA : 0 ≤ A) (ha : 0 < a) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (σ : Type) (T : Bool → MovingSlotData σ n) (B : ℕ) (p : Fin m → ℕ), + (∀ b, (T b).Frequencies (· ≠ 0)) → + (∀ b, (T b).Frequencies (fun s => s.natAbs ≤ B)) → + (B : ℝ) ≤ Real.exp (A * m) → + (∀ i, (p i).Prime) → Function.Injective p → + (∀ i, Real.exp (Real.exp (a * L)) ≤ (p i : ℝ)) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + let r := movingPairFrequencyModulus T + let M := ∏ i, bulkResidueModuli r p i + 0 < r ∧ + (∀ b, (T b).frequencyProduct ∣ movingPairFrequencyBase T) ∧ + movingPairFrequencyBase T ^ (n + 1) ∣ (r : ℤ) ∧ + Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j)) ∧ + 0 < M ∧ M ≤ bulkProgressionCutoff L ∧ + (∀ u : ℝ, Real.exp ((39 / 10000 : ℝ) * L) ≤ u → (M : ℝ) ≤ Real.exp u) := by + let C : ℝ := (2 * (2 ^ (n + 1) - 1) * (n + 1) : ℕ) * A + have hC : 0 ≤ C := mul_nonneg (Nat.cast_nonneg _) hA + have hK : 0 ≤ (k : ℝ) ^ 4 := by positivity + filter_upwards [frequency_modulus_lt_spectators C ((k : ℝ) ^ 4) a hC hK ha, + bulkResidueModulus_progression_range C ((k : ℝ) ^ 4) hC hK, + eventually_ge_atTop (0 : ℝ)] with L hlt hrange hL + dsimp only + intro σ T B p hf hB hBexp hp hinj hplower hpupper + let r := movingPairFrequencyModulus T + have hr : 0 < r := movingPairFrequencyModulus_pos T hf + have hrex : (r : ℝ) ≤ Real.exp (C * spectatorBulkCount k L) := by + simpa only [C, mul_assoc] using movingPairFrequencyModulus_exp T B A _ hB hBexp + have hm := spectatorBulkCount_upper k L hL + have hri := hlt _ r p hm hrex hplower + have hM := hrange _ r p hm hrex hpupper + refine ⟨hr, movingPairFrequencyBase_dvd T, movingPairFrequencyModulus_precision T, + bulkResidueModuli_pairwise_of_lt r hr p hp hinj hri, + bulkResidueModulus_positive r hr p (fun i => (hp i).pos), hM, ?_⟩ + intro u hu + apply (Nat.cast_le.mpr hM).trans + apply (Nat.floor_le (Real.exp_nonneg _)).trans + apply Real.exp_le_exp.mpr + apply le_trans _ hu + exact Real.exp_le_exp.mpr (by linarith) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeCoefficientSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeCoefficientSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..3122d3fc4efe98f7e5f7f607d5ae0d5263f109af --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeCoefficientSupport.lean @@ -0,0 +1,349 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateAmplitude + +namespace OAI + +/-! # Integer substitution on the nonzero original coefficient support -/ +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPrimeNodeFactor_substitution_on_right {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) + (u : TreeLeafTuple (List σ) n) (small bulk : TreeLeafTuple (List σ) (n + 1)) + (XL XR : ℕ) (s v w : ℤ) (I : Finset ℕ) + (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hsV : s.natAbs ≤ V (n + 1)) + (hv : v.natAbs ≤ childBound (n + 1)) (hw : w.natAbs ≤ childBound (n + 1)) : + let U := MovingSlotReversal.naturalProduct value (flattenMovingSlots n u) + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let LH := XL * MovingSlotReversal.naturalProduct value CL + let RH := XR * MovingSlotReversal.naturalProduct value CR + let p := movingTopPivot value CL CR (flattenMovingSlots n u) XL XR s v w + let A := movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n v + (appendMovingSlotLeaves n u small.1) bulk.1 p XL + let B := movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n w + (appendMovingSlotLeaves n u small.2) bulk.2 p XR + (∀ p ∈ I, p * U ≤ pivotBound (n + 1)) → + (B ≠ 0 → 2 * pivotBound (n + 1) * childBound (n + 1) < RH) → + (∀ q, q.Prime → q ∣ RH → V (n + 1) < q) → + (∀ q, q.Prime → q ∣ U → childBound (n + 1) < q) → + movingPrimeNodeFactor value outside childBound pivotBound φ G n CL CR + (flattenMovingSlots n u) XL XR s v w * A * star B = + if validTransferredPivot I (v * RH - w * LH) (s * U) then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) * A * star B else 0 := by + intro U CL CR LH RH p A B hbound hgap hRH hU + by_cases hB : B = 0 + · simp only [hB, star_zero, mul_zero, ite_self] + · exact movingPrimeNodeFactor_substitution value outside μ childBound pivotBound V F hF + φ G n u small bulk XL XR s v w I hI hφ hsV hv hw hbound (hgap hB) hRH hU + +theorem movingTemplateCoefficient_integer_node_on_coefficients {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (hsV : s.natAbs ≤ V (n + 1)) + (left right : MovingRegularSlot n r m → σ) (XL XR : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) + (hVL : V (n + 1) < XL) (hVR : V (n + 1) < XR) + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ) (w : ℤ), + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w + (movingRestoreSample n r m u right) p XR ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < XR * ∏ i, value (right i)) + (hRH : ∀ q, q.Prime → q ∣ XR * (∏ i, value (right i)) → V (n + 1) < q) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G (n + 1) r m s + (movingTemplatePairSample n r m left right) XL XR = + ∑ u : TreeLeafIndex n × Fin 4 → σ, + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + let LH := XL * ∏ i, value (left i) + let RH := XR * ∏ i, value (right i) + let p := reconstructedPivot (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) + if validTransferredPivot I (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) then + (φ (Real.log p - G (n + 1)) : ℂ) * + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m v.val + (movingRestoreSample n r m u left) p XL * + star (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w.val + (movingRestoreSample n r m u right) p XR) + else 0 := by + by_cases hs : s = 0 + · subst s + change movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G + (n + 1) 0 _ _ XL XR = _ + rw [movingFrequencyCoefficient_zero value outside μ childBound pivotBound V F hF φ G] + simp only [zero_mul, validTransferredPivot, ne_eq, not_true_eq_false, false_and, + ite_false, Finset.sum_const_zero, mul_zero] + · + let K := fun u : TreeLeafIndex n × Fin 4 → σ => + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + let LH := XL * ∏ i, value (left i) + let RH := XR * ∏ i, value (right i) + let p := reconstructedPivot (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) + if validTransferredPivot I (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) then + (φ (Real.log p - G (n + 1)) : ℂ) * + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m v.val + (movingRestoreSample n r m u left) p XL * + star (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w.val + (movingRestoreSample n r m u right) p XR) + else 0 + change _ = ∑ u, K u + rw [← (movingTemplateCompensationEquiv σ n).sum_comp K] + rw [movingTemplateCoefficient_prime_node value outside μ childBound pivotBound V hV F hF + φ G n r m s hs hsV left right XL XR hXL hXR hVL hVR] + apply Finset.sum_congr rfl + intro a _ + have hpμ := movingTemplateCompensationEquiv_prior (μ n) n a + have hU := movingTemplateCompensationEquiv_product value n a + by_cases ha : movingCompensationPrior (μ n) n a = 0 + · simp only [K, hpμ, ha, Complex.ofReal_zero, zero_mul] + · have hc := hcomp (movingTemplateCompensationEquiv σ n a) (hpμ ▸ ha) + dsimp only [K] + rw [hpμ, Complex.ofReal_mul, mul_assoc] + apply congrArg (fun z : ℂ => (movingCompensationPrior (μ n) n a : ℂ) * z) + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro v _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro w _ + let small := (treeLeafMap (List.map left) n (movingTemplateSmall n r m), + treeLeafMap (List.map right) n (movingTemplateSmall n r m)) + let bulk := (treeLeafMap (List.map left) n (bulkSlotLeaves n m (movingTemplateBulk n r m)), + treeLeafMap (List.map right) n (bulkSlotLeaves n m (movingTemplateBulk n r m))) + have ht := movingPrimeNodeFactor_substitution_on_right value outside μ childBound pivotBound V F hF + φ G n (movingCompensationSlots n a) small bulk XL XR s v.val w.val I hI hφ hsV + (((mem_transferFrequencyRange _ _).mp v.property).trans hchild) + (((mem_transferFrequencyRange _ _).mp w.property).trans hchild) + dsimp only [small, bulk] at ht + have hCL := movingTemplateMapped_product value n r m left + have hCR := movingTemplateMapped_product value n r m right + simp only [hU, hCL, hCR] at ht + specialize ht hc.1 (fun hB => hgap (movingTemplateCompensationEquiv σ n a) + (hpμ ▸ ha) _ _ (by simpa only [movingTemplateCoefficient_restored] using hB)) hRH hc.2 + simp only [movingTemplateCoefficient_restored] + dsimp only [movingTopPivot] at ht ⊢ + simp only [hU, hCL, hCR, Complex.ofReal_mul, Nat.cast_prod] at ht ⊢ + split_ifs at ht ⊢ <;> simpa only [mul_assoc, mul_zero] using ht + +theorem movingTemplateCoefficient_transformed_integer_node_on_coefficients {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (hsV : s.natAbs ≤ V (n + 1)) + (left right : MovingRegularSlot n r m → σ) (XL XR : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) + (hVL : V (n + 1) < XL) (hVR : V (n + 1) < XR) + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ) (w : ℤ), + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w + (movingRestoreSample n r m u right) p XR ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < XR * ∏ i, value (right i)) + (hRH : ∀ q, q.Prime → q ∣ XR * (∏ i, value (right i)) → V (n + 1) < q) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) + (hleft : ∀ i, value (left i) ≠ 0) (hright : ∀ i, value (right i) ≠ 0) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G (n + 1) r m s + (movingTemplatePairSample n r m left right) XL XR * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then XL else XR) + (value ∘ movingTemplatePairSample n r m left right)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s = + ∑ u : TreeLeafIndex n × Fin 4 → σ, + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + let LH := XL * ∏ i, value (left i) + let RH := XR * ∏ i, value (right i) + let p := reconstructedPivot (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) + if validTransferredPivot I (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) then + (φ (Real.log p - G (n + 1)) : ℂ) * + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m v.val + (movingRestoreSample n r m u left) p XL * + star (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w.val + (movingRestoreSample n r m u right) p XR) * + movingTaggedTransform + (Sum.elim (movingOneGiantModuli XL (value ∘ left)) + (movingOneGiantModuli XR (value ∘ right))) + (Sum.elim (Sum.elim (fun _ : Unit => true) (fun _ => false)) + (Sum.elim (fun _ : Unit => true) (fun _ => false))) + greg ggiant favorable outside.prod s + else 0 := by + have hn := movingTemplateCoefficient_integer_node_on_coefficients value outside μ childBound pivotBound V hV + F hF φ G n r m s hsV left right XL XR hXL hXR hVL hVR I hI hφ hchild hgap hRH hcomp + have ht := movingTaggedTransform_paired value n r m left right XL XR + hXL.ne_zero hXR.ne_zero hleft hright greg ggiant favorable outside.prod s + rw [hn, Finset.sum_mul] + apply Finset.sum_congr rfl + intro u _ + rw [mul_assoc, Finset.sum_mul] + apply congrArg (fun z : ℂ => + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * z) + apply Finset.sum_congr rfl + intro v _ + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro w _ + dsimp only + split_ifs + · congr 1 + exact ht.symm + · exact zero_mul _ + +theorem movingTemplateCoefficient_averaged_integer_node_on_coefficients {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (hsV : s.natAbs ≤ V (n + 1)) + (ν : MovingRegularSlot (n + 1) r m → σ → ℝ) + (XL XR : ℕ) (hXL : XL.Prime) (hXR : XR.Prime) + (hVL : V (n + 1) < XL) (hVR : V (n + 1) < XR) + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ right, movingTemplateSidePrior n r m ν false right ≠ 0 → + ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ) (w : ℤ), + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w + (movingRestoreSample n r m u right) p XR ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < XR * ∏ i, value (right i)) + (hRH : ∀ right, movingTemplateSidePrior n r m ν false right ≠ 0 → + ∀ q, q.Prime → q ∣ XR * (∏ i, value (right i)) → V (n + 1) < q) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + (∑ y : MovingRegularSlot (n + 1) r m → σ, ((∏ i, ν i (y i) : ℝ) : ℂ) * + (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G (n + 1) r m s y XL XR * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then XL else XR) (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s)) = + ∑ u : TreeLeafIndex n × Fin 4 → σ, + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * + ∑ left : MovingRegularSlot n r m → σ, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right : MovingRegularSlot n r m → σ, (movingTemplateSidePrior n r m ν false right : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + movingTemplateIntegerFourierTerm value outside μ childBound pivotBound V F φ G n r m I + XL XR s left right greg ggiant favorable u v.val w.val := by + let A := fun y : MovingRegularSlot (n + 1) r m → σ => + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G (n + 1) r m s y XL XR * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then XL else XR) (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s + let M := fun u : TreeLeafIndex n × Fin 4 → σ => + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) + let B := fun left right u => + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + movingTemplateIntegerFourierTerm value outside μ childBound pivotBound V F φ G n r m I + XL XR s left right greg ggiant favorable u v.val w.val + have hn left right (hr : movingTemplateSidePrior n r m ν false right ≠ 0) : + A (movingTemplatePairSample n r m left right) = ∑ u, M u * B left right u := by + exact movingTemplateCoefficient_transformed_integer_node_on_coefficients value outside μ childBound pivotBound V hV + F hF φ G n r m s hsV left right XL XR hXL hXR hVL hVR I hI hφ hchild + (hgap right hr) (hRH right hr) hcomp (fun i => (hvalue _).ne_zero) + (fun i => (hvalue _).ne_zero) greg ggiant favorable + change (∑ y, ((∏ i, ν i (y i) : ℝ) : ℂ) * A y) = _ + rw [movingTemplatePair_average] + change (∑ left, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right, (movingTemplateSidePrior n r m ν false right : ℂ) * + A (movingTemplatePairSample n r m left right)) = _ + have he : (∑ left, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right, (movingTemplateSidePrior n r m ν false right : ℂ) * + A (movingTemplatePairSample n r m left right)) = + ∑ left, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right, (movingTemplateSidePrior n r m ν false right : ℂ) * + ∑ u, M u * B left right u := by + apply Finset.sum_congr rfl + intro left _ + congr 1 + apply Finset.sum_congr rfl + intro right _ + by_cases hr : movingTemplateSidePrior n r m ν false right = 0 + · simp only [hr, Complex.ofReal_zero, zero_mul] + · rw [hn left right hr] + rw [he] + change _ = ∑ u, M u * ∑ left, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right, (movingTemplateSidePrior n r m ν false right : ℂ) * B left right u + simp only [Finset.mul_sum] + conv_lhs => + arg 2 + ext left + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro u _ + apply Finset.sum_congr rfl + intro left _ + apply Finset.sum_congr rfl + intro right _ + ring + +theorem movingTemplatePrimeAmplitude_next_on_coefficients {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg : Finset ℕ) (hPg : ∀ q ∈ Pg, q.Prime) (ρ : Pg → ℝ) + (ν : MovingRegularSlot (n + 1) r m → σ → ℝ) + (hlarge : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right, movingTemplateSidePrior n r m ν false right ≠ 0 → + ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ) (w : ℤ), + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w + (movingRestoreSample n r m u right) p XR ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hRH : ∀ XR : Pg, ∀ right, movingTemplateSidePrior n r m ν false right ≠ 0 → + ∀ q, q.Prime → q ∣ (XR : ℕ) * (∏ i, value (right i)) → V (n + 1) < q) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G (n + 1) r m + Pg ρ ν greg ggiant favorable = + ∑ XL : Pg, (ρ XL : ℂ) * ∑ XR : Pg, (ρ XR : ℂ) * + ∑ s : transferFrequencyRange (V (n + 1)), + ∑ u : TreeLeafIndex n × Fin 4 → σ, + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * + ∑ left : MovingRegularSlot n r m → σ, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right : MovingRegularSlot n r m → σ, (movingTemplateSidePrior n r m ν false right : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + movingTemplateIntegerFourierTerm value outside μ childBound pivotBound V F φ G + n r m I XL XR s.val left right greg ggiant favorable u v.val w.val := by + unfold movingTemplatePrimeAmplitude + apply Finset.sum_congr rfl + intro XL _ + congr 1 + apply Finset.sum_congr rfl + intro XR _ + congr 1 + apply Finset.sum_congr rfl + intro s _ + exact movingTemplateCoefficient_averaged_integer_node_on_coefficients value hvalue outside μ + childBound pivotBound V hV F hF φ G n r m s.val + ((mem_transferFrequencyRange _ _).mp s.property) ν XL XR + (hPg _ XL.property) (hPg _ XR.property) (hlarge XL) (hlarge XR) + I hI hφ hchild (hgap XR) (hRH XR) hcomp greg ggiant favorable + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeCutoffFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeCutoffFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..72e4aa0ccb3cc69a613e45dc38aa93b8041890ec --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeCutoffFactor.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCutoffPolynomials +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFourierSupported + +namespace OAI + +/-! # Keeping the original logarithmic cutoff in every moving node -/ + +namespace Ostmann +open scoped Classical + +noncomputable def movingNaturalNodeCutoff {σ : Type*} (value : σ → ℕ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) : {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → ℂ + | _, .leaf _ _, _, _ => 1 + | n + 1, .node s CL CR u left right, L, R => + let p := (MovingSlotData.step s CL CR u left right false).naturalPivot value L R + (positiveLogCutoff φ (G (n + 1)) p : ℂ) * + movingNaturalNodeCutoff value φ G left p L * movingNaturalNodeCutoff value φ G right p R + +theorem movingNaturalNodeCutoff_star {σ : Type*} (value : σ → ℕ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) {n : ℕ} (T : MovingSlotData σ n) (L R : ℕ) : + star (movingNaturalNodeCutoff value φ G T L R) = movingNaturalNodeCutoff value φ G T L R := by + have hstar (a : ℝ) : star (a : ℂ) = (a : ℂ) := by simp + induction T generalizing L R with + | leaf => simp only [movingNaturalNodeCutoff, star_one] + | node s CL CR u left right ihL ihR => + simp only [movingNaturalNodeCutoff, star_mul, hstar, ihL, ihR] + ring + +noncomputable def movingPhiExtra {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (x : MovingSlotState σ) (s v w : ℤ) : ℝ := + extra x s v w * positiveLogCutoff φ (G x.depth) + ((historyPivot (movingSlotSystem value childBound pivotBound) x s v w / x.compensation value : ℕ) : ℝ) + +/-- The smooth cutoff is factored out of the original recursion, even when +an arithmetic guard vanishes. All other node factors remain in `extra`. -/ +theorem movingSlotWeight_node_cutoff {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) (L R : ℕ) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingPhiExtra value childBound pivotBound extra φ G)) + n ⟨n, T, L, R⟩ t = + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, L, R⟩ t * + movingNaturalNodeCutoff value φ G T L R := by + let sys := movingSlotSystem value childBound pivotBound + let cut := movingSlotCutoff value childBound pivotBound extra + let cutφ := movingSlotCutoff value childBound pivotBound (movingPhiExtra value childBound pivotBound extra φ G) + induction T generalizing L R with + | leaf s regular => simp only [recursiveTransferWeight, movingNaturalNodeCutoff, mul_one] + | @node n s CL CR u left right ihL ihR => + let x : MovingSlotState σ := ⟨n + 1, .node s CL CR u left right, L, R⟩ + let p := (MovingSlotData.step s CL CR u left right false).naturalPivot value L R + have hp : historyPivot sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) / + MovingSlotReversal.naturalProduct value u = p := by + simp only [historyPivot, sys, movingSlotSystem, MovingSlotState.leftProduct, + MovingSlotState.rightProduct, x, ← hT.1, ← hT.2.1.root, ← hT.2.2.root, + p, MovingSlotReversal.naturalPivot, MovingSlotData.step, movingGiantPivot, Nat.mul_one] + have hc : (cutφ x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) : ℂ) = + (cut x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) : ℂ) * + (positiveLogCutoff φ (G (n + 1)) p : ℂ) := by + dsimp only [cutφ, cut, movingSlotCutoff, movingPhiExtra] + split_ifs <;> simp only [Complex.ofReal_mul, Complex.ofReal_zero, zero_mul] + congr 2 + change positiveLogCutoff φ (G (n + 1)) ((historyPivot sys x t.1 _ _ / MovingSlotReversal.naturalProduct value u : ℕ) : ℝ) = _ + rw [hp] + change recursiveTransferWeight sys F cutφ (n + 1) x t = _ + simp only [recursiveTransferWeight] + split_ifs + · change (cutφ x t.1 _ _ : ℂ) * + recursiveTransferWeight sys F cutφ n ⟨n, left, _, L⟩ t.2.1 * + star (recursiveTransferWeight sys F cutφ n ⟨n, right, _, R⟩ t.2.2) = + ((cut x t.1 _ _ : ℂ) * recursiveTransferWeight sys F cut n ⟨n, left, _, L⟩ t.2.1 * + star (recursiveTransferWeight sys F cut n ⟨n, right, _, R⟩ t.2.2)) * _ + rw [hp, hc, ihL t.2.1 hT.2.1 p L, ihR t.2.2 hT.2.2 p R] + simp only [star_mul, movingNaturalNodeCutoff_star] + change _ = _ * ((positiveLogCutoff φ (G (n + 1)) p : ℂ) * + movingNaturalNodeCutoff value φ G left p L * movingNaturalNodeCutoff value φ G right p R) + ring + · exact (zero_mul _).symm + +theorem movingNaturalNodeCutoff_eq_real {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (φ : ℝ → ℝ) (G : ℕ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (L R : ℕ) (hI : T.Integral value L R) : + movingNaturalNodeCutoff value φ G T L R = movingRealNodeCutoff value φ G T L R := by + induction T generalizing L R with + | leaf => rfl + | node s CL CR u left right ihL ihR => + have hp := (MovingSlotData.step s CL CR u left right false).realPivot_eq value L R hf.1 + (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) hI.1 + simp only [movingNaturalNodeCutoff, movingRealNodeCutoff, hp, + ihL hf.2.1 _ _ hI.2.1, ihR hf.2.2 _ _ hI.2.2] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeDivisibility.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeDivisibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..1707a90696399111ea93a7d2fba96a9e545febff --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeDivisibility.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkPreorder + +namespace OAI + +/-! # Every nonzero moving history retains its sampled compensation divisibility -/ + +namespace Ostmann +open scoped Classical + +theorem recursiveTransferWeight_node_cutoff_ne_zero {State : Type*} + (sys : TransferHistorySystem State) (F : State → ℤ → ℂ) + (E : State → ℤ → ℤ → ℤ → ℝ) (n : ℕ) (x : State) (t : FrequencyTree ℤ n) + (hw : recursiveTransferWeight sys F E n x t ≠ 0) : + ∀ z ∈ transferNodeList sys n x t, E z.state z.root z.left z.right ≠ 0 := by + induction n generalizing x with + | zero => simp [transferNodeList] + | succ n ih => + let P := historyPivot sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + have hv := recursiveTransferWeight_nonzero_valid sys F E (n + 1) x t hw + have hroot := (validTransferHistory_reconstructed_iff sys n x t).mp hv + rw [recursiveTransferWeight_node sys F E n x t P hroot.1] at hw + have hleft : recursiveTransferWeight sys F E n (sys.leftState x P) t.2.1 ≠ 0 := by + intro hz + simp only [hz, mul_zero, zero_mul, ne_eq, not_true_eq_false] at hw + have hright : recursiveTransferWeight sys F E n (sys.rightState x P) t.2.2 ≠ 0 := by + intro hz + simp only [hz, star_zero, mul_zero, ne_eq, not_true_eq_false] at hw + have hc : E x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) ≠ 0 := by + intro hz + simp only [hz, Complex.ofReal_zero, zero_mul, ne_eq, not_true_eq_false] at hw + intro z hz + rcases List.mem_cons.mp hz with hz | hz + · subst z + exact hc + · rcases List.mem_append.mp hz with hz | hz + · exact ih _ _ hleft z hz + · exact ih _ _ hright z hz + +theorem movingSlotWeight_node_divisible {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) (n : ℕ) (x : MovingSlotState σ) + (t : FrequencyTree ℤ n) + (hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound E) n x t ≠ 0) + (j : Fin (2 ^ n - 1)) : + let z := transferNodeArray (movingSlotSystem value childBound pivotBound) n x t j + 0 < z.state.compensation value ∧ + z.state.compensation value ∣ z.pivot (movingSlotSystem value childBound pivotBound) := by + let sys := movingSlotSystem value childBound pivotBound + let z := transferNodeArray sys n x t j + have hz : z ∈ transferNodeList sys n x t := by + unfold z transferNodeArray + rw [List.getD_eq_getElem _ _ (by rw [transferNodeList_length]; exact j.isLt)] + exact List.getElem_mem _ + have hc := recursiveTransferWeight_node_cutoff_ne_zero sys F + (movingSlotCutoff value childBound pivotBound E) n x t hw z hz + by_contra h + apply hc + exact ite_eq_right h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeGuards.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeGuards.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f4925440820e02a1623e116d2716f209c94b455 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeGuards.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFourierSupported +import OAI.NumberTheory.Ostmann.Construction.WordTransferGuardPolynomial + +namespace OAI + +/-! # Polynomial and residue tests for the actual moving-giant node -/ + +namespace Ostmann +open scoped Classical + +def movingNodeWord (childBound pivotBound : ℕ) : WordTransferNode Bool where + target := false + left := [false] + right := [true] + childBound := childBound + pivotBound := pivotBound + +/-- The two word entries are the complete current child products, including +all regular factors. The reconstructed pivot here is the composite u*p. -/ +noncomputable def movingNodeGuard (CL CR : ℕ) (s v w : ℤ) (hs : s ≠ 0) + (childBound pivotBound : ℕ) (L R : HistoryFormula Bool) : WordTransferGuard Bool := + wordTransferGuard (movingNodeWord childBound pivotBound) s v w hs + (fun b => if b then .product R (.external CR) else .product L (.external CL)) + +/-- Identification with the original validity predicate, before any +arithmetic restriction is removed. -/ +theorem movingNodeGuard_iff {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (s : ℤ) (CL CR u : List σ) + (left right : MovingSlotData σ n) (hs : s ≠ 0) (XL XR : ℕ) + (L R : HistoryFormula Bool) (a : Bool → ℤ) + (hL : L.value (fun b => (a b : ℚ)) = (XL : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (XR : ℚ)) : + (movingNodeGuard (MovingSlotReversal.naturalProduct value CL) + (MovingSlotReversal.naturalProduct value CR) s left.frequency right.frequency hs + (childBound (n + 1)) (pivotBound (n + 1)) L R).ValidAt a ↔ + ∃ P, ValidTransferNode (movingSlotSystem value childBound pivotBound) + ⟨n + 1, .node s CL CR u left right, XL, XR⟩ s left.frequency right.frequency P := by + let d := movingNodeWord (childBound (n + 1)) (pivotBound (n + 1)) + let env : Bool → HistoryFormula Bool := fun b => + if b then .product R (.external (MovingSlotReversal.naturalProduct value CR)) + else .product L (.external (MovingSlotReversal.naturalProduct value CL)) + let x : Bool → ℕ := fun b => if b then XR * MovingSlotReversal.naturalProduct value CR + else XL * MovingSlotReversal.naturalProduct value CL + have henv (b : Bool) : (env b).value (fun j => (a j : ℚ)) = (x b : ℚ) := by + cases b <;> simp only [env, x, Bool.false_eq_true, ite_false, ite_true, + HistoryFormula.value_product, HistoryFormula.value_external, hL, hR, + Nat.cast_mul, Int.cast_natCast] + have hh := wordTransferGuard_iff d (.leaf []) (.leaf []) s left.frequency right.frequency hs env a x henv + change (wordTransferGuard d s left.frequency right.frequency hs env).ValidAt a ↔ _ + rw [hh] + apply exists_congr + intro P + have hpL : wordTransferLeft ((WordTransferTemplate.node d (.leaf []) (.leaf [])).state x) = + XL * MovingSlotReversal.naturalProduct value CL := by simp [wordTransferLeft, WordTransferTemplate.state, d, movingNodeWord, x] + have hpR : wordTransferRight ((WordTransferTemplate.node d (.leaf []) (.leaf [])).state x) = + XR * MovingSlotReversal.naturalProduct value CR := by simp [wordTransferRight, WordTransferTemplate.state, d, movingNodeWord, x] + constructor <;> intro h + · exact ⟨h.root_ne_zero, by simpa only [wordTransferSystem, hpR, movingSlotSystem, MovingSlotState.rightProduct] using h.root_unit, + by simpa only [wordTransferSystem, hpL, hpR, movingSlotSystem, MovingSlotState.leftProduct, MovingSlotState.rightProduct] using h.relation, + h.pivot_pos, h.pivot_bound, h.left_bound, h.right_bound, + by simpa only [wordTransferSystem, hpR, movingSlotSystem, MovingSlotState.rightProduct, wordTransferPivotBound, wordTransferChildBound, WordTransferTemplate.state, d, movingNodeWord, wordTransferRight, x, List.map_cons, List.map_nil, List.prod_cons, List.prod_nil, Bool.true_eq, ite_true, Nat.mul_one] using h.range_gap, h.pivot_unit⟩ + · exact ⟨h.root_ne_zero, by simpa only [wordTransferSystem, hpR, movingSlotSystem, MovingSlotState.rightProduct] using h.root_unit, + by simpa only [wordTransferSystem, hpL, hpR, movingSlotSystem, MovingSlotState.leftProduct, MovingSlotState.rightProduct] using h.relation, + h.pivot_pos, h.pivot_bound, h.left_bound, h.right_bound, + by simpa only [wordTransferSystem, hpR, movingSlotSystem, MovingSlotState.rightProduct, wordTransferPivotBound, wordTransferChildBound, WordTransferTemplate.state, d, movingNodeWord, wordTransferRight, x, List.map_cons, List.map_nil, List.prod_cons, List.prod_nil, Bool.true_eq, ite_true, Nat.mul_one] using h.range_gap, h.pivot_unit⟩ + +/-- At an actual moving node all non-residue validity tests are exactly +three polynomial inequalities in the chosen top giant coordinate. -/ +theorem movingNodeGuard_polynomials {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (s : ℤ) (CL CR u : List σ) + (left right : MovingSlotData σ n) (hs : s ≠ 0) (XL XR : ℕ) + (L R : HistoryFormula Bool) (a : Bool → ℤ) (coord : Bool) (z : ℤ) + (hL : L.value (fun b => (Function.update a coord z b : ℚ)) = (XL : ℚ)) + (hR : R.value (fun b => (Function.update a coord z b : ℚ)) = (XR : ℚ)) : + let g := movingNodeGuard (MovingSlotReversal.naturalProduct value CL) + (MovingSlotReversal.naturalProduct value CR) s left.frequency right.frequency hs + (childBound (n + 1)) (pivotBound (n + 1)) L R + (g.residueAt (Function.update a coord z) ∧ g.frequencyBounds ∧ + ∀ j, 0 ≤ (g.polynomials a coord j).eval (z : ℝ)) ↔ + ∃ P, ValidTransferNode (movingSlotSystem value childBound pivotBound) + ⟨n + 1, .node s CL CR u left right, XL, XR⟩ s left.frequency right.frequency P := by + let g := movingNodeGuard (MovingSlotReversal.naturalProduct value CL) + (MovingSlotReversal.naturalProduct value CR) s left.frequency right.frequency hs + (childBound (n + 1)) (pivotBound (n + 1)) L R + have hh := movingNodeGuard_iff value childBound pivotBound s CL CR u left right hs XL XR L R + (Function.update a coord z) hL hR + have hp := (g.validAt_polynomials a coord z).symm + have hu : @Function.update Bool (fun _ => ℤ) instDecidableEqBool a coord z = + @Function.update Bool (fun _ => ℤ) (fun x y => Classical.propDecidable (x = y)) a coord z := by + funext b + by_cases hb : b = coord <;> simp [Function.update, hb] + rw [← hu] at hp + exact hp.trans hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeUnits.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeUnits.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6b46a3cba2edb7312ffc7ee35c33a75cda29081 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNodeUnits.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensatedEquations +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRecursiveSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyResidues + +namespace OAI + +/-! # Coefficient units forced by the original local support masks -/ + +namespace Ostmann +open scoped Classical + +theorem movingNodeAtPath_root {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (t : FrequencyTree ℤ n) (hT : T.Follows t) (XL XR : ℕ) (path : List Bool) : + let z := transferNodeAtPath (movingSlotSystem value childBound pivotBound) n + ⟨n, T, XL, XR⟩ t path + z.state.data.frequency = z.root := by + induction T generalizing XL XR path with + | leaf s C => exact hT + | node s CL CR U l r ihL ihR => + cases path with + | nil => exact hT.1 + | cons b path => + cases b + · exact ihL t.2.1 hT.2.1 _ XL path + · exact ihR t.2.2 hT.2.2 _ XR path + +theorem MovingSlotData.frequency_dvd_product {σ : Type*} {n : ℕ} (T : MovingSlotData σ n) : + T.frequency ∣ T.frequencyProduct := by + cases T with + | leaf => exact dvd_refl _ + | node => exact dvd_mul_of_dvd_left (dvd_mul_right _ _) _ + +theorem movingLocalSupport_products_units {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (x : MovingSlotState σ) (s : ℤ) + (hs : x.data.frequency = s) (hsmall : ∀ i, IsCoprime (value i : ℤ) s) + (hx : movingLocalSupport value outside x) : + IsCoprime (x.leftProduct value : ℤ) s ∧ IsCoprime (x.rightProduct value : ℤ) s := by + have hL : IsCoprime (x.leftGiant : ℤ) s := + hs ▸ hx.2.1.of_isCoprime_of_dvd_right x.data.frequency_dvd_product + have hR : IsCoprime (x.rightGiant : ℤ) s := + hs ▸ hx.2.2.1.of_isCoprime_of_dvd_right x.data.frequency_dvd_product + rcases x with ⟨n, T, XL, XR⟩ + cases T with + | leaf => exact ⟨isCoprime_one_left, isCoprime_one_left⟩ + | node f CL CR U l r => + constructor + · exact_mod_cast hL.mul_left (movingNaturalProduct_coprime value CL s (fun i _ => hsmall i)) + · exact_mod_cast hR.mul_left (movingNaturalProduct_coprime value CR s (fun i _ => hsmall i)) + +theorem movingSlotWeight_node_localSupport {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (x : MovingSlotState σ) (t : FrequencyTree ℤ n) + (hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingGuardedExtra value outside E)) n x t ≠ 0) + (j : Fin (2 ^ n - 1)) : + movingLocalSupport value outside + (transferNodeArray (movingSlotSystem value childBound pivotBound) n x t j).state := by + let sys := movingSlotSystem value childBound pivotBound + let z := transferNodeArray sys n x t j + have hz : z ∈ transferNodeList sys n x t := by + unfold z transferNodeArray + rw [List.getD_eq_getElem _ _ (by rw [transferNodeList_length]; exact j.isLt)] + exact List.getElem_mem _ + have hc := recursiveTransferWeight_node_cutoff_ne_zero sys F + (movingSlotCutoff value childBound pivotBound (movingGuardedExtra value outside E)) + n x t hw z hz + rw [movingSlotCutoff_guarded] at hc + by_contra hn + exact hc (ite_eq_right hn) + +theorem movingSample_coefficient_units {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (S : Finset ℤ) (n : ℕ) (t : FrequencyTree S n) + (small bulk : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) (XL XR : ℕ) + (hsmall : ∀ i s, s ∈ S → IsCoprime (value i : ℤ) s) + (hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingGuardedExtra value outside E)) n + ⟨n, buildMovingSlotData n (frequencyTreeMap Subtype.val n t) small bulk a, XL, XR⟩ + (frequencyTreeMap Subtype.val n t) ≠ 0) (j : Fin (2 ^ n - 1)) : + let D := movingSampleAncestorScheme value S n t small a XL XR + let tz := frequencyTreeMap Subtype.val n t + let p := movingGiantArray value childBound pivotBound n + ⟨n, buildMovingSlotData n tz small bulk a, XL, XR⟩ tz + IsCoprime (D.leftCoefficient p j) (D.frequencies j).root ∧ + IsCoprime (D.rightCoefficient p j) (D.frequencies j).root := by + dsimp only + let sys := movingSlotSystem value childBound pivotBound + let tz := frequencyTreeMap Subtype.val n t + let T := buildMovingSlotData n tz small bulk a + let x : MovingSlotState σ := ⟨n, T, XL, XR⟩ + let z := transferNodeArray sys n x tz j + have hlocal := movingSlotWeight_node_localSupport value outside childBound pivotBound F E n x tz hw j + have hf := transferNodeArray_frequencies sys S n x t j + have hroot := congrArg NodeFrequencies.root hf + dsimp only [ReconstructedTransferNode.frequencies] at hroot + have hr := movingNodeAtPath_root value childBound pivotBound T tz + (buildMovingSlotData_follows n tz small bulk a) XL XR (preorderNodePath n j) + rw [← transferNodeArray_path] at hr + have hu := movingLocalSupport_products_units value outside z.state z.root hr + (fun i => hroot.symm ▸ hsmall i _ (singleTreeNodeFrequencies_root_mem S n t j.val j.isLt)) hlocal + have hp := movingSampleNode_products value childBound pivotBound S n t small bulk a XL XR j + rw [hp.2.1, hp.2.2, hroot] at hu + exact ⟨hu.2.of_mul_left_left, hu.1.of_mul_left_left⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedEnergyBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedEnergyBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..462eb6228b9760214a27eecebcbc506c7cc2124f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedEnergyBound.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNormalizedStatistic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPrimeStatisticBound + +namespace OAI + +/-! # The arithmetic energy bounds the original normalized giant average -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- The four unit-rectangle energy bounds give the full original giant law. +The factors from the two harmonic normalizations are retained explicitly. -/ +theorem movingPrimeCore_normalized_energy_bound {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) + (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφnorm : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (hν : ∀ b a, 0 ≤ ν b a) (hmass : ∀ b, ∑ a, ν b a = 1) + (hidentical : ∀ j k, ν (slot j) = ν (slot k)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (gLeft gRight E : ℝ) (hE : 0 ≤ E) + (henergy : ∀ i j : Bool, + let u := if i then gLeft else gLeft - 1 + let r := if j then gRight else gRight - 1 + (movingOriginalSymmetrizedEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg gLeft gRight false u (u + 1) r (r + 1) u).re ≤ E) : + ‖smoothGiantExternalAverage ν (V n) φ gLeft gRight (fun s y p r => + movingPrimeCore q value outside μ childBound pivotBound V f g Dq S ψ X lo hi φ G + n m small slot greg ggiant favorable s y (Real.log p) (Real.log r))‖ ^ 2 ≤ + 16 * Real.exp (2 * (smoothGiantLogNormalizer (smoothGiantPrimeRange gLeft) φ gLeft + + smoothGiantLogNormalizer (smoothGiantPrimeRange gRight) φ gRight)) * + (diagonalOuterMajorant Bφ Dφ false * (2 * V n + 1 : ℕ) * Real.exp 2 * E) := by + apply smoothGiantExternalAverage_full_cell_bound ν (V n) φ gLeft gRight _ hout + intro i j + rw [movingPrimeCore_interval_eq] + have hb := movingOriginalPrimeStatistic_upper q value outside μ ν childBound pivotBound V + f g Dq S ψ X lo hi φ hφ Bφ Dφ hBφ hDφ hφnorm hlip hout G n m small slot hsmall + hν hmass hidentical greg ggiant favorable gLeft gRight false + (if i then gLeft else gLeft - 1) ((if i then gLeft else gLeft - 1) + 1) + (if j then gRight else gRight - 1) ((if j then gRight else gRight - 1) + 1) + (if i then gLeft else gLeft - 1) (le_refl _) (le_refl _) E hE (henergy i j) + simpa only [sub_self, Real.exp_zero, one_pow, one_mul] using hb + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedFinalRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedFinalRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bf07937a46adc04abdbb50c325a90d68a68379c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedFinalRate.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFinalRate + +namespace OAI + +/-! # The final numerical contradiction retains both giant normalizers -/ +namespace Ostmann +open Filter + +theorem moving_normalized_amplitude_lower (B r m cg : ℝ) (η statistic : ℂ) + (hloss : 2 * cg ≤ r * m) + (hid : η = (Real.exp (2 * cg) : ℂ) * statistic) + (hlower : Real.exp (-B * r * m) ≤ ‖η‖) : + Real.exp (-(B + 1) * r * m) ≤ ‖statistic‖ := by + rw [hid, norm_mul, Complex.norm_real, Real.norm_of_nonneg (Real.exp_nonneg _)] at hlower + have h := mul_le_mul_of_nonneg_left hlower (Real.exp_nonneg (-2 * cg)) + have hinv : Real.exp (-2 * cg) * Real.exp (2 * cg) = 1 := by + rw [← Real.exp_add] + convert Real.exp_zero using 1 + congr 1 + ring + have hs : Real.exp (-2 * cg + -B * r * m) ≤ ‖statistic‖ := by + calc + _ = Real.exp (-2 * cg) * Real.exp (-B * r * m) := Real.exp_add _ _ + _ ≤ Real.exp (-2 * cg) * (Real.exp (2 * cg) * ‖statistic‖) := h + _ = _ := by rw [← mul_assoc, hinv, one_mul] + exact (Real.exp_le_exp.mpr (by nlinarith only [hloss])).trans hs + +theorem eventually_moving_normalized_numeric_contradiction (Bs BD Bz B C : ℝ) (hC : 0 ≤ C) : + ∀ᶠ k : ℕ in atTop, ∀ᶠ L : ℝ in atTop, + let m := spectatorBulkCount k L + let r : ℝ := (2 : ℝ) ^ k + let A := movingFrequencyRate Bs BD Bz ((k : ℝ) ^ 4) k + let D := Bs + 8 * Real.log ((k : ℝ) ^ 4) + ∀ V : ℕ, (V : ℝ) ≤ Real.exp (A * m) → 0 ≤ A → + ∀ Δ cg : ℝ, Δ ≤ D * m → cg ≤ L → ∀ η statistic : ℂ, + η = (Real.exp (2 * cg) : ℂ) * statistic → + Real.exp (-B * r * m) ≤ ‖η‖ → + ‖statistic‖ ^ 2 ≤ C * (2 * V + 1 : ℕ) * Real.exp 5 * + (4 * ((((2 ^ k + 1) * (2 ^ k) ^ (2 * 2 ^ k) : ℕ) : ℝ) * + Real.exp (r * m * (-(3 / 4 : ℝ) * Real.log ((2 : ℝ) ^ k) + 5 / 4)) * + (Real.exp (r * Δ + (Real.log 12 + 1) * r * m + m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-(A + (2 * (B + 1) + 1) * r + 1) * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)))) → False := by + filter_upwards [eventually_moving_numeric_contradiction Bs BD Bz (B + 1) + (4 * C * Real.exp 3) (by positivity), eventually_ge_atTop (2 : ℕ)] with k hk hk2 + filter_upwards [hk, eventually_ge_atTop (1 : ℝ)] with L hfinal hL + dsimp only at hfinal ⊢ + intro V hV hA Δ cg hΔ hcg η statistic hid hlower hupper + have hkR : (2 : ℝ) ≤ k := by exact_mod_cast hk2 + have hk4 : (16 : ℝ) ≤ (k : ℝ) ^ 4 := by + convert pow_le_pow_left₀ (by norm_num : (0 : ℝ) ≤ 2) hkR 4 using 1 + norm_num + have hm := spectatorBulkCount_lower k L + have hr : (1 : ℝ) ≤ 2 ^ k := one_le_pow₀ (by norm_num) + have hloss : 2 * cg ≤ (2 : ℝ) ^ k * spectatorBulkCount k L := by + have hm2 : 2 * L ≤ (spectatorBulkCount k L : ℝ) := by + nlinarith [mul_le_mul_of_nonneg_right hk4 (show 0 ≤ L by linarith)] + have hrm := mul_le_mul_of_nonneg_right hr (show 0 ≤ (spectatorBulkCount k L : ℝ) by positivity) + nlinarith + apply hfinal V hV hA Δ hΔ statistic + (moving_normalized_amplitude_lower B (2 ^ k) (spectatorBulkCount k L) cg η statistic hloss hid hlower) + have hexp : Real.exp 5 = Real.exp 3 * Real.exp 2 := by + rw [← Real.exp_add] + norm_num + convert hupper using 1 + rw [hexp] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedMaskedEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedMaskedEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..00ca55ed6fe171ba1639c06ba2f64991fa468c89 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedMaskedEnergy.lean @@ -0,0 +1,46 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMaskedOriginalIntegral +import OAI.NumberTheory.Ostmann.Characters.MixedExternalPartition + +namespace OAI + +/-! # The exact normalization of the original masked diagonal energy -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingMaskedTemplateEnergy_original_interval {J : Type} + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (q : J → ℕ) [∀ i, Fact (q i).Prime] + (outside : List ℕ) (μ : ℕ → P → ℝ) (n r m : ℕ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset J) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (Q : MovingRegularSlot n r m → Finset ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (center : ℝ) : + let H := G (n + 1) + let Pg := smoothGiantPrimeRange H + let Pivots := Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊ + let ν := movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i)) + (movingMaskedTemplateEnergy P Pg Pivots hP outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val q (fun _ => f) g Dq S ψ X lo hi) φ G n r m Q greg + (fun _ => 1) : ℂ) = + (Real.exp (smoothGiantLogNormalizer Pg φ H + center) : ℂ) * + movingWeightedDiagonalEnergy q Subtype.val outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n (movingTemplateSmall n (4 + r) m) + (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m)) + (fun s => movingTemplateExternalMultiplier P hP n (4 + r) m + (movingRestoredActive n r m) outside greg s φ H H false) + (H - 1) (H + 1) (H - 1) (H + 1) center := by + intro H Pg Pivots ν + have h := movingMaskedTemplateEnergy_interval P hP outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val q (fun _ => f) g Dq S ψ X lo hi) φ hout G n r m Q greg center + have hi := movingMaskedTemplateKernel_original_integral P hP q outside μ n r m ν + childBound pivotBound V f g Dq S ψ X lo hi φ G greg H + (H - 1) (H + 1) (H - 1) (H + 1) center + exact h.trans (congrArg (fun z : ℂ => + (Real.exp (smoothGiantLogNormalizer Pg φ H + center) : ℂ) * z) hi) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedStatistic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedStatistic.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f238a86edd9b9809108d1ecf3d3db072f44d2cd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedStatistic.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.Ostmann.Construction.PrimeExternalLogCoordinates +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPrimeStatistic + +namespace OAI + +/-! # The original normalized moving amplitude and the proved prime statistic -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingPrimeCore {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (s : ℤ) (y : B → σ) (x z : ℝ) : ℂ := + (movingGiantPhase value outside small (bulkSlotLeaves n m slot) ggiant favorable s y x z * + movingExternalRegularFactor value outside small (bulkSlotLeaves n m slot) greg s y x z) * + movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulkSlotLeaves n m slot)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + +/-- At prime points, the logarithmic coordinates and the positive-log +cutoffs agree with the original statistic on every rectangle. -/ +theorem movingPrimeCore_interval_eq {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (gLeft gRight u v r w : ℝ) : + primeExternalAverage ν (V n) u v r w (fun s y x z => + (φ (x - gLeft) : ℂ) * (φ (z - gRight) : ℂ) * + movingPrimeCore q value outside μ childBound pivotBound V f g Dq S ψ X lo hi φ G + n m small slot greg ggiant favorable + s y (Real.log ⌊Real.exp x⌋₊) (Real.log ⌊Real.exp z⌋₊)) = + movingOriginalPrimeStatistic q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg ggiant favorable gLeft gRight false u v r w := by + unfold movingOriginalPrimeStatistic + refine primeExternalAverage_congr_primes ν (V n) u v r w _ _ ?_ + intro s y p r hp hr + have hp' : (0 : ℝ) < p := Nat.cast_pos.mpr hp.pos + have hr' : (0 : ℝ) < r := Nat.cast_pos.mpr hr.pos + simp only [movingPrimeCore, Real.exp_log hp', Real.exp_log hr', Nat.floor_natCast, + giantOuterWeight, Bool.false_eq_true, ite_false, mul_one, positiveLogCutoff, + hp', hr', ite_true] + ring + +/-- Exact identification of the two normalized giant priors with the +full-cell moving statistic. All normalizers and both phases remain present. -/ +theorem movingPrimeCore_normalized_eq {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (gLeft gRight : ℝ) (hout : ∀ x, 1 ≤ |x| → φ x = 0) : + smoothGiantExternalAverage ν (V n) φ gLeft gRight (fun s y p r => + movingPrimeCore q value outside μ childBound pivotBound V f g Dq S ψ X lo hi φ G + n m small slot greg ggiant favorable s y (Real.log p) (Real.log r)) = + (Real.exp (smoothGiantLogNormalizer (smoothGiantPrimeRange gLeft) φ gLeft + + smoothGiantLogNormalizer (smoothGiantPrimeRange gRight) φ gRight) : ℂ) * + movingOriginalPrimeStatistic q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg ggiant favorable gLeft gRight false + (gLeft - 1) (gLeft + 1) (gRight - 1) (gRight + 1) := by + rw [smoothGiantExternalAverage_log_cutoff ν (V n) φ gLeft gRight hout] + apply congrArg (fun z : ℂ => + (Real.exp (smoothGiantLogNormalizer (smoothGiantPrimeRange gLeft) φ gLeft + + smoothGiantLogNormalizer (smoothGiantPrimeRange gRight) φ gRight) : ℂ) * z) + unfold movingOriginalPrimeStatistic + refine primeExternalAverage_congr_primes ν (V n) (gLeft - 1) (gLeft + 1) (gRight - 1) (gRight + 1) _ _ ?_ + intro s y p r hp hr + have hp' : (0 : ℝ) < p := Nat.cast_pos.mpr hp.pos + have hr' : (0 : ℝ) < r := Nat.cast_pos.mpr hr.pos + simp only [Real.exp_log hp', Real.exp_log hr', Nat.floor_natCast, + movingPrimeCore, giantOuterWeight, Bool.false_eq_true, ite_false, mul_one] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedSymmetrizedEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedSymmetrizedEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc7e5b248df9569e04cea1a332815a50d8728a20 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingNormalizedSymmetrizedEnergy.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSymmetrizedMaskedIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateExternalMultiplier + +namespace OAI + +/-! # Exact normalization of the original bulk-averaged masked energy -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingTemplateMaskedSymmetrizedEnergy + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (ν : MovingRegularSlot n r m → P → ℝ) (active : MovingRegularSlot n r m → Bool) + (greg : ∀ q : ℕ, ZMod q → ℂ) (Jleft Jright : ℝ) (diagonal : Bool) + (u v a b center : ℝ) : ℂ := + mixedExternalAverage ν (V n) u v a b center (fun s y x z => + (‖movingBulkAveragedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) * + movingTemplateExternalMultiplier P hP n r m active outside greg s φ Jleft Jright diagonal y x z) + +theorem movingSymmetrizedMaskedTemplateKernel_original_integral + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (n r m : ℕ) (ν : MovingRegularSlot n (4 + r) m → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (greg : ∀ q : ℕ, ZMod q → ℂ) + (H : ℝ) (u v a b center : ℝ) : + mixedExternalAverage ν (V n) u v a b center + (fun s x z y => (φ (z - H) : ℂ) * (φ (y - H) : ℂ) * + (movingSymmetrizedMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G + n r m greg x ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ s : ℝ)) = + movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G + n (4 + r) m ν (movingRestoredActive n r m) greg H H false u v a b center := by + unfold movingTemplateMaskedSymmetrizedEnergy mixedExternalAverage + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro x _ + congr 1 + unfold complexPrimeInterval + apply Finset.sum_congr rfl + intro Xg hXg + split_ifs + · congr 1 + unfold complexIntegerInterval + apply Finset.sum_congr rfl + intro piv hpiv + congr 1 + have hp : (0 : ℝ) < piv := by + exact_mod_cast (Nat.zero_le _).trans_lt (Finset.mem_Ioc.mp hpiv).1 + have hq : (0 : ℝ) < Xg := by + exact_mod_cast (Nat.zero_le _).trans_lt (Finset.mem_Ioc.mp hXg).1 + simp only [Real.exp_log hp, Real.exp_log hq, Nat.floor_natCast, + movingSymmetrizedMaskedTemplateKernel, movingTemplateExternalMultiplier, + giantOuterWeight, positiveLogCutoff, ite_eq_left hp, ite_eq_left hq, + Bool.false_eq_true, ite_false, mul_one, Complex.ofReal_mul, Complex.ofReal_pow] + ring + · rfl + +theorem movingSymmetrizedMaskedTemplateEnergy_original_interval + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (center : ℝ) : + let H := G (n + 1) + let Pg := smoothGiantPrimeRange H + let I := Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊ + let ν := movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i)) + (movingSymmetrizedMaskedTemplateEnergy P Pg I hP outside μ childBound pivotBound V F φ G + n r m Q greg (fun _ => 1) : ℂ) = + (Real.exp (smoothGiantLogNormalizer Pg φ H + center) : ℂ) * + movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G + n (4 + r) m ν (movingRestoredActive n r m) greg H H false + (H - 1) (H + 1) (H - 1) (H + 1) center := by + dsimp only + rw [movingSymmetrizedMaskedTemplateEnergy_interval P hP outside μ childBound pivotBound V + F φ hout G n r m Q greg center] + rw [movingSymmetrizedMaskedTemplateKernel_original_integral] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceIntegrality.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceIntegrality.lean new file mode 100644 index 0000000000000000000000000000000000000000..668b1abb59f752cff02c8f66b9f8c7f984edcdd7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceIntegrality.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleIntegrality + +namespace OAI + +/-! # Every occurrence follows the actual reconstructed integer path -/ + +namespace Ostmann +open scoped Classical + +theorem movingSlotNaturalPath_append {σ : Type*} (value : σ → ℕ) + (a b : List (MovingSlotReversal σ)) (pair : ℕ × ℕ) : + movingSlotNaturalPath value (a ++ b) pair = + movingSlotNaturalPath value a (movingSlotNaturalPath value b pair) := by + induction a with + | nil => rfl + | cons s a ih => simp only [List.cons_append, movingSlotNaturalPath, ih] + +theorem movingSlotPathIntegral_append {σ : Type*} (value : σ → ℕ) + (a b : List (MovingSlotReversal σ)) (pair : ℕ × ℕ) : + MovingSlotPathIntegral value (a ++ b) pair ↔ + MovingSlotPathIntegral value b pair ∧ + MovingSlotPathIntegral value a (movingSlotNaturalPath value b pair) := by + induction a with + | nil => simp [MovingSlotPathIntegral] + | cons s a ih => + simp only [List.cons_append, MovingSlotPathIntegral, movingSlotNaturalPath_append, ih, and_assoc] + +/-- The integral support at a tree yields all the local integer equalities +used in the polynomial line interpretation. This is constructive for every +listed occurrence, including both child orders. -/ +theorem MovingSlotData.occurrence_integral {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (XL XR : ℕ) (hT : T.Integral value XL XR) : + ∀ o ∈ T.occurrences, + MovingSlotPathIntegral value o.path (XL, XR) ∧ + o.current.IntegralAt value (movingSlotNaturalPath value o.path (XL, XR)) := by + induction T generalizing XL XR with + | leaf s regular => simp [occurrences] + | @node n s CL CR u left right ihL ihR => + let step := MovingSlotData.step s CL CR u left right + let p := (step false).naturalPivot value XL XR + have hroot : (step false).IntegralAt value (XL, XR) := hT.1 + have htrue : (step true).IntegralAt value (XL, XR) := hroot + have hleft := ihL p XL hT.2.1 + have hright := ihR p XR hT.2.2 + intro o ho + rcases List.mem_cons.mp ho with ho | ho + · subst o + exact ⟨trivial, hroot⟩ + · rcases List.mem_append.mp ho with ho | ho + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + obtain ⟨hp, hc⟩ := hleft o' ho' + have hpair : movingSlotNaturalPath value [step true] (XL, XR) = (p, XL) := rfl + constructor + · change MovingSlotPathIntegral value (o'.path ++ [step true]) (XL, XR) + rw [movingSlotPathIntegral_append, hpair] + exact ⟨⟨trivial, htrue⟩, hp⟩ + · change o'.current.IntegralAt value (movingSlotNaturalPath value (o'.path ++ [step true]) (XL, XR)) + rw [movingSlotNaturalPath_append, hpair] + exact hc + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + obtain ⟨hp, hc⟩ := hright o' ho' + have hpair : movingSlotNaturalPath value [step false] (XL, XR) = (p, XR) := rfl + constructor + · change MovingSlotPathIntegral value (o'.path ++ [step false]) (XL, XR) + rw [movingSlotPathIntegral_append, hpair] + exact ⟨⟨trivial, hroot⟩, hp⟩ + · change o'.current.IntegralAt value (movingSlotNaturalPath value (o'.path ++ [step false]) (XL, XR)) + rw [movingSlotNaturalPath_append, hpair] + exact hc + +theorem buildMovingSlotData_occurrence_integral {σ : Type*} (value : σ → ℕ) (n : ℕ) + (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) (XL XR : ℕ) + (hT : (buildMovingGiantTree n t (movingSlotValues value n small) (samples.values value)).Integral + XL XR (movingSlotValues value n bulk)) + (o : MovingSlotOccurrence σ) + (ho : o ∈ (buildMovingSlotData n t small bulk samples).occurrences) : + MovingSlotPathIntegral value o.path (XL, XR) ∧ + o.current.IntegralAt value (movingSlotNaturalPath value o.path (XL, XR)) := + MovingSlotData.occurrence_integral value _ XL XR + ((buildMovingSlotData_integral value n t small bulk samples XL XR).mpr hT) o ho + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceNumerator.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceNumerator.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d13b64ade1f0858eb452b6812f54cebde6c137d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceNumerator.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOccurrenceIntegrality +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOccurrenceUnits + +namespace OAI + +/-! # Identifying the occurrence lines with the actual integer numerators -/ + +namespace Ostmann +open scoped Classical + +theorem movingSlotLine_integer_numerator {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (path : List (MovingSlotReversal σ)) + (current : MovingSlotReversal σ) (XL XR : ℕ) + (hvalid : MovingSlotPathIntegral value path (XL, XR)) + (hunit : ∀ s ∈ path, + MovingSlotReversal.naturalReduction q value s.polynomial.v ≠ 0 ∧ + MovingSlotReversal.naturalReduction q value s.polynomial.w ≠ 0 ∧ + MovingSlotReversal.naturalReduction q value s.polynomial.u ≠ 0) : + let φ := MovingSlotReversal.naturalReduction q value + let pair := movingSlotNaturalPath value path (XL, XR) + ((movingSlotLine path current).normalized φ).1 * (XL : ZMod q) + + ((movingSlotLine path current).normalized φ).2 * (XR : ZMod q) = + (current.leftFrequency : ZMod q) * + ((pair.2 * MovingSlotReversal.naturalProduct value current.rightSlots : ℕ) : ZMod q) - + (current.rightFrequency : ZMod q) * + ((pair.1 * MovingSlotReversal.naturalProduct value current.leftSlots : ℕ) : ZMod q) := by + let φ := MovingSlotReversal.naturalReduction q value + let T := movingPolynomialAncestors (path.map MovingSlotReversal.polynomial) + have hden : φ T.denominator ≠ 0 := by + apply movingPolynomialAncestors_denominator + intro s hs + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs + exact (hunit t ht).2.2 + have he := movingSlotNaturalPath_realized value path (XL, XR) hvalid hunit + have hL := congrArg Prod.fst he + have hR := congrArg Prod.snd he + change (T.normalized φ).a * (XL : ZMod q) + (T.normalized φ).b * XR = _ at hL + change (T.normalized φ).c * (XL : ZMod q) + (T.normalized φ).d * XR = _ at hR + change ((T.numeratorLine current.polynomial.v current.polynomial.w).normalized φ).1 * + (XL : ZMod q) + + ((T.numeratorLine current.polynomial.v current.polynomial.w).normalized φ).2 * XR = _ + rw [PolynomialGiantRows.normalized_numeratorLine T _ _ φ hden] + dsimp only + calc + _ = φ current.polynomial.v * ((T.normalized φ).c * XL + (T.normalized φ).d * XR) - + φ current.polynomial.w * ((T.normalized φ).a * XL + (T.normalized φ).b * XR) := by ring + _ = _ := by + rw [hL, hR] + simp only [φ, MovingSlotReversal.naturalReduction, MovingSlotReversal.polynomial, + MovingSlotReversal.coefficient_nat_eval, Nat.cast_mul] + ring + +/-- All prerequisites of the numerator identity now follow from the original +numeric tree support and the actual type-separated sampled primes. -/ +theorem sampled_occurrence_numerator {σ : Type*} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) (XL XR : ℕ) + (hsmall : ∀ i ∈ flattenMovingSlots n small, n ≤ tier i) + (hbulk : ∀ i ∈ flattenMovingSlots n bulk, n ≤ tier i) + (hsamples : samples.Levels tier) + (hI : (buildMovingGiantTree n t (movingSlotValues value n small) (samples.values value)).Integral + XL XR (movingSlotValues value n bulk)) + (o : MovingSlotOccurrence σ) (ho : o ∈ (buildMovingSlotData n t small bulk samples).occurrences) + (rep : σ) (hrep : tier rep < o.level) + (hfreq : movingGiantFrequencyUnits (value rep) n t) : + let _ : Fact (value rep).Prime := ⟨hprime rep⟩ + let φ := MovingSlotReversal.naturalReduction (value rep) value + let pair := movingSlotNaturalPath value o.path (XL, XR) + ((movingSlotLine o.path o.current).normalized φ).1 * (XL : ZMod (value rep)) + + ((movingSlotLine o.path o.current).normalized φ).2 * (XR : ZMod (value rep)) = + (o.current.leftFrequency : ZMod (value rep)) * + ((pair.2 * MovingSlotReversal.naturalProduct value o.current.rightSlots : ℕ) : ZMod (value rep)) - + (o.current.rightFrequency : ZMod (value rep)) * + ((pair.1 * MovingSlotReversal.naturalProduct value o.current.leftSlots : ℕ) : ZMod (value rep)) := by + let : Fact (value rep).Prime := ⟨hprime rep⟩ + have hlevels := buildMovingSlotData_levels tier n t small bulk samples hsmall hbulk hsamples + have hfreq' := buildMovingSlotData_frequencyUnits n t small bulk samples hfreq + have hu := MovingSlotData.occurrence_units_of_prime_types tier value hprime hdisjoint + _ hlevels o ho rep hrep hfreq' + have hi := buildMovingSlotData_occurrence_integral value n t small bulk samples XL XR hI o ho + exact movingSlotLine_integer_numerator value o.path o.current XL XR hi.1 hu.1 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceRelabel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..e271e1184f67262d0fd5d3179637b8ad13bdaaef --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceRelabel.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPolynomialRelabel +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalBaseAverage + +namespace OAI + +/-! # Actual internal-prime line systems commute with slot relabelling -/ + +namespace Ostmann +open scoped Classical + +def MovingSlotOccurrence.map {σ τ : Type*} (f : σ → τ) + (o : MovingSlotOccurrence σ) : MovingSlotOccurrence τ := + ⟨o.level, o.current.map f, o.path.map (MovingSlotReversal.map f)⟩ + +theorem MovingSlotOccurrence.map_extend {σ τ : Type*} (f : σ → τ) + (o : MovingSlotOccurrence σ) (s : MovingSlotReversal σ) : + (o.extend s).map f = (o.map f).extend (s.map f) := by + simp only [map, extend, List.map_append, List.map_singleton] + +theorem MovingSlotData.occurrences_map {σ τ : Type*} (f : σ → τ) + {n : ℕ} (T : MovingSlotData σ n) : + (T.map f).occurrences = T.occurrences.map (MovingSlotOccurrence.map f) := by + induction T with + | leaf => rfl + | node s CL CR u left right ihL ihR => + simp only [MovingSlotData.map, occurrences, step_map, ihL, ihR, + List.map_cons, List.map_append, List.map_map, Function.comp_def, + MovingSlotOccurrence.map, MovingSlotOccurrence.extend, List.map_nil] + +/-- The finite index of occurrences is only bookkeeping: the event itself is +exactly the conjunction over the original compensation slots. -/ +theorem movingPrimeLineSystem_iff {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) (x y : ZMod p) : + (∀ j : MovingPrimeOccurrences value T p, + let L := movingPrimeOccurrenceLine value T p j + let φ := MovingSlotReversal.naturalReduction p value + φ L.a * x + φ L.b * y = 0) ↔ + (∀ side o, o ∈ (T side).occurrences → + ∀ i ∈ o.current.compensationSlots, value i = p → + let L := movingSlotLine o.path o.current + let φ := MovingSlotReversal.naturalReduction p value + φ L.a * x + φ L.b * y = 0) := by + constructor + · intro h side o ho i hi hv + obtain ⟨k, hk, hko⟩ := List.mem_iff_getElem.mp ho + let j : MovingPrimeOccurrences value T p := + ⟨side, ⟨⟨k, hk⟩, by simpa only [List.get_eq_getElem, hko] using ⟨i, hi, hv⟩⟩⟩ + simpa only [movingPrimeOccurrenceLine, movingPrimeOccurrence, j, List.get_eq_getElem, hko] using h j + · intro h j + obtain ⟨i, hi, hv⟩ := j.2.property + exact h j.1 _ (List.get_mem _ _) i hi hv + +theorem movingSlotLine_natural_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (p : ℕ) (path : List (MovingSlotReversal σ)) + (current : MovingSlotReversal σ) : + let L := movingSlotLine path current + let L' := movingSlotLine (path.map (MovingSlotReversal.map f)) (current.map f) + let φ := MovingSlotReversal.naturalReduction p (value ∘ f) + let φ' := MovingSlotReversal.naturalReduction p value + φ' L'.a = φ L.a ∧ φ' L'.b = φ L.b := by + have h := movingSlotLine_map f path current + dsimp only + rw [h.1, h.2.1] + simp only [MovingSlotReversal.naturalReduction, MvPolynomial.eval₂Hom_rename, + Function.comp_def, and_self] + +theorem movingPrimeLineSystem_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) {n : ℕ} (T : Bool → MovingSlotData σ n) (p : ℕ) + (x y : ZMod p) : + (∀ j : MovingPrimeOccurrences value (fun side => (T side).map f) p, + let L := movingPrimeOccurrenceLine value (fun side => (T side).map f) p j + let φ := MovingSlotReversal.naturalReduction p value + φ L.a * x + φ L.b * y = 0) ↔ + (∀ j : MovingPrimeOccurrences (value ∘ f) T p, + let L := movingPrimeOccurrenceLine (value ∘ f) T p j + let φ := MovingSlotReversal.naturalReduction p (value ∘ f) + φ L.a * x + φ L.b * y = 0) := by + rw [movingPrimeLineSystem_iff, movingPrimeLineSystem_iff] + constructor + · intro h side o ho i hi hv + have he := h side (o.map f) (by rw [MovingSlotData.occurrences_map]; exact List.mem_map.mpr ⟨o, ho, rfl⟩) + (f i) (List.mem_map.mpr ⟨i, hi, rfl⟩) hv + have hl := movingSlotLine_natural_map f value p o.path o.current + change _ = 0 at he + simpa only [MovingSlotOccurrence.map, hl.1, hl.2] using he + · intro h side o ho i hi hv + rw [MovingSlotData.occurrences_map] at ho + obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + obtain ⟨i', hi', rfl⟩ := List.mem_map.mp hi + have he := h side o' ho' i' hi' hv + have hl := movingSlotLine_natural_map f value p o'.path o'.current + change _ = 0 + simpa only [MovingSlotOccurrence.map, hl.1, hl.2] using he + +theorem movingInternalBaseProbability_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) {n : ℕ} (T : Bool → MovingSlotData σ n) + (p : ℕ) [Fact p.Prime] : + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value (fun side => (T side).map f) p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value (fun side => (T side).map f) p j).b) = + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction p (value ∘ f) + (movingPrimeOccurrenceLine (value ∘ f) T p j).a) + (fun j => MovingSlotReversal.naturalReduction p (value ∘ f) + (movingPrimeOccurrenceLine (value ∘ f) T p j).b) := by + unfold internalLineProbability + simp only [ite_true, ← Nat.card_eq_fintype_card] + apply congrArg (fun k : ℕ => (k : ℝ) / Nat.card (ZMod p × (ZMod p)ˣ)) + exact Nat.card_congr (Equiv.subtypeEquivRight (fun z : ZMod p × (ZMod p)ˣ => + movingPrimeLineSystem_map f value T p z.1 z.2)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceSquares.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceSquares.lean new file mode 100644 index 0000000000000000000000000000000000000000..b59473590d406f1bcd637a09c90cabab8704e51f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceSquares.lean @@ -0,0 +1,140 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSquareSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSquareLines + +namespace OAI + +/-! # The full square support as the actual occurrence line tests -/ + +namespace Ostmann +open scoped Classical + +def MovingSlotReversal.integerNumerator {σ : Type*} (value : σ → ℕ) + (s : MovingSlotReversal σ) (pair : ℕ × ℕ) : ℤ := + s.leftFrequency * ((pair.2 * MovingSlotReversal.naturalProduct value s.rightSlots : ℕ) : ℤ) - + s.rightFrequency * ((pair.1 * MovingSlotReversal.naturalProduct value s.leftSlots : ℕ) : ℤ) + +/-- All recursive exclusions are exactly the exclusions in the recorded +occurrence list, evaluated along their actual natural paths. -/ +theorem MovingSlotData.squareTests_iff_occurrences {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : + T.PrimeSquareTests value XL XR ↔ + ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, + ¬ (value i : ℤ) ^ 2 ∣ o.current.integerNumerator value + (movingSlotNaturalPath value o.path (XL, XR)) := by + induction T generalizing XL XR with + | leaf => simp [PrimeSquareTests, occurrences] + | @node n s CL CR U left right ihL ihR => + let step := MovingSlotData.step s CL CR U left right + let p := (step false).naturalPivot value XL XR + have hl := ihL p XL + have hr := ihR p XR + constructor + · rintro ⟨hroot, hleft, hright⟩ o ho i hi + rcases List.mem_cons.mp ho with ho | ho + · subst o + exact hroot (value i) (List.mem_map.mpr ⟨i, hi, rfl⟩) + · rcases List.mem_append.mp ho with ho | ho + · obtain ⟨o', hmem, rfl⟩ := List.mem_map.mp ho + have h := hl.mp hleft o' hmem i hi + simpa only [MovingSlotOccurrence.extend, movingSlotNaturalPath_append, + movingSlotNaturalPath, MovingSlotReversal.naturalStep, p, step, MovingSlotReversal.naturalPivot, + MovingSlotData.step, ite_true] using h + · obtain ⟨o', hmem, rfl⟩ := List.mem_map.mp ho + have h := hr.mp hright o' hmem i hi + simpa only [MovingSlotOccurrence.extend, movingSlotNaturalPath_append, + movingSlotNaturalPath, MovingSlotReversal.naturalStep, p, step, MovingSlotReversal.naturalPivot, + MovingSlotData.step, Bool.false_eq_true, ite_false] using h + · intro h + refine ⟨?_, hl.mpr ?_, hr.mpr ?_⟩ + · intro b hb + obtain ⟨i, hi, rfl⟩ := List.mem_map.mp hb + exact h ⟨n + 1, step false, []⟩ (List.mem_cons_self) i hi + · intro o ho i hi + have hh := h (o.extend (step true)) + (List.mem_cons_of_mem _ (List.mem_append_left _ (List.mem_map.mpr ⟨o, ho, rfl⟩))) i hi + simpa only [MovingSlotOccurrence.extend, movingSlotNaturalPath_append, + movingSlotNaturalPath, MovingSlotReversal.naturalStep, p, step, MovingSlotReversal.naturalPivot, + MovingSlotData.step, ite_true] using hh + · intro o ho i hi + have hh := h (o.extend (step false)) + (List.mem_cons_of_mem _ (List.mem_append_right _ (List.mem_map.mpr ⟨o, ho, rfl⟩))) i hi + simpa only [MovingSlotOccurrence.extend, movingSlotNaturalPath_append, + movingSlotNaturalPath, MovingSlotReversal.naturalStep, p, step, MovingSlotReversal.naturalPivot, + MovingSlotData.step, Bool.false_eq_true, ite_false] using hh + +/-- A current compensation slot belongs to the type immediately below the +occurrence, including when a prime represents multiple occurrences. -/ +theorem MovingSlotData.occurrence_compensation_level {σ : Type*} (tier : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (hT : T.Levels tier) : + ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, tier i < o.level := by + induction T with + | leaf => simp [occurrences] + | @node n s CL CR U left right ihL ihR => + intro o ho i hi + rcases List.mem_cons.mp ho with ho | ho + · subst o + have he := hT.2.2.1 i hi + change tier i < n + 1 + omega + · rcases List.mem_append.mp ho with ho | ho + · obtain ⟨o', hmem, rfl⟩ := List.mem_map.mp ho + exact ihL hT.2.2.2.1 o' hmem i hi + · obtain ⟨o', hmem, rfl⟩ := List.mem_map.mp ho + exact ihR hT.2.2.2.2 o' hmem i hi + +theorem MovingSlotData.occurrences_length {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) : T.occurrences.length = 2 ^ n - 1 := by + induction T with + | leaf => simp [occurrences] + | @node n s CL CR U left right ihL ihR => + simp only [occurrences, List.length_cons, List.length_append, List.length_map, ihL, ihR, + pow_succ] + have hpos : 0 < 2 ^ n := pow_pos (by decide) n + omega + +/-- The full recursive support has only linear equations at the original +pair of giants modulo the current compensation-prime squares. -/ +theorem MovingSlotData.squareTests_iff_lines {σ : Type*} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + {n : ℕ} (T : MovingSlotData σ n) (hlevels : T.Levels tier) + (hfreq : ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (XL XR : ℕ) (hI : T.Integral value XL XR) : + T.PrimeSquareTests value XL XR ↔ + ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, + let φ := MovingSlotReversal.naturalReduction (value i ^ 2) value + φ (movingSlotLine o.path o.current).a * (XL : ZMod (value i ^ 2)) + + φ (movingSlotLine o.path o.current).b * (XR : ZMod (value i ^ 2)) ≠ 0 := by + rw [T.squareTests_iff_occurrences value XL XR] + apply forall₂_congr + intro o ho + apply forall₂_congr + intro i hi + let : Fact (value i).Prime := ⟨hprime i⟩ + have hu := T.occurrence_units_of_prime_types tier value hprime hdisjoint hlevels + o ho i (T.occurrence_compensation_level tier hlevels o ho i hi) (hfreq i) + have hv := (T.occurrence_integral value XL XR hI o ho).1 + exact (not_congr (movingSlotLine_square_zero_iff value o.path o.current XL XR hv + (fun s hs => (hu.1 s hs).2.2))).symm + +/-- Full original pairwise support reduces to top coprimality and precisely +these square-line exclusions. The arithmetic and frequency guards are kept. -/ +theorem MovingSlotData.fullPairwise_iff_lines {σ : Type*} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + {n : ℕ} (T : MovingSlotData σ n) (hlevels : T.Levels tier) + (hcoh : T.RegularCoherent) (hc : T.CompensationPrimeData value) + (hf : ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (XL XR : ℕ) (hI : T.Integral value XL XR) + (hcross : T.CrossFrequencyUnits value XL XR) : + T.FullPairwise value XL XR ↔ T.CurrentPairwise value XL XR ∧ + ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, + let φ := MovingSlotReversal.naturalReduction (value i ^ 2) value + φ (movingSlotLine o.path o.current).a * (XL : ZMod (value i ^ 2)) + + φ (movingSlotLine o.path o.current).b * (XR : ZMod (value i ^ 2)) ≠ 0 := by + rw [T.fullPairwise_iff_squareTests value hcoh hc XL XR hI hcross, + T.squareTests_iff_lines tier value hprime hdisjoint hlevels hf XL XR hI] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceUnits.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceUnits.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2efe6cceb2ebdedc212bf64c5d80bdc6f4c8165 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOccurrenceUnits.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleSlots +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotRealization + +namespace OAI + +/-! # Unit coefficients for the actual sampled occurrence paths -/ + +namespace Ostmann +open scoped Classical + +def MovingSlotReversal.Frequencies {σ : Type*} (s : MovingSlotReversal σ) + (P : ℤ → Prop) : Prop := P s.leftFrequency ∧ P s.rightFrequency ∧ P s.rootFrequency + +def MovingSlotData.Frequencies {σ : Type*} (P : ℤ → Prop) : {n : ℕ} → MovingSlotData σ n → Prop + | _, .leaf s _ => P s + | _, .node s _ _ _ left right => P s ∧ left.Frequencies P ∧ right.Frequencies P + +theorem MovingSlotData.Frequencies.root {σ : Type*} {P : ℤ → Prop} {n : ℕ} + {T : MovingSlotData σ n} (h : T.Frequencies P) : P T.frequency := by + cases T with + | leaf => exact h + | node => exact h.1 + +theorem MovingSlotData.occurrence_frequencies {σ : Type*} (P : ℤ → Prop) {n : ℕ} + (T : MovingSlotData σ n) (hT : T.Frequencies P) : + ∀ o ∈ T.occurrences, o.current.Frequencies P ∧ ∀ s ∈ o.path, s.Frequencies P := by + induction T with + | leaf => simp [occurrences] + | @node n s CL CR u left right ihL ihR => + intro o ho + have hb (b : Bool) : (step s CL CR u left right b).Frequencies P := + ⟨hT.2.1.root, hT.2.2.root, hT.1⟩ + rcases List.mem_cons.mp ho with ho | ho + · subst o + exact ⟨hb false, by simp⟩ + · rcases List.mem_append.mp ho with ho | ho + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + have h := ihL hT.2.1 o' ho' + refine ⟨h.1, ?_⟩ + intro t ht + rcases List.mem_append.mp ht with ht | ht + · exact h.2 t ht + · simpa only [List.mem_singleton.mp ht] using hb true + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + have h := ihR hT.2.2 o' ho' + refine ⟨h.1, ?_⟩ + intro t ht + rcases List.mem_append.mp ht with ht | ht + · exact h.2 t ht + · simpa only [List.mem_singleton.mp ht] using hb false + +/-- The current compensation primes can repeat within their equality pattern. +Only their disjointness from the earlier coefficient types is used here. -/ +theorem MovingSlotData.occurrence_units {σ : Type*} {q : ℕ} [Fact q.Prime] + (tier : σ → ℕ) (value : σ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hlevels : T.Levels tier) (hfreq : T.Frequencies (fun s => (s : ZMod q) ≠ 0)) + (o : MovingSlotOccurrence σ) (ho : o ∈ T.occurrences) + (hcop : ∀ i, o.level ≤ tier i → (value i).Coprime q) : + (∀ s ∈ o.path, + MovingSlotReversal.naturalReduction q value s.polynomial.v ≠ 0 ∧ + MovingSlotReversal.naturalReduction q value s.polynomial.w ≠ 0 ∧ + MovingSlotReversal.naturalReduction q value s.polynomial.u ≠ 0) ∧ + MovingSlotReversal.naturalReduction q value o.current.polynomial.v ≠ 0 ∧ + MovingSlotReversal.naturalReduction q value o.current.polynomial.w ≠ 0 := by + have hl := (T.occurrence_bounds tier hlevels o ho).2.2 + have hf := T.occurrence_frequencies _ hfreq o ho + have hc (s : ℤ) (slots : List σ) (hs : (s : ZMod q) ≠ 0) + (hslots : ∀ i ∈ slots, o.level ≤ tier i) : + MovingSlotReversal.naturalReduction q value (movingSlotCoefficient s slots) ≠ 0 := by + simpa only [MovingSlotReversal.naturalReduction] using + movingSlotCoefficient_ne_zero (fun i => (value i : ZMod q)) s slots hs + (fun i hi => ((ZMod.isUnit_iff_coprime _ _).mpr (hcop i (hslots i hi))).ne_zero) + refine ⟨?_, hc _ _ hf.1.1 hl.2.2, hc _ _ hf.1.2.1 hl.2.1⟩ + intro s hs + exact ⟨hc _ _ (hf.2 s hs).1 (hl.1 s hs).2.1, + hc _ _ (hf.2 s hs).2.1 (hl.1 s hs).1, + hc _ _ (hf.2 s hs).2.2 (hl.1 s hs).2.2⟩ + +/-- Disjoint prime types discharge all denominator and nonzero-row conditions +at every occurrence of the selected representative. -/ +theorem MovingSlotData.occurrence_units_of_prime_types {σ : Type*} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + {n : ℕ} (T : MovingSlotData σ n) (hlevels : T.Levels tier) + (o : MovingSlotOccurrence σ) (ho : o ∈ T.occurrences) (rep : σ) + (hrep : tier rep < o.level) + (hfreq : T.Frequencies (fun s => (s : ZMod (value rep)) ≠ 0)) : + (∀ s ∈ o.path, + MovingSlotReversal.naturalReduction (value rep) value s.polynomial.v ≠ 0 ∧ + MovingSlotReversal.naturalReduction (value rep) value s.polynomial.w ≠ 0 ∧ + MovingSlotReversal.naturalReduction (value rep) value s.polynomial.u ≠ 0) ∧ + MovingSlotReversal.naturalReduction (value rep) value o.current.polynomial.v ≠ 0 ∧ + MovingSlotReversal.naturalReduction (value rep) value o.current.polynomial.w ≠ 0 := by + let : Fact (value rep).Prime := ⟨hprime rep⟩ + apply T.occurrence_units tier value hlevels hfreq o ho + intro i hi + exact (Nat.coprime_primes (hprime i) (hprime rep)).mpr + (hdisjoint i rep (by omega)) + +theorem buildMovingSlotData_frequencyUnits {σ : Type*} {q : ℕ} (n : ℕ) + (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) (h : movingGiantFrequencyUnits q n t) : + (buildMovingSlotData n t small bulk samples).Frequencies (fun s => (s : ZMod q) ≠ 0) := by + induction samples with + | leaf => exact h + | @node n samples left right ihL ihR => + exact ⟨h.1, ihL _ _ _ h.2.1, ihR _ _ _ h.2.2⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOneGiant.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOneGiant.lean new file mode 100644 index 0000000000000000000000000000000000000000..91c3dd642c80657e1469256d6e88a82db0c194ac --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOneGiant.lean @@ -0,0 +1,135 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairedTransform +import OAI.NumberTheory.Ostmann.Characters.NormalizedResidueFamily +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSumFactors + +namespace OAI + +/-! # One surviving giant and its actual regular Fourier factors -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance oneGiantSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +def movingOneGiantModuli {I : Type*} (X : ℕ) (p : I → ℕ) : Unit ⊕ I → ℕ := + Sum.elim (fun _ => X) p + +instance movingOneGiantModuli_prime {I : Type*} (X : ℕ) (p : I → ℕ) + [Fact X.Prime] [∀ i, Fact (p i).Prime] (i : Unit ⊕ I) : + Fact (movingOneGiantModuli X p i).Prime := by + cases i <;> dsimp only [movingOneGiantModuli, Sum.elim] <;> infer_instance + +instance movingOneGiantModuli_neZero {I : Type*} (X : ℕ) (p : I → ℕ) + [NeZero X] [∀ i, NeZero (p i)] (i : Unit ⊕ I) : + NeZero (movingOneGiantModuli X p i) := by + cases i <;> dsimp only [movingOneGiantModuli, Sum.elim] <;> infer_instance + +noncomputable def movingOneGiantFactors {I : Type*} (X : ℕ) (p : I → ℕ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + ∀ i, ZMod (movingOneGiantModuli X p i) → ℂ + | .inl _ => fun t => if favorable X then complexUnitPhase (ggiant X t) else 0 + | .inr i => greg (p i) + +theorem movingOneGiantModuli_product {I : Type*} [Fintype I] (X : ℕ) (p : I → ℕ) : + (∏ i, movingOneGiantModuli X p i) = X * ∏ i, p i := by + simp only [movingOneGiantModuli, Fintype.prod_sum_type, Sum.elim_inl, Sum.elim_inr, + Fintype.prod_unique] + +theorem movingOneGiantFactors_giant_norm {I : Type*} (X : ℕ) (p : I → ℕ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (x : ZMod X) : + ‖movingOneGiantFactors X p greg ggiant favorable (.inl ()) x‖ ≤ 1 := by + dsimp only [movingOneGiantFactors] + split_ifs + · exact complexUnitPhase_norm_le _ + · simp only [norm_zero, zero_le_one] + +theorem movingOneGiantFactors_neg {I : Type*} (X : ℕ) (p : I → ℕ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ x, ggiant X (-x) = conj (ggiant X x)) + (hregular : ∀ i x, greg (p i) (-x) = conj (greg (p i) x)) + (i : Unit ⊕ I) (x : ZMod (movingOneGiantModuli X p i)) : + movingOneGiantFactors X p greg ggiant favorable i (-x) = + conj (movingOneGiantFactors X p greg ggiant favorable i x) := by + cases i with + | inl _ => + dsimp only [movingOneGiantFactors] + split_ifs + · exact (congrArg complexUnitPhase (hgiant x)).trans (complexUnitPhase_conj _) + · exact (map_zero _).symm + | inr i => exact hregular i x + +/-- The restored full factor is in the order required by giant transfer. -/ +theorem movingOneGiant_restored {σ : Type*} (value : σ → ℕ) + (n r m : ℕ) (u : TreeLeafIndex n × Fin 4 → σ) + (y : MovingRegularSlot n r m → σ) (P X : ℕ) + (hP : P ≠ 0) (hX : X ≠ 0) (hu : ∀ i, value (u i) ≠ 0) (hy : ∀ i, value (y i) ≠ 0) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (D : ℕ) (s : ℤ) : + let _ : NeZero P := ⟨hP⟩ + let _ : NeZero X := ⟨hX⟩ + let _ : ∀ i, NeZero ((value ∘ u) i) := fun i => ⟨hu i⟩ + let _ : ∀ i, NeZero ((value ∘ y) i) := fun i => ⟨hy i⟩ + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then P else X) + (value ∘ movingRestoreSample n r m u y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable D s = + movingRegularTransform + (Sum.elim (movingOneGiantModuli P (value ∘ u)) (movingOneGiantModuli X (value ∘ y))) + (movingSumFactors (movingOneGiantModuli P (value ∘ u)) + (movingOneGiantModuli X (value ∘ y)) + (movingOneGiantFactors P (value ∘ u) greg ggiant favorable) + (movingOneGiantFactors X (value ∘ y) greg ggiant favorable)) D s := by + dsimp only + rw [movingTaggedTransform_restored value n r m u y P X hP hX hu hy] + unfold movingTaggedTransform movingRegularTransform + apply Finset.prod_congr rfl + intro i _ + rcases i with ((i | i) | (i | i)) <;> rfl + +/-- The original compensation, giant, and surviving priors may be left +abstract while reindexing their common full Fourier factor. -/ +theorem movingOneGiant_restored_average {σ A : Type} [Fintype σ] [Fintype A] + (value : σ → ℕ) (hvalue : ∀ z, value z ≠ 0) (n r m : ℕ) + (P : Finset ℕ) (hP : ∀ p : P, (p : ℕ) ≠ 0) + (X : A → ℕ) (hX : ∀ a, X a ≠ 0) (y : A → MovingRegularSlot n r m → σ) + (v : A → ℤ) (D : ℕ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (wU : (TreeLeafIndex n × Fin 4 → σ) → ℂ) (wP : P → ℂ) + (W : (TreeLeafIndex n × Fin 4 → σ) → P → A → ℂ) : + let _ : ∀ p : P, NeZero (p : ℕ) := fun p => ⟨hP p⟩ + let _ : ∀ a, NeZero (X a) := fun a => ⟨hX a⟩ + let _ : ∀ z, NeZero (value z) := fun z => ⟨hvalue z⟩ + let _ : ∀ (u : TreeLeafIndex n × Fin 4 → σ) i, NeZero ((value ∘ u) i) := fun u i => ⟨hvalue (u i)⟩ + let _ : ∀ a i, NeZero ((value ∘ y a) i) := fun a i => ⟨hvalue (y a i)⟩ + (∑ u : TreeLeafIndex n × Fin 4 → σ, wU u * ∑ p : P, wP p * ∑ a, W u p a * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then (p : ℕ) else X a) + (value ∘ movingRestoreSample n r m u (y a))) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable D (v a)) = + ∑ u : TreeLeafIndex n × Fin 4 → σ, wU u * ∑ p : P, wP p * ∑ a, W u p a * + movingRegularTransform + (Sum.elim (movingOneGiantModuli (p : ℕ) (value ∘ u)) + (movingOneGiantModuli (X a) (value ∘ y a))) + (movingSumFactors (movingOneGiantModuli (p : ℕ) (value ∘ u)) + (movingOneGiantModuli (X a) (value ∘ y a)) + (movingOneGiantFactors (p : ℕ) (value ∘ u) greg ggiant favorable) + (movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable)) D (v a) := by + dsimp only + apply Finset.sum_congr rfl + intro u _ + apply congrArg (fun z : ℂ => wU u * z) + apply Finset.sum_congr rfl + intro p _ + apply congrArg (fun z : ℂ => wP p * z) + apply Finset.sum_congr rfl + intro a _ + exact congrArg (fun z : ℂ => W u p a * z) + (movingOneGiant_restored value n r m u (y a) p (X a) (hP p) (hX a) + (fun i => hvalue (u i)) (fun i => hvalue (y a i)) greg ggiant favorable D (v a)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOneGiantDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOneGiantDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f7e25c30a4e3a867102b210039e9d7771f1d8e9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOneGiantDiagonal.lean @@ -0,0 +1,168 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOneGiant +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalEnergy + +namespace OAI + +/-! # Identifying the single giant on a product/frequency diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance oneGiantDiagonalSum_neZero {J I : Type*} (Q : J → ℕ) (L : I → ℕ) + [∀ j, NeZero (Q j)] [∀ i, NeZero (L i)] (i : J ⊕ I) : + NeZero (Sum.elim Q L i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +/-- A prime in the giant range cannot be exchanged with any of the +regular primes when two complete products agree. -/ +theorem oneGiant_product_eq {J : Type*} [Fintype J] + (X Y : ℕ) (hX : X.Prime) (hY : Y.Prime) + (p q : J → ℕ) (hq : ∀ i, (q i).Prime) + (hsep : ∀ i, X ≠ q i) + (he : X * ∏ i, p i = Y * ∏ i, q i) : + X = Y ∧ (∏ i, p i) = ∏ i, q i := by + have hd : X ∣ Y * ∏ i, q i := he ▸ Nat.dvd_mul_right X (∏ i, p i) + have hXY : X ∣ Y := by + rcases hX.dvd_mul.mp hd with h | h + · exact h + · obtain ⟨i, hi⟩ := prime_dvd_prime_product q hq X hX h + exact (hsep i hi).elim + have h := (Nat.dvd_prime hY).mp hXY + have hEq : X = Y := h.resolve_left hX.ne_one + exact ⟨hEq, Nat.eq_of_mul_eq_mul_left hX.pos (hEq ▸ he)⟩ + +/-- The full one-giant Fourier factor splits with its exact CRT cofactor. +The regular part is expressed only by its prime product. -/ +theorem movingOneGiant_transform_product {J : Type*} [Fintype J] + (X : ℕ) [Fact X.Prime] (p : J → ℕ) [∀ i, Fact (p i).Prime] + (hp : Function.Injective p) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (D : ℕ) (v : ℤ) : + movingRegularTransform (movingOneGiantModuli X p) + (movingOneGiantFactors X p greg ggiant favorable) D v = + (if favorable X then + complexUnitPhase (ggiant X ((v : ZMod X) * ((D * ∏ i, p i : ℕ) : ZMod X)⁻¹)) + else 0) * primeProductTransform greg (D * X) (∏ i, p i) v := by + calc + _ = movingRegularTransform (fun _ : Unit => X) + (fun _ t => if favorable X then complexUnitPhase (ggiant X t) else 0) + (D * ∏ i, p i) v * + movingRegularTransform p (fun j => greg (p j)) (D * ∏ _ : Unit, X) v := by + convert moving_regular_transform_split (fun _ : Unit => X) p + (fun _ t => if favorable X then complexUnitPhase (ggiant X t) else 0) + (fun j => greg (p j)) D v using 1 + congr 1 + funext i + cases i <;> rfl + _ = _ := by + rw [movingRegularTransform_eq_primeProduct p hp] + simp only [movingRegularTransform, tupleCofactor, Finset.univ_unique, + Finset.erase_singleton, Finset.prod_empty, Finset.prod_singleton, mul_one] + +/-- The surviving giant is constant on every supported diagonal fibre. +Its unit phase can therefore be removed after grouping; the regular +prime-product transform and the original grouped coefficient remain. -/ +theorem movingOneGiant_pivot_diagonal_le {A J : Type*} [Fintype A] [Fintype J] + (X : A → ℕ) [∀ a, Fact (X a).Prime] + (p : A → J → ℕ) [∀ a i, Fact (p a i).Prime] + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (D : ℕ) (v : A → ℤ) (W : A → ℂ) + (hinj : ∀ a, W a ≠ 0 → Function.Injective (p a)) + (hv : ∀ a, W a ≠ 0 → v a ≠ 0) + (hvg : ∀ a, W a ≠ 0 → (v a).natAbs < X a) + (hvr : ∀ a, W a ≠ 0 → ∀ i, (v a).natAbs < p a i) + (hsep : ∀ a b, W a ≠ 0 → W b ≠ 0 → ∀ i, X a ≠ p b i) : + (pivotDiagonal (fun a => X a * ∏ i, p a i) v + (fun a => W a * movingRegularTransform (movingOneGiantModuli (X a) (p a)) + (movingOneGiantFactors (X a) (p a) greg ggiant favorable) D (v a))).re ≤ + ∑ k ∈ Finset.univ.image (fun a => (X a, (∏ i, p a i), v a)), + ‖primeProductTransform greg (D * k.1) k.2.1 k.2.2‖ ^ 2 * + ‖groupedCoefficient (fun a => (X a, (∏ i, p a i), v a)) W k‖ ^ 2 := by + let key := fun a => (X a, (∏ i, p a i), v a) + let phase := fun k : ℕ × ℕ × ℤ => + if favorable k.1 then + complexUnitPhase (ggiant k.1 + ((k.2.2 : ZMod k.1) * ((D * k.2.1 : ℕ) : ZMod k.1)⁻¹)) + else 0 + let regular := fun k : ℕ × ℕ × ℤ => primeProductTransform greg (D * k.1) k.2.1 k.2.2 + have hphase (k : ℕ × ℕ × ℤ) : ‖phase k‖ ≤ 1 := by + dsimp only [phase] + split_ifs + · exact complexUnitPhase_norm_le _ + · simp only [norm_zero, zero_le_one] + have hsmall a (ha : W a ≠ 0) q (hq : q.Prime) (hd : q ∣ X a * ∏ i, p a i) : + (v a).natAbs < q := by + rcases hq.dvd_mul.mp hd with hd | hd + · have he := (Nat.dvd_prime (Fact.out : (X a).Prime)).mp hd + rw [he.resolve_left hq.ne_one] + exact hvg a ha + · obtain ⟨i, rfl⟩ := prime_dvd_prime_product (p a) (fun i => Fact.out) q hq hd + exact hvr a ha i + have he : pivotDiagonal (fun a => X a * ∏ i, p a i) v + (fun a => W a * movingRegularTransform (movingOneGiantModuli (X a) (p a)) + (movingOneGiantFactors (X a) (p a) greg ggiant favorable) D (v a)) = + ∑ a, ∑ b, if key a = key b then + (W a * (phase (key a) * regular (key a))) * + conj (W b * (phase (key b) * regular (key b))) else 0 := by + unfold pivotDiagonal + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + by_cases ha : W a = 0 + · simp only [ha, zero_mul, ite_self] + by_cases hb : W b = 0 + · simp only [hb, zero_mul, map_zero, mul_zero, ite_self] + have hz := pivot_zero_numerator_iff (X a * ∏ i, p a i) (X b * ∏ i, p b i) + (Nat.mul_pos (Fact.out : (X a).Prime).pos + (Finset.prod_pos (fun i _ => (Fact.out : (p a i).Prime).pos))) + (v a) (v b) (hv a ha) (hv b hb) (hsmall a ha) (hsmall b hb) + have hk : ((X a * ∏ i, p a i) = X b * ∏ i, p b i) ∧ v a = v b ↔ key a = key b := by + constructor + · rintro ⟨hp, hv⟩ + obtain ⟨hX, hR⟩ := oneGiant_product_eq (X a) (X b) Fact.out Fact.out + (p a) (p b) (fun i => Fact.out) (hsep a b ha hb) hp + exact Prod.ext hX (Prod.ext hR hv) + · intro h + have h' : X a = X b ∧ (∏ i, p a i) = ∏ i, p b i ∧ v a = v b := by + simpa only [key, Prod.mk.injEq] using h + exact ⟨by rw [h'.1, h'.2.1], h'.2.2⟩ + simp only [hz.trans hk] + rw [movingOneGiant_transform_product (X a) (p a) (hinj a ha), + movingOneGiant_transform_product (X b) (p b) (hinj b hb)] + rw [he, finite_diagonal_common_transform key W (fun k => phase k * regular k)] + apply Finset.sum_le_sum + intro k _ + rw [norm_mul, mul_pow] + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + exact mul_le_of_le_one_left (sq_nonneg _) + (pow_le_one₀ (norm_nonneg _) (hphase k)) + +/-- Cauchy on the identified fibre charges exactly its original prior mass. +There is no extra frequency cardinality or bound on each giant factor before +the diagonal has been grouped. -/ +theorem movingOneGiant_weighted_pivot_diagonal_le {A J : Type*} [Fintype A] [Fintype J] + (X : A → ℕ) [∀ a, Fact (X a).Prime] + (p : A → J → ℕ) [∀ a i, Fact (p a i).Prime] + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (D : ℕ) (v : A → ℤ) (μ : A → ℝ) (W : A → ℂ) (θ : ℕ × ℕ × ℤ → ℝ) + (hμ : ∀ a, 0 ≤ μ a) + (hinj : ∀ a, (μ a : ℂ) * W a ≠ 0 → Function.Injective (p a)) + (hv : ∀ a, (μ a : ℂ) * W a ≠ 0 → v a ≠ 0) + (hvg : ∀ a, (μ a : ℂ) * W a ≠ 0 → (v a).natAbs < X a) + (hvr : ∀ a, (μ a : ℂ) * W a ≠ 0 → ∀ i, (v a).natAbs < p a i) + (hsep : ∀ a b, (μ a : ℂ) * W a ≠ 0 → (μ b : ℂ) * W b ≠ 0 → ∀ i, X a ≠ p b i) + (hmass : ∀ k, (∑ a, if (X a, (∏ i, p a i), v a) = k then μ a else 0) ≤ θ k) : + (pivotDiagonal (fun a => X a * ∏ i, p a i) v + (fun a => (μ a : ℂ) * W a * movingRegularTransform (movingOneGiantModuli (X a) (p a)) + (movingOneGiantFactors (X a) (p a) greg ggiant favorable) D (v a))).re ≤ + ∑ a, μ a * θ (X a, (∏ i, p a i), v a) * + ‖W a * primeProductTransform greg (D * X a) (∏ i, p a i) (v a)‖ ^ 2 := by + exact (movingOneGiant_pivot_diagonal_le X p greg ggiant favorable D v + (fun a => (μ a : ℂ) * W a) hinj hv hvg hvr hsep).trans + (finite_grouped_weighted_energy_le (fun a => (X a, (∏ i, p a i), v a)) μ W + (fun k => primeProductTransform greg (D * k.1) k.2.1 k.2.2) θ hμ hmass) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalBulkAction.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalBulkAction.lean new file mode 100644 index 0000000000000000000000000000000000000000..091ad46eb942e180e4df305bc23f823913e8ab91 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalBulkAction.lean @@ -0,0 +1,118 @@ +import OAI.NumberTheory.Ostmann.Construction.SelectedBulkPermutation +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalMatchedCorrelation +import OAI.NumberTheory.Ostmann.Characters.MixedExternalAverage + +namespace OAI + +/-! # The original coefficient and common transform under bulk reassignment -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem MovingSlotReversal.naturalProduct_selected_bulk {B A : Type*} + (value : A → ℕ) (n m : ℕ) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (e : Equiv.Perm (TreeLeafIndex n × Fin m)) (y : B → A) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) : + naturalProduct (value ∘ selectedBulkSample slot e y) + (flattenMovingSlots n small ++ flattenMovingSlots n (bulkSlotLeaves n m slot)) = + naturalProduct (value ∘ y) + (flattenMovingSlots n small ++ flattenMovingSlots n (bulkSlotLeaves n m slot)) := by + have hs : (flattenMovingSlots n small).map (selectedBulkSample slot e y) = + (flattenMovingSlots n small).map y := + List.map_congr_left (fun i hi => selectedBulkSample_nonbulk slot e y i (hsmall i hi)) + have hb : (flattenMovingSlots n (bulkSlotLeaves n m slot)).map (selectedBulkSample slot e y) = + (flattenMovingSlots n (bulkSlotLeaves n m (slot ∘ e.symm))).map y := by + rw [← flattenMovingSlots_map, selectedBulkSample_bulk_leaves, flattenMovingSlots_map] + unfold naturalProduct + simp only [← List.map_map, List.map_append, List.prod_append] + rw [hs, hb] + exact congrArg (_ * ·) (((bulkSlotLeaves_perm_matching n m slot e).map y).map value).prod_eq + +theorem movingExternalDiagonalWeight_selectedBulkSample {B A : Type*} + (value : A → ℕ) (outside : List ℕ) (n m : ℕ) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (e : Equiv.Perm (TreeLeafIndex n × Fin m)) (y : B → A) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (greg : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) (φ : ℝ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (x z : ℝ) : + movingExternalDiagonalWeight value outside small (bulkSlotLeaves n m slot) + greg s φ Jleft Jright diagonal (selectedBulkSample slot e y) x z = + movingExternalDiagonalWeight value outside small (bulkSlotLeaves n m slot) + greg s φ Jleft Jright diagonal y x z := by + unfold movingExternalDiagonalWeight + rw [MovingSlotReversal.naturalProduct_selected_bulk value n m small slot e y hsmall] + +theorem movingExternalDiagonalWeight_positive {B A : Type*} {n : ℕ} + (value : A → ℕ) (outside : List ℕ) (small bulk : TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) + (Jleft Jright : ℝ) (diagonal : Bool) (y : B → A) (x z : ℝ) : + ∃ t : ℝ, 0 ≤ t ∧ + movingExternalDiagonalWeight value outside small bulk greg s φ Jleft Jright diagonal y x z = t := by + have hc (a : ℝ) (J : ℝ) : 0 ≤ positiveLogCutoff φ J a := by + unfold positiveLogCutoff + split_ifs + · exact hφ _ + · exact le_rfl + unfold movingExternalDiagonalWeight giantOuterWeight + let a := positiveLogCutoff φ Jleft (⌊Real.exp x⌋₊ : ℝ) + let b := positiveLogCutoff φ Jright (⌊Real.exp z⌋₊ : ℝ) + let c := if diagonal then Real.exp Jright / (⌊Real.exp z⌋₊ : ℝ) else 1 + refine ⟨a * b * c * ‖primeProductTransform greg + (outside.prod * ⌊Real.exp x⌋₊ * ⌊Real.exp z⌋₊) + (MovingSlotReversal.naturalProduct (value ∘ y) + (flattenMovingSlots n small ++ flattenMovingSlots n bulk)) s‖ ^ 2, ?_, ?_⟩ + · have ha : 0 ≤ a := hc _ _ + have hb : 0 ≤ b := hc _ _ + have hc' : 0 ≤ c := by dsimp [c]; split_ifs <;> positivity + positivity + · dsimp only [a, b, c] + cases diagonal <;> simp only [Bool.false_eq_true, ite_false, ite_true] <;> push_cast <;> rfl + +theorem movingFrequencyCoefficient_bulk_action {σ B : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n m : ℕ) (s : ℤ) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (e : Equiv.Perm (TreeLeafIndex n × Fin m)) (y : B → σ) (XL XR : ℕ) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) : + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n s + (treeLeafMap (List.map (selectedBulkSample slot e y)) n small) + (treeLeafMap (List.map (selectedBulkSample slot e y)) n (bulkSlotLeaves n m slot)) XL XR = + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n s + (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m (slot ∘ e.symm))) XL XR := by + rw [selectedBulkSample_small_leaves n small slot e y hsmall, + selectedBulkSample_bulk_leaves] + +theorem movingOriginalMatchedCorrelation_bulk_action {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : SchwartzMap ℝ ℂ) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (e : Equiv.Perm (TreeLeafIndex n × Fin m)) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : + let F := fun s y x z => movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m slot)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + movingOriginalMatchedCorrelation q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n small (movingPatternBulkLeaves n m slot e) greg + Jleft Jright diagonal u v r w center = + mixedExternalAverage ν (V n) u v r w center (fun s y x z => + (F s y x z * star (F s (selectedBulkSample slot e y) x z)) * + movingExternalDiagonalWeight value outside small (bulkSlotLeaves n m slot) + greg s φ Jleft Jright diagonal y x z) := by + dsimp only + simp only [mixedExternalAverage, movingOriginalMatchedCorrelation, + movingPatternBulkLeaves, Bool.false_eq_true, ite_false, ite_true, + movingFrequencyCoefficient_bulk_action value outside μ childBound pivotBound V + _ φ G n m _ small slot e _ _ _ hsmall] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalDiagonalEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalDiagonalEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..335071cfc7be823495c76d8f722b997a39255fb6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalDiagonalEnergy.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalDiagonalPatterns +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalEnergyPatterns + +namespace OAI + +/-! # The complete original diagonal energy and its pattern expansion -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem frequencyRoot_movingRootedFrequencyTree (V : ℕ → ℕ) (n : ℕ) + (s : ℤ) (a : MovingDescendantFrequencyIndex V n) : + frequencyRoot n (movingRootedFrequencyTree V n s a) = s := by + cases n <;> rfl + +noncomputable def movingOriginalDiagonalEnergy {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small bulk : TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : ℂ := + ∑ s : transferFrequencyRange (V n), ∑ y : B → σ, ((∏ b, ν b (y b) : ℝ) : ℂ) * + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n bulk) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) * + movingExternalDiagonalWeight value outside small bulk greg s.val φ Jleft Jright diagonal y x z)) + +theorem movingOriginalDiagonalEnergy_eq {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small bulk : TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : + movingOriginalDiagonalEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n small bulk greg Jleft Jright diagonal u v r w center = + ∑ s : transferFrequencyRange (V n), ∑ a : MovingDescendantFrequencyIndex V n, + ∑ b : MovingDescendantFrequencyIndex V n, + movingOriginalDiagonalMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n (fun side => if side then movingRootedFrequencyTree V n s.val b + else movingRootedFrequencyTree V n s.val a) + small bulk greg s.val Jleft Jright diagonal u v r w center := by + unfold movingOriginalDiagonalEnergy + apply Finset.sum_congr rfl + intro s _ + have heq (y : B → σ) (x z : ℝ) : + (‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n bulk) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) = + ∑ a : MovingDescendantFrequencyIndex V n, ∑ b : MovingDescendantFrequencyIndex V n, + movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (movingRootedFrequencyTree V n s.val a) + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n bulk) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (movingRootedFrequencyTree V n s.val b) + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n bulk) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊) := by + rw [movingFrequencyCoefficient_original, Complex.star_def, ← Complex.mul_conj'] + simp only [map_sum, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + simp_rw [heq, Finset.sum_mul, complexIntegerInterval_sum, complexPrimeInterval_sum, + Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + rw [Finset.sum_comm] + rfl + +theorem movingOriginalDiagonalMean_zero_frequency {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (side : Bool) (hzero : ¬ ∀ s ∈ allFrequencyList n (t side), s ≠ 0) : + movingOriginalDiagonalMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n t small bulk greg sreg Jleft Jright diagonal u v r w center = 0 := by + have hz := movingOriginalSampleAverage_zero_frequency q value outside μ childBound pivotBound + (fun _ => f) (fun _ _ => hf) g Dq S ψ X lo hi φ G n (t side) + unfold movingOriginalDiagonalMean + cases side <;> + simp_rw [hz _ _ _ _ hzero] <;> + simp only [star_zero, zero_mul, mul_zero, complexPrimeInterval, complexIntegerInterval, + Finset.sum_const_zero, ite_self] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalDiagonalMean.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalDiagonalMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..19fcb4914c4c85bb35423f1b60aa4e8c063da9b3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalDiagonalMean.lean @@ -0,0 +1,113 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleDiagonalExpansion +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPatternMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalProduct +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeRelabel + +namespace OAI + +/-! # Equality patterns of the original mixed diagonal mean -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- The common regular multiplier depends only on the external draws. -/ +noncomputable def movingExternalDiagonalWeight {σ B : Type*} {n : ℕ} + (value : σ → ℕ) (outside : List ℕ) (small bulk : TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (φ : ℝ → ℝ) (Jleft Jright : ℝ) (diagonal : Bool) + (y : B → σ) (x z : ℝ) : ℂ := + let XL := ⌊Real.exp x⌋₊ + let XR := ⌊Real.exp z⌋₊ + (giantOuterWeight φ Jleft Jright diagonal XL XR : ℂ) * + (‖primeProductTransform greg (outside.prod * XL * XR) + (MovingSlotReversal.naturalProduct (value ∘ y) + (flattenMovingSlots n small ++ flattenMovingSlots n bulk)) sreg‖ ^ 2 : ℝ) + +noncomputable def movingOriginalDiagonalKernel {σ I B : Type*} {n : ℕ} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (y : B → σ) (a : MovingSampleSlots σ n × MovingSampleSlots σ n) : ℂ := + let H := fun b XL XR => + let T := buildMovingSlotData n (t b) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n bulk) (if b then a.2 else a.1) + movingSupportedWeight value outside T XL XR + (movingOriginalGiantWeight q value childBound pivotBound (fun _ => f) + (fun _ _ _ _ => 1) g Dq S ψ X lo hi φ G T (t b) XL XR) + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (H false ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (H true ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + movingExternalDiagonalWeight value outside small bulk greg sreg φ Jleft Jright diagonal y x z)) + +/-- Both history averages and the external law are the original ones. -/ +noncomputable def movingOriginalDiagonalMean {σ I B : Type*} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : ℂ := + ∑ y : B → σ, ((∏ b, ν b (y b) : ℝ) : ℂ) * + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t false) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n bulk) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t true) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n bulk) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + movingExternalDiagonalWeight value outside small bulk greg sreg φ Jleft Jright diagonal y x z)) + +theorem movingOriginalDiagonalMean_patterns {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + movingOriginalDiagonalMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n t small bulk greg sreg Jleft Jright diagonal u v r w center = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → σ, + movingOriginalPatternWeight (e s) μ ν value n (fun i => Quotient.mk'' i) + (fun x => movingOriginalDiagonalKernel q value outside childBound pivotBound f g Dq S + ψ X lo hi φ G t small bulk greg sreg Jleft Jright diagonal u v r w center + (fun b => x ((e s).symm (.inl b))) + ((movingSamplePairCoordinates σ n).symm + (fun i => x ((e s).symm (.inr (Quotient.mk'' i)))))) x := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + let H := movingOriginalDiagonalKernel q value outside childBound pivotBound f g Dq S + ψ X lo hi φ G t small bulk greg sreg Jleft Jright diagonal u v r w center + have hpair (y : B → σ) : + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t false) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n bulk) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t true) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n bulk) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + movingExternalDiagonalWeight value outside small bulk greg sreg φ Jleft Jright diagonal y x z)) = + ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ a : {a : Quotient s → σ // Function.Injective a}, + (internalPatternWeight (fun i => Quotient.mk'' i) + (fun i => μ (movingSampleTier i.2)) value a.val : ℂ) * + H y ((movingSamplePairCoordinates σ n).symm (fun i => a.val (Quotient.mk'' i))) := by + simp_rw [movingOriginalSampleAverage_compensated] + exact movingCompensatedAverage_diagonal_patterns μ value n _ _ _ u v r w center + unfold movingOriginalDiagonalMean + simp_rw [hpair] + exact moving_external_pattern_mean μ ν value n H N e + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalDiagonalPatterns.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalDiagonalPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..de0ab52ab40a8f47dc9f5a430217365384fc472c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalDiagonalPatterns.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalDiagonalMean + +namespace OAI + +/-! # The original diagonal mean in the arithmetic pattern coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingPatternRegularSlots_eq_map {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) : + movingPatternRegularSlots e n m small slot = + (flattenMovingSlots n small ++ flattenMovingSlots n (bulkSlotLeaves n m slot)).map + (fun b => e.symm (.inl b)) := by + unfold movingPatternRegularSlots movingPatternFiniteSmall + change _ ++ flattenMovingSlots n + (bulkSlotLeaves n m ((fun b => e.symm (.inl b)) ∘ slot)) = _ + rw [← bulkSlotLeaves_map, flattenMovingSlots_map, flattenMovingSlots_map, List.map_append] + +theorem movingOriginalDiagonalKernel_fin {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (x : Fin (N + 1) → primes) : + movingOriginalDiagonalKernel p (fun q : primes => (q : ℕ)) outside + childBound pivotBound f g Dq Finset.univ ψ X lo hi φ G t small + (bulkSlotLeaves n m slot) greg sreg Jleft Jright diagonal u v a b center + (fun j => x (e.symm (.inl j))) + ((movingSamplePairCoordinates primes n).symm + (fun i => x (e.symm (.inr (pattern i))))) = + movingOriginalPatternDiagonalObservable e t small slot pattern primes hprimes p g Dq + (movingPatternRegularSlots e n m small slot).get (fun _ => true) sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e n m small slot)) greg f outside childBound pivotBound + ψ X lo hi φ G Jleft Jright diagonal u v a b center x := by + have heval (side : Bool) : + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern side).map x = + buildMovingSlotData n (t side) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n small) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n (bulkSlotLeaves n m slot)) + (movingPatternSamples primes n (fun i => x (e.symm (.inr (pattern i)))) side) := by + have hbulk : movingPatternBulkLeaves n m slot (Equiv.refl _) = + fun _ => bulkSlotLeaves n m slot := by + funext b + cases b <;> rfl + rw [movingPatternFinBulkData, hbulk] + exact movingPatternFinData_evaluate e t (fun _ => small) + (fun _ => bulkSlotLeaves n m slot) pattern x side + have hterm (side : Bool) (XL XR : ℕ) : + let T := buildMovingSlotData n (t side) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n small) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n (bulkSlotLeaves n m slot)) + (movingPatternSamples primes n (fun i => x (e.symm (.inr (pattern i)))) side) + movingSupportedWeight (fun q : primes => (q : ℕ)) outside T XL XR + (movingOriginalGiantWeight p (fun q : primes => (q : ℕ)) childBound pivotBound + (fun _ => f) (fun _ _ _ _ => 1) g Dq Finset.univ ψ X lo hi φ G T (t side) XL XR) = + movingSupportedWeight (fun i => (x i : ℕ)) outside + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern side) XL XR + (movingOriginalGiantWeight p (fun i => (x i : ℕ)) childBound pivotBound + (fun _ => f) (fun _ _ _ _ => 1) g Dq Finset.univ ψ X lo hi φ G + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern side) + (t side) XL XR) := by + dsimp only + rw [← heval side, movingOriginalGiantWeight_map, movingSupportedWeight_map] + rfl + have hprod : MovingSlotReversal.naturalProduct (fun i => (x i : ℕ)) + (movingPatternRegularSlots e n m small slot) = + MovingSlotReversal.naturalProduct (fun j => (x (e.symm (.inl j)) : ℕ)) + (flattenMovingSlots n small ++ flattenMovingSlots n (bulkSlotLeaves n m slot)) := by + rw [movingPatternRegularSlots_eq_map, MovingSlotReversal.naturalProduct_map] + rfl + rw [movingOriginalPatternDiagonalObservable_primeProduct] + unfold movingOriginalDiagonalKernel + dsimp only + rw [← movingPatternSamples_pair] + dsimp only + apply congrArg (complexPrimeInterval 1 0 a b) + funext y + apply congrArg (complexIntegerInterval 1 0 u v center) + funext z + simp only [Bool.false_eq_true, ite_false, ite_true] + rw [hterm false, hterm true] + unfold movingExternalDiagonalWeight movingOriginalSupportedOuterPair + dsimp only + rw [hprod] + exact (mul_assoc _ _ _).symm + +theorem movingOriginalDiagonalMean_finite_patterns {B : Type} [Fintype B] + {n m : ℕ} (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + movingOriginalDiagonalMean p (fun q : primes => (q : ℕ)) outside μ ν childBound pivotBound + f g Dq Finset.univ ψ X lo hi φ G n t small (bulkSlotLeaves n m slot) greg sreg + Jleft Jright diagonal u v a b center = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n + (fun i => Quotient.mk'' i) + (movingOriginalPatternDiagonalObservable (e s) t small slot (fun i => Quotient.mk'' i) + primes hprimes p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun _ => true) sreg (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside childBound pivotBound + ψ X lo hi φ G Jleft Jright diagonal u v a b center) x := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + rw [movingOriginalDiagonalMean_patterns p (fun q : primes => (q : ℕ)) outside μ ν] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro x _ + unfold movingOriginalPatternWeight + congr 1 + unfold movingPatternInjectionGuard + split_ifs + · exact movingOriginalDiagonalKernel_fin (e s) t small slot _ primes hprimes p g Dq greg sreg + f outside childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center x + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalEnergyBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalEnergyBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..c71d712a86fa984c830500abaa77fcfa1ea75939 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalEnergyBound.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNormalizedMaskedEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedEnergyPartition +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeMaskedEnergy + +namespace OAI + +/-! # Transferring the arithmetic cell bound to the original discrete energy -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingMaskedTemplateEnergy_original_bound {J : Type} + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (q : J → ℕ) [∀ i, Fact (q i).Prime] + (outside : List ℕ) (μ : ℕ → P → ℝ) (n r m : ℕ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset J) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (Q : MovingRegularSlot n r m → Finset ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (center E : ℝ) + (hcell : ∀ i j : Bool, ‖movingWeightedDiagonalEnergy q Subtype.val outside μ + (movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i))) + childBound pivotBound V f g Dq S ψ X lo hi φ G n + (movingTemplateSmall n (4 + r) m) (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m)) + (fun s => movingTemplateExternalMultiplier P hP n (4 + r) m + (movingRestoredActive n r m) outside greg s φ (G (n + 1)) (G (n + 1)) false) + (if i then G (n + 1) else G (n + 1) - 1) ((if i then G (n + 1) else G (n + 1) - 1) + 1) + (if j then G (n + 1) else G (n + 1) - 1) ((if j then G (n + 1) else G (n + 1) - 1) + 1) + center‖ ≤ E) : + movingMaskedTemplateEnergy P (smoothGiantPrimeRange (G (n + 1))) + (Finset.Ioc ⌊Real.exp (G (n + 1) - 1)⌋₊ ⌊Real.exp (G (n + 1) + 1)⌋₊) + hP outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val q (fun _ => f) g Dq S ψ X lo hi) φ G n r m Q greg (fun _ => 1) ≤ + Real.exp (smoothGiantLogNormalizer (smoothGiantPrimeRange (G (n + 1))) φ (G (n + 1)) + center) * + (4 * E) := by + have hid := movingMaskedTemplateEnergy_original_interval P hP q outside μ n r m + childBound pivotBound V f g Dq S ψ X lo hi φ hout G Q greg center + dsimp only at hid + have hn := congrArg norm hid + simp only [norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_pos (Real.exp_pos _)] at hn + have hc := movingWeightedDiagonalEnergy_full_cell_bound q Subtype.val outside μ + (movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i))) + childBound pivotBound V f g Dq S ψ X lo hi φ G n + (movingTemplateSmall n (4 + r) m) (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m)) + (fun s => movingTemplateExternalMultiplier P hP n (4 + r) m + (movingRestoredActive n r m) outside greg s φ (G (n + 1)) (G (n + 1)) false) + (G (n + 1)) (G (n + 1)) center E hcell + exact (le_abs_self _).trans (hn.trans_le (mul_le_mul_of_nonneg_left hc (Real.exp_nonneg _))) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalEnergyPatterns.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalEnergyPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..7dded38d2e7af6b5792b9ccc7b1d1fd86e1df50d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalEnergyPatterns.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPatternMean + +namespace OAI + +/-! # The actual coefficient energy as a sum over the original equality patterns -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- The original coefficient square is bounded by the absolute pattern means +with both histories' bottom cutoffs retained. There is no extra root-frequency +or ambient-prime cardinality factor. -/ +theorem movingFrequencyCoefficient_original_pattern_bound {σ I B : Type} + [Fintype σ] [Fintype B] + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : {d : ℕ} → MovingSlotData σ d → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small bulk : TreeLeafTuple (List B) n) (u v r w : ℝ) + (hV : Monotone V) (hF : ∀ d (T : MovingSlotData σ d), F T 0 = 0) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → σ, + movingOriginalPatternWeight (e s) μ ν value n (fun i => Quotient.mk'' i) + (movingOriginalPatternPrimeObservable (e s) (fun i => Quotient.mk'' i) q value + outside childBound pivotBound F g Dq S ψ X lo hi φ G + (fun side => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t)) + small bulk u v r w) x + ‖∑ a : transferFrequencyRange (V n), ∑ z : B → σ, ((∏ b, ν b (z b) : ℝ) : ℂ) * + complexPrimeInterval 1 0 r w (fun y => complexPrimeInterval 1 0 u v (fun x => + (‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n a.val + (treeLeafMap (List.map z) n small) (treeLeafMap (List.map z) n bulk) + ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊‖ ^ 2 : ℂ)))‖ ≤ + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ∑ s : Setoid (Bool × MovingSampleIndex n), ‖term t s‖ := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let M := movingOriginalPrimePairMean q value outside μ childBound pivotBound F g Dq S + ψ X lo hi φ G n (fun z : B → σ => ∏ b, ν b (z b)) + (fun z => treeLeafMap (List.map z) n small) + (fun z => treeLeafMap (List.map z) n bulk) u v r w + have hzL (a : ScheduledFrequencyIndex V n) (t : FrequencyTree ℤ n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M (scheduledFrequencyHistory V n a) t = 0 := by + dsimp only [M, movingOriginalPrimePairMean] + simp_rw [movingOriginalSampleAverage_zero_frequency q value outside μ childBound pivotBound + F hF g Dq S ψ X lo hi φ G n _ _ _ _ _ ha, zero_mul] + simp only [complexPrimeInterval, zero_mul, ite_self, Finset.sum_const_zero, mul_zero] + have hzR (t : FrequencyTree ℤ n) (a : ScheduledFrequencyIndex V n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M t (scheduledFrequencyHistory V n a) = 0 := by + dsimp only [M, movingOriginalPrimePairMean] + simp_rw [movingOriginalSampleAverage_zero_frequency q value outside μ childBound pivotBound + F hF g Dq S ψ X lo hi φ G n _ _ _ _ _ ha, star_zero, mul_zero] + simp only [complexPrimeInterval, zero_mul, ite_self, Finset.sum_const_zero, mul_zero] + have hs := same_root_scheduled_pair_sum_le V n + (fun a b => ‖M (scheduledFrequencyHistory V n a) (scheduledFrequencyHistory V n b)‖) + (fun _ _ => norm_nonneg _) + have hh (a : transferFrequencyRange (V n)) (b : MovingDescendantFrequencyIndex V n) : + scheduledFrequencyHistory V n ((scheduledFrequencyRootEquiv V n).symm (a, b)) = + movingRootedFrequencyTree V n a.val b := by + rw [scheduledFrequencyRootEquiv_history, Equiv.apply_symm_apply] + simp_rw [hh] at hs + have he := paired_scheduled_history_sum_le V hV n (fun a b => ‖M a b‖) + (fun _ _ => norm_nonneg _) (fun a t ha => by rw [hzL a t ha, norm_zero]) + (fun t a ha => by rw [hzR t a ha, norm_zero]) + rw [movingFrequencyCoefficient_original_mean_square q value outside μ childBound pivotBound V + F g Dq S ψ X lo hi φ G n (fun z : B → σ => ∏ b, ν b (z b)) + (fun z => treeLeafMap (List.map z) n small) (fun z => treeLeafMap (List.map z) n bulk) u v r w] + apply le_trans _ (hs.trans (he.trans ?_)) + · apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro a _ + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro b _ + exact norm_sum_le _ _ + · apply Finset.sum_le_sum + intro t _ + have hpatterns := movingOriginalPrimePairMean_patterns q value outside μ ν childBound + pivotBound F g Dq S ψ X lo hi φ G n + (fun side => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t)) + small bulk u v r w N e + change M _ _ = _ at hpatterns + split_ifs + · rw [hpatterns] + exact norm_sum_le _ _ + · exact Finset.sum_nonneg (fun _ _ => norm_nonneg _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalEnergyRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalEnergyRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..41d1fdc6621d3ba7793111ad264daa0c37ba4071 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalEnergyRate.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalEnergyPatterns +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticTwoPrimePatternNormRate + +namespace OAI + +/-! # The sharp pattern budget applied to the actual coefficient energy -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +/-- This is the actual external-prior coefficient energy. The local premise +is precisely the original prime-pattern bound, with its retained split +probabilities; it is supplied by the prime arithmetic comparison. -/ +theorem movingFrequencyCoefficient_original_pattern_rate + (ψ : 𝓢(ℝ, ℂ)) (n k : ℕ) (hk : 0 < k) (hn : n ≤ k) + (Bwindow Cfreq Cprior ε : ℝ) (hCfreq : 0 ≤ Cfreq) (hCprior : 1 ≤ Cprior) + (hε : 0 < ε) (hdepth : 8 * (Cprior + 1) ≤ (k : ℝ) ^ 3) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∃ D : ℝ, 0 ≤ D ∧ + (∀ d : ℕ, d ≠ 0 → (d : ℝ) ≤ Real.exp (2 * Cfreq * m) → + (d.divisors.card : ℝ) ≤ D) ∧ + ∀ (σ I B : Type) [Fintype σ] [Fintype B] + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : {d : ℕ} → MovingSlotData σ d → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (P : Finset I) + (X Δ hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small bulk : TreeLeafTuple (List B) n) (u v r w : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s), + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let K := ((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt (Real.exp Δ)) ^ (2 ^ n) * + Bwindow ^ (2 ^ n - 1)) ^ 2 * + ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * 2 ^ (2 ^ n * m) + let err := Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → σ, + movingOriginalPatternWeight (e s) μ ν value n (fun i => Quotient.mk'' i) + (movingOriginalPatternPrimeObservable (e s) (fun i => Quotient.mk'' i) q value + outside childBound pivotBound F g Dq P ψ X (Real.exp Δ) hi φ G + (fun side => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t)) + small bulk u v r w) x + Monotone V → (∀ d (T : MovingSlotData σ d), F T 0 = 0) → + (Sfreq.card : ℝ) ≤ Real.exp (Cfreq * m) → + (V n : ℝ) ≤ Real.exp (Cfreq * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + (∀ s t, ‖term t s‖ ≤ + ((4 : ℝ) ^ Fintype.card (Quotient s) * + (Real.exp (Cprior * L)) ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) * + (err + K * (frequencyLeafWeight (pairedFrequencyLeaf Sfreq (V 0)) n t * + ((frequencySplitList Sfreq n t).map (pairFrequencySupportBound D)).prod))) → + ‖∑ a : transferFrequencyRange (V n), ∑ z : B → σ, ((∏ b, ν b (z b) : ℝ) : ℂ) * + complexPrimeInterval 1 0 r w (fun y => complexPrimeInterval 1 0 u v (fun x => + (‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq P ψ X (Real.exp Δ) hi) φ G n a.val + (treeLeafMap (List.map z) n small) (treeLeafMap (List.map z) n bulk) + ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊‖ ^ 2 : ℂ)))‖ ≤ + Real.exp ((2 ^ n : ℕ) * Δ + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + ε * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + filter_upwards [arithmetic_two_prime_original_pattern_norm_rate ψ n k hk hn + Bwindow Cfreq Cprior ε hCfreq hCprior hε hdepth] with L hrate + dsimp only at hrate ⊢ + obtain ⟨D, hD, hdiv, hrate⟩ := hrate + refine ⟨D, hD, hdiv, ?_⟩ + intro σ I B _ _ q _ value outside μ ν childBound pivotBound V F g Dq P X Δ hi φ G + small bulk u v r w N e + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → σ, + movingOriginalPatternWeight (e s) μ ν value n (fun i => Quotient.mk'' i) + (movingOriginalPatternPrimeObservable (e s) (fun i => Quotient.mk'' i) q value + outside childBound pivotBound F g Dq P ψ X (Real.exp Δ) hi φ G + (fun side => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t)) + small bulk u v r w) x + intro hV hF hcard hVn hV0 hterm + have hS : ∀ s ∈ Sfreq, s ≠ 0 ∧ s.natAbs ≤ V n := by + intro s hs + exact ⟨(Finset.mem_erase.mp hs).1, + (mem_transferFrequencyRange _ _).mp (Finset.mem_erase.mp hs).2⟩ + have hsum := hrate Sfreq (V n) (V 0) Δ + (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcard hS hVn hV0 (by positivity) le_rfl + (fun s t => (‖term t s‖ : ℂ)) (by + intro s t + rw [Complex.norm_real, Real.norm_of_nonneg (norm_nonneg _)] + exact hterm s t) + have hnonneg : 0 ≤ ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ‖term t s‖ := by positivity + simp only [← Complex.ofReal_sum, Complex.norm_real, Real.norm_of_nonneg hnonneg] at hsum + have hactual := movingFrequencyCoefficient_original_pattern_bound q value outside μ ν + childBound pivotBound V F g Dq P ψ X (Real.exp Δ) hi φ G n small bulk u v r w hV hF N e + apply hactual.trans + rw [Finset.sum_comm] + exact hsum + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalGiantComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalGiantComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4db0bf445fdebc4951f0c5067bea35cd679af6c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalGiantComparison.lean @@ -0,0 +1,190 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairedPrimeResidueRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairedMixedResidueRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPairedFactor +import OAI.NumberTheory.Ostmann.Construction.GiantHaarIntegral +import OAI.NumberTheory.Ostmann.Construction.GiantModulusCutoff + +namespace OAI + +/-! # Joint giant idealization for the actual two-history coefficients -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +theorem PublishedProgressionInput.moving_original_paired_prime_comparison + (P : PublishedProgressionInput) {σ I : Type*} (p : I → ℕ) [∀ i, Fact (p i).Prime] + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) + (hf : ∀ b, (T b).Frequencies (· ≠ 0)) (t : Bool → FrequencyTree ℤ n) + (_hT : ∀ b, (T b).Follows (t b)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), + (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q M : ℕ, 2 ≤ Q → ∀ hM0 : 1 ≤ M, M ≤ Q → + (∀ b, movingTopPeriod value hvalue childBound pivotBound (T b) (hf b) ∣ M) → + (∀ b, ∀ i ∈ S, (p i : ℤ) * movingSpectatorDenominator value (T b) ∣ (M : ℤ)) → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + Real.log (M : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + letI : NeZero M := ⟨Nat.ne_of_gt (Nat.zero_lt_one.trans_le hM0)⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingResidueCoefficient p value (F false) (E false) g (Dq false) S + (T false) (nodes false) a b * + conj (movingResidueCoefficient p value (F true) (E true) g (Dq true) S (T true) (nodes true) a b) + (∀ a ∈ reducedResidues M, ∀ b ∈ reducedResidues M, + 2 * ‖c a b‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + ‖complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + movingOriginalGiantWeight p value childBound pivotBound (F false) (E false) g (Dq false) S + ψ X lo hi φ G (T false) (t false) ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + conj (movingOriginalGiantWeight p value childBound pivotBound (F true) (E true) g (Dq true) S + ψ X lo hi φ G (T true) (t true) ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊))) - + ∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q M c x y / ((x : ℂ) * (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_paired_prime_residue_sum_rate (σ := σ) n C d, + eventually_gt_atTop (0 : ℝ)] with L hL hL0 + intro value hvalue childBound pivotBound T hf t hT F E g hg Dq S ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip hout V hV Q M hQ hM0 hMQ hM hMq hlog hMlog + u v r s hu huv hshort hr hrs hrshort + dsimp only + intro hbudget + have : NeZero M := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingResidueCoefficient p value (F false) (E false) g (Dq false) S + (T false) (nodes false) a b * + conj (movingResidueCoefficient p value (F true) (E true) g (Dq true) S (T true) (nodes true) a b) + let H := fun x y => movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + have hfactor := prime_pair_residue_factorization M (by omega) u v r s + (fun z hz _ => giant_interval_gt_modulus L hL0 M (by omega) hMlog u v hu z hz) + (fun z hz _ => giant_interval_gt_modulus L hL0 M (by omega) hMlog r s hr z hz) + (fun x y => movingOriginalGiantWeight p value childBound pivotBound (F false) (E false) g (Dq false) S + ψ X lo hi φ G (T false) (t false) x y * + conj (movingOriginalGiantWeight p value childBound pivotBound (F true) (E true) g (Dq true) S + ψ X lo hi φ G (T true) (t true) x y)) c H (by + intro x _ hx y _ hy a _ b _ hxa hyb + have hx0 : (0 : ℝ) < x := by exact_mod_cast hx.pos + have hy0 : (0 : ℝ) < y := by exact_mod_cast hy.pos + dsimp only [H] + rw [Real.exp_log hx0, Real.exp_log hy0] + exact movingOriginalGiantWeight_paired_factor p value hvalue childBound pivotBound F E g hg Dq S + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout T t hT hf x y a b M hM hMq + (Int.natCast_modEq_iff.mpr hxa) (Int.natCast_modEq_iff.mpr hyb)) + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + V hV Q M hQ hM0 hMQ hlog u v r s hu huv hshort hr hrs hrshort hMlog c hbudget + dsimp only at h + have hbase := measurable_movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + have hmeas : Measurable (Function.uncurry H) := by + have hh := measurable_exp_pair_mul + (movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G) hbase (1 : ℂ) + simpa only [one_mul] using hh + have hnorm (x y : ℝ) : ‖H x y‖ ≤ + ((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) ^ 2 := + movingRealKernelPair_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ _ _ + have hu1 : 1 ≤ u := (Real.one_le_exp (by positivity)).trans hu + have hr1 : 1 ≤ r := (Real.one_le_exp (by positivity)).trans hr + rw [primeGiantMeasure_pair_haar_integral P Q M u v r s hu1 hr1 H hmeas _ hnorm c] at h + rw [hfactor] + exact h + +theorem PublishedProgressionInput.moving_original_paired_mixed_comparison + (P : PublishedProgressionInput) {σ I : Type*} (p : I → ℕ) [∀ i, Fact (p i).Prime] + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) + (hf : ∀ b, (T b).Frequencies (· ≠ 0)) (t : Bool → FrequencyTree ℤ n) + (_hT : ∀ b, (T b).Follows (t b)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), + (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q M : ℕ, 2 ≤ Q → ∀ hM0 : 1 ≤ M, M ≤ Q → + (∀ b, movingTopPeriod value hvalue childBound pivotBound (T b) (hf b) ∣ M) → + (∀ b, ∀ i ∈ S, (p i : ℤ) * movingSpectatorDenominator value (T b) ∣ (M : ℤ)) → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + Real.log (M : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + letI : NeZero M := ⟨Nat.ne_of_gt (Nat.zero_lt_one.trans_le hM0)⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingResidueCoefficient p value (F false) (E false) g (Dq false) S + (T false) (nodes false) a b * + conj (movingResidueCoefficient p value (F true) (E true) g (Dq true) S (T true) (nodes true) a b) + (∀ a ∈ Finset.range M, ∀ b ∈ reducedResidues M, + 2 * ‖c a b‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalGiantWeight p value childBound pivotBound (F false) (E false) g (Dq false) S + ψ X lo hi φ G (T false) (t false) ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + conj (movingOriginalGiantWeight p value childBound pivotBound (F true) (E true) g (Dq true) S + ψ X lo hi φ G (T true) (t true) ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊))) - + ∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * correctedMixedPairAverage P Q M c y / (y : ℂ)‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_paired_mixed_residue_sum_rate (σ := σ) n C d, + eventually_gt_atTop (0 : ℝ)] with L hL hL0 + intro value hvalue childBound pivotBound T hf t hT F E g hg Dq S ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip hout V hV Q M hQ hM0 hMQ hM hMq hlog hMlog + u v r s J hJ huv hshort hvJ hr hrs hrshort + dsimp only + intro hbudget + have : NeZero M := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingResidueCoefficient p value (F false) (E false) g (Dq false) S + (T false) (nodes false) a b * + conj (movingResidueCoefficient p value (F true) (E true) g (Dq true) S (T true) (nodes true) a b) + let H := fun x y => movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + have hfactor := mixed_pair_residue_factorization M (by omega) u v r s J + (fun z hz _ => giant_interval_gt_modulus L hL0 M (by omega) hMlog r s hr z hz) + (fun x y => movingOriginalGiantWeight p value childBound pivotBound (F false) (E false) g (Dq false) S + ψ X lo hi φ G (T false) (t false) x y * + conj (movingOriginalGiantWeight p value childBound pivotBound (F true) (E true) g (Dq true) S + ψ X lo hi φ G (T true) (t true) x y)) c H (by + intro x hx y _ hy a _ b _ hxa hyb + have hx0 : (0 : ℝ) < x := + (Real.exp_pos u).trans (Nat.lt_of_floor_lt (Finset.mem_Ioc.mp hx).1) + have hy0 : (0 : ℝ) < y := by exact_mod_cast hy.pos + dsimp only [H] + rw [Real.exp_log hx0, Real.exp_log hy0] + exact movingOriginalGiantWeight_paired_factor p value hvalue childBound pivotBound F E g hg Dq S + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout T t hT hf x y a b M hM hMq + (Int.natCast_modEq_iff.mpr hxa) (Int.natCast_modEq_iff.mpr hyb)) + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + V hV Q M hQ hM0 hMQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hMlog c hbudget + dsimp only at h + have hbase := measurable_movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + have hmeas : Measurable (Function.uncurry H) := by + have hh := measurable_exp_pair_mul + (movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G) hbase (1 : ℂ) + simpa only [one_mul] using hh + have hnorm (x y : ℝ) : ‖H x y‖ ≤ + ((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) ^ 2 := + movingRealKernelPair_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ _ _ + have hr1 : 1 ≤ r := (Real.one_le_exp (by positivity)).trans hr + rw [mixedGiantMeasure_pair_haar_integral P Q M u v r s J hr1 H hmeas _ hnorm c] at h + rw [hfactor] + exact h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalGiantWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalGiantWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..fceaed061146ff0ca4eb24b60334ac601402ced6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalGiantWeight.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRealKernel + +namespace OAI + +/-! # A name for the literal original recursive giant coefficient -/ + +namespace Ostmann +open scoped BigOperators Classical SchwartzMap + +noncomputable def movingOriginalGiantWeight {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (XL XR : ℕ) : ℂ := + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => (movingWindowLeaf value X lo hi (movingDataLeaf F) x s * + movingFourierLeaf value ψ X x s) * + ∏ i ∈ S, spectatorHistoryLeaf (movingSlotModulus value) (g i) (Dq i) x s) + (movingSlotCutoff value childBound pivotBound + (movingPhiExtra value childBound pivotBound (movingDataExtra E) φ G)) n ⟨n, T, XL, XR⟩ t + +theorem movingOriginalGiantWeight_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hf : T.Frequencies (· ≠ 0)) (XL XR a b M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + movingOriginalGiantWeight q value childBound pivotBound F E g Dq S ψ X lo hi φ G T t XL XR = + movingResidueCoefficient q value F E g Dq S T nodes a b * + movingRealKernel value T nodes ψ X lo hi hlo hhi φ G XL XR := + moving_recursive_real_kernel q value hvalue childBound pivotBound F E g hg Dq S + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout T t hT hf XL XR a b M hM hMq hL hR + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalLeafMultiplier.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalLeafMultiplier.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1703607f50b580b55a0828f8ff5898892bba4ef --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalLeafMultiplier.lean @@ -0,0 +1,31 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalSampleExpansion + +namespace OAI + +/-! # Scalar multipliers in the original terminal coefficient -/ + +namespace Ostmann +open scoped Classical SchwartzMap + +theorem movingOriginalLeaf_mul {σ I : Type*} (value : σ → ℕ) (q : I → ℕ) + [∀ i, Fact (q i).Prime] (w : {n : ℕ} → MovingSlotData σ n → ℂ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (x : MovingSlotState σ) (s : ℤ) : + movingOriginalLeaf value q (fun T s => w T * F T s) g Dq S ψ X lo hi x s = + w x.data * movingOriginalLeaf value q F g Dq S ψ X lo hi x s := by + unfold movingOriginalLeaf movingWindowLeaf movingDataLeaf + split <;> ring + +theorem movingOriginalLeaf_zero {σ I : Type*} (value : σ → ℕ) (q : I → ℕ) + [∀ i, Fact (q i).Prime] (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (hF : ∀ {n} (T : MovingSlotData σ n), F T 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (x : MovingSlotState σ) : + movingOriginalLeaf value q F g Dq S ψ X lo hi x 0 = 0 := by + unfold movingOriginalLeaf movingWindowLeaf movingDataLeaf + split <;> simp only [hF, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalLogCoefficientPair.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalLogCoefficientPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..e25a241b429bc02b3689d16bd67e0543cf30aee8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalLogCoefficientPair.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkPairedLogWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkOriginalCoefficient + +namespace OAI + +/-! # Exact retained-log factors in the original paired Fourier coefficients -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalCoefficientPair_bulk_log {σ I : Type} [Fintype σ] + (value tier : σ → ℕ) (hvalue : ∀ a, 0 < value a) + (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → σ → ℝ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {d : ℕ} → MovingSlotData σ d → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (childBound pivotBound V : ℕ → ℕ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (s : ℤ) (small : TreeLeafTuple (List σ) n) + (bulk : Bool → TreeLeafTuple (List σ) n) + (hn : n ≤ k) (hsmall : ∀ i ∈ flattenMovingSlots n small, tier i ≠ k) + (hbulk : ∀ b i, i ∈ flattenMovingSlots n (bulk b) → tier i = k) + (XL XR : ℕ) : + let coeff := fun b => movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s small (bulk b) XL XR + let weighted := fun b => movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q + (fun T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F T s) + g Dq S ψ X lo hi) φ G n s small (bulk b) XL XR + weighted false * star (weighted true) = + (logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ + (2 ^ n + 2 ^ n) : ℝ) * + ((∏ j, bulkLogCutoffWeight (fun a => (value a : ℝ)) cb + (movingBulkPairedCutoffSlots n bulk j) : ℝ) : ℂ) * + (coeff false * star (coeff true)) := by + dsimp only + rw [movingFrequencyCoefficient_original_bulk_log value tier k outside cb cd μ hμ q F g Dq S + ψ X lo hi childBound pivotBound V φ G n s small (bulk false) hn hsmall (hbulk false) XL XR, + movingFrequencyCoefficient_original_bulk_log value tier k outside cb cd μ hμ q F g Dq S + ψ X lo hi childBound pivotBound V φ G n s small (bulk true) hn hsmall (hbulk true) XL XR, + star_mul] + calc + _ = ((treeLeafProduct (U := ℝ) n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n (bulk false)) : ℂ) * + star (treeLeafProduct (U := ℝ) n (treeLeafMap (movingBulkListLogWeight value outside cb cd) n (bulk true)) : ℂ)) * + (movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s small (bulk false) XL XR * + star (movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s small (bulk true) XL XR)) := by ring + _ = _ := by rw [movingBulkLeafProduct_pair_eq_cutoffs value hvalue outside cb cd n bulk] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalLogGiantWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalLogGiantWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6ffa1863f8fe857d703271b9d9b64ec18e7b688 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalLogGiantWeight.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkOriginalCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkLogTrees + +namespace OAI + +/-! # The actual terminal log factors in the original giant coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- The terminal weights factor from the full original recursion, with its +sharp windows, cutoffs and support retained. -/ +theorem movingOriginalGiantWeight_bulk_log {σ I : Type*} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value tier : σ → ℕ) + (k : ℕ) (outside : List ℕ) (cb cd : ℝ) (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (XL XR : ℕ) : + movingOriginalGiantWeight q value childBound pivotBound + (fun T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F T s) + E g Dq S ψ X lo hi φ G T t XL XR = + (movingBulkTreeLogWeight value tier k outside cb cd T : ℂ) * + movingOriginalGiantWeight q value childBound pivotBound F E g Dq S + ψ X lo hi φ G T t XL XR := by + have hleaf : movingOriginalLeaf value q + (fun T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F T s) + g Dq S ψ X lo hi = + fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * + movingOriginalLeaf value q F g Dq S ψ X lo hi x s := by + funext x s + exact movingOriginalLeaf_bulk_log value tier k outside cb cd q F g Dq S ψ X lo hi x s + change recursiveTransferWeight _ (movingOriginalLeaf value q _ g Dq S ψ X lo hi) _ _ _ _ = _ + rw [hleaf] + exact movingSlotWeight_bulk_log value tier k outside cb cd childBound pivotBound + (movingOriginalLeaf value q F g Dq S ψ X lo hi) _ T XL XR t + +/-- Both original branches retain their own terminal grouping inside the +common prime average; the fixed outside profile is the only scalar extracted. -/ +theorem movingOriginalGiantWeight_pair_bulk_log {σ I : Type*} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value tier : σ → ℕ) + (hvalue : ∀ a, 0 < value a) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) (XL XR : ℕ) : + let slots := Fin.append + (fun j : Fin (bulkLogLeafLists tier k (T false)).length => (bulkLogLeafLists tier k (T false))[j]) + (fun j : Fin (bulkLogLeafLists tier k (T true)).length => (bulkLogLeafLists tier k (T true))[j]) + let W := fun b => movingOriginalGiantWeight q value childBound pivotBound + (fun T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F b T s) + (E b) g (Dq b) S ψ X lo hi φ G (T b) (t b) XL XR + W false * star (W true) = + (logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ + (2 ^ n + 2 ^ n) : ℝ) * + ((∏ j, bulkLogCutoffWeight (fun a => (value a : ℝ)) cb (slots j) : ℝ) : ℂ) * + (movingOriginalGiantWeight q value childBound pivotBound (F false) (E false) g + (Dq false) S ψ X lo hi φ G (T false) (t false) XL XR * + star (movingOriginalGiantWeight q value childBound pivotBound (F true) (E true) g + (Dq true) S ψ X lo hi φ G (T true) (t true) XL XR)) := by + dsimp only + rw [movingOriginalGiantWeight_bulk_log, movingOriginalGiantWeight_bulk_log, star_mul] + calc + _ = ((movingBulkTreeLogWeight value tier k outside cb cd (T false) : ℂ) * + star (movingBulkTreeLogWeight value tier k outside cb cd (T true) : ℂ)) * + (movingOriginalGiantWeight q value childBound pivotBound (F false) (E false) g + (Dq false) S ψ X lo hi φ G (T false) (t false) XL XR * + star (movingOriginalGiantWeight q value childBound pivotBound (F true) (E true) g + (Dq true) S ψ X lo hi φ G (T true) (t true) XL XR)) := by ring + _ = _ := by rw [movingBulkPairLogWeight_eq_cutoff_product value tier hvalue k outside cb cd T] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalMatchedCorrelation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalMatchedCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d509746213dc120f6a76cb8a45ad3e7d8495cee8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalMatchedCorrelation.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalMatchedPatterns +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalDiagonalEnergy + +namespace OAI + +/-! # The full original correlation of two matched bulk assignments -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingOriginalMatchedCorrelation {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : ℂ := + ∑ s : transferFrequencyRange (V n), ∑ y : B → σ, ((∏ b, ν b (y b) : ℝ) : ℂ) * + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk false)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk true)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + movingExternalDiagonalWeight value outside small (bulk false) greg s.val φ Jleft Jright diagonal y x z)) + +theorem movingOriginalMatchedCorrelation_eq {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : + movingOriginalMatchedCorrelation q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n small bulk greg Jleft Jright diagonal u v r w center = + ∑ s : transferFrequencyRange (V n), ∑ a : MovingDescendantFrequencyIndex V n, + ∑ b : MovingDescendantFrequencyIndex V n, + movingOriginalMatchedMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n (fun side => if side then movingRootedFrequencyTree V n s.val b + else movingRootedFrequencyTree V n s.val a) + small bulk greg s.val Jleft Jright diagonal u v r w center := by + unfold movingOriginalMatchedCorrelation + apply Finset.sum_congr rfl + intro s _ + have heq (y : B → σ) (x z : ℝ) : + (movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk false)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk true)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) = + ∑ a : MovingDescendantFrequencyIndex V n, ∑ b : MovingDescendantFrequencyIndex V n, + movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (movingRootedFrequencyTree V n s.val a) + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk false)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (movingRootedFrequencyTree V n s.val b) + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk true)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊) := by + simp only [movingFrequencyCoefficient_original, star_sum, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + simp_rw [heq, Finset.sum_mul, complexIntegerInterval_sum, complexPrimeInterval_sum, + Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + rw [Finset.sum_comm] + rfl + +theorem movingOriginalMatchedMean_zero_frequency {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (side : Bool) (hzero : ¬ ∀ s ∈ allFrequencyList n (t side), s ≠ 0) : + movingOriginalMatchedMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n t small bulk greg sreg Jleft Jright diagonal u v r w center = 0 := by + have hz := movingOriginalSampleAverage_zero_frequency q value outside μ childBound pivotBound + (fun _ => f) (fun _ _ => hf) g Dq S ψ X lo hi φ G n (t side) + unfold movingOriginalMatchedMean + cases side <;> + simp_rw [hz _ _ _ _ hzero] <;> + simp only [star_zero, zero_mul, mul_zero, complexPrimeInterval, complexIntegerInterval, + Finset.sum_const_zero, ite_self] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalMatchedMean.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalMatchedMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d40dbe9b8422c51cc1ee879c0777a42d0ff1863 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalMatchedMean.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalDiagonalMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMatchedProduct + +namespace OAI + +/-! # The original matched-history mean and its exact equality patterns -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingOriginalMatchedKernel {σ I B : Type*} {n : ℕ} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (y : B → σ) (a : MovingSampleSlots σ n × MovingSampleSlots σ n) : ℂ := + let H := fun b XL XR => + let T := buildMovingSlotData n (t b) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulk b)) (if b then a.2 else a.1) + movingSupportedWeight value outside T XL XR + (movingOriginalGiantWeight q value childBound pivotBound (fun _ => f) + (fun _ _ _ _ => 1) g Dq S ψ X lo hi φ G T (t b) XL XR) + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (H false ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (H true ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + movingExternalDiagonalWeight value outside small (bulk false) greg sreg φ Jleft Jright diagonal y x z)) + +/-- Both history averages and the external law are the original ones. -/ +noncomputable def movingOriginalMatchedMean {σ I B : Type*} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : ℂ := + ∑ y : B → σ, ((∏ b, ν b (y b) : ℝ) : ℂ) * + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t false) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulk false)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t true) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulk true)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + movingExternalDiagonalWeight value outside small (bulk false) greg sreg φ Jleft Jright diagonal y x z)) + +theorem movingOriginalMatchedMean_patterns {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + movingOriginalMatchedMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n t small bulk greg sreg Jleft Jright diagonal u v r w center = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → σ, + movingOriginalPatternWeight (e s) μ ν value n (fun i => Quotient.mk'' i) + (fun x => movingOriginalMatchedKernel q value outside childBound pivotBound f g Dq S + ψ X lo hi φ G t small bulk greg sreg Jleft Jright diagonal u v r w center + (fun b => x ((e s).symm (.inl b))) + ((movingSamplePairCoordinates σ n).symm + (fun i => x ((e s).symm (.inr (Quotient.mk'' i)))))) x := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + let H := movingOriginalMatchedKernel q value outside childBound pivotBound f g Dq S + ψ X lo hi φ G t small bulk greg sreg Jleft Jright diagonal u v r w center + have hpair (y : B → σ) : + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t false) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulk false)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t true) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulk true)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + movingExternalDiagonalWeight value outside small (bulk false) greg sreg φ Jleft Jright diagonal y x z)) = + ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ a : {a : Quotient s → σ // Function.Injective a}, + (internalPatternWeight (fun i => Quotient.mk'' i) + (fun i => μ (movingSampleTier i.2)) value a.val : ℂ) * + H y ((movingSamplePairCoordinates σ n).symm (fun i => a.val (Quotient.mk'' i))) := by + simp_rw [movingOriginalSampleAverage_compensated] + exact movingCompensatedAverage_diagonal_patterns μ value n _ _ _ u v r w center + unfold movingOriginalMatchedMean + simp_rw [hpair] + exact moving_external_pattern_mean μ ν value n H N e + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalMatchedPatterns.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalMatchedPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..24d73d9ec146793ccb2e5e4da27d86551567f3a1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalMatchedPatterns.lean @@ -0,0 +1,127 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalMatchedMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalDiagonalPatterns + +namespace OAI + +/-! # Matched sampled histories in their original arithmetic pattern coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalMatchedKernel_fin {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (x : Fin (N + 1) → primes) : + movingOriginalMatchedKernel p (fun q : primes => (q : ℕ)) outside + childBound pivotBound f g Dq Finset.univ ψ X lo hi φ G t small + (movingPatternBulkLeaves n m slot perm) greg sreg Jleft Jright diagonal u v a b center + (fun j => x (e.symm (.inl j))) + ((movingSamplePairCoordinates primes n).symm + (fun i => x (e.symm (.inr (pattern i))))) = + movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes p g Dq + (movingPatternRegularSlots e n m small slot).get (fun _ => true) sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e n m small slot)) greg f outside childBound pivotBound + ψ X lo hi φ G Jleft Jright diagonal u v a b center x := by + have heval (side : Bool) : + (movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern side).map x = + buildMovingSlotData n (t side) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n small) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n + (movingPatternBulkLeaves n m slot perm side)) + (movingPatternSamples primes n (fun i => x (e.symm (.inr (pattern i)))) side) := by + exact movingPatternFinData_evaluate e t (fun _ => small) + (movingPatternBulkLeaves n m slot perm) pattern x side + have hterm (side : Bool) (XL XR : ℕ) : + let T := buildMovingSlotData n (t side) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n small) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n + (movingPatternBulkLeaves n m slot perm side)) + (movingPatternSamples primes n (fun i => x (e.symm (.inr (pattern i)))) side) + movingSupportedWeight (fun q : primes => (q : ℕ)) outside T XL XR + (movingOriginalGiantWeight p (fun q : primes => (q : ℕ)) childBound pivotBound + (fun _ => f) (fun _ _ _ _ => 1) g Dq Finset.univ ψ X lo hi φ G T (t side) XL XR) = + movingSupportedWeight (fun i => (x i : ℕ)) outside + (movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern side) XL XR + (movingOriginalGiantWeight p (fun i => (x i : ℕ)) childBound pivotBound + (fun _ => f) (fun _ _ _ _ => 1) g Dq Finset.univ ψ X lo hi φ G + (movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern side) + (t side) XL XR) := by + dsimp only + rw [← heval side, movingOriginalGiantWeight_map, movingSupportedWeight_map] + rfl + have hprod : MovingSlotReversal.naturalProduct (fun i => (x i : ℕ)) + (movingPatternRegularSlots e n m small slot) = + MovingSlotReversal.naturalProduct (fun j => (x (e.symm (.inl j)) : ℕ)) + (flattenMovingSlots n small ++ flattenMovingSlots n (bulkSlotLeaves n m slot)) := by + rw [movingPatternRegularSlots_eq_map, MovingSlotReversal.naturalProduct_map] + rfl + rw [movingOriginalPatternMatchedObservable_primeProduct] + unfold movingOriginalMatchedKernel + dsimp only + rw [← movingPatternSamples_pair] + dsimp only + apply congrArg (complexPrimeInterval 1 0 a b) + funext y + apply congrArg (complexIntegerInterval 1 0 u v center) + funext z + simp only [Bool.false_eq_true, ite_false, ite_true] + rw [hterm false, hterm true] + unfold movingExternalDiagonalWeight movingOriginalSupportedOuterPair + dsimp only + rw [hprod] + exact (mul_assoc _ _ _).symm + +theorem movingOriginalMatchedMean_finite_patterns {B : Type} [Fintype B] + {n m : ℕ} (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + movingOriginalMatchedMean p (fun q : primes => (q : ℕ)) outside μ ν childBound pivotBound + f g Dq Finset.univ ψ X lo hi φ G n t small (movingPatternBulkLeaves n m slot perm) greg sreg + Jleft Jright diagonal u v a b center = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n + (fun i => Quotient.mk'' i) + (movingOriginalPatternMatchedObservable (e s) t small slot perm (fun i => Quotient.mk'' i) + primes hprimes p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun _ => true) sreg (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside childBound pivotBound + ψ X lo hi φ G Jleft Jright diagonal u v a b center) x := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + rw [movingOriginalMatchedMean_patterns p (fun q : primes => (q : ℕ)) outside μ ν] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro x _ + unfold movingOriginalPatternWeight + congr 1 + unfold movingPatternInjectionGuard + split_ifs + · exact movingOriginalMatchedKernel_fin (e s) t small slot perm _ primes hprimes p g Dq greg sreg + f outside childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center x + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPair.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cd45830c41cb14bcec32f97afe8658c07ede81d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPair.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalGiantWeight +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePairResidues + +namespace OAI + +/-! # Exact residue decomposition of the original recursive averages -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem moving_original_prime_pair_residues {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hf : T.Frequencies (· ≠ 0)) (M : ℕ) (hM0 : 0 < M) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (u v r s : ℝ) + (hu : ∀ p ∈ Finset.Ioc ⌊Real.exp u⌋₊ ⌊Real.exp v⌋₊, p.Prime → M < p) + (hr : ∀ p ∈ Finset.Ioc ⌊Real.exp r⌋₊ ⌊Real.exp s⌋₊, p.Prime → M < p) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + movingOriginalGiantWeight q value childBound pivotBound F E g Dq S ψ X lo hi φ G T t + ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊)) = + ∑ b ∈ reducedResidues M, ∑ a ∈ reducedResidues M, + complexPrimeInterval M b r s (fun y => complexPrimeInterval M a u v (fun x => + movingResidueCoefficient q value F E g Dq S T nodes a b * + movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) := by + dsimp only + apply prime_pair_residue_factorization M hM0 u v r s hu hr + intro p hp hpp z hz hzp a ha b hb hpa hzb + have hp0 : (0 : ℝ) < p := by exact_mod_cast hpp.pos + have hz0 : (0 : ℝ) < z := by exact_mod_cast hzp.pos + rw [Real.exp_log hp0, Real.exp_log hz0] + exact movingOriginalGiantWeight_factor q value hvalue childBound pivotBound F E g hg Dq S + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout T t hT hf p z a b M hM hMq + (Int.natCast_modEq_iff.mpr hpa) (Int.natCast_modEq_iff.mpr hzb) + +theorem moving_original_mixed_pair_residues {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hf : T.Frequencies (· ≠ 0)) (M : ℕ) (hM0 : 0 < M) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (u v r s J : ℝ) + (hr : ∀ p ∈ Finset.Ioc ⌊Real.exp r⌋₊ ⌊Real.exp s⌋₊, p.Prime → M < p) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalGiantWeight q value childBound pivotBound F E g Dq S ψ X lo hi φ G T t + ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊)) = + ∑ b ∈ reducedResidues M, ∑ a ∈ Finset.range M, + complexPrimeInterval M b r s (fun y => complexIntegerInterval M a u v J (fun x => + movingResidueCoefficient q value F E g Dq S T nodes a b * + movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) := by + dsimp only + apply mixed_pair_residue_factorization M hM0 u v r s J hr + intro p hp z hz hzp a ha b hb hpa hzb + have hp0 : (0 : ℝ) < p := + (Real.exp_pos u).trans (Nat.lt_of_floor_lt (Finset.mem_Ioc.mp hp).1) + have hz0 : (0 : ℝ) < z := by exact_mod_cast hzp.pos + rw [Real.exp_log hp0, Real.exp_log hz0] + exact movingOriginalGiantWeight_factor q value hvalue childBound pivotBound F E g hg Dq S + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout T t hT hf p z a b M hM hMq + (Int.natCast_modEq_iff.mpr hpa) (Int.natCast_modEq_iff.mpr hzb) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPairedFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPairedFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4676aa913df226c9b75ed82ba52b0ec860d2382 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPairedFactor.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalGiantWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPair + +namespace OAI + +/-! # The original product of histories has the paired real kernel -/ + +namespace Ostmann +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +theorem movingOriginalGiantWeight_paired_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (hT : ∀ b, (T b).Follows (t b)) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (XL XR a b M : ℕ) + (hM : ∀ b, movingTopPeriod value hvalue childBound pivotBound (T b) (hf b) ∣ M) + (hMq : ∀ b, ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value (T b) ∣ (M : ℤ)) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + movingOriginalGiantWeight q value childBound pivotBound (F false) (E false) g (Dq false) S + ψ X lo hi φ G (T false) (t false) XL XR * + conj (movingOriginalGiantWeight q value childBound pivotBound (F true) (E true) g (Dq true) S + ψ X lo hi φ G (T true) (t true) XL XR) = + (movingResidueCoefficient q value (F false) (E false) g (Dq false) S (T false) (nodes false) a b * + conj (movingResidueCoefficient q value (F true) (E true) g (Dq true) S (T true) (nodes true) a b)) * + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G XL XR := by + dsimp only + rw [movingOriginalGiantWeight_factor q value hvalue childBound pivotBound (F false) (E false) g hg + (Dq false) S ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout (T false) (t false) (hT false) + (hf false) XL XR a b M (hM false) (hMq false) hL hR, + movingOriginalGiantWeight_factor q value hvalue childBound pivotBound (F true) (E true) g hg + (Dq true) S ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout (T true) (t true) (hT true) + (hf true) XL XR a b M (hM true) (hMq true) hL hR, + map_mul, movingRealKernelPair] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPatternMean.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPatternMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..4028d890c3986dc41fef433fa2e59b10446cec75 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPatternMean.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeSquareBudget +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPatternSum +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternArithmeticComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleMap + +namespace OAI + +/-! # Exact equality patterns under the original external prime law -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- The fixed-sample prime integral before choosing any equality pattern. -/ +noncomputable def movingOriginalPairPrimeKernel {σ I B : Type} {n : ℕ} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) + (F : {d : ℕ} → MovingSlotData σ d → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (u v r w : ℝ) (y : B → σ) (a : MovingSampleSlots σ n × MovingSampleSlots σ n) : ℂ := + let H := fun b XL XR => + let T := buildMovingSlotData n (t b) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n bulk) (if b then a.2 else a.1) + movingSupportedWeight value outside T XL XR + (movingOriginalGiantWeight q value childBound pivotBound F (fun _ _ _ _ => 1) + g Dq S ψ X lo hi φ G T (t b) XL XR) + complexPrimeInterval 1 0 r w (fun y => complexPrimeInterval 1 0 u v (fun x => + H false ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * star (H true ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊))) + +/-- The same actual prime integral in the full finite pattern coordinates. -/ +noncomputable def movingOriginalPatternPrimeObservable {σ I B C : Type} + {N n : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (pattern : Bool × MovingSampleIndex n → C) + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) + (F : {d : ℕ} → MovingSlotData σ d → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (u v r w : ℝ) (x : Fin (N + 1) → σ) : ℂ := + movingOriginalPairPrimeKernel q value outside childBound pivotBound F g Dq S + ψ X lo hi φ G t small bulk u v r w (fun b => x (e.symm (.inl b))) + ((movingSamplePairCoordinates σ n).symm (fun i => x (e.symm (.inr (pattern i))))) + +/-- Finite reindexing is proved independently of the large prime integrand. -/ +theorem moving_external_pattern_mean {σ B : Type} [Fintype σ] [Fintype B] + (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) (value : σ → ℕ) (n : ℕ) + (H : (B → σ) → (MovingSampleSlots σ n × MovingSampleSlots σ n) → ℂ) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + ∀ (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s), + (∑ y : B → σ, ((∏ b, ν b (y b) : ℝ) : ℂ) * + ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ z : {z : Quotient s → σ // Function.Injective z}, + (internalPatternWeight (fun i => Quotient.mk'' i) + (fun i => μ (movingSampleTier i.2)) value z.val : ℂ) * + H y ((movingSamplePairCoordinates σ n).symm (fun i => z.val (Quotient.mk'' i)))) = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → σ, + movingOriginalPatternWeight (e s) μ ν value n (fun i => Quotient.mk'' i) + (fun x => H (fun b => x ((e s).symm (.inl b))) + ((movingSamplePairCoordinates σ n).symm + (fun i => x ((e s).symm (.inr (Quotient.mk'' i)))))) x := by + dsimp only + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + intro N e + simp only [Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro s _ + let obs := fun x : Fin (N s + 1) → σ => H (fun b => x ((e s).symm (.inl b))) + ((movingSamplePairCoordinates σ n).symm (fun i => x ((e s).symm (.inr (Quotient.mk'' i))))) + have heq := movingOriginalPattern_sum_fin (e s) μ ν value n (fun i => Quotient.mk'' i) obs + dsimp only [obs] at heq + simp only [finite_univ_canonical] at heq ⊢ + unfold movingOriginalPatternWeight + simp only [finite_univ_canonical] at heq ⊢ + refine Eq.trans ?_ heq + apply Finset.sum_congr rfl + intro y _ + apply Finset.sum_congr rfl + intro z _ + simp only [Equiv.apply_symm_apply, Sum.elim_inl, Sum.elim_inr, mul_assoc] + +/-- Exact passage from the original two-history mean to the full coordinate +sum used by the arithmetic comparison. No independence of repeated internal +samples, deleted prime law, or new normalization is introduced. -/ +theorem movingOriginalPrimePairMean_patterns {σ I B : Type} + [Fintype σ] [Fintype B] + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (u v r w : ℝ) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + ∀ (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s), + movingOriginalPrimePairMean q value outside μ childBound pivotBound F g Dq S ψ X lo hi + φ G n (fun y : B → σ => ∏ b, ν b (y b)) + (fun y => treeLeafMap (List.map y) n small) + (fun y => treeLeafMap (List.map y) n bulk) u v r w (t false) (t true) = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → σ, + movingOriginalPatternWeight (e s) μ ν value n (fun i => Quotient.mk'' i) + (movingOriginalPatternPrimeObservable (e s) (fun i => Quotient.mk'' i) + q value outside childBound pivotBound F g Dq S ψ X lo hi φ G t small bulk u v r w) x := by + dsimp only + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + intro N e + let H := movingOriginalPairPrimeKernel q value outside childBound pivotBound F g Dq S + ψ X lo hi φ G t small bulk u v r w + have hpair (y : B → σ) := movingOriginal_prime_pair_patterns q value outside μ + childBound pivotBound (fun _ => F) g (fun _ => Dq) S ψ X lo hi φ G n t + (fun _ => treeLeafMap (List.map y) n small) + (fun _ => treeLeafMap (List.map y) n bulk) u v r w + dsimp only at hpair + have hexp : movingOriginalPrimePairMean q value outside μ childBound pivotBound F g Dq S + ψ X lo hi φ G n (fun y : B → σ => ∏ b, ν b (y b)) + (fun y => treeLeafMap (List.map y) n small) + (fun y => treeLeafMap (List.map y) n bulk) u v r w (t false) (t true) = + ∑ y : B → σ, ((∏ b, ν b (y b) : ℝ) : ℂ) * + ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ z : {z : Quotient s → σ // Function.Injective z}, + (internalPatternWeight (fun i => Quotient.mk'' i) + (fun i => μ (movingSampleTier i.2)) value z.val : ℂ) * + H y ((movingSamplePairCoordinates σ n).symm (fun i => z.val (Quotient.mk'' i))) := by + unfold movingOriginalPrimePairMean + apply Finset.sum_congr rfl + intro y _ + congr 1 + exact hpair y + rw [hexp] + exact moving_external_pattern_mean μ ν value n H N e + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPatternSum.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPatternSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe133e73dcd2f2bca9507c6c9da2e0bd016f5738 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPatternSum.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSumCoordinates + +namespace OAI + +/-! # Original pattern weights and their exact zero extension -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingPatternInjectionGuard {A B C : Type*} {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (G : (Fin (N + 1) → A) → ℂ) + (x : Fin (N + 1) → A) : ℂ := + if Function.Injective (fun c => x (e.symm (.inr c))) then G x else 0 + +theorem movingPatternInjectionGuard_norm {A B C : Type*} {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (G : (Fin (N + 1) → A) → ℂ) + (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) (x : Fin (N + 1) → A) : + ‖movingPatternInjectionGuard e G x‖ ≤ D := by + unfold movingPatternInjectionGuard + split_ifs + · exact hG x + · simpa only [norm_zero] using hD + +theorem movingPatternInjectionGuard_nonzero {A B C : Type*} {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (G : (Fin (N + 1) → A) → ℂ) + (x : Fin (N + 1) → A) (hx : movingPatternInjectionGuard e G x ≠ 0) : + Function.Injective (fun c => x (e.symm (.inr c))) ∧ G x ≠ 0 := by + unfold movingPatternInjectionGuard at hx + split_ifs at hx with h + · exact ⟨h, hx⟩ + · exact False.elim (hx rfl) + +/-- The original dependent pattern coefficient with independent external +priors is exactly the full finite-coordinate sum with this support mask. -/ +theorem movingOriginalPattern_sum_fin {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (n : ℕ) (pattern : Bool × MovingSampleIndex n → C) + (G : (Fin (N + 1) → A) → ℂ) : + (∑ y : B → A, ∑ z : {z : C → A // Function.Injective z}, + ((∏ b, ν b (y b) : ℝ) : ℂ) * + (internalPatternWeight pattern (fun i => μ (movingSampleTier i.2)) prime z.val : ℂ) * + G (fun i => Sum.elim y z.val (e i))) = + ∑ x : Fin (N + 1) → A, ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * movingPatternInjectionGuard e G x := by + rw [sum_external_injective_pattern_fin e (fun y z => + ((∏ b, ν b (y b) : ℝ) : ℂ) * + (internalPatternWeight pattern (fun i => μ (movingSampleTier i.2)) prime z : ℂ) * + G (fun i => Sum.elim y z (e i)))] + apply Finset.sum_congr rfl + intro x _ + have heval : (fun i => Sum.elim (fun b => x (e.symm (.inl b))) + (fun c => x (e.symm (.inr c))) (e i)) = x := by + have h (j : B ⊕ C) : Sum.elim (fun b => x (e.symm (.inl b))) + (fun c => x (e.symm (.inr c))) j = x (e.symm j) := by cases j <;> rfl + funext i + rw [h, Equiv.symm_apply_apply] + rw [heval] + have hp := movingPairCompensatedMass_pattern μ prime n pattern + (fun c => x (e.symm (.inr c))) + simp only [Function.comp_def] at hp + rw [hp] + unfold movingPatternInjectionGuard + split_ifs <;> simp only [mul_zero] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPhaseStatistic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPhaseStatistic.lean new file mode 100644 index 0000000000000000000000000000000000000000..afe950a0cfc22b316485a479dd952777e2c7143d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPhaseStatistic.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantPhase +import OAI.NumberTheory.Ostmann.Characters.MixedBoundedPhaseStatistic + +namespace OAI + +/-! # The original statistic with both giant Fourier phases retained -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingOriginalPhaseStatistic {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : ℂ := + let F := fun s y x z => movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m slot)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + mixedExternalAverage ν (V n) u v r w center (fun s y x z => + ((movingGiantPhase value outside small (bulkSlotLeaves n m slot) + ggiant favorable s y x z * movingExternalRegularFactor value outside small (bulkSlotLeaves n m slot) + greg s y x z) * F s y x z) * + giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊) + +theorem movingOriginalPhaseStatistic_cauchy {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (hν : ∀ b a, 0 ≤ ν b a) (hidentical : ∀ j k, ν (slot j) = ν (slot k)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : + ‖movingOriginalPhaseStatistic q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg ggiant favorable Jleft Jright diagonal u v r w center‖ ^ 2 ≤ + (mixedExternalAverage ν (V n) u v r w center (fun _ _ x z => + giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)).re * + (movingOriginalSymmetrizedEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg Jleft Jright diagonal u v r w center).re := by + let F := fun s y x z => movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m slot)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + let H := movingExternalRegularFactor value outside small (bulkSlotLeaves n m slot) greg + let P := movingGiantPhase value outside small (bulkSlotLeaves n m slot) ggiant favorable + let W := fun (x z : ℝ) => giantOuterWeight φ Jleft Jright diagonal + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + have hW (x z : ℝ) : 0 ≤ (W x z).re ∧ ((W x z).re : ℂ) = W x z := by + obtain ⟨a, ha, heq⟩ := giantOuterWeight_positive φ hφ Jleft Jright diagonal + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + change W x z = (a : ℂ) at heq + rw [heq] + simpa only [Complex.ofReal_re] using And.intro ha (Eq.refl (a : ℂ)) + have hH (e s y x z) : H s (selectedBulkSample slot e y) x z = H s y x z := by + dsimp [H, movingExternalRegularFactor] + rw [MovingSlotReversal.naturalProduct_selected_bulk value n m small slot e y hsmall] + have hP (e s y x z) : P s (selectedBulkSample slot e y) x z = P s y x z := by + exact movingGiantPhase_selectedBulkSample value outside n m small slot e y hsmall + ggiant favorable s x z + have hPnorm (s y x z) : ‖P s y x z‖ ≤ 1 := + movingGiantPhase_norm_le value outside small (bulkSlotLeaves n m slot) ggiant favorable s y x z + have hc := mixedBulkSymmetrize_bounded_statistic_cauchy n m slot ν hν hidentical (V n) + u v r w center F H P hH hP hPnorm (fun x z => (W x z).re) (fun x z => (hW x z).1) + simp only [(hW _ _).2] at hc + exact hc + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPhaseStatisticBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPhaseStatisticBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..66f6bb9c5323048e95e16d5f3cdbd3757ecceb8b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPhaseStatisticBound.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPhaseStatistic +import OAI.NumberTheory.Ostmann.Characters.MixedExternalMass +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalOuterWeight + +namespace OAI + +/-! # A finite upper bound for the original symmetrized statistic -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalPhaseStatistic_upper {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) + (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφnorm : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (hν : ∀ b a, 0 ≤ ν b a) (hmass : ∀ b, ∑ a, ν b a = 1) (hidentical : ∀ j k, ν (slot j) = ν (slot k)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (hshort : w ≤ r + 1) (hvcenter : v ≤ center + 1) (E : ℝ) (hE : 0 ≤ E) + (henergy : (movingOriginalSymmetrizedEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg Jleft Jright diagonal u v r w center).re ≤ E) : + ‖movingOriginalPhaseStatistic q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg ggiant favorable Jleft Jright diagonal u v r w center‖ ^ 2 ≤ + diagonalOuterMajorant Bφ Dφ diagonal * (2 * V n + 1 : ℕ) * Real.exp 2 * E := by + let W := fun (_ : ℤ) (_ : B → σ) (x z : ℝ) => + giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + have hC := (diagonalOuterMajorant_pos Bφ Dφ diagonal).le + have hW (s y x z) : 0 ≤ (W s y x z).re := by + obtain ⟨a, ha, heq⟩ := giantOuterWeight_positive φ hφ Jleft Jright diagonal + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + change W s y x z = (a : ℂ) at heq + rw [heq] + exact ha + have hWupper (s y x z) : (W s y x z).re ≤ diagonalOuterMajorant Bφ Dφ diagonal := by + apply (Complex.re_le_norm _).trans + exact (giantOuterWeight_norm φ Jleft Jright Bφ Dφ hBφ hDφ hφnorm hlip hout diagonal _ _).trans + (by unfold diagonalOuterMajorant; linarith) + have hm0 := mixedExternalAverage_re_nonneg ν hν (V n) u v r w center W hW + have hmb := mixedExternalAverage_mass_bound ν hν hmass (V n) u v r w center + (diagonalOuterMajorant Bφ Dφ diagonal) hC W hWupper + have hmupper : (mixedExternalAverage ν (V n) u v r w center W).re ≤ + diagonalOuterMajorant Bφ Dφ diagonal * (2 * V n + 1 : ℕ) * Real.exp 2 := by + apply hmb.trans + apply mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) + (mul_nonneg hC (Nat.cast_nonneg _)) + have hc := movingOriginalPhaseStatistic_cauchy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ hφ G n m small slot hsmall hν hidentical greg ggiant favorable + Jleft Jright diagonal u v r w center + exact hc.trans ((mul_le_mul_of_nonneg_left henergy hm0).trans + (mul_le_mul_of_nonneg_right hmupper hE)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPrimeExpansion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPrimeExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..76867a869fcdadbe75a694de5c12487b20f6714f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPrimeExpansion.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePrimeExpansion + +namespace OAI + +/-! # The original giant-prime mean as a sum of supported pattern means -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalSampleAverage_compensated {σ I : Type*} [Fintype σ] + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) : + movingOriginalSampleAverage q value outside μ childBound pivotBound F g Dq S ψ X lo hi φ G + n t small bulk XL XR = + movingCompensatedAverage μ value n (fun a => + movingSupportedWeight value outside (buildMovingSlotData n t small bulk a) XL XR + (movingOriginalGiantWeight q value childBound pivotBound F (fun _ _ _ _ => 1) + g Dq S ψ X lo hi φ G (buildMovingSlotData n t small bulk a) t XL XR)) := by + rw [movingOriginalSampleAverage_eq, movingSupportedSampledWeight_eq] + congr 1 + funext a + exact movingSupportedSampleTerm_original q value outside childBound pivotBound F g Dq S + ψ X lo hi φ G n t small bulk XL XR a + +/-- The finite original giant-prime square is exactly a sum of pattern means +of the original fully supported history pair. This is the input to the proved +prime-to-Page comparison; no prime is removed or reweighted here. -/ +theorem movingOriginal_prime_pair_patterns {σ I : Type*} [Fintype σ] + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List σ) n) + (u v r s : ℝ) : + letI := sampleSetoidFintype (Bool × MovingSampleIndex n) + let W := fun b x y => movingOriginalSampleAverage q value outside μ childBound pivotBound + (F b) g (Dq b) S ψ X lo hi φ G n (t b) (small b) (bulk b) ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ + let H := fun b x y a => + movingSupportedWeight value outside (buildMovingSlotData n (t b) (small b) (bulk b) a) + ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ + (movingOriginalGiantWeight q value childBound pivotBound (F b) (fun _ _ _ _ => 1) + g (Dq b) S ψ X lo hi φ G (buildMovingSlotData n (t b) (small b) (bulk b) a) (t b) + ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊) + complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + W false x y * star (W true x y))) = + ∑ eqp : Setoid (Bool × MovingSampleIndex n), + ∑ z : {z : Quotient eqp → σ // Function.Injective z}, + let a := (movingSamplePairCoordinates σ n).symm (fun i => z.val (Quotient.mk'' i)) + (internalPatternWeight (fun i => Quotient.mk'' i) + (fun i => μ (movingSampleTier i.2)) value z.val : ℂ) * + complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + H false x y a.1 * star (H true x y a.2))) := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + simp_rw [movingOriginalSampleAverage_compensated] + exact movingCompensatedAverage_prime_pair_patterns μ value n _ _ u v r s + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPrimeStatistic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPrimeStatistic.lean new file mode 100644 index 0000000000000000000000000000000000000000..35680b1ea1db712eec8615a75c71ed7a0dc80639 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPrimeStatistic.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantPhase +import OAI.NumberTheory.Ostmann.Construction.PrimeExternalAverage + +namespace OAI + +/-! # The original statistic with both giant Fourier phases retained -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingOriginalPrimeStatistic {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w : ℝ) : ℂ := + let F := fun s y x z => movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m slot)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + primeExternalAverage ν (V n) u v r w (fun s y x z => + ((movingGiantPhase value outside small (bulkSlotLeaves n m slot) + ggiant favorable s y x z * movingExternalRegularFactor value outside small (bulkSlotLeaves n m slot) + greg s y x z) * F s y x z) * + giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊) + +theorem movingOriginalPrimeStatistic_cauchy {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (hν : ∀ b a, 0 ≤ ν b a) (hidentical : ∀ j k, ν (slot j) = ν (slot k)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : + ‖movingOriginalPrimeStatistic q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg ggiant favorable Jleft Jright diagonal u v r w‖ ^ 2 ≤ + Real.exp (center - u) ^ 2 * + (mixedExternalAverage ν (V n) u v r w center (fun _ _ x z => + giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)).re * + (movingOriginalSymmetrizedEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg Jleft Jright diagonal u v r w center).re := by + let F := fun s y x z => movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m slot)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + let H := movingExternalRegularFactor value outside small (bulkSlotLeaves n m slot) greg + let P := movingGiantPhase value outside small (bulkSlotLeaves n m slot) ggiant favorable + let W := fun (x z : ℝ) => giantOuterWeight φ Jleft Jright diagonal + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + have hW (x z : ℝ) : 0 ≤ (W x z).re ∧ ((W x z).re : ℂ) = W x z := by + obtain ⟨a, ha, heq⟩ := giantOuterWeight_positive φ hφ Jleft Jright diagonal + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + change W x z = (a : ℂ) at heq + rw [heq] + simpa only [Complex.ofReal_re] using And.intro ha (Eq.refl (a : ℂ)) + have hH (e s y x z) : H s (selectedBulkSample slot e y) x z = H s y x z := by + dsimp [H, movingExternalRegularFactor] + rw [MovingSlotReversal.naturalProduct_selected_bulk value n m small slot e y hsmall] + have hP (e s y x z) : P s (selectedBulkSample slot e y) x z = P s y x z := by + exact movingGiantPhase_selectedBulkSample value outside n m small slot e y hsmall + ggiant favorable s x z + have hPnorm (s y x z) : ‖P s y x z‖ ≤ 1 := + movingGiantPhase_norm_le value outside small (bulkSlotLeaves n m slot) ggiant favorable s y x z + have hc := primeExternalAverage_bounded_statistic_cauchy n m slot ν hν hidentical (V n) + u v r w center F H P hH hP hPnorm (fun x z => (W x z).re) (fun x z => (hW x z).1) + simp only [(hW _ _).2] at hc + exact hc + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPrimeStatisticBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPrimeStatisticBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..58e91a911a093f6115ba6befd9d89de8f031e521 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalPrimeStatisticBound.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPrimeStatistic +import OAI.NumberTheory.Ostmann.Characters.MixedExternalMass +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalOuterWeight + +namespace OAI + +/-! # A finite upper bound for the original symmetrized statistic -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalPrimeStatistic_upper {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) + (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφnorm : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (hν : ∀ b a, 0 ≤ ν b a) (hmass : ∀ b, ∑ a, ν b a = 1) (hidentical : ∀ j k, ν (slot j) = ν (slot k)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (hshort : w ≤ r + 1) (hvcenter : v ≤ center + 1) (E : ℝ) (hE : 0 ≤ E) + (henergy : (movingOriginalSymmetrizedEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg Jleft Jright diagonal u v r w center).re ≤ E) : + ‖movingOriginalPrimeStatistic q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg ggiant favorable Jleft Jright diagonal u v r w‖ ^ 2 ≤ + Real.exp (center - u) ^ 2 * diagonalOuterMajorant Bφ Dφ diagonal * + (2 * V n + 1 : ℕ) * Real.exp 2 * E := by + let W := fun (_ : ℤ) (_ : B → σ) (x z : ℝ) => + giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + have hC := (diagonalOuterMajorant_pos Bφ Dφ diagonal).le + have hW (s y x z) : 0 ≤ (W s y x z).re := by + obtain ⟨a, ha, heq⟩ := giantOuterWeight_positive φ hφ Jleft Jright diagonal + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + change W s y x z = (a : ℂ) at heq + rw [heq] + exact ha + have hWupper (s y x z) : (W s y x z).re ≤ diagonalOuterMajorant Bφ Dφ diagonal := by + apply (Complex.re_le_norm _).trans + exact (giantOuterWeight_norm φ Jleft Jright Bφ Dφ hBφ hDφ hφnorm hlip hout diagonal _ _).trans + (by unfold diagonalOuterMajorant; linarith) + have hm0 := mixedExternalAverage_re_nonneg ν hν (V n) u v r w center W hW + have hmb := mixedExternalAverage_mass_bound ν hν hmass (V n) u v r w center + (diagonalOuterMajorant Bφ Dφ diagonal) hC W hWupper + have hmupper : (mixedExternalAverage ν (V n) u v r w center W).re ≤ + diagonalOuterMajorant Bφ Dφ diagonal * (2 * V n + 1 : ℕ) * Real.exp 2 := by + apply hmb.trans + apply mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) + (mul_nonneg hC (Nat.cast_nonneg _)) + have hc := movingOriginalPrimeStatistic_cauchy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ hφ G n m small slot hsmall hν hidentical greg ggiant favorable + Jleft Jright diagonal u v r w center + have hstep := mul_le_mul_of_nonneg_left henergy + (mul_nonneg (sq_nonneg (Real.exp (center - u))) hm0) + have hnext := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hmupper (sq_nonneg (Real.exp (center - u)))) hE + exact hc.trans ((hstep.trans hnext).trans_eq (by ring)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalSampleExpansion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalSampleExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8df7e253f3a978cc4cc0ee30cf32be6fb91cfd1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalSampleExpansion.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePairExpansion + +namespace OAI + +/-! # The original Fourier coefficient under the exact internal sampling law -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingOriginalLeaf {σ I : Type*} (value : σ → ℕ) (q : I → ℕ) + [∀ i, Fact (q i).Prime] (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (x : MovingSlotState σ) (s : ℤ) : ℂ := + (movingWindowLeaf value X lo hi (movingDataLeaf F) x s * movingFourierLeaf value ψ X x s) * + ∏ i ∈ S, spectatorHistoryLeaf (movingSlotModulus value) (g i) (Dq i) x s + +noncomputable def movingOriginalNode {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (φ : ℝ → ℝ) (G : ℕ → ℝ) : + MovingSlotState σ → ℤ → ℤ → ℤ → ℝ := + movingPhiExtra value childBound pivotBound (fun _ _ _ _ => 1) φ G + +theorem movingOriginalNode_local {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (φ : ℝ → ℝ) (G : ℕ → ℝ) : + movingLocalExtra (movingOriginalNode value childBound pivotBound φ G) = + movingOriginalNode value childBound pivotBound φ G := by + funext x s v w + rcases x with ⟨n, T, XL, XR⟩ + cases T <;> rfl + +theorem movingOriginalNode_compensated {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (φ : ℝ → ℝ) (G : ℕ → ℝ) : + movingCompensatedExtra value (movingOriginalNode value childBound pivotBound φ G) = + movingPhiExtra value childBound pivotBound (movingDataExtra (movingCompensationExtra value)) φ G := by + funext x s v w + rcases x with ⟨n, T, XL, XR⟩ + cases T <;> simp only [movingCompensatedExtra, movingOriginalNode, movingPhiExtra, + movingDataExtra, movingCompensationExtra, MovingSlotState.compensation, Nat.cast_one, one_mul] + +/-- The sampled Fourier coefficient, with all original support and all +original internal probabilities. -/ +noncomputable def movingOriginalSampleAverage {σ I : Type*} [Fintype σ] + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) : ℂ := + ∑ a : MovingSampleSlots σ n, (movingSamplesPrior μ a : ℂ) * + movingSupportedWeight value outside (buildMovingSlotData n t small bulk a) XL XR + (movingOriginalGiantWeight q value childBound pivotBound F (movingCompensationExtra value) + g Dq S ψ X lo hi φ G (buildMovingSlotData n t small bulk a) t XL XR) + +/-- The Fourier/window/spectator coefficient is exactly the local sampled +recursion already expanded above. -/ +theorem movingOriginalSampleAverage_eq {σ I : Type*} [Fintype σ] + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) : + movingOriginalSampleAverage q value outside μ childBound pivotBound F g Dq S ψ X lo hi φ G + n t small bulk XL XR = + movingSupportedSampledWeight value outside μ childBound pivotBound + (movingOriginalLeaf value q F g Dq S ψ X lo hi) + (movingOriginalNode value childBound pivotBound φ G) n t small bulk XL XR := by + unfold movingSupportedSampledWeight + rw [movingSampledWeight_supported, movingLocalExtra_compensated, movingOriginalNode_local, + movingOriginalNode_compensated] + rfl + +/-- After extracting compensation, the retained term is the original giant +coefficient with unit data at internal nodes. -/ +theorem movingSupportedSampleTerm_original {σ I : Type*} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) + (a : MovingSampleSlots σ n) : + movingSupportedSampleTerm value outside childBound pivotBound + (movingOriginalLeaf value q F g Dq S ψ X lo hi) + (movingOriginalNode value childBound pivotBound φ G) n t small bulk XL XR a = + movingSupportedWeight value outside (buildMovingSlotData n t small bulk a) XL XR + (movingOriginalGiantWeight q value childBound pivotBound F (fun _ _ _ _ => 1) + g Dq S ψ X lo hi φ G (buildMovingSlotData n t small bulk a) t XL XR) := by + unfold movingSupportedSampleTerm + rw [movingOriginalNode_local] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalStatistic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalStatistic.lean new file mode 100644 index 0000000000000000000000000000000000000000..fee2b57f1bcf1e967ff09a2af5003c8f815f23f2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalStatistic.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalSymmetrization +import OAI.NumberTheory.Ostmann.Characters.MixedExternalStatistic + +namespace OAI + +/-! # The original mixed arithmetic statistic and its symmetrized upper bound -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingExternalRegularFactor {σ B : Type*} {n : ℕ} + (value : σ → ℕ) (outside : List ℕ) (small bulk : TreeLeafTuple (List B) n) + (greg : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) (y : B → σ) (x z : ℝ) : ℂ := + primeProductTransform greg (outside.prod * ⌊Real.exp x⌋₊ * ⌊Real.exp z⌋₊) + (MovingSlotReversal.naturalProduct (value ∘ y) + (flattenMovingSlots n small ++ flattenMovingSlots n bulk)) s + +theorem giantOuterWeight_positive (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) + (Jleft Jright : ℝ) (diagonal : Bool) (L R : ℝ) : + ∃ a : ℝ, 0 ≤ a ∧ giantOuterWeight φ Jleft Jright diagonal L R = a := by + have hc (x J : ℝ) : 0 ≤ positiveLogCutoff φ J x := by + unfold positiveLogCutoff + split_ifs + · exact hφ _ + · exact le_rfl + refine ⟨positiveLogCutoff φ Jleft L * positiveLogCutoff φ Jright R * + (if diagonal then Real.exp Jright / R else 1), ?_, ?_⟩ + · have hratio : 0 ≤ (if diagonal then Real.exp Jright / R else 1) ∨ R ≤ 0 := by + by_cases hR : 0 ≤ R + · left; split_ifs <;> positivity + · exact Or.inr (le_of_not_ge hR) + rcases hratio with hratio | hR + · exact mul_nonneg (mul_nonneg (hc _ _) (hc _ _)) hratio + · simp only [positiveLogCutoff, not_lt.mpr hR, ite_false, mul_zero, zero_mul] + exact le_rfl + · unfold giantOuterWeight + cases diagonal <;> simp only [Bool.false_eq_true, ite_false, ite_true] <;> push_cast <;> rfl + +noncomputable def movingOriginalStatistic {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : ℂ := + let F := fun s y x z => movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m slot)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + mixedExternalAverage ν (V n) u v r w center (fun s y x z => + (movingExternalRegularFactor value outside small (bulkSlotLeaves n m slot) + greg s y x z * F s y x z) * + giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊) + +theorem movingOriginalStatistic_cauchy {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (hν : ∀ b a, 0 ≤ ν b a) (hidentical : ∀ j k, ν (slot j) = ν (slot k)) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : + ‖movingOriginalStatistic q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg Jleft Jright diagonal u v r w center‖ ^ 2 ≤ + (mixedExternalAverage ν (V n) u v r w center (fun _ _ x z => + giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)).re * + (movingOriginalSymmetrizedEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg Jleft Jright diagonal u v r w center).re := by + let F := fun s y x z => movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m slot)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + let H := movingExternalRegularFactor value outside small (bulkSlotLeaves n m slot) greg + let W := fun (x z : ℝ) => giantOuterWeight φ Jleft Jright diagonal + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + have hW (x z : ℝ) : 0 ≤ (W x z).re ∧ ((W x z).re : ℂ) = W x z := by + obtain ⟨a, ha, heq⟩ := giantOuterWeight_positive φ hφ Jleft Jright diagonal + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + change W x z = (a : ℂ) at heq + rw [heq] + simpa only [Complex.ofReal_re] using And.intro ha (Eq.refl (a : ℂ)) + have hH (e s y x z) : H s (selectedBulkSample slot e y) x z = H s y x z := by + dsimp [H, movingExternalRegularFactor] + rw [MovingSlotReversal.naturalProduct_selected_bulk value n m small slot e y hsmall] + have hc := mixedBulkSymmetrize_statistic_cauchy n m slot ν hν hidentical (V n) + u v r w center F H hH (fun x z => (W x z).re) (fun x z => (hW x z).1) + simp only [(hW _ _).2] at hc + exact hc + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalStatisticBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalStatisticBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..c0ecb63089fbfb076cabe1c2b444daa55f33972d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalStatisticBound.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalStatistic +import OAI.NumberTheory.Ostmann.Characters.MixedExternalMass +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalOuterWeight + +namespace OAI + +/-! # A finite upper bound for the original symmetrized statistic -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalStatistic_upper {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) + (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφnorm : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (hν : ∀ b a, 0 ≤ ν b a) (hmass : ∀ b, ∑ a, ν b a = 1) (hidentical : ∀ j k, ν (slot j) = ν (slot k)) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (hshort : w ≤ r + 1) (hvcenter : v ≤ center + 1) (E : ℝ) (hE : 0 ≤ E) + (henergy : (movingOriginalSymmetrizedEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg Jleft Jright diagonal u v r w center).re ≤ E) : + ‖movingOriginalStatistic q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg Jleft Jright diagonal u v r w center‖ ^ 2 ≤ + diagonalOuterMajorant Bφ Dφ diagonal * (2 * V n + 1 : ℕ) * Real.exp 2 * E := by + let W := fun (_ : ℤ) (_ : B → σ) (x z : ℝ) => + giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + have hC := (diagonalOuterMajorant_pos Bφ Dφ diagonal).le + have hW (s y x z) : 0 ≤ (W s y x z).re := by + obtain ⟨a, ha, heq⟩ := giantOuterWeight_positive φ hφ Jleft Jright diagonal + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + change W s y x z = (a : ℂ) at heq + rw [heq] + exact ha + have hWupper (s y x z) : (W s y x z).re ≤ diagonalOuterMajorant Bφ Dφ diagonal := by + apply (Complex.re_le_norm _).trans + exact (giantOuterWeight_norm φ Jleft Jright Bφ Dφ hBφ hDφ hφnorm hlip hout diagonal _ _).trans + (by unfold diagonalOuterMajorant; linarith) + have hm0 := mixedExternalAverage_re_nonneg ν hν (V n) u v r w center W hW + have hmb := mixedExternalAverage_mass_bound ν hν hmass (V n) u v r w center + (diagonalOuterMajorant Bφ Dφ diagonal) hC W hWupper + have hmupper : (mixedExternalAverage ν (V n) u v r w center W).re ≤ + diagonalOuterMajorant Bφ Dφ diagonal * (2 * V n + 1 : ℕ) * Real.exp 2 := by + apply hmb.trans + apply mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) + (mul_nonneg hC (Nat.cast_nonneg _)) + have hc := movingOriginalStatistic_cauchy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ hφ G n m small slot hsmall hν hidentical greg + Jleft Jright diagonal u v r w center + exact hc.trans ((mul_le_mul_of_nonneg_left henergy hm0).trans + (mul_le_mul_of_nonneg_right hmupper hE)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalSymmetrization.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalSymmetrization.lean new file mode 100644 index 0000000000000000000000000000000000000000..d39274331aadb37f0697de6d7ed931b98aca3505 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalSymmetrization.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalBulkAction +import OAI.NumberTheory.Ostmann.Characters.MixedBulkSymmetrization + +namespace OAI + +/-! # The original coefficient symmetrization with its common regular multiplier -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingOriginalSymmetrizedEnergy {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) : ℂ := + let F := fun s y x z => movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m slot)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + mixedExternalAverage ν (V n) u v r w center (fun s y x z => + (‖mixedBulkSymmetrize n m slot F s y x z‖ ^ 2 : ℂ) * + movingExternalDiagonalWeight value outside small (bulkSlotLeaves n m slot) + greg s φ Jleft Jright diagonal y x z) + +theorem movingOriginalSymmetrizedEnergy_bound {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) (G : ℕ → ℝ) + (n m : ℕ) (hm : 1 ≤ m) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (hν : ∀ b a, 0 ≤ ν b a) (hidentical : ∀ j k, ν (slot j) = ν (slot k)) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center D E : ℝ) + (hD : 0 ≤ D) (hE : 0 ≤ E) + (hdiag : ‖movingOriginalDiagonalEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n small (bulkSlotLeaves n m slot) greg Jleft Jright diagonal u v r w center‖ ≤ D) + (hgood : ∀ e : Equiv.Perm (TreeLeafIndex n × Fin m), + 4 * Fintype.card (arrangementGraph m e).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex n) → + ‖movingOriginalMatchedCorrelation q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n small (movingPatternBulkLeaves n m slot e) greg + Jleft Jright diagonal u v r w center‖ ≤ E) : + (movingOriginalSymmetrizedEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n m small slot greg Jleft Jright diagonal u v r w center).re ≤ + (((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) * + Real.exp ((2 ^ n : ℝ) * m * (-(3 / 4 : ℝ) * Real.log (2 ^ n : ℕ) + 5 / 4)) * D + E := by + let F := fun s y x z => movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m slot)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + let W := fun s y x z => movingExternalDiagonalWeight value outside small + (bulkSlotLeaves n m slot) greg s φ Jleft Jright diagonal y x z + have hW (s y x z) : 0 ≤ (W s y x z).re ∧ ((W s y x z).re : ℂ) = W s y x z := by + obtain ⟨a, ha, heq⟩ := movingExternalDiagonalWeight_positive value outside small + (bulkSlotLeaves n m slot) greg s φ hφ Jleft Jright diagonal y x z + change W s y x z = (a : ℂ) at heq + rw [heq] + simpa only [Complex.ofReal_re] using And.intro ha (Eq.refl (a : ℂ)) + have hinv (e s y x z) : (W s (selectedBulkSample slot e y) x z).re = (W s y x z).re := + congrArg Complex.re (movingExternalDiagonalWeight_selectedBulkSample value outside n m + small slot e y hsmall greg s φ Jleft Jright diagonal x z) + have hd : (mixedExternalAverage ν (V n) u v r w center + (fun s y x z => (‖F s y x z‖ ^ 2 : ℂ) * (W s y x z).re)).re ≤ D := by + simp only [(hW _ _ _ _).2] + exact (Complex.re_le_norm _).trans hdiag + have hg (e : Equiv.Perm (TreeLeafIndex n × Fin m)) + (he : 4 * Fintype.card (arrangementGraph m e).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex n)) : + ‖mixedExternalAverage ν (V n) u v r w center + (fun s y x z => (F s y x z * star (F s (selectedBulkSample slot e y) x z)) * + (W s y x z).re)‖ ≤ E := by + simp only [(hW _ _ _ _).2] + rw [← movingOriginalMatchedCorrelation_bulk_action q value outside μ ν childBound pivotBound V + f g Dq S ψ X lo hi φ G n m small slot e hsmall greg Jleft Jright diagonal u v r w center] + exact hgood e he + have h := mixedBulkSymmetrize_energy_bound n m hm slot ν hν hidentical (V n) + u v r w center F (fun s y x z => (W s y x z).re) (fun s y x z => (hW s y x z).1) + hinv D E hD hE hd hg + simp only [(hW _ _ _ _).2] at h + exact h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalWeightRelabel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalWeightRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..e6b42fc5afc76bf42a30504c84f3cbd00a3a1c01 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOriginalWeightRelabel.lean @@ -0,0 +1,130 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotStateRelabel +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRecursiveSupport + +namespace OAI + +/-! # The original giant weight commutes with evaluating pattern labels -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +@[simp] theorem movingSlotModulus_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (x : MovingSlotState σ) : + movingSlotModulus value (x.map f) = movingSlotModulus (value ∘ f) x := by + rcases x with ⟨n, T, XL, XR⟩ + cases T <;> simp only [MovingSlotState.map, MovingSlotData.map, movingSlotModulus, + ← List.map_append, MovingSlotReversal.naturalProduct_map] + +theorem movingSlotCutoff_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (childBound pivotBound : ℕ → ℕ) + (extra : MovingSlotState τ → ℤ → ℤ → ℤ → ℝ) + (x : MovingSlotState σ) (s v w : ℤ) : + movingSlotCutoff value childBound pivotBound extra (x.map f) s v w = + movingSlotCutoff (value ∘ f) childBound pivotBound + (fun x => extra (x.map f)) x s v w := by + simp only [movingSlotCutoff, MovingSlotState.compensation_map, movingHistoryPivot_map] + +theorem movingPhiExtra_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (childBound pivotBound : ℕ → ℕ) + (extra : MovingSlotState τ → ℤ → ℤ → ℤ → ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (x : MovingSlotState σ) (s v w : ℤ) : + movingPhiExtra value childBound pivotBound extra φ G (x.map f) s v w = + movingPhiExtra (value ∘ f) childBound pivotBound + (fun x => extra (x.map f)) φ G x s v w := by + simp only [movingPhiExtra, MovingSlotState.map_depth, movingHistoryPivot_map, + MovingSlotState.compensation_map] + +theorem movingOriginalGiantWeight_map {σ τ I : Type*} (f : σ → τ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : τ → ℕ) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData τ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData τ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (XL XR : ℕ) : + movingOriginalGiantWeight q value childBound pivotBound F E g Dq S ψ X lo hi φ G + (T.map f) t XL XR = + movingOriginalGiantWeight q (value ∘ f) childBound pivotBound + (fun T => F (T.map f)) (fun T => E (T.map f)) g Dq S ψ X lo hi φ G T t XL XR := by + unfold movingOriginalGiantWeight + change recursiveTransferWeight _ _ _ n + ((⟨n, T, XL, XR⟩ : MovingSlotState σ).map f) t = _ + rw [movingRecursiveWeight_map] + congr 1 + · funext x s + simp only [movingWindowLeaf, movingDataLeaf, movingFourierLeaf, + spectatorHistoryLeaf, movingSlotModulus_map, MovingSlotState.map_data] + rfl + · funext x s v w + rw [movingSlotCutoff_map] + congr 1 + funext y a b c + rw [movingPhiExtra_map] + rfl + +@[simp] theorem MovingSlotData.regularSlots_map {σ τ : Type*} (f : σ → τ) + {n : ℕ} (T : MovingSlotData σ n) : (T.map f).regularSlots = T.regularSlots.map f := by + cases T <;> simp only [MovingSlotData.map, MovingSlotData.regularSlots, List.map_append] + +@[simp] theorem MovingSlotData.frequencyProduct_map {σ τ : Type*} (f : σ → τ) + {n : ℕ} (T : MovingSlotData σ n) : (T.map f).frequencyProduct = T.frequencyProduct := by + induction T with + | leaf => rfl + | node s CL CR u l r ihL ihR => + simp only [MovingSlotData.map, MovingSlotData.frequencyProduct, ihL, ihR] + +@[simp] theorem MovingSlotData.currentSlots_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : + (T.map f).currentSlots value XL XR = T.currentSlots (value ∘ f) XL XR := by + simp only [MovingSlotData.currentSlots, MovingSlotData.regularSlots_map, List.map_map] + +theorem movingLocalGiantUnits_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℤ) : + movingLocalGiantUnits value outside (T.map f) XL XR ↔ + movingLocalGiantUnits (value ∘ f) outside T XL XR := by + simp only [movingLocalGiantUnits, MovingSlotData.frequencyProduct_map, + MovingSlotData.regularSlots_map, MovingSlotReversal.naturalProduct_map] + +theorem MovingSlotReversal.naturalPivot_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (s : MovingSlotReversal σ) (XL XR : ℕ) : + (s.map f).naturalPivot value XL XR = s.naturalPivot (value ∘ f) XL XR := by + simp only [MovingSlotReversal.naturalPivot, MovingSlotReversal.map, + MovingSlotReversal.naturalProduct_map] + +theorem movingLocalSupport_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (outside : List ℕ) (x : MovingSlotState σ) : + movingLocalSupport value outside (x.map f) ↔ + movingLocalSupport (value ∘ f) outside x := by + change (((x.data.map f).currentSlots value x.leftGiant x.rightGiant ++ outside).Pairwise Nat.Coprime ∧ + movingLocalGiantUnits value outside (x.data.map f) x.leftGiant x.rightGiant) ↔ _ + rw [MovingSlotData.currentSlots_map, movingLocalGiantUnits_map] + rfl + +theorem movingFullSupport_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : + movingFullSupport value outside (T.map f) XL XR ↔ + movingFullSupport (value ∘ f) outside T XL XR := by + induction T generalizing XL XR with + | leaf s regular => + change movingLocalSupport value outside + ((⟨0, .leaf s regular, XL, XR⟩ : MovingSlotState σ).map f) ↔ _ + exact movingLocalSupport_map f value outside _ + | node s CL CR u l r ihL ihR => + have hlocal := movingLocalSupport_map f value outside + (⟨_, .node s CL CR u l r, XL, XR⟩ : MovingSlotState σ) + change movingLocalSupport value outside + ⟨_, .node s (CL.map f) (CR.map f) (u.map f) (l.map f) (r.map f), XL, XR⟩ ↔ _ at hlocal + simp only [MovingSlotData.map, movingFullSupport_node, MovingSlotData.step_map, + MovingSlotReversal.naturalPivot_map, ihL, ihR, hlocal] + +theorem movingSupportedWeight_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (XL XR : ℕ) (z : ℂ) : + movingSupportedWeight value outside (T.map f) XL XR z = + movingSupportedWeight (value ∘ f) outside T XL XR z := by + simp only [movingSupportedWeight, movingFullSupport_map] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterCoprimeComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterCoprimeComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..5ecafb7306ba695c76503128b71fb2e285734084 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterCoprimeComparison.lean @@ -0,0 +1,178 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterHaarComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterNormBudget +import OAI.NumberTheory.Ostmann.Construction.GiantCoprimeRates +import OAI.NumberTheory.Ostmann.Construction.GiantModulusCutoff + +namespace OAI + +/-! # Coprime top giants under the literal prime and integer laws -/ + +namespace Ostmann +universe u +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_outer_coprime_prime_haar_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + if (⌊Real.exp x⌋₊).Coprime ⌊Real.exp y⌋₊ then + c (⌊Real.exp x⌋₊ % q) (⌊Real.exp y⌋₊ % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ + else 0)) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_outer_prime_haar_rate n C d, + prime_pair_coprime_removal_rate C d, eventually_gt_atTop (0 : ℝ)] with L hL hR hL0 + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c A hA0 hA hbudget + have hL := hL σ + have : NeZero q := ⟨by omega⟩ + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let H := fun x y => movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + let F0 := fun x y : ℕ => c (x % q) (y % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal x y + let K := A * (giantOuterScalar diagonal * movingOuterVariationBudget ψ V lo hi n B D diagonal) + have hs : 0 ≤ giantOuterScalar diagonal := by cases diagonal <;> simp [giantOuterScalar, (Real.exp_pos _).le] + have hv : 0 ≤ movingOuterVariationBudget ψ V lo hi n B D diagonal := by + cases diagonal <;> unfold movingOuterVariationBudget <;> simp only [Bool.false_eq_true, ite_false, ite_true] <;> positivity + have hK0 : 0 ≤ K := mul_nonneg hA0 (mul_nonneg hs hv) + have hK : K ≤ Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + calc + K ≤ 2 * K := by linarith + _ = 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal := by ring + _ ≤ _ := hbudget + have hnorm (x y : ℕ) : ‖F0 x y‖ ≤ K := by + dsimp only [F0] + rw [norm_mul] + exact mul_le_mul (hA _ (Nat.mod_lt _ (by omega)) _ (Nat.mod_lt _ (by omega))) + (movingOuterKernel_norm_variation value T nodes ψ X lo hi V hlo hhi hV φ G Jleft Jright B D + hB hD hφ hlip hout diagonal x y) (norm_nonneg _) hA0 + have hremove := hR u v r s K hu hrshort hK0 hK F0 (fun x _ y _ => hnorm x y) + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D + hB hD hφ hlip hout diagonal V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c (by + intro a ha b hb + have ha0 := Finset.mem_range.mp (Finset.mem_filter.mp ha).1 + have hb0 := Finset.mem_range.mp (Finset.mem_filter.mp hb).1 + exact (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right (hA a ha0 b hb0) hs) (by norm_num)) hv).trans hbudget) + have hfactor := prime_pair_residue_factorization q (by omega) u v r s + (fun z hz _ => giant_interval_gt_modulus L hL0 q (by omega) hqlog u v hu z hz) + (fun z hz _ => giant_interval_gt_modulus L hL0 q (by omega) hqlog r s hr z hz) + F0 c H (by + intro x _ hx y _ hy a ha b hb hxa hyb + have hx0 : (0 : ℝ) < x := by exact_mod_cast hx.pos + have hy0 : (0 : ℝ) < y := by exact_mod_cast hy.pos + have ha0 : a < q := Finset.mem_range.mp (Finset.mem_filter.mp ha).1 + have hb0 : b < q := Finset.mem_range.mp (Finset.mem_filter.mp hb).1 + have hxa' : x % q = a := by simpa only [Nat.ModEq, Nat.mod_eq_of_lt ha0] using hxa + have hyb' : y % q = b := by simpa only [Nat.ModEq, Nat.mod_eq_of_lt hb0] using hyb + dsimp only [F0, H] + rw [hxa', hyb', Real.exp_log hx0, Real.exp_log hy0]) + dsimp only at h + rw [← hfactor] at h + exact (norm_sub_le_norm_sub_add_norm_sub _ _ _).trans (add_le_add hremove h) + +theorem PublishedProgressionInput.moving_outer_coprime_mixed_haar_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + if (⌊Real.exp x⌋₊).Coprime ⌊Real.exp y⌋₊ then + c (⌊Real.exp x⌋₊ % q) (⌊Real.exp y⌋₊ % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ + else 0)) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * correctedMixedPairAverage P Q q c y / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_outer_mixed_haar_rate n C d, + mixed_pair_coprime_removal_rate C d, eventually_gt_atTop (0 : ℝ)] with L hL hR hL0 + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog c A hA0 hA hbudget + have hL := hL σ + have : NeZero q := ⟨by omega⟩ + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let H := fun x y => movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + let F0 := fun x y : ℕ => c (x % q) (y % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal x y + let K := A * (giantOuterScalar diagonal * movingOuterVariationBudget ψ V lo hi n B D diagonal) + have hs : 0 ≤ giantOuterScalar diagonal := by cases diagonal <;> simp [giantOuterScalar, (Real.exp_pos _).le] + have hv : 0 ≤ movingOuterVariationBudget ψ V lo hi n B D diagonal := by + cases diagonal <;> unfold movingOuterVariationBudget <;> simp only [Bool.false_eq_true, ite_false, ite_true] <;> positivity + have hK0 : 0 ≤ K := mul_nonneg hA0 (mul_nonneg hs hv) + have hK : K ≤ Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + calc + K ≤ 2 * K := by linarith + _ = 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal := by ring + _ ≤ _ := hbudget + have hnorm (x y : ℕ) : ‖F0 x y‖ ≤ K := by + dsimp only [F0] + rw [norm_mul] + exact mul_le_mul (hA _ (Nat.mod_lt _ (by omega)) _ (Nat.mod_lt _ (by omega))) + (movingOuterKernel_norm_variation value T nodes ψ X lo hi V hlo hhi hV φ G Jleft Jright B D + hB hD hφ hlip hout diagonal x y) (norm_nonneg _) hA0 + have hremove := hR u v r s J K hr hvJ hrshort hK0 hK F0 (fun x _ y _ => hnorm x y) + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D + hB hD hφ hlip hout diagonal V hV Q q hQ hq hqQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog c (by + intro a ha b hb + have ha0 := Finset.mem_range.mp ha + have hb0 := Finset.mem_range.mp (Finset.mem_filter.mp hb).1 + exact (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right (hA a ha0 b hb0) hs) (by norm_num)) hv).trans hbudget) + have hfactor := mixed_pair_residue_factorization q (by omega) u v r s J + (fun z hz _ => giant_interval_gt_modulus L hL0 q (by omega) hqlog r s hr z hz) + F0 c H (by + intro x hx y _ hy a ha b hb hxa hyb + have hx0 : (0 : ℝ) < x := (Real.exp_pos u).trans (Nat.lt_of_floor_lt (Finset.mem_Ioc.mp hx).1) + have hy0 : (0 : ℝ) < y := by exact_mod_cast hy.pos + have ha0 : a < q := Finset.mem_range.mp ha + have hb0 : b < q := Finset.mem_range.mp (Finset.mem_filter.mp hb).1 + have hxa' : x % q = a := by simpa only [Nat.ModEq, Nat.mod_eq_of_lt ha0] using hxa + have hyb' : y % q = b := by simpa only [Nat.ModEq, Nat.mod_eq_of_lt hb0] using hyb + dsimp only [F0, H] + rw [hxa', hyb', Real.exp_log hx0, Real.exp_log hy0]) + dsimp only at h + rw [← hfactor] at h + exact (norm_sub_le_norm_sub_add_norm_sub _ _ _).trans (add_le_add hremove h) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterHaarComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterHaarComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..b0663d4b47300daa0df65ae5bcf9aa68842210a2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterHaarComparison.lean @@ -0,0 +1,124 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterResidueComparison +import OAI.NumberTheory.Ostmann.Construction.GiantHaarIntegral + +namespace OAI + +/-! # The original outer-prior comparisons as corrected Haar integrals -/ + +namespace Ostmann +universe u +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_outer_prime_haar_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + (∀ a ∈ reducedResidues q, ∀ b ∈ reducedResidues q, + 2 * (‖c a b‖ * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + letI : NeZero q := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖(∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c a b * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y)))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_outer_prime_residue_sum_rate n C d, + eventually_ge_atTop (0 : ℝ)] with L hL hL0 + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c hbudget + have hL := hL σ + have : NeZero q := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let H := fun x y => movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D + hB hD hφ hlip hout diagonal V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c hbudget + dsimp only at h ⊢ + have hmeas : Measurable (Function.uncurry H) := by + have hh := measurable_exp_pair_mul + (movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal) + (measurable_movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal) (1 : ℂ) + simpa only [one_mul] using hh + have hnorm (x y : ℝ) : ‖H x y‖ ≤ + (((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) ^ 2 * + (giantOuterScalar diagonal * (2 * B + D * (Real.exp 2 - 1)) ^ 2 * (if diagonal then 1 + Real.exp 2 else 2))) := by + dsimp only [H, movingOuterKernel] + rw [norm_mul] + exact mul_le_mul (movingRealKernelPair_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ _ _) + (giantOuterWeight_norm φ Jleft Jright B D hB hD hφ hlip hout diagonal _ _) (norm_nonneg _) (by positivity) + have hu1 : 1 ≤ u := (Real.one_le_exp (by positivity)).trans hu + have hr1 : 1 ≤ r := (Real.one_le_exp (by positivity)).trans hr + rw [primeGiantMeasure_pair_haar_integral P Q q u v r s hu1 hr1 H hmeas _ hnorm c] at h + exact h + +theorem PublishedProgressionInput.moving_outer_mixed_haar_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + (∀ a ∈ Finset.range q, ∀ b ∈ reducedResidues q, + 2 * (‖c a b‖ * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + letI : NeZero q := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖(∑ b ∈ reducedResidues q, ∑ a ∈ Finset.range q, + complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c a b * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y)))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * correctedMixedPairAverage P Q q c y / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_outer_mixed_residue_sum_rate n C d, + eventually_ge_atTop (0 : ℝ)] with L hL hL0 + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog c hbudget + have hL := hL σ + have : NeZero q := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let H := fun x y => movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D + hB hD hφ hlip hout diagonal V hV Q q hQ hq hqQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog c hbudget + dsimp only at h ⊢ + have hmeas : Measurable (Function.uncurry H) := by + have hh := measurable_exp_pair_mul + (movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal) + (measurable_movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal) (1 : ℂ) + simpa only [one_mul] using hh + have hnorm (x y : ℝ) : ‖H x y‖ ≤ + (((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) ^ 2 * + (giantOuterScalar diagonal * (2 * B + D * (Real.exp 2 - 1)) ^ 2 * (if diagonal then 1 + Real.exp 2 else 2))) := by + dsimp only [H, movingOuterKernel] + rw [norm_mul] + exact mul_le_mul (movingRealKernelPair_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ _ _) + (giantOuterWeight_norm φ Jleft Jright B D hB hD hφ hlip hout diagonal _ _) (norm_nonneg _) (by positivity) + have hr1 : 1 ≤ r := (Real.one_le_exp (by positivity)).trans hr + rw [mixedGiantMeasure_pair_haar_integral P Q q u v r s J hr1 H hmeas _ hnorm c] at h + exact h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterIntegerRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterIntegerRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..36f2523c26e911b81be995a78e59046bf9f902c6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterIntegerRate.lean @@ -0,0 +1,46 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterKernelRates +import OAI.NumberTheory.Ostmann.Arithmetic.MovingIntegerPairRate + +namespace OAI + +/-! # Integer slice rate with the original giant cutoff factors -/ + +namespace Ostmann +universe u +open Filter MeasureTheory +open scoped Classical SchwartzMap + +theorem moving_outer_kernel_integer_rate (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal coord : Bool) (fixed : ℝ) + (q a : ℕ), 0 < q → ∀ u v J : ℝ, u ≤ v → + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → ∀ c : ℂ, + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := movingOuterPolynomialFactors value T (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip diagonal + 2 * (‖c‖ * giantOuterScalar diagonal) * smoothPolynomialBudget W ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + ‖complexIntegerInterval q a u v J (fun y => c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) - + ∫ y in Set.Ioc u v, (c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) * + (integerLogDensity q J y : ℂ)‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [moving_pair_integer_error_rate n C d] with L hL + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal coord fixed q a hq u v J huv hJ c + dsimp only + intro hbudget + apply (moving_outer_kernel_integer_bound value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi + φ G Jleft Jright B D hB hD hφ hlip hout diagonal coord fixed q a hq u v J huv c).trans + convert hL J _ hJ hbudget using 1 + push_cast + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterJointComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterJointComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1d4fbbce8c0488bc39a3c6bebd59109a47c914e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterJointComparison.lean @@ -0,0 +1,171 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterKernelRates +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelTransport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterIntegerRate + +namespace OAI + +/-! # Joint transport with the literal outer priors and diagonal reciprocal -/ + +namespace Ostmann +universe u +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +noncomputable def movingOuterVariationBudget (ψ : 𝓢(ℝ, ℂ)) (V lo hi : ℝ) (n : ℕ) + (B D : ℝ) (diagonal : Bool) : ℝ := + (movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 * + ((2 * B + D * (Real.exp 2 - 1)) ^ 2 * (if diagonal then 1 + Real.exp 2 else 2)) + +theorem PublishedProgressionInput.moving_outer_joint_prime_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) + (hf : ∀ b, (T b).Frequencies (· ≠ 0)) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), + (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q a b : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → a.Coprime q → b.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → ∀ c : ℂ, + 2 * (‖c‖ * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂primeGiantMeasure P Q q a u v‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) * + (reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) + 2) := by + filter_upwards [P.moving_outer_kernel_prime_rate n C d, eventually_ge_atTop (0 : ℝ)] with L hL hL0 + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q a b hQ hq hqQ ha hb hlog u v r s hu huv hshort hr hrs hrshort c hbudget + have hL := hL σ + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let H := fun x y => c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + let μ := primeGiantMeasure P Q q a u v + let ν := primeGiantMeasure P Q q b r s + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hu1 : 1 ≤ u := (Real.one_le_exp (by positivity)).trans hu + have hr1 : 1 ≤ r := (Real.one_le_exp (by positivity)).trans hr + have : IsFiniteMeasure μ := finite_primeGiantMeasure P Q q a u v (by linarith) + have : IsFiniteMeasure ν := finite_primeGiantMeasure P Q q b r s (by linarith) + have hscalar : 0 ≤ giantOuterScalar diagonal := by cases diagonal <;> simp [giantOuterScalar, (Real.exp_pos _).le] + have hsmall (coord : Bool) (fixed : ℝ) : + 2 * (‖c‖ * giantOuterScalar diagonal) * smoothPolynomialBudget + (movingOuterPolynomialFactors value T (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip diagonal) ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) := + (mul_le_mul_of_nonneg_left (movingOuterPolynomialFactors_budget value T _ _ ψ X lo hi V hlo hhi hV + φ G Jleft Jright B D hB hD hφ hlip diagonal) (by positivity)).trans hbudget + have hleft (y : ℝ) : ‖complexPrimeInterval q a u v (fun x => H x y) - ∫ x, H x y ∂μ‖ ≤ err := by + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal false (Real.exp y) Q q a hQ hq hqQ ha hlog u v hu huv hshort c (hsmall false (Real.exp y)) + rw [primeGiantMeasure_integral P Q q a u v (by linarith)] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hright (x : ℝ) : ‖complexPrimeInterval q b r s (H x) - ∫ y, H x y ∂ν‖ ≤ err := by + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal true (Real.exp x) Q q b hQ hq hqQ hb hlog r s hr hrs hrshort c (hsmall true (Real.exp x)) + rw [primeGiantMeasure_integral P Q q b r s (by linarith)] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hmeas := measurable_exp_pair_mul + (movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal) + (measurable_movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal) c + have hnorm (x y : ℝ) : ‖H x y‖ ≤ ‖c‖ * + (((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) ^ 2 * + (giantOuterScalar diagonal * (2 * B + D * (Real.exp 2 - 1)) ^ 2 * (if diagonal then 1 + Real.exp 2 else 2))) := by + dsimp only [H, movingOuterKernel] + rw [norm_mul, norm_mul] + apply mul_le_mul_of_nonneg_left _ (norm_nonneg c) + exact mul_le_mul (movingRealKernelPair_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ _ _) + (giantOuterWeight_norm φ Jleft Jright B D hB hD hφ hlip hout diagonal _ _) (norm_nonneg _) (by positivity) + have hpair := prime_pair_integral_transport q a b u v r s μ ν H hmeas _ hnorm err err hleft hright + have hmass : μ.real Set.univ ≤ 2 := primeGiantMeasure_mass_le_two P Q q a hq u v hu1 huv hshort + apply hpair.trans + have hmul := mul_le_mul_of_nonneg_left hmass (Real.exp_pos (-Real.exp ((125 / 10000 : ℝ) * L))).le + dsimp only [err] at * + nlinarith + +theorem PublishedProgressionInput.moving_outer_joint_mixed_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) + (hf : ∀ b, (T b).Frequencies (· ≠ 0)) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), + (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q a b : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → b.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → ∀ c : ℂ, + 2 * (‖c‖ * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂integerGiantMeasure q J u v‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) * + (reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) + Real.exp (v - J)) := by + filter_upwards [P.moving_outer_kernel_prime_rate n C d, moving_outer_kernel_integer_rate n C d, + eventually_ge_atTop (0 : ℝ)] with L hL hI hL0 + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q a b hQ hq hqQ hb hlog u v r s J hJ huv hshort hr hrs hrshort c hbudget + have hL := hL σ + have hI := hI σ + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let H := fun x y => c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + let μ := integerGiantMeasure q J u v + let ν := primeGiantMeasure P Q q b r s + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hr1 : 1 ≤ r := (Real.one_le_exp (by positivity)).trans hr + have : IsFiniteMeasure μ := finite_integerGiantMeasure q J u v + have : IsFiniteMeasure ν := finite_primeGiantMeasure P Q q b r s (by linarith) + have hscalar : 0 ≤ giantOuterScalar diagonal := by cases diagonal <;> simp [giantOuterScalar, (Real.exp_pos _).le] + have hsmall (coord : Bool) (fixed : ℝ) : + 2 * (‖c‖ * giantOuterScalar diagonal) * smoothPolynomialBudget + (movingOuterPolynomialFactors value T (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip diagonal) ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) := + (mul_le_mul_of_nonneg_left (movingOuterPolynomialFactors_budget value T _ _ ψ X lo hi V hlo hhi hV + φ G Jleft Jright B D hB hD hφ hlip diagonal) (by positivity)).trans hbudget + have hleft (y : ℝ) : ‖complexIntegerInterval q a u v J (fun x => H x y) - ∫ x, H x y ∂μ‖ ≤ err := by + have h := hI value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal false (Real.exp y) q a (by omega) u v J huv hJ c (hsmall false (Real.exp y)) + rw [integerGiantMeasure_integral q J u v] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hright (x : ℝ) : ‖complexPrimeInterval q b r s (H x) - ∫ y, H x y ∂ν‖ ≤ err := by + have h := hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal true (Real.exp x) Q q b hQ hq hqQ hb hlog r s hr hrs hrshort c (hsmall true (Real.exp x)) + rw [primeGiantMeasure_integral P Q q b r s (by linarith)] + simpa only [H, err, movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] using h + have hmeas := measurable_exp_pair_mul + (movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal) + (measurable_movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal) c + have hnorm (x y : ℝ) : ‖H x y‖ ≤ ‖c‖ * + (((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) ^ 2 * + (giantOuterScalar diagonal * (2 * B + D * (Real.exp 2 - 1)) ^ 2 * (if diagonal then 1 + Real.exp 2 else 2))) := by + dsimp only [H, movingOuterKernel] + rw [norm_mul, norm_mul] + apply mul_le_mul_of_nonneg_left _ (norm_nonneg c) + exact mul_le_mul (movingRealKernelPair_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ _ _) + (giantOuterWeight_norm φ Jleft Jright B D hB hD hφ hlip hout diagonal _ _) (norm_nonneg _) (by positivity) + have hpair := mixed_pair_integral_transport q a b u v r s J μ ν H hmeas _ hnorm err err hleft hright + have hmass : μ.real Set.univ ≤ Real.exp (v - J) := + integerGiantMeasure_mass_le q (by omega) J u v huv hshort + apply hpair.trans + have hmul := mul_le_mul_of_nonneg_left hmass (Real.exp_pos (-Real.exp ((125 / 10000 : ℝ) * L))).le + dsimp only [err] at * + nlinarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterKernel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4d787941e743843782f689b435a933ec6829621 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterKernel.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.Ostmann.Construction.GiantOuterFactors +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPair + +namespace OAI + +/-! # The two-history kernel with its original outer priors and diagonal ratio -/ + +namespace Ostmann +open MeasureTheory +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +noncomputable def giantOuterWeight (φ : ℝ → ℝ) (Jleft Jright : ℝ) (diagonal : Bool) + (L R : ℝ) : ℂ := + (positiveLogCutoff φ Jleft L : ℂ) * (positiveLogCutoff φ Jright R : ℂ) * + (if diagonal then ((Real.exp Jright / R : ℝ) : ℂ) else 1) + +noncomputable def movingOuterKernel {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (L R : ℝ) : ℂ := + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G L R * + giantOuterWeight φ Jleft Jright diagonal L R + +theorem giantOuterWeight_polynomial (L R : Polynomial ℝ) (φ : ℝ → ℝ) + (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (x : ℝ) : + giantOuterWeight φ Jleft Jright diagonal (L.eval x) (R.eval x) = + (giantOuterScalar diagonal : ℂ) * + smoothPolynomialWeight (giantOuterFactors L R φ Jleft Jright B D hB hD hφ hlip diagonal) x := + (giantOuterFactors_value L R φ Jleft Jright B D hB hD hφ hlip hout diagonal x).symm + +theorem giantOuterWeight_norm (φ : ℝ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (L R : ℝ) : + ‖giantOuterWeight φ Jleft Jright diagonal L R‖ ≤ + giantOuterScalar diagonal * (2 * B + D * (Real.exp 2 - 1)) ^ 2 * + (if diagonal then 1 + Real.exp 2 else 2) := by + have hs : 0 ≤ giantOuterScalar diagonal := by cases diagonal <;> simp [giantOuterScalar, (Real.exp_pos _).le] + have hv := giantOuterWeight_polynomial (Polynomial.C L) (Polynomial.C R) φ Jleft Jright B D + hB hD hφ hlip hout diagonal 0 + simp only [Polynomial.eval_C] at hv + rw [hv, norm_mul, Complex.norm_real, Real.norm_of_nonneg hs] + have h := mul_le_mul_of_nonneg_left (smoothPolynomialWeight_norm + (giantOuterFactors (Polynomial.C L) (Polynomial.C R) φ Jleft Jright B D hB hD hφ hlip diagonal) 0) hs + rw [giantOuterFactors_budget] at h + simpa only [mul_assoc] using h + +theorem measurable_giantOuterWeight (φ : ℝ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) : + Measurable (fun z : ℝ × ℝ => giantOuterWeight φ Jleft Jright diagonal z.1 z.2) := by + have hc (J : ℝ) : Measurable (fun x => (positiveLogCutoff φ J x : ℂ)) := by + have he (x : ℝ) := logCutoffPolynomialFactor_value Polynomial.X φ J B D hB hD hφ hlip hout x + simp only [Polynomial.eval_X] at he + exact ((logCutoffPolynomialFactor Polynomial.X φ J B D hB hD hφ hlip).continuous_value.congr he).measurable + have hratio : Measurable (fun z : ℝ × ℝ => if diagonal then ((Real.exp Jright / z.2 : ℝ) : ℂ) else 1) := by + cases diagonal + · exact measurable_const + · exact Complex.continuous_ofReal.measurable.comp (measurable_const.div measurable_snd) + exact ((hc Jleft).comp measurable_fst |>.mul ((hc Jright).comp measurable_snd)).mul hratio + +theorem measurable_movingOuterKernel {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) : + Measurable (fun z : ℝ × ℝ => movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal z.1 z.2) := + (measurable_movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout).mul + (measurable_giantOuterWeight φ Jleft Jright B D hB hD hφ hlip hout diagonal) + +theorem movingOuterKernel_slice_polynomial {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal coord : Bool) (fixed z : ℝ) : + let W := fun b => movingSmoothPolynomialFactors value (T b) + (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + let O := giantOuterFactors (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + φ Jleft Jright B D hB hD hφ hlip diagonal + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal + (movingRealPair coord fixed z false) (movingRealPair coord fixed z true) = + ((giantOuterScalar diagonal : ℂ) * + (movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair coord fixed z) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair coord fixed z)))) * + smoothPolynomialWeight (Fin.append (pairedPolynomialFactors (W false) (W true)) O) z := by + dsimp only + unfold movingOuterKernel + rw [movingRealKernelPair_slice_polynomial value T nodes ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout] + have hv := giantOuterWeight_polynomial (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + φ Jleft Jright B D hB hD hφ hlip hout diagonal z + rw [(movingCoordinate_eval coord fixed z).1, (movingCoordinate_eval coord fixed z).2] at hv + rw [hv] + simp only [smoothPolynomialWeight, Fin.prod_univ_add, Fin.append_left, Fin.append_right] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterKernelRates.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterKernelRates.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4598c008cb9f06b5322c00197b020ca98f158f1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterKernelRates.lean @@ -0,0 +1,134 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterSlices + +namespace OAI + +/-! # Prime slice comparison with both outer priors and the diagonal ratio -/ + +namespace Ostmann +universe u +open Filter MeasureTheory +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +theorem PublishedProgressionInput.moving_outer_kernel_prime_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) + (hf : ∀ b, (T b).Frequencies (· ≠ 0)) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal coord : Bool) (fixed : ℝ) + (Q q a : ℕ), 2 ≤ Q → 1 ≤ q → q ≤ Q → a.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v : ℝ, Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → ∀ c : ℂ, + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := movingOuterPolynomialFactors value T (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip diagonal + 2 * (‖c‖ * giantOuterScalar diagonal) * smoothPolynomialBudget W ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + ‖complexPrimeInterval q a u v (fun y => c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G + Jleft Jright diagonal (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) - + ∫ y in Set.Ioc u v, (c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [P.root_integral_prime_rate C d (2 * movingKernelRootBudget n)] with L hL + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal coord fixed Q q a hQ hq hqQ ha hlog u v hu huv hshort c + dsimp only + intro hbudget + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := movingOuterPolynomialFactors value T (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip diagonal + let gate := fun x => movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair coord fixed x) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair coord fixed x)) + let w := fun x => c * (giantOuterScalar diagonal : ℂ) * gate x + have hscalar : 0 ≤ giantOuterScalar diagonal := by cases diagonal <;> simp [giantOuterScalar, (Real.exp_pos _).le] + obtain ⟨S, hS, hroots, hconst⟩ := movingOuterKernel_slice_roots value hvalue childBound pivotBound + T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip diagonal coord fixed + have hw (x : ℝ) : ‖w x‖ ≤ ‖c‖ * giantOuterScalar diagonal := by + have hg : ‖gate x‖ ≤ 1 := by + dsimp only [gate] + rw [norm_mul, Complex.norm_conj] + exact (mul_le_mul (movingRealGateWeight_norm value (T false) (nodes false) X lo hi _) + (movingRealGateWeight_norm value (T true) (nodes true) X lo hi _) (norm_nonneg _) (by norm_num)).trans_eq (one_mul 1) + dsimp only [w] + rw [norm_mul, norm_mul, Complex.norm_real, Real.norm_of_nonneg hscalar] + exact mul_le_of_le_one_right (mul_nonneg (norm_nonneg _) hscalar) hg + have hc (x y : ℝ) (hcode : rootCellCode S x = rootCellCode S y) : w x = w y := + congrArg (c * (giantOuterScalar diagonal : ℂ) * ·) (hconst x y hcode) + have he (z : ℝ) : w z * smoothPolynomialWeight W z = + c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal + (movingRealPair coord fixed z false) (movingRealPair coord fixed z true) := by + rw [movingOuterKernel_slice_polynomial value T nodes ψ X lo hi hlo hhi φ G + Jleft Jright B D hB hD hφ hlip hout diagonal coord fixed z] + dsimp only [w, W, gate, movingOuterPolynomialFactors] + ring + have h := hL Q q a hQ hq hqQ ha hlog u v hu huv hshort _ W S hS hroots w + (‖c‖ * giantOuterScalar diagonal) (mul_nonneg (norm_nonneg _) hscalar) hw hc hbudget + simpa only [he] using h + +theorem moving_outer_kernel_integer_bound {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal coord : Bool) (fixed : ℝ) + (q a : ℕ) (hq : 0 < q) (u v J : ℝ) (huv : u ≤ v) (c : ℂ) : + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := movingOuterPolynomialFactors value T (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip diagonal + ‖complexIntegerInterval q a u v J (fun y => c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G + Jleft Jright diagonal (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) - + ∫ y in Set.Ioc u v, (c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal + (movingRealPair coord fixed (Real.exp y) false) (movingRealPair coord fixed (Real.exp y) true)) * + (integerLogDensity q J y : ℂ)‖ ≤ + 4 * ((2 * movingKernelRootBudget n : ℕ) : ℝ) * (‖c‖ * giantOuterScalar diagonal) * + smoothPolynomialBudget W * Real.exp (-J) := by + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := movingOuterPolynomialFactors value T (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip diagonal + let gate := fun x => movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair coord fixed x) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair coord fixed x)) + let w := fun x => c * (giantOuterScalar diagonal : ℂ) * gate x + have hscalar : 0 ≤ giantOuterScalar diagonal := by cases diagonal <;> simp [giantOuterScalar, (Real.exp_pos _).le] + obtain ⟨S, hS, hroots, hconst⟩ := movingOuterKernel_slice_roots value hvalue childBound pivotBound + T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip diagonal coord fixed + have hw (x : ℝ) : ‖w x‖ ≤ ‖c‖ * giantOuterScalar diagonal := by + have hg : ‖gate x‖ ≤ 1 := by + dsimp only [gate] + rw [norm_mul, Complex.norm_conj] + exact (mul_le_mul (movingRealGateWeight_norm value (T false) (nodes false) X lo hi _) + (movingRealGateWeight_norm value (T true) (nodes true) X lo hi _) (norm_nonneg _) (by norm_num)).trans_eq (one_mul 1) + dsimp only [w] + rw [norm_mul, norm_mul, Complex.norm_real, Real.norm_of_nonneg hscalar] + exact mul_le_of_le_one_right (mul_nonneg (norm_nonneg _) hscalar) hg + have hc (x y : ℝ) (hcode : rootCellCode S x = rootCellCode S y) : w x = w y := + congrArg (c * (giantOuterScalar diagonal : ℂ) * ·) (hconst x y hcode) + have he (z : ℝ) : w z * smoothPolynomialWeight W z = + c * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal + (movingRealPair coord fixed z false) (movingRealPair coord fixed z true) := by + rw [movingOuterKernel_slice_polynomial value T nodes ψ X lo hi hlo hhi φ G + Jleft Jright B D hB hD hφ hlip hout diagonal coord fixed z] + dsimp only [w, W, gate, movingOuterPolynomialFactors] + ring + have h := root_integral_integer_bound q a hq u v J huv W S hroots w + (‖c‖ * giantOuterScalar diagonal) (mul_nonneg (norm_nonneg _) hscalar) hw hc + simp only [he] at h + apply h.trans + have hK : ((S.card + 1 : ℕ) : ℝ) ≤ ((2 * movingKernelRootBudget n : ℕ) : ℝ) := by exact_mod_cast hS + have hn : 0 ≤ 4 * (‖c‖ * giantOuterScalar diagonal) * smoothPolynomialBudget W * Real.exp (-J) := + mul_nonneg (mul_nonneg (mul_nonneg (by norm_num) (mul_nonneg (norm_nonneg _) hscalar)) + (smoothPolynomialBudget_nonneg W)) (Real.exp_pos _).le + calc + _ = ((S.card + 1 : ℕ) : ℝ) * + (4 * (‖c‖ * giantOuterScalar diagonal) * smoothPolynomialBudget W * Real.exp (-J)) := by ring + _ ≤ ((2 * movingKernelRootBudget n : ℕ) : ℝ) * + (4 * (‖c‖ * giantOuterScalar diagonal) * smoothPolynomialBudget W * Real.exp (-J)) := + mul_le_mul_of_nonneg_right hK hn + _ = _ := by ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterNormBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterNormBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..bdb418bec7e4ccebf71c9b15f0169392ba890d3b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterNormBudget.lean @@ -0,0 +1,46 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterJointComparison + +namespace OAI + +/-! # A uniform norm budget for the full giant kernel -/ + +namespace Ostmann +open scoped Classical ComplexConjugate SchwartzMap + +theorem movingOuterKernel_norm_variation {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (L R : ℝ) : + ‖movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal L R‖ ≤ + giantOuterScalar diagonal * movingOuterVariationBudget ψ V lo hi n B D diagonal := by + have hs : 0 ≤ giantOuterScalar diagonal := by cases diagonal <;> simp [giantOuterScalar, (Real.exp_pos _).le] + let W := movingOuterPolynomialFactors value T (movingCoordinateLeft false R) (movingCoordinateRight false R) + ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip diagonal + let g := movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair false R L) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair false R L)) + have hg : ‖g‖ ≤ 1 := by + dsimp only [g] + rw [norm_mul, Complex.norm_conj] + exact (mul_le_mul (movingRealGateWeight_norm value (T false) (nodes false) X lo hi _) + (movingRealGateWeight_norm value (T true) (nodes true) X lo hi _) (norm_nonneg _) (by norm_num)).trans_eq (one_mul 1) + have he := movingOuterKernel_slice_polynomial value T nodes ψ X lo hi hlo hhi φ G + Jleft Jright B D hB hD hφ hlip hout diagonal false R L + simp only [movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] at he + have he' : movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal L R = + ((giantOuterScalar diagonal : ℂ) * g) * smoothPolynomialWeight W L := he + rw [he', norm_mul, norm_mul, Complex.norm_real, Real.norm_of_nonneg hs] + calc + _ ≤ (giantOuterScalar diagonal * 1) * smoothPolynomialBudget W := + mul_le_mul (mul_le_mul_of_nonneg_left hg hs) (smoothPolynomialWeight_norm W L) + (norm_nonneg _) (by positivity) + _ ≤ _ := by + rw [mul_one] + exact mul_le_mul_of_nonneg_left + (movingOuterPolynomialFactors_budget value T _ _ ψ X lo hi V hlo hhi hV φ G Jleft Jright B D hB hD hφ hlip diagonal) hs + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterResidueComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterResidueComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc526f9851b9eef90d13d8aa1420e9c09b3f1085 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterResidueComparison.lean @@ -0,0 +1,124 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterJointComparison +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePairResidues +import OAI.NumberTheory.Ostmann.Construction.GiantResidueSumBound + +namespace OAI + +/-! # All residue pairs with both original outer giant priors -/ + +namespace Ostmann +universe u +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_outer_prime_residue_sum_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + (∀ a ∈ reducedResidues q, ∀ b ∈ reducedResidues q, + 2 * (‖c a b‖ * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖(∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c a b * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y)))) - + (∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + ∫ x, ∫ y, c a b * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂primeGiantMeasure P Q q a u v)‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_outer_joint_prime_rate n C d, + giant_residue_sum_error_rate (Real.exp 1 + 2) (by positivity)] with L hL hR + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c hbudget + have hL := hL σ + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hm (b : ℕ) : reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) ≤ Real.exp 1 := + (reciprocalPrimeInterval_le_exp q b r s).trans (Real.exp_le_exp.mpr (by linarith)) + have hpoint (b : ℕ) (hb : b ∈ reducedResidues q) (a : ℕ) (ha : a ∈ reducedResidues q) : + ‖complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c a b * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c a b * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂primeGiantMeasure P Q q a u v‖ ≤ err * (Real.exp 1 + 2) := by + exact (hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q a b hQ hq hqQ (Finset.mem_filter.mp ha).2 (Finset.mem_filter.mp hb).2 hlog + u v r s hu huv hshort hr hrs hrshort (c a b) (hbudget a ha b hb)).trans + (mul_le_mul_of_nonneg_left (by linarith [hm b]) (Real.exp_pos _).le) + apply (finite_pair_comparison (reducedResidues q) (reducedResidues q) _ _ _ hpoint).trans + have hc : ((reducedResidues q).card : ℝ) ≤ q := Nat.cast_le.mpr (reducedResidues_card_le q) + calc + _ ≤ (q : ℝ) * q * (err * (Real.exp 1 + 2)) := by gcongr + _ = (q : ℝ) ^ 2 * (Real.exp 1 + 2) * err := by ring + _ ≤ _ := hR q (by omega) hqlog + +theorem PublishedProgressionInput.moving_outer_mixed_residue_sum_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + (∀ a ∈ Finset.range q, ∀ b ∈ reducedResidues q, + 2 * (‖c a b‖ * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖(∑ b ∈ reducedResidues q, ∑ a ∈ Finset.range q, + complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c a b * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y)))) - + (∑ b ∈ reducedResidues q, ∑ a ∈ Finset.range q, + ∫ x, ∫ y, c a b * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂integerGiantMeasure q J u v)‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_outer_joint_mixed_rate n C d, + giant_residue_sum_error_rate (2 * Real.exp 1) (by positivity)] with L hL hR + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q hQ hq hqQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog c hbudget + have hL := hL σ + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hm (b : ℕ) : reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) ≤ Real.exp 1 := + (reciprocalPrimeInterval_le_exp q b r s).trans (Real.exp_le_exp.mpr (by linarith)) + have hpoint (b : ℕ) (hb : b ∈ reducedResidues q) (a : ℕ) (ha : a ∈ Finset.range q) : + ‖complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c a b * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c a b * movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂integerGiantMeasure q J u v‖ ≤ err * (2 * Real.exp 1) := by + exact (hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q a b hQ hq hqQ (Finset.mem_filter.mp hb).2 hlog + u v r s J hJ huv hshort hr hrs hrshort (c a b) (hbudget a ha b hb)).trans + (mul_le_mul_of_nonneg_left (by + have hmass : Real.exp (v - J) ≤ Real.exp 1 := Real.exp_le_exp.mpr (by linarith) + linarith [hm b]) (Real.exp_pos _).le) + apply (finite_pair_comparison (reducedResidues q) (Finset.range q) _ _ _ hpoint).trans + have hc : ((reducedResidues q).card : ℝ) ≤ q := Nat.cast_le.mpr (reducedResidues_card_le q) + calc + _ ≤ (q : ℝ) * q * (err * (2 * Real.exp 1)) := by + simp only [Finset.card_range] + gcongr + _ = (q : ℝ) ^ 2 * (2 * Real.exp 1) * err := by ring + _ ≤ _ := hR q (by omega) hqlog + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterSlices.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterSlices.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbd293b1b9040ce755b9f1aa48d6cec98ae149be --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterSlices.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterKernel + +namespace OAI + +/-! # Root and variation bounds with the original outer giant priors -/ + +namespace Ostmann +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +theorem smoothPolynomialBudget_append {n m : ℕ} (F : Fin n → ClippedPolynomialFactor) + (G : Fin m → ClippedPolynomialFactor) : + smoothPolynomialBudget (Fin.append F G) = smoothPolynomialBudget F * smoothPolynomialBudget G := by + unfold smoothPolynomialBudget + rw [Fin.prod_univ_add] + simp only [Fin.append_left, Fin.append_right] + +noncomputable def movingOuterPolynomialFactors {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (diagonal : Bool) := + Fin.append (pairedPolynomialFactors + (movingSmoothPolynomialFactors value (T false) L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (movingSmoothPolynomialFactors value (T true) L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip)) + (giantOuterFactors L R φ Jleft Jright B D hB hD hφ hlip diagonal) + +theorem movingOuterPolynomialFactors_budget {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (diagonal : Bool) : + smoothPolynomialBudget (movingOuterPolynomialFactors value T L R ψ X lo hi hlo hhi φ G + Jleft Jright B D hB hD hφ hlip diagonal) ≤ + (movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 * + ((2 * B + D * (Real.exp 2 - 1)) ^ 2 * (if diagonal then 1 + Real.exp 2 else 2)) := by + have houter : 0 ≤ (2 * B + D * (Real.exp 2 - 1)) ^ 2 * + (if diagonal then 1 + Real.exp 2 else 2) := by split <;> positivity + rw [movingOuterPolynomialFactors, smoothPolynomialBudget_append, giantOuterFactors_budget] + exact mul_le_mul_of_nonneg_right + (movingPairedSmoothPolynomialFactors_budget value T L R ψ X lo hi V hlo hhi hV φ G B D hB hD hφ hlip) houter + +theorem giantOuterFactors_slice_no_roots (φ : ℝ → ℝ) (Jleft Jright B D : ℝ) + (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (diagonal coord : Bool) (fixed : ℝ) (i : Fin 3) : + ((giantOuterFactors (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + φ Jleft Jright B D hB hD hφ hlip diagonal i).polynomial.derivative).roots = 0 := by + fin_cases i <;> cases coord <;> cases diagonal <;> + simp [giantOuterFactors, movingCoordinateLeft, movingCoordinateRight, + giantReciprocalFactor, reciprocalPolynomialFactor, logCutoffPolynomialFactor, + Polynomial.derivative_mul, Polynomial.roots_C] + +theorem movingOuterKernel_slice_roots {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (diagonal coord : Bool) (fixed : ℝ) : + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let W := movingOuterPolynomialFactors value T (movingCoordinateLeft coord fixed) (movingCoordinateRight coord fixed) + ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip diagonal + ∃ S : Finset ℝ, S.card + 1 ≤ 2 * movingKernelRootBudget n ∧ + (∀ i r, r ∈ (W i).polynomial.derivative.roots → r ∈ S) ∧ + (∀ x y, rootCellCode S x = rootCellCode S y → + (movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair coord fixed x) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair coord fixed x))) = + (movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair coord fixed y) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair coord fixed y)))) := by + dsimp only + obtain ⟨S, hS, hroots, hconst⟩ := movingRealKernelPair_slice_root_data value hvalue childBound pivotBound + T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip coord fixed + refine ⟨S, hS, ?_, hconst⟩ + intro i r + refine Fin.addCases ?_ ?_ i + · intro j hj + apply hroots j r + simpa only [movingOuterPolynomialFactors, Fin.append_left] using hj + · intro j hj + simp only [movingOuterPolynomialFactors, Fin.append_right, + giantOuterFactors_slice_no_roots φ Jleft Jright B D hB hD hφ hlip diagonal coord fixed j, + Multiset.notMem_zero] at hj + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterVariationScale.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterVariationScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3e3fd1393cb73035fc9cb876e8a9e2fd2a387f1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOuterVariationScale.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantVariation +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterJointComparison + +namespace OAI + +/-! # The moving-window budget for the original outer-prior kernel -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- The two original outer factors and the diagonal reciprocal ratio cost +only a fixed constant, uniformly in the giant cell centers. -/ +theorem movingOuterVariationBudget_bound (ψ : 𝓢(ℝ, ℂ)) (V lo hi : ℝ) + (n : ℕ) (B D : ℝ) (diagonal : Bool) : + 2 * giantOuterScalar diagonal * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + (2 * Real.exp 1 * (2 * B + D * (Real.exp 2 - 1)) ^ 2 * (3 + Real.exp 2)) * + (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 := by + have he : (1 : ℝ) ≤ Real.exp 1 := Real.one_le_exp (by norm_num) + have hcoef : 2 * giantOuterScalar diagonal * (if diagonal then 1 + Real.exp 2 else 2) ≤ + 2 * Real.exp 1 * (3 + Real.exp 2) := by + have hp := mul_nonneg (Real.exp_nonneg (1 : ℝ)) (Real.exp_nonneg (2 : ℝ)) + cases diagonal <;> simp only [giantOuterScalar, Bool.false_eq_true, ite_false, ite_true] <;> + nlinarith only [he, hp, Real.exp_pos (1 : ℝ)] + have hh := mul_le_mul_of_nonneg_right hcoef + (mul_nonneg (sq_nonneg (2 * B + D * (Real.exp 2 - 1))) + (sq_nonneg (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)))) + convert hh using 1 <;> (try unfold movingOuterVariationBudget) <;> ring + +/-- Actual spectator growth, bounded harmonic normalizers and every moving +bottom window fit the common giant comparison budget. -/ +theorem moving_outer_variation_scale (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin B D H : ℝ) (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hH : 0 ≤ H) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ L : ℝ, 1 ≤ L → + let m := spectatorBulkCount k L + ∀ (p : Fin m → ℕ) (V lo hi amp : ℝ) (diagonal : Bool), + 0 ≤ V → V ≤ Real.exp (A * m) → lo ≤ hi → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 0 ≤ amp → amp ≤ 4 * (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 * Real.exp (H * L + H * L * Real.exp ((12 / 1000 : ℝ) * L)) → + 2 * (amp * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ 2 + C * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + obtain ⟨C₀, hC₀, hbase⟩ := movingPattern_pointwise_cost_budget ψ n r₀ k A Wwin B D hA hWwin + let F := 2 * Real.exp 1 * (2 * B + D * (Real.exp 2 - 1)) ^ 2 * (3 + Real.exp 2) + have hF : 0 ≤ F := by dsimp only [F]; positivity + let C := C₀ + H + F + have hC : C₀ ≤ C := by dsimp only [C]; linarith only [hH, hF] + refine ⟨C, hC₀.trans hC, ?_⟩ + intro L hL + dsimp only + intro p V lo hi amp diagonal hV hVA hhi hwidth hp hamp hampup + have hL0 : 0 ≤ L := le_trans (by norm_num) hL + have houter := movingOuterVariationBudget_bound ψ V lo hi n B D diagonal + have hbase' := hbase L hL p V lo hi hV hVA hhi hwidth hp + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hFE : F ≤ Real.exp (F * L) := by + have hh := mul_le_mul_of_nonneg_left hL hF + linarith only [hh, Real.add_one_le_exp (F * L)] + have hbound : + 2 * (amp * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C₀ * L ^ 2 + C₀ * L * Real.exp ((1 / 1000 : ℝ) * L)) * + Real.exp ((H + F) * L + H * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + calc + _ = amp * (2 * giantOuterScalar diagonal * movingOuterVariationBudget ψ V lo hi n B D diagonal) := by ring + _ ≤ amp * (F * W) := mul_le_mul_of_nonneg_left houter hamp + _ ≤ (4 * (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 * Real.exp (H * L + H * L * Real.exp ((12 / 1000 : ℝ) * L))) * (F * W) := + mul_le_mul_of_nonneg_right hampup (mul_nonneg hF (sq_nonneg _)) + _ = (4 * (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 * W) * (F * Real.exp (H * L + H * L * Real.exp ((12 / 1000 : ℝ) * L))) := by ring + _ ≤ Real.exp (C₀ * L ^ 2 + C₀ * L * Real.exp ((1 / 1000 : ℝ) * L)) * + (Real.exp (F * L) * Real.exp (H * L + H * L * Real.exp ((12 / 1000 : ℝ) * L))) := + mul_le_mul hbase' (mul_le_mul_of_nonneg_right hFE (Real.exp_nonneg _)) + (mul_nonneg hF (Real.exp_nonneg _)) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 2; ring + apply hbound.trans + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + have hLsq : L ≤ L ^ 2 := by nlinarith only [hL] + have hpoly := mul_le_mul_of_nonneg_left hLsq (add_nonneg hH hF) + have hscale : Real.exp ((1 / 1000 : ℝ) * L) ≤ Real.exp ((12 / 1000 : ℝ) * L) := + Real.exp_le_exp.mpr (by linarith only [hL0]) + have hterm := mul_le_mul_of_nonneg_left hscale + (mul_nonneg (le_trans (by norm_num) hC₀) hL0) + have hextra := mul_nonneg (mul_nonneg hF hL0) + (Real.exp_nonneg ((12 / 1000 : ℝ) * L)) + dsimp only [C] at ⊢ + nlinarith only [hpoly, hterm, hextra] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOutsideResidues.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOutsideResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab5bb3f2645eaa6d30fd6250229cfacc7f6ec4dd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingOutsideResidues.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingModularSpectator + +namespace OAI + +/-! # Outside giant-unit tests in spectator coordinates -/ + +namespace Ostmann +open scoped Classical + +def movingSignedOutsideUnits {σ : Type*} (value : σ → ℕ) (M : ℤ) : + {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → Prop + | _, .leaf _ _, x, y => IsCoprime x M ∧ IsCoprime y M + | _, .node s CL CR U left right, x, y => + let p := (MovingSlotData.step s CL CR U left right false).signedPivot value x y + (IsCoprime x M ∧ IsCoprime y M) ∧ + movingSignedOutsideUnits value M left p x ∧ movingSignedOutsideUnits value M right p y + +theorem movingSignedAuxiliaryUnits_split {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (x y : ℤ) : + movingSignedAuxiliaryUnits value outside T x y ↔ + movingSignedFrequencyUnits value T x y ∧ movingSignedOutsideUnits value outside.prod T x y := by + induction T generalizing x y with + | leaf => + simp only [movingSignedAuxiliaryUnits, movingSignedFrequencyUnits, + movingSignedOutsideUnits, movingAuxiliaryLocalUnits, movingFrequencyLocalUnits] + tauto + | node s CL CR U left right ihL ihR => + simp only [movingSignedAuxiliaryUnits, movingSignedFrequencyUnits, + movingSignedOutsideUnits, movingAuxiliaryLocalUnits, movingFrequencyLocalUnits, ihL, ihR] + tauto + +def movingModularGiantUnits {σ : Type*} (value : σ → ℕ) (q : ℕ) [Fact q.Prime] : + {n : ℕ} → MovingSlotData σ n → ZMod q → ZMod q → Prop + | _, .leaf _ _, x, y => x ≠ 0 ∧ y ≠ 0 + | _, .node s CL CR U left right, x, y => + let p := (MovingSlotData.step s CL CR U left right false).modularPivot value q x y + (x ≠ 0 ∧ y ≠ 0) ∧ + movingModularGiantUnits value q left p x ∧ movingModularGiantUnits value q right p y + +theorem movingModularGiantUnits_local {σ : Type*} (value : σ → ℕ) + (q : ℕ) [Fact q.Prime] {n : ℕ} (T : MovingSlotData σ n) (x y : ZMod q) + (h : movingModularGiantUnits value q T x y) : x ≠ 0 ∧ y ≠ 0 := by + cases T with + | leaf => exact h + | node => exact h.1 + +theorem movingSignedOutsideUnits_modular {σ : Type*} (value : σ → ℕ) + (q : ℕ) [Fact q.Prime] {n : ℕ} (T : MovingSlotData σ n) + (hden : T.ModularDenominators value q) (x y : ℤ) (hI : T.SignedIntegral value x y) : + movingSignedOutsideUnits value q T x y ↔ movingModularGiantUnits value q T x y := by + have hlocal (z : ℤ) : IsCoprime z (q : ℤ) ↔ (z : ZMod q) ≠ 0 := by + rw [isCoprime_comm, ← ZMod.coe_int_isUnit_iff_isCoprime, isUnit_iff_ne_zero] + induction T generalizing x y with + | leaf => exact and_congr (hlocal x) (hlocal y) + | node s CL CR U left right ihL ihR => + simp only [movingSignedOutsideUnits, movingModularGiantUnits, + (MovingSlotData.step s CL CR U left right false).modularPivot_of_signedIntegral + value q hden.1 hden.2.1 x y hI.1, hlocal, + ihL hden.2.2.1 _ _ hI.2.1, ihR hden.2.2.2 _ _ hI.2.2] + +/-- With the original zero convention, a nonzero spectator coefficient +already enforces every outside giant-unit test at that prime. -/ +theorem movingModularSpectator_nonzero_units {σ : Type*} (value : σ → ℕ) + (q : ℕ) [Fact q.Prime] (g : ZMod q → ℂ) (D : (ZMod q)ˣ) (hg0 : g 0 = 0) + {n : ℕ} (T : MovingSlotData σ n) (x y : ZMod q) + (h : movingModularSpectator value q g D T x y ≠ 0) : + movingModularGiantUnits value q T x y := by + induction T generalizing x y with + | leaf s C => + constructor + · intro hx + exact h (by simp [movingModularSpectator, hx, hg0]) + · intro hy + exact h (by simp [movingModularSpectator, hy, hg0]) + | node s CL CR U left right ihL ihR => + let p := (MovingSlotData.step s CL CR U left right false).modularPivot value q x y + have hp : p ≠ 0 := by + intro hp + exact h (by simp only [movingModularSpectator, p, hp, ite_true]) + have hm : movingModularSpectator value q g D left p x * + star (movingModularSpectator value q g D right p y) ≠ 0 := by + simpa only [movingModularSpectator, show + (MovingSlotData.step s CL CR U left right false).modularPivot value q x y ≠ 0 from hp, + ite_false] using h + have hl := ihL p x (mul_ne_zero_iff.mp hm).1 + have hr := ihR p y (by + intro hz + exact (mul_ne_zero_iff.mp hm).2 (by rw [hz, star_zero])) + exact ⟨⟨(movingModularGiantUnits_local value q left p x hl).2, + (movingModularGiantUnits_local value q right p y hr).2⟩, hl, hr⟩ + +theorem movingSignedOutsideUnits_mul {σ : Type*} (value : σ → ℕ) (M N : ℤ) + {n : ℕ} (T : MovingSlotData σ n) (x y : ℤ) : + movingSignedOutsideUnits value (M * N) T x y ↔ + movingSignedOutsideUnits value M T x y ∧ movingSignedOutsideUnits value N T x y := by + induction T generalizing x y with + | leaf => simp only [movingSignedOutsideUnits, IsCoprime.mul_right_iff]; tauto + | node s CL CR U left right ihL ihR => + simp only [movingSignedOutsideUnits, IsCoprime.mul_right_iff, ihL, ihR] + tauto + +theorem movingSignedOutsideUnits_one {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (x y : ℤ) : movingSignedOutsideUnits value 1 T x y := by + induction T generalizing x y with + | leaf => exact ⟨isCoprime_one_right, isCoprime_one_right⟩ + | node s CL CR U left right ihL ihR => + exact ⟨⟨isCoprime_one_right, isCoprime_one_right⟩, ihL _ _, ihR _ _⟩ + +theorem movingSignedOutsideUnits_list {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (x y : ℤ) : + movingSignedOutsideUnits value (outside.prod : ℤ) T x y ↔ + ∀ q ∈ outside, movingSignedOutsideUnits value (q : ℤ) T x y := by + induction outside with + | nil => simp only [List.prod_nil, Nat.cast_one, List.not_mem_nil, IsEmpty.forall_iff, + implies_true, iff_true]; exact movingSignedOutsideUnits_one value T x y + | cons q outside ih => + simp only [List.prod_cons, Nat.cast_mul, movingSignedOutsideUnits_mul, ih, + List.forall_mem_cons] + +theorem movingModularSpectatorProduct_outside_units {σ I : Type*} + (value : σ → ℕ) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (hg0 : ∀ i ∈ S, g i 0 = 0) (outside : List ℕ) + (hcover : ∀ p ∈ outside, ∃ i ∈ S, q i = p) + {n : ℕ} (T : MovingSlotData σ n) (hden : ∀ i ∈ S, T.ModularDenominators value (q i)) + (x y : ℤ) (hI : T.SignedIntegral value x y) + (hz : (∏ i ∈ S, movingModularSpectator value (q i) (g i) (D i) T x y) ≠ 0) : + movingSignedOutsideUnits value (outside.prod : ℤ) T x y := by + apply (movingSignedOutsideUnits_list value outside T x y).mpr + intro p hp + obtain ⟨i, hi, rfl⟩ := hcover p hp + apply (movingSignedOutsideUnits_modular value (q i) T (hden i hi) x y hI).mpr + apply movingModularSpectator_nonzero_units value (q i) (g i) (D i) (hg0 i hi) T x y + exact (Finset.prod_ne_zero_iff.mp hz) i hi + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairAdaptiveSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairAdaptiveSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..9aea9f1851e82706e87ea7758ce075e7c597c7af --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairAdaptiveSupport.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.Ostmann.Tree.PairedFrequencyProjection +import OAI.NumberTheory.Ostmann.Arithmetic.VariableModulusSupport + +namespace OAI + +/-! # Paired adaptive data from the original two moving histories -/ + +namespace Ostmann +open scoped Classical + +noncomputable def movingPairAdaptiveData {σ : Type*} (value : σ → ℕ) + (S : Finset ℤ) (n R : ℕ) (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0) (hR : ∀ s ∈ S, s.natAbs ∣ R) + (small : Bool → TreeLeafTuple (List σ) n) (a : Bool → MovingSampleSlots σ n) + (XL XR : ℕ) : (ZMod (R ^ (n + 2)))ˣ → List (ZMod (R ^ (n + 2)))ˣ → + Option (ArithmeticSplitData (R ^ (n + 2)) × ArithmeticSplitData (R ^ (n + 2))) := + let D := fun b => movingSampleAncestorScheme value S n + (frequencyPairProjection S n b t) (small b) (a b) XL XR + let hs := fun (b : Bool) (i : Fin (2 ^ n - 1)) => hS _ (singleTreeNodeFrequencies_root_mem S n + (frequencyPairProjection S n b t) i.val i.isLt) + let hsr := fun (b : Bool) (i : Fin (2 ^ n - 1)) => hR _ (singleTreeNodeFrequencies_root_mem S n + (frequencyPairProjection S n b t) i.val i.isLt) + compensatedPairData n R n (D false) (D true) + (movingSampleCompensation value n (small false) (a false)) + (movingSampleCompensation value n (small true) (a true)) + (hs false) (hs true) (hsr false) (hsr true) + +theorem movingPairAdaptiveData_frequencies {σ : Type*} (value : σ → ℕ) + (S : Finset ℤ) (n R : ℕ) (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0) (hR : ∀ s ∈ S, s.natAbs ∣ R) + (small : Bool → TreeLeafTuple (List σ) n) (a : Bool → MovingSampleSlots σ n) + (XL XR : ℕ) (total : (ZMod (R ^ (n + 2)))ˣ) (past : List (ZMod (R ^ (n + 2)))ˣ) + (d e : ArithmeticSplitData (R ^ (n + 2))) + (hde : movingPairAdaptiveData value S n R t hS hR small a XL XR total past = some (d, e)) : + d.hasFrequencies (treeNodeFrequencies S n t past.length).1 ∧ + e.hasFrequencies (treeNodeFrequencies S n t past.length).2 := by + by_cases hj : past.length < 2 ^ n - 1 + · have h := compensatedPairData_frequencies n R n + (movingSampleAncestorScheme value S n (frequencyPairProjection S n false t) + (small false) (a false) XL XR) + (movingSampleAncestorScheme value S n (frequencyPairProjection S n true t) + (small true) (a true) XL XR) + (movingSampleCompensation value n (small false) (a false)) + (movingSampleCompensation value n (small true) (a true)) + _ _ _ _ total past hj d e hde + simpa only [movingSampleAncestorScheme, forwardTreeAncestorScheme, treeAncestorScheme, + treeNodeFrequencies_projection, Bool.false_eq_true, ite_false, ite_true] using h + · simp only [movingPairAdaptiveData, compensatedPairData, compensatedAdaptiveData, + hj, dite_false, pairArithmeticData] at hde + cases hde + +/-- Each nonzero original weight forces its own tests; both use precisely +the same bulk tuple. Their paired support is consequently one. -/ +theorem movingPairAdaptiveData_actual_support {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → MovingSlotState σ → ℤ → ℂ) + (E : Bool → MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (S : Finset ℤ) (n R : ℕ) [NeZero (R ^ (n + 2))] (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0) (hR : ∀ s ∈ S, s.natAbs ∣ R) + (small : Bool → TreeLeafTuple (List σ) n) (bulk : TreeLeafTuple (List σ) n) + (a : Bool → MovingSampleSlots σ n) (XL XR : ℕ) + (hsmall : ∀ i, IsCoprime (value i : ℤ) (R : ℤ)) + (y : TreeLeafTuple (ZMod (R ^ (n + 2)))ˣ n) + (hy : treeIntegerResidues (R ^ (n + 2)) n + (treeLeafMap (fun q : ℕ => (q : ℤ)) n (movingSlotValues value n bulk)) y) + (hw : ∀ b, recursiveTransferWeight (movingSlotSystem value childBound pivotBound) (F b) + (movingSlotCutoff value childBound pivotBound (movingGuardedExtra value outside (E b))) n + ⟨n, buildMovingSlotData n (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t)) + (small b) bulk (a b), XL, XR⟩ + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t)) ≠ 0) : + arithmeticLeafSupport n + (movingPairAdaptiveData value S n R t hS hR small a XL XR) y = 1 := by + change arithmeticLeafSupport n + (fun total past => pairArithmeticData + (compensatedAdaptiveData n R n + (movingSampleAncestorScheme value S n (frequencyPairProjection S n false t) + (small false) (a false) XL XR) + (movingSampleCompensation value n (small false) (a false)) _ _ total past) + (compensatedAdaptiveData n R n + (movingSampleAncestorScheme value S n (frequencyPairProjection S n true t) + (small true) (a true) XL XR) + (movingSampleCompensation value n (small true) (a true)) _ _ total past)) y = 1 + rw [arithmeticLeafSupport_pair, + movingSample_adaptive_support value outside childBound pivotBound (F false) (E false) + S n R (frequencyPairProjection S n false t) (fun s hs => ⟨hS s hs, hR s hs⟩) + (small false) bulk (a false) XL XR hsmall y hy (hw false), + movingSample_adaptive_support value outside childBound pivotBound (F true) (E true) + S n R (frequencyPairProjection S n true t) (fun s hs => ⟨hS s hs, hR s hs⟩) + (small true) bulk (a true) XL XR hsmall y hy (hw true), one_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairCoprimeComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairCoprimeComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a0f83ec9ebac6e8467292cd742206c46eeb7dbc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairCoprimeComparison.lean @@ -0,0 +1,127 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairHaarComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairNormBudget +import OAI.NumberTheory.Ostmann.Construction.GiantCoprimeRates +import OAI.NumberTheory.Ostmann.Construction.GiantModulusCutoff + +namespace OAI + +/-! # Coprime top giants under the literal prime and integer laws -/ + +namespace Ostmann +universe u v +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_pair_coprime_prime_haar_rate_uniform (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * A * (movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + if (⌊Real.exp x⌋₊).Coprime ⌊Real.exp y⌋₊ then + c (⌊Real.exp x⌋₊ % q) (⌊Real.exp y⌋₊ % q) * + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ + else 0)) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_pair_prime_haar_rate_uniform n C d, + prime_pair_coprime_removal_rate C d, eventually_gt_atTop (0 : ℝ)] with L hL hR hL0 + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c A hA0 hA hbudget + have : NeZero q := ⟨by omega⟩ + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let H := fun x y => movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + let F0 := fun x y : ℕ => c (x % q) (y % q) * + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G x y + let K := A * (movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hv : 0 ≤ (movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 := sq_nonneg _ + have hK0 : 0 ≤ K := mul_nonneg hA0 hv + have hK : K ≤ Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + calc + K ≤ 2 * K := by linarith + _ = 2 * A * (movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 := by ring + _ ≤ _ := hbudget + have hnorm (x y : ℕ) : ‖F0 x y‖ ≤ K := by + dsimp only [F0] + rw [norm_mul] + exact mul_le_mul (hA _ (Nat.mod_lt _ (by omega)) _ (Nat.mod_lt _ (by omega))) + (movingRealKernelPair_norm_variation value T nodes ψ X lo hi V hlo hhi hV φ G B D + hB hD hφ hlip hout x y) (norm_nonneg _) hA0 + have hremove := hR u v r s K hu hrshort hK0 hK F0 (fun x _ y _ => hnorm x y) + have h := hL σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D + hB hD hφ hlip hout V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c (by + intro a ha b hb + have ha0 := Finset.mem_range.mp (Finset.mem_filter.mp ha).1 + have hb0 := Finset.mem_range.mp (Finset.mem_filter.mp hb).1 + exact (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (hA a ha0 b hb0) (by norm_num)) hv).trans hbudget) + have hfactor := prime_pair_residue_factorization q (by omega) u v r s + (fun z hz _ => giant_interval_gt_modulus L hL0 q (by omega) hqlog u v hu z hz) + (fun z hz _ => giant_interval_gt_modulus L hL0 q (by omega) hqlog r s hr z hz) + F0 c H (by + intro x _ hx y _ hy a ha b hb hxa hyb + have hx0 : (0 : ℝ) < x := by exact_mod_cast hx.pos + have hy0 : (0 : ℝ) < y := by exact_mod_cast hy.pos + have ha0 : a < q := Finset.mem_range.mp (Finset.mem_filter.mp ha).1 + have hb0 : b < q := Finset.mem_range.mp (Finset.mem_filter.mp hb).1 + have hxa' : x % q = a := by simpa only [Nat.ModEq, Nat.mod_eq_of_lt ha0] using hxa + have hyb' : y % q = b := by simpa only [Nat.ModEq, Nat.mod_eq_of_lt hb0] using hyb + dsimp only [F0, H] + rw [hxa', hyb', Real.exp_log hx0, Real.exp_log hy0]) + dsimp only at h + rw [← hfactor] at h + exact (norm_sub_le_norm_sub_add_norm_sub _ _ _).trans (add_le_add hremove h) + +theorem PublishedProgressionInput.moving_pair_coprime_prime_haar_rate (P : PublishedProgressionInput) + {σ : Type u} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * A * (movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + if (⌊Real.exp x⌋₊).Coprime ⌊Real.exp y⌋₊ then + c (⌊Real.exp x⌋₊ % q) (⌊Real.exp y⌋₊ % q) * + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ + else 0)) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_pair_coprime_prime_haar_rate_uniform n C d] with L hL + exact hL σ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairHaarComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairHaarComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff273d1a3ab460c48fcfa6c48e5abaa585aa69cc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairHaarComparison.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairedPrimeResidueRate +import OAI.NumberTheory.Ostmann.Construction.GiantHaarIntegral + +namespace OAI + +/-! # The two-history kernel under its original prime interval law -/ + +namespace Ostmann +universe u v +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_pair_prime_haar_rate_uniform (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + (∀ a ∈ reducedResidues q, ∀ b ∈ reducedResidues q, + 2 * ‖c a b‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + letI : NeZero q := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖(∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_paired_prime_residue_sum_rate_uniform n C d, + eventually_ge_atTop (0 : ℝ)] with L hL hL0 + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c hbudget + have : NeZero q := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let H := fun x y => movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + have h := hL σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D + hB hD hφ hlip hout V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c hbudget + dsimp only at h ⊢ + have hmeas : Measurable (Function.uncurry H) := by + have hh := measurable_exp_pair_mul + (movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G) + (measurable_movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout) (1 : ℂ) + simpa only [one_mul] using hh + have hnorm (x y : ℝ) : ‖H x y‖ ≤ + ((SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1)) ^ 2 := + movingRealKernelPair_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ _ _ + have hu1 : 1 ≤ u := (Real.one_le_exp (by positivity)).trans hu + have hr1 : 1 ≤ r := (Real.one_le_exp (by positivity)).trans hr + rw [primeGiantMeasure_pair_haar_integral P Q q u v r s hu1 hr1 H hmeas _ hnorm c] at h + exact h + +theorem PublishedProgressionInput.moving_pair_prime_haar_rate (P : PublishedProgressionInput) + {σ : Type u} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + (∀ a ∈ reducedResidues q, ∀ b ∈ reducedResidues q, + 2 * ‖c a b‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + letI : NeZero q := ⟨by omega⟩ + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖(∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_pair_prime_haar_rate_uniform n C d] with L hL + exact hL σ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairNormBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairNormBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..867429344b160d2a96316a1ff7a92ddbef96159d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairNormBudget.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPair + +namespace OAI + +/-! # A uniform norm budget for the two-history giant kernel -/ + +namespace Ostmann +open scoped Classical ComplexConjugate SchwartzMap + +theorem movingRealKernelPair_norm_variation {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L R : ℝ) : + ‖movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G L R‖ ≤ + (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 := by + let W := pairedPolynomialFactors + (movingSmoothPolynomialFactors value (T false) (movingCoordinateLeft false R) + (movingCoordinateRight false R) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (movingSmoothPolynomialFactors value (T true) (movingCoordinateLeft false R) + (movingCoordinateRight false R) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + let g := movingRealGateWeight value (T false) (nodes false) X lo hi (movingRealPair false R L) * + conj (movingRealGateWeight value (T true) (nodes true) X lo hi (movingRealPair false R L)) + have hg : ‖g‖ ≤ 1 := by + dsimp only [g] + rw [norm_mul, Complex.norm_conj] + exact (mul_le_mul (movingRealGateWeight_norm value (T false) (nodes false) X lo hi _) + (movingRealGateWeight_norm value (T true) (nodes true) X lo hi _) (norm_nonneg _) (by norm_num)).trans_eq (one_mul 1) + have he := movingRealKernelPair_slice_polynomial value T nodes ψ X lo hi hlo hhi φ G + B D hB hD hφ hlip hout false R L + simp only [movingRealPair, Bool.false_eq_true, ite_false, topGiantReal, ite_true] at he + have he' : movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G L R = + g * smoothPolynomialWeight W L := he + rw [he', norm_mul] + calc + _ ≤ 1 * smoothPolynomialBudget W := + mul_le_mul hg (smoothPolynomialWeight_norm W L) (norm_nonneg _) zero_le_one + _ ≤ _ := by + rw [one_mul] + exact movingPairedSmoothPolynomialFactors_budget value T _ _ ψ X lo hi V hlo hhi hV + φ G B D hB hD hφ hlip + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairSquareLoss.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairSquareLoss.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7dfdb11f9f17f81834258d84de0d8ef07ca6129 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairSquareLoss.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeOccurrences +import OAI.NumberTheory.Ostmann.Arithmetic.JointSquareLiftExclusions + +namespace OAI + +/-! # Square-exclusion loss for both actual moving histories -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingInternalPairFactor_on_fiber {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) + (x₀ y₀ : ZMod p) + (hbase : ∀ j : MovingPrimeOccurrences value T p, + let φ := MovingSlotReversal.naturalReduction p value + let L := movingPrimeOccurrenceLine value T p j + φ L.a * x₀ + φ L.b * y₀ = 0) + (v : SquareLiftPairs p x₀ y₀) : + movingInternalPairFactor value T p v.1.1 v.2.1 = + if ∀ j : MovingPrimeOccurrences value T p, + let φ := MovingSlotReversal.naturalReduction (p ^ 2) value + let L := movingPrimeOccurrenceLine value T p j + φ L.a * v.1.1 + φ L.b * v.2.1 ≠ 0 then 1 else 0 := by + have hz (j : MovingPrimeOccurrences value T p) : + let φ := MovingSlotReversal.naturalReduction (p ^ 2) value + let L := movingPrimeOccurrenceLine value T p j + squareReduction p (φ L.a * v.1.1 + φ L.b * v.2.1) = 0 := by + simpa only [map_add, map_mul, naturalReduction_square, v.1.property, v.2.property] using hbase j + have hs : (∀ side, movingInternalLocalSupport value (T side) p v.1.1 v.2.1) ↔ + ∀ j : MovingPrimeOccurrences value T p, + let φ := MovingSlotReversal.naturalReduction (p ^ 2) value + let L := movingPrimeOccurrenceLine value T p j + φ L.a * v.1.1 + φ L.b * v.2.1 ≠ 0 := by + refine (movingInternalLocalSupport_occurrences value T p v.1.1 v.2.1).trans ?_ + exact ⟨fun h j => (h j).2, fun h j => ⟨hz j, h j⟩⟩ + by_cases h : ∀ side, movingInternalLocalSupport value (T side) p v.1.1 v.2.1 + · simp only [movingInternalPairFactor, ite_eq_left h, ite_eq_left (hs.mp h)] + · have hn := fun hn => h (hs.mpr hn) + simp only [movingInternalPairFactor, ite_eq_right h, ite_eq_right hn] + +theorem moving_internal_pair_fiber_product {σ I : Type*} [Fintype I] {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : I → ℕ) + (x₀ y₀ : ∀ i, ZMod (p i)) + (hbase : ∀ i (j : MovingPrimeOccurrences value T (p i)), + let φ := MovingSlotReversal.naturalReduction (p i) value + let L := movingPrimeOccurrenceLine value T (p i) j + φ L.a * x₀ i + φ L.b * y₀ i = 0) + (v : ∀ i, SquareLiftPairs (p i) (x₀ i) (y₀ i)) (w : ℂ) : + (∏ i, movingInternalPairFactor value T (p i) (v i).1.1 (v i).2.1) * w = + if ∀ i (j : MovingPrimeOccurrences value T (p i)), + let φ := MovingSlotReversal.naturalReduction (p i ^ 2) value + let L := movingPrimeOccurrenceLine value T (p i) j + φ L.a * (v i).1.1 + φ L.b * (v i).2.1 ≠ 0 then w else 0 := by + simp_rw [movingInternalPairFactor_on_fiber value T _ _ _ (hbase _)] + by_cases h : ∀ i (j : MovingPrimeOccurrences value T (p i)), + let φ := MovingSlotReversal.naturalReduction (p i ^ 2) value + let L := movingPrimeOccurrenceLine value T (p i) j + φ L.a * (v i).1.1 + φ L.b * (v i).2.1 ≠ 0 + · rw [ite_eq_left h] + have he : (∏ i, if ∀ j : MovingPrimeOccurrences value T (p i), + let φ := MovingSlotReversal.naturalReduction (p i ^ 2) value + let L := movingPrimeOccurrenceLine value T (p i) j + φ L.a * (v i).1.1 + φ L.b * (v i).2.1 ≠ 0 then (1 : ℂ) else 0) = 1 := + Finset.prod_eq_one (fun i _ => ite_eq_left (h i)) + rw [he, one_mul] + · rw [ite_eq_right h] + obtain ⟨i, hi⟩ := not_forall.mp h + have he : (∏ i, if ∀ j : MovingPrimeOccurrences value T (p i), + let φ := MovingSlotReversal.naturalReduction (p i ^ 2) value + let L := movingPrimeOccurrenceLine value T (p i) j + φ L.a * (v i).1.1 + φ L.b * (v i).2.1 ≠ 0 then (1 : ℂ) else 0) = 0 := + Finset.prod_eq_zero (Finset.mem_univ i) (ite_eq_right hi) + rw [he, zero_mul] + +/-- The two-history loss counts each node once even if it contains several +copies of the same prime. All its nonzero-row assumptions are derived. -/ +theorem moving_pair_joint_square_loss {σ I : Type*} [Fintype I] [DecidableEq I] + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hf : ∀ i side, (T side).Frequencies (fun s => (s : ZMod (p i)) ≠ 0)) + (x₀ y₀ : ∀ i, ZMod (p i)) (hy : ∀ i, y₀ i ≠ 0) + (hbase : ∀ i (j : MovingPrimeOccurrences value T (p i)), + let φ := MovingSlotReversal.naturalReduction (p i) value + let L := movingPrimeOccurrenceLine value T (p i) j + φ L.a * x₀ i + φ L.b * y₀ i = 0) + (F : (∀ i, SquareLiftPairs (p i) (x₀ i) (y₀ i)) → ℂ) + (B : ℝ) (hB : 0 ≤ B) (hF : ∀ v, ‖F v‖ ≤ B) : + (Fintype.card (∀ i, SquareLiftPairs (p i) (x₀ i) (y₀ i)) : ℝ)⁻¹ * + ‖(∑ v, (∏ i, movingInternalPairFactor value T (p i) (v i).1.1 (v i).2.1) * F v) - + ∑ v, F v‖ ≤ + 4 * B * (2 ^ n - 1 : ℕ) * ∑ i, (p i : ℝ)⁻¹ := by + let J := fun i => MovingPrimeOccurrences value T (p i) + let φ := fun i => MovingSlotReversal.naturalReduction (p i ^ 2) value + let L := fun i (j : J i) => movingPrimeOccurrenceLine value T (p i) j + have hr (i : I) (j : J i) : + squareReduction (p i) (φ i (L i j).a) ≠ 0 ∨ + squareReduction (p i) (φ i (L i j).b) ≠ 0 := by + simp only [φ, naturalReduction_square] + exact movingPrimeOccurrenceLine_nonzero tier value hprime hdisjoint T hlevels (p i) (hf i) j + have hb := joint_square_lift_removed_mass_le p J + (fun i j => φ i (L i j).a) (fun i j => φ i (L i j).b) x₀ y₀ hy hr + (by simpa only [φ, naturalReduction_square] using hbase) F B hB hF + simp_rw [moving_internal_pair_fiber_product value T p x₀ y₀ hbase] + refine hb.trans ?_ + calc + 2 * B * ∑ i, (Fintype.card (J i) : ℝ) / p i ≤ + 2 * B * ∑ i, (2 * (2 ^ n - 1 : ℕ) : ℝ) / (p i : ℝ) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + apply Finset.sum_le_sum + intro i _ + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact_mod_cast movingPrimeOccurrences_card value T (p i) + _ = _ := by simp only [div_eq_mul_inv, ← Finset.mul_sum]; ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedLogSlots.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedLogSlots.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b4cea9e66248c2864267252d29759cadb198637 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedLogSlots.lean @@ -0,0 +1,43 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkLogTrees + +namespace OAI + +/-! # Logarithmic factors indexed by the actual terminal leaves -/ + +namespace Ostmann +open scoped Classical BigOperators + +def movingPairedLogSlots {σ : Type*} (tier : σ → ℕ) (k : ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) : + Fin ((bulkLogLeafLists tier k (T false)).length + + (bulkLogLeafLists tier k (T true)).length) → List σ := + Fin.append (fun j => (bulkLogLeafLists tier k (T false))[j]) + (fun j => (bulkLogLeafLists tier k (T true))[j]) + +theorem movingPairedLogSlots_count {σ : Type*} (tier : σ → ℕ) (k : ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) : + (bulkLogLeafLists tier k (T false)).length + + (bulkLogLeafLists tier k (T true)).length = 2 * 2 ^ n := by + rw [bulkLogLeafLists_length, bulkLogLeafLists_length] + omega + +/-- The concrete terminal groups satisfy exactly the length hypothesis of +the weighted Page comparison. No bound on a fictitious common grouping is used. -/ +theorem movingPairedLogSlots_length_le {σ : Type*} (tier : σ → ℕ) (k : ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (r : ℕ) + (hT : ∀ b, (T b).RegularLengthLE r) : + ∀ j, (movingPairedLogSlots tier k T j).length ≤ r := by + intro j + refine Fin.addCases ?_ ?_ j + · intro i + simp only [movingPairedLogSlots, Fin.append_left] + exact bulkLogLeafLists_length_le tier k (T false) r (hT false) _ + (List.getElem_mem i.isLt) + · intro i + simp only [movingPairedLogSlots, Fin.append_right] + exact bulkLogLeafLists_length_le tier k (T true) r (hT true) _ + (List.getElem_mem i.isLt) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedMixedResidueRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedMixedResidueRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..933fc33412c52787494d4d6c2c3c3af879032d63 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedMixedResidueRate.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingJointMixedPairRate +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePairResidues +import OAI.NumberTheory.Ostmann.Construction.GiantResidueSumBound + +namespace OAI + +/-! # Simultaneous giant idealization summed over every integer–unit residue pair -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_paired_mixed_residue_sum_rate (P : PublishedProgressionInput) + {σ : Type*} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + (∀ a ∈ Finset.range q, ∀ b ∈ reducedResidues q, + 2 * ‖c a b‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖(∑ b ∈ reducedResidues q, ∑ a ∈ Finset.range q, + complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)))) - + (∑ b ∈ reducedResidues q, ∑ a ∈ Finset.range q, + ∫ x, ∫ y, c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂integerGiantMeasure q J u v)‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_joint_kernelPair_mixed_rate (σ := σ) n C d, + giant_residue_sum_error_rate (2 * Real.exp 1) (by positivity)] with L hL hR + intro value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q hQ hq hqQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog c hbudget + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hm (b : ℕ) : reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) ≤ Real.exp 1 := + (reciprocalPrimeInterval_le_exp q b r s).trans (Real.exp_le_exp.mpr (by linarith)) + have hpoint (b : ℕ) (hb : b ∈ reducedResidues q) (a : ℕ) (ha : a ∈ Finset.range q) : + ‖complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J (fun x => + c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂integerGiantMeasure q J u v‖ ≤ err * (2 * Real.exp 1) := by + exact (hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q a b hQ hq hqQ (Finset.mem_filter.mp hb).2 hlog + u v r s J hJ huv hshort hr hrs hrshort (c a b) (hbudget a ha b hb)).trans + (mul_le_mul_of_nonneg_left (by + have hmass : Real.exp (v - J) ≤ Real.exp 1 := Real.exp_le_exp.mpr (by linarith) + linarith [hm b]) (Real.exp_pos _).le) + apply (finite_pair_comparison (reducedResidues q) (Finset.range q) _ _ _ hpoint).trans + have hc : ((reducedResidues q).card : ℝ) ≤ q := Nat.cast_le.mpr (reducedResidues_card_le q) + calc + _ ≤ (q : ℝ) * q * (err * (2 * Real.exp 1)) := by + simp only [Finset.card_range] + gcongr + _ = (q : ℝ) ^ 2 * (2 * Real.exp 1) * err := by ring + _ ≤ _ := hR q (by omega) hqlog + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedPrimeResidueRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedPrimeResidueRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..57886bc921e38bec1684b4a63717ac0e67380cfe --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedPrimeResidueRate.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingJointPairRate +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePairResidues +import OAI.NumberTheory.Ostmann.Construction.GiantResidueSumBound + +namespace OAI + +/-! # Simultaneous giant idealization summed over every unit residue pair -/ + +namespace Ostmann +universe u v +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_paired_prime_residue_sum_rate_uniform (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + (∀ a ∈ reducedResidues q, ∀ b ∈ reducedResidues q, + 2 * ‖c a b‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖(∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)))) - + (∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + ∫ x, ∫ y, c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂primeGiantMeasure P Q q a u v)‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_joint_kernelPair_prime_rate_uniform n C d, + giant_residue_sum_error_rate (Real.exp 1 + 2) (by positivity)] with L hL hR + intro σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c hbudget + dsimp only + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hm (b : ℕ) : reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) ≤ Real.exp 1 := + (reciprocalPrimeInterval_le_exp q b r s).trans (Real.exp_le_exp.mpr (by linarith)) + have hpoint (b : ℕ) (hb : b ∈ reducedResidues q) (a : ℕ) (ha : a ∈ reducedResidues q) : + ‖complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂primeGiantMeasure P Q q a u v‖ ≤ err * (Real.exp 1 + 2) := by + exact (hL σ value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q a b hQ hq hqQ (Finset.mem_filter.mp ha).2 (Finset.mem_filter.mp hb).2 hlog + u v r s hu huv hshort hr hrs hrshort (c a b) (hbudget a ha b hb)).trans + (mul_le_mul_of_nonneg_left (by linarith [hm b]) (Real.exp_pos _).le) + apply (finite_pair_comparison (reducedResidues q) (reducedResidues q) _ _ _ hpoint).trans + have hc : ((reducedResidues q).card : ℝ) ≤ q := Nat.cast_le.mpr (reducedResidues_card_le q) + calc + _ ≤ (q : ℝ) * q * (err * (Real.exp 1 + 2)) := by gcongr + _ = (q : ℝ) ^ 2 * (Real.exp 1 + 2) * err := by ring + _ ≤ _ := hR q (by omega) hqlog + +theorem PublishedProgressionInput.moving_paired_prime_residue_sum_rate (P : PublishedProgressionInput) + {σ : Type u} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + (∀ a ∈ reducedResidues q, ∀ b ∈ reducedResidues q, + 2 * ‖c a b‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + ‖(∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)))) - + (∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + ∫ x, ∫ y, c a b * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂primeGiantMeasure P Q q a u v)‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_paired_prime_residue_sum_rate_uniform n C d] with L hL + exact hL σ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedTransform.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedTransform.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8e55d5e38dbc6f05ec714fceb7f92b7969eaa01 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairedTransform.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTransferTransform + +namespace OAI + +/-! # The surviving Fourier factors in the paired regular template -/ + +namespace Ostmann +open scoped Classical BigOperators + +local instance pairedSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +def movingPairedGiantEquiv (n r m : ℕ) : + ((Unit ⊕ MovingRegularSlot n r m) ⊕ (Unit ⊕ MovingRegularSlot n r m)) ≃ + (Bool ⊕ MovingRegularSlot (n + 1) r m) where + toFun + | .inl (.inl _) => .inl true + | .inl (.inr i) => .inr (.inl i.1, i.2) + | .inr (.inl _) => .inl false + | .inr (.inr i) => .inr (.inr i.1, i.2) + invFun + | .inl true => .inl (.inl ()) + | .inl false => .inr (.inl ()) + | .inr (.inl i, j) => .inl (.inr (i, j)) + | .inr (.inr i, j) => .inr (.inr (i, j)) + left_inv := by + intro i + rcases i with ((u | ⟨i, j⟩) | (u | ⟨i, j⟩)) + · cases u; rfl + · rfl + · cases u; rfl + · rfl + right_inv := by + intro i + rcases i with (b | ⟨i, j⟩) + · cases b <;> rfl + · cases i <;> rfl + +/-- Both surviving giants and every regular factor occur once in the next +full transform. This is independent of the reconstructed pivot. -/ +theorem movingTaggedTransform_paired {A : Type*} (value : A → ℕ) + (n r m : ℕ) (left right : MovingRegularSlot n r m → A) (XL XR : ℕ) + (hXL : XL ≠ 0) (hXR : XR ≠ 0) + (hleft : ∀ i, value (left i) ≠ 0) (hright : ∀ i, value (right i) ≠ 0) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (D : ℕ) (s : ℤ) : + movingTaggedTransform + (Sum.elim (Sum.elim (fun _ : Unit => XL) (value ∘ left)) + (Sum.elim (fun _ : Unit => XR) (value ∘ right))) + (Sum.elim (Sum.elim (fun _ : Unit => true) (fun _ => false)) + (Sum.elim (fun _ : Unit => true) (fun _ => false))) greg ggiant favorable D s = + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then XL else XR) + (value ∘ movingTemplatePairSample n r m left right)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable D s := by + let p : Bool ⊕ MovingRegularSlot (n + 1) r m → ℕ := + Sum.elim (fun b => if b then XL else XR) + (value ∘ movingTemplatePairSample n r m left right) + let t : Bool ⊕ MovingRegularSlot (n + 1) r m → Bool := + Sum.elim (fun _ => true) (fun _ => false) + have hp : ∀ i, p i ≠ 0 := by + intro i + rcases i with (b | ⟨j, k⟩) + · cases b <;> assumption + · cases j with + | inl j => exact hleft (j, k) + | inr j => exact hright (j, k) + have ht : t ∘ movingPairedGiantEquiv n r m = + Sum.elim (Sum.elim (fun _ : Unit => true) (fun _ => false)) + (Sum.elim (fun _ : Unit => true) (fun _ => false)) := by + funext i + rcases i with ((i | i) | (i | i)) <;> rfl + have hv : p ∘ movingPairedGiantEquiv n r m = + Sum.elim (Sum.elim (fun _ : Unit => XL) (value ∘ left)) + (Sum.elim (fun _ : Unit => XR) (value ∘ right)) := by + funext i + rcases i with ((i | i) | (i | i)) <;> rfl + have he := movingTaggedTransform_equiv (movingPairedGiantEquiv n r m) p hp t + greg ggiant favorable D s + rw [ht, hv] at he + exact he + +/-- The tagged presentation is the same full transform used by the +coefficient-to-prime-statistic identity. -/ +theorem movingTaggedTransform_full {I : Type*} [Fintype I] + (q : Bool → ℕ) (p : I → ℕ) [∀ b, NeZero (q b)] [∀ i, NeZero (p i)] + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (D : ℕ) (s : ℤ) : + movingTaggedTransform (Sum.elim q p) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable D s = + movingRegularTransform (Sum.elim q p) + (fun i => match i with + | .inl b => fun t => if favorable (q b) then complexUnitPhase (ggiant (q b) t) else 0 + | .inr j => greg (p j)) D s := by + unfold movingTaggedTransform movingRegularTransform + apply Finset.prod_congr rfl + intro i _ + cases i <;> rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairwiseSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairwiseSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..e4102629d48f1e96dbc8834ac5c33d83d924ed54 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPairwiseSupport.lean @@ -0,0 +1,118 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularSlots + +namespace OAI + +/-! # Reducing full moving-history coprimality to the new compensation tests -/ + +namespace Ostmann +open scoped Classical + +def MovingSlotData.currentSlots {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (XL XR : ℕ) : List ℕ := + XL :: XR :: T.regularSlots.map value + +def MovingSlotData.CurrentPairwise {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (XL XR : ℕ) : Prop := + (T.currentSlots value XL XR).Pairwise Nat.Coprime + +private theorem parent_current_perm {σ : Type*} (value : σ → ℕ) {n : ℕ} + (s : ℤ) (CL CR U : List σ) (left right : MovingSlotData σ n) (XL XR : ℕ) : + ((.node s CL CR U left right : MovingSlotData σ (n + 1)).currentSlots value XL XR).Perm + ((XL :: CL.map value) ++ (XR :: CR.map value)) := by + apply List.perm_iff_count.mpr + intro a + simp only [MovingSlotData.currentSlots, MovingSlotData.regularSlots, + List.map_append, List.count_cons, List.count_append] + omega + +private theorem child_current_perm {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (U C : List σ) (h : T.regularSlots.Perm (U ++ C)) + (p x : ℕ) : (T.currentSlots value p x).Perm (p :: (U.map value ++ (x :: C.map value))) := by + have hp := List.perm_iff_count.mp (h.map value) + apply List.perm_iff_count.mpr + intro a + have ha := hp a + simp only [List.map_append, List.count_append] at ha + simp only [MovingSlotData.currentSlots, List.count_cons, List.count_append] + omega + +/-- The local equivalence is stated on the actual child states. Slot +coherence is available for every `buildMovingSlotData` by construction. -/ +theorem moving_node_pairwise_iff {σ : Type*} (value : σ → ℕ) {n : ℕ} + (s : ℤ) (CL CR U : List σ) (left right : MovingSlotData σ n) + (hcoh : (.node s CL CR U left right : MovingSlotData σ (n + 1)).RegularCoherent) + (XL XR : ℕ) + (hold : (.node s CL CR U left right : MovingSlotData σ (n + 1)).CurrentPairwise value XL XR) + (hv : IsCoprime left.frequency (XL * MovingSlotReversal.naturalProduct value CL : ℤ)) + (hw : IsCoprime right.frequency (XR * MovingSlotReversal.naturalProduct value CR : ℤ)) + (hI : (MovingSlotData.step s CL CR U left right false).IntegralAt value (XL, XR)) : + let p := (MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR + (left.CurrentPairwise value p XL ∧ right.CurrentPairwise value p XR) ↔ + (U.map value).Pairwise Nat.Coprime ∧ p.Coprime (MovingSlotReversal.naturalProduct value U) := by + dsimp only + let p := (MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR + have hp := (parent_current_perm value s CL CR U left right XL XR).pairwise_iff (R := Nat.Coprime) + (fun h => h.symm) + have hleft := (child_current_perm value left U CL hcoh.1 p XL).pairwise_iff (R := Nat.Coprime) + (fun h => h.symm) + have hright := (child_current_perm value right U CR hcoh.2.1 p XR).pairwise_iff (R := Nat.Coprime) + (fun h => h.symm) + have h := moving_children_pairwise_iff (XL :: CL.map value) (XR :: CR.map value) + (U.map value) p s left.frequency right.frequency (hp.mp hold) + (by simpa only [List.prod_cons, MovingSlotReversal.naturalProduct, Nat.cast_mul] using hv) + (by simpa only [List.prod_cons, MovingSlotReversal.naturalProduct, Nat.cast_mul] using hw) + (by simpa only [List.prod_cons, MovingSlotReversal.naturalProduct, MovingSlotData.step, p] + using hI.2) + exact (and_congr hleft hright).trans h + +/-- Cross-branch frequency tests are retained explicitly at every node. -/ +def MovingSlotData.CrossFrequencyUnits {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → Prop + | _, .leaf _ _, _, _ => True + | _, .node s CL CR U left right, XL, XR => + let p := (MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR + IsCoprime left.frequency (XL * MovingSlotReversal.naturalProduct value CL : ℤ) ∧ + IsCoprime right.frequency (XR * MovingSlotReversal.naturalProduct value CR : ℤ) ∧ + left.CrossFrequencyUnits value p XL ∧ right.CrossFrequencyUnits value p XR + +def MovingSlotData.FullPairwise {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → Prop + | _, T@(.leaf _ _), XL, XR => T.CurrentPairwise value XL XR + | _, T@(.node s CL CR U left right), XL, XR => + let p := (MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR + T.CurrentPairwise value XL XR ∧ left.FullPairwise value p XL ∧ right.FullPairwise value p XR + +def MovingSlotData.NewCompensationUnits {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → Prop + | _, .leaf _ _, _, _ => True + | _, .node s CL CR U left right, XL, XR => + let p := (MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR + ((U.map value).Pairwise Nat.Coprime ∧ p.Coprime (MovingSlotReversal.naturalProduct value U)) ∧ + left.NewCompensationUnits value p XL ∧ right.NewCompensationUnits value p XR + +/-- Full pairwise coprimality down the original moving tree is equivalent +to top coprimality and the new compensation tests. Integral reconstruction +and all cross-frequency tests remain hypotheses on these exact states. -/ +theorem MovingSlotData.fullPairwise_iff {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hcoh : T.RegularCoherent) (XL XR : ℕ) + (hI : T.Integral value XL XR) (hfreq : T.CrossFrequencyUnits value XL XR) : + T.FullPairwise value XL XR ↔ T.CurrentPairwise value XL XR ∧ T.NewCompensationUnits value XL XR := by + induction T generalizing XL XR with + | leaf => simp only [FullPairwise, NewCompensationUnits, and_true] + | node s CL CR U left right ihL ihR => + have hL := ihL hcoh.2.2.1 _ _ hI.2.1 hfreq.2.2.1 + have hR := ihR hcoh.2.2.2 _ _ hI.2.2 hfreq.2.2.2 + change (_ ∧ _ ∧ _) ↔ _ ∧ (_ ∧ _ ∧ _) + rw [hL, hR] + constructor + · rintro ⟨htop, ⟨hl, hnewL⟩, ⟨hr, hnewR⟩⟩ + exact ⟨htop, (moving_node_pairwise_iff value s CL CR U left right hcoh XL XR htop + hfreq.1 hfreq.2.1 hI.1).mp ⟨hl, hr⟩, hnewL, hnewR⟩ + · rintro ⟨htop, hnew, hnewL, hnewR⟩ + have hc := (moving_node_pairwise_iff value s CL CR U left right hcoh XL XR htop + hfreq.1 hfreq.2.1 hI.1).mpr hnew + exact ⟨htop, ⟨hc.1, hnewL⟩, ⟨hc.2, hnewR⟩⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternActualLines.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternActualLines.lean new file mode 100644 index 0000000000000000000000000000000000000000..a91e9a53a31a95436fc2df6ff04c157f7816a7a0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternActualLines.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFinite +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampledIndexedProbability + +namespace OAI + +/-! # The actual field average in fixed pattern coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators + +def movingPatternValueData {A B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (x : Fin (N + 1) → A) + (side : Bool) : MovingSlotData A n := + buildMovingSlotData n (t side) + (treeLeafMap (List.map (fun b => x (e.symm (.inl b)))) n (small side)) + (treeLeafMap (List.map (fun b => x (e.symm (.inl b)))) n (bulk side)) + (movingPatternSamples A n (fun i => x (e.symm (.inr (pattern i)))) side) + +/-- The field average over both original giant residues is precisely the +simultaneous line probability appearing in the fixed-coordinate comparison. +This identification needs no assumptions forbidding sample coincidences. -/ +theorem movingPatternActualBaseAverage {A B C : Type*} {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (x : Fin (N + 1) → A) (c : C) : + let p := prime (x (e.symm (.inr c))) + let _ : Fact p.Prime := ⟨hprime _⟩ + (Fintype.card (ZMod p × (ZMod p)ˣ) : ℂ)⁻¹ * + (∑ z : ZMod p × (ZMod p)ˣ, + movingInternalBaseFactor prime (movingPatternValueData e n t small bulk pattern x) p z.1 z.2) = + (movingSampledInternalProbability prime hprime + (movingPatternFinData e n t small bulk pattern) x (e.symm (.inr c)) : ℂ) := by + let p := prime (x (e.symm (.inr c))) + let _ : Fact p.Prime := ⟨hprime _⟩ + let T := fun side => movingPatternSlotData n (t side) (small side) (bulk side) pattern side + let eval : B ⊕ C → A := + Sum.elim (fun b => x (e.symm (.inl b))) (fun c => x (e.symm (.inr c))) + have he : (fun side => (T side).map eval) = movingPatternValueData e n t small bulk pattern x := by + funext side + exact movingPatternSlotData_evaluate _ _ n (t side) (small side) (bulk side) pattern side + have hv : prime ∘ eval = (fun i => prime (x i)) ∘ e.symm := by + funext i + cases i <;> rfl + dsimp only + rw [movingInternalBaseFactor_average] + have ha := movingInternalBaseProbability_map eval prime T p + have hf := movingInternalBaseProbability_map e.symm (fun i => prime (x i)) T p + rw [hv, he] at ha + exact congrArg (fun y : ℝ => (y : ℂ)) (ha.trans hf.symm) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternArithmeticComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternArithmeticComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..10d18ad278620ae9e9174e8fffed31d7f13d9eca --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternArithmeticComparison.lean @@ -0,0 +1,127 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternAveragedSquare +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLineComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPatternSum + +namespace OAI + +/-! # The original internal arithmetic coefficient versus symbolic flags -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingPatternLineProduct {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (x : Fin (N + 1) → A) : ℂ := + ∏ c, (movingSampledInternalProbability prime hprime + (movingPatternFinData e n t small bulk pattern) x (e.symm (.inr c)) : ℂ) + +noncomputable def movingPatternHaarProduct {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (x : Fin (N + 1) → A) : ℂ := + let T := movingPatternFinData e n t small bulk pattern + letI : ∀ c : C, Fact (prime (x (e.symm (.inr c)))).Prime := fun _ => ⟨hprime _⟩ + ∏ c, movingInternalHaarAverage (fun i => prime (x i)) T (prime (x (e.symm (.inr c)))) + +noncomputable def movingPatternFlagProduct {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (x : Fin (N + 1) → A) : ℂ := + let T := movingPatternFinData e n t small bulk pattern + let base := movingPatternFinRepresentative e n t small bulk pattern rep + ∏ c, (internalLineFlagWeight true (prime (x (e.symm (.inr c)))) + (fun s => arithmeticTestFlag (lineTestPolynomials + (movingIndexedLine T (e.symm (.inr c)) (base c)) + ⟨(base c).1, (base c).2.val⟩ s = 0)) : ℂ) + +noncomputable def movingOriginalPatternWeight {A B C : Type*} [Fintype B] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (n : ℕ) (pattern : Bool × MovingSampleIndex n → C) + (G : (Fin (N + 1) → A) → ℂ) (x : Fin (N + 1) → A) : ℂ := + ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * movingPatternInjectionGuard e G x + +/-- Remove the actual prime-square exclusions and replace the remaining +simultaneous line probabilities by their symbolic flags under the original +pattern law. No injectivity assumption is imposed on the sampling measure. -/ +theorem movingPattern_arithmetic_comparison {A B C : Type*} + [Fintype A] [Nonempty A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ b, (movingPatternFinData e n t small bulk pattern b).SizeLE d) + (hfreq : ∀ b, (movingPatternFinData e n t small bulk pattern b).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E α β V : ℝ) (hE : 0 ≤ E) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hmax : ∀ j a, μ j a ≤ α) (hnmax : ∀ j a, ν j a ≤ α) + (hpmax : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≤ β) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + Real.exp V ≤ prime a) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hcross : ∀ x, G x ≠ 0 → ∀ b c, + prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (hfmod : ∀ x, G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) : + let κ := D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternHaarProduct e prime hprime n t small bulk pattern x - + movingPatternFlagProduct e prime n t small bulk pattern rep x)‖ ≤ + κ * (((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) + + 2 * ((Fintype.card C * (2 + 2 * (2 ^ n - 1)) : ℕ) : ℝ) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β)) := by + let H := movingPatternInjectionGuard e G + have hH : ∀ x, ‖H x‖ ≤ D := movingPatternInjectionGuard_norm e G D hD hG + have hsupp (x) (hx : H x ≠ 0) : G x ≠ 0 := + (movingPatternInjectionGuard_nonzero e G x hx).2 + have hsq := movingPattern_averaged_square_error e prime hprime tierB tierC t small bulk pattern rep + hsmall hbulk htier μ ν hμ hν hmass hnmass E V hbound hprimeSize H D hD hH + (fun x hx => hdisjoint x (hsupp x hx)) (fun x hx => hfmod x (hsupp x hx)) + have hline := movingPattern_line_comparison e prime hpInj hprime tierB tierC t small bulk pattern rep + hsmall hbulk htier d F U hF hU hsize hfreq hvalues μ ν hμ hν hmass hnmass E α β V + hE hα hβ hV hbound hmax hnmax hpmax + (fun c a ha => (Real.le_log_iff_exp_le (Nat.cast_pos.mpr (hprime a).pos)).mpr + (hprimeSize c a ha)) + H D hD hH (fun x hx => hdisjoint x (hsupp x hx)) + (fun x hx => (movingPatternInjectionGuard_nonzero e G x hx).1) + (fun x hx => hcross x (hsupp x hx)) (fun x hx => hfmod x (hsupp x hx)) + dsimp only at hsq hline ⊢ + have heq : (∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternHaarProduct e prime hprime n t small bulk pattern x - + movingPatternFlagProduct e prime n t small bulk pattern rep x)) = + (∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternSquareDifference e prime hprime n t small bulk pattern x) + + ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternLineProduct e prime hprime n t small bulk pattern x - + movingPatternFlagProduct e prime n t small bulk pattern rep x) := by + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro x _ + unfold movingPatternHaarProduct movingPatternSquareDifference movingPatternLineProduct + ring + rw [heq] + apply (norm_add_le _ _).trans + calc + _ ≤ _ + _ := add_le_add hsq hline + _ = _ := by ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternArithmeticData.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternArithmeticData.lean new file mode 100644 index 0000000000000000000000000000000000000000..67168010ea4cf45135b459961801a984a627c69b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternArithmeticData.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkData +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationSupport + +namespace OAI + +/-! # Arithmetic support of the actual finite pattern trees -/ + +namespace Ostmann +open scoped Classical + +theorem movingPatternFinBulkData_regular_coherent {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (b : Bool) : (movingPatternFinBulkData e n m t small slot perm pattern b).RegularCoherent := by + rw [movingPatternFinBulkData_build] + exact buildMovingSlotData_regular_coherent _ _ _ _ _ + +/-- Every compensation prime comes from an internal equality class. The +strict level separation excludes all external regular slots. -/ +theorem movingPatternFinBulkData_internal_cover {A B C : Type*} [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ j, n ≤ tierB j) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (value : A → ℕ) (x : Fin (N + 1) → A) : + ∀ b, ∀ o ∈ (movingPatternFinBulkData e n m t small slot perm pattern b).occurrences, + ∀ i ∈ o.current.compensationSlots, + value (x i) ∈ Finset.univ.image (fun c : C => value (x (e.symm (.inr c)))) := by + intro b o ho i hi + let tier := (Sum.elim tierB tierC) ∘ e + let T := movingPatternFinBulkData e n m t small slot perm pattern b + have hlevels : T.Levels tier := + movingPatternFinBulkData_levels e tierB tierC n m t small slot perm pattern hB htier b + have hlt := T.occurrence_compensation_level tier hlevels o ho i hi + have hbound := (T.occurrence_bounds tier hlevels o ho).2.1 + have hiN : tier i < n := lt_of_lt_of_le hlt (by omega) + cases he : e i with + | inl j => + have hj := hB j + simp only [tier, Function.comp_apply, he, Sum.elim_inl] at hiN + omega + | inr c => + apply Finset.mem_image.mpr + refine ⟨c, Finset.mem_univ _, ?_⟩ + have hh := e.symm_apply_apply i + rw [he] at hh + rw [hh] + +/-- Both histories have the same top regular product. No sampled internal +prime or history frequency enters this product. -/ +theorem movingPatternFinBulkData_regular_product {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) (value : Fin (N + 1) → ℕ) (b : Bool) : + MovingSlotReversal.naturalProduct value + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern b).regularSlots = + MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) := by + rw [movingPatternFinBulkData_build] + have hp := buildMovingSlotData_regular_perm n (t b) + (movingPatternFiniteSmall e n small) + (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot)) + (movingPatternFiniteSamples e n pattern b) + have he : (if b then bulkSlotLeaves n m (movingPatternBulkEmbedding e slot ∘ (Equiv.refl _).symm) + else bulkSlotLeaves n m (movingPatternBulkEmbedding e slot)) = + bulkSlotLeaves n m (movingPatternBulkEmbedding e slot) := by cases b <;> rfl + rw [he] + exact (hp.map value).prod_eq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternAveragedSquare.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternAveragedSquare.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a1fb271e12fb5f1684628239a6b04766046aa96 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternAveragedSquare.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSquareError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternActualLines + +namespace OAI + +/-! # The actual square-exclusion error averaged under original pattern weights -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingPatternSquareDifference {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (x : Fin (N + 1) → A) : ℂ := + let T := movingPatternFinData e n t small bulk pattern + letI : ∀ c : C, Fact (prime (x (e.symm (.inr c)))).Prime := fun _ => ⟨hprime _⟩ + (∏ c, movingInternalHaarAverage (fun i => prime (x i)) T (prime (x (e.symm (.inr c))))) - + ∏ c, (movingSampledInternalProbability prime hprime T x (e.symm (.inr c)) : ℂ) + +/-- All square exclusions can be removed under the literal dependent pattern +law. The loss keeps the inverse-prime scale from every internal class. -/ +theorem movingPattern_averaged_square_error {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E V : ℝ) (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + Real.exp V ≤ prime a) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hfmod : ∀ x, G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) : + let W := fun x : Fin (N + 1) → A => + ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * G x + ‖∑ x, W x * movingPatternSquareDifference e prime hprime n t small bulk pattern x‖ ≤ + (D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + ((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) := by + dsimp only + let T := movingPatternFinData e n t small bulk pattern + let prior := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let W := fun x : Fin (N + 1) → A => + ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * G x + have hm (i) : ∑ a, prior i a = 1 := by + dsimp only [prior] + cases e i with + | inl b => exact hnmass b + | inr c => exact hmass _ + have hdom (x) : ‖W x‖ * + (∏ c, internalLineScalar true (prime (x (e.symm (.inr c))))) ≤ + (D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + productPrior prior x := + movingPattern_fin_prior_bound e μ ν prime n pattern rep E hprime hμ hν hbound G D hD hG x + apply productPrior_relative_error prior hm W + (movingPatternSquareDifference e prime hprime n t small bulk pattern) + (fun x => ∏ c, internalLineScalar true (prime (x (e.symm (.inr c))))) + (D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) + ((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) (by positivity) + hdom + intro x hx + have hg : G x ≠ 0 := by + intro hz + exact hx (by simp only [W, hz, mul_zero]) + have hscalar : 0 < ∏ c, internalLineScalar true (prime (x (e.symm (.inr c)))) := by + apply Finset.prod_pos + intro c _ + simp only [internalLineScalar, ite_true] + exact inv_pos.mpr (Nat.cast_pos.mpr (hprime _).pos) + have hprior : productPrior prior x ≠ 0 := by + intro hz + have hh := hdom x + rw [hz, mul_zero] at hh + exact (not_le_of_gt (mul_pos (norm_pos_iff.mpr hx) hscalar)) hh + have hsample (c) : μ (movingSampleTier (rep c).val.2) (x (e.symm (.inr c))) ≠ 0 := by + have hh := (Finset.prod_ne_zero_iff.mp hprior) (e.symm (.inr c)) (Finset.mem_univ _) + simpa only [prior, Equiv.apply_symm_apply, Sum.elim_inr] using hh + have h := movingRepresentativeProduct_error ((Sum.elim tierB tierC) ∘ e) + (fun i => prime (x i)) (fun i => hprime _) (hdisjoint x hg) T + (movingPatternFinData_levels e tierB tierC n t small bulk pattern hsmall hbulk htier) + (fun c => e.symm (.inr c)) (movingPatternFinRepresentative e n t small bulk pattern rep) + (hfmod x hg) V (fun c => hprimeSize c _ (hsample c)) + simpa only [movingPatternSquareDifference, movingInternalLineProbability, + movingSampledInternalProbability, internalLineScalar, ite_true] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBadEventRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBadEventRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..f47fa409c162c26c2fc5da2f2daad341e49debd4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBadEventRate.lean @@ -0,0 +1,163 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelGain +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCost +import OAI.NumberTheory.Ostmann.Arithmetic.BulkDeletionRate + +namespace OAI + +/-! # Collision and deletion errors for the actual pattern kernel -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem movingPattern_bad_event_rate (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi B D F Cnorm : ℝ) (hA : 0 ≤ A) (hhi : lo ≤ hi) (hF : 0 ≤ F) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (p : Fin m → ℕ) (S deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (Z : (TreeLeafIndex n × Fin m) → ℝ) (amp H T : ℝ), + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ j, 0 ≤ Z j) → (∀ j, Z j ≤ Real.exp H) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cnorm * L)) → H ≤ Cnorm * L → + 0 ≤ amp → amp ≤ Real.exp (F * m) → + Real.exp ((39 / 10000 : ℝ) * L) ≤ T → + (∀ j q, q ∈ S j → Real.exp T ≤ (q : ℝ)) → + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let cost := amp * (∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * W + cost * (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * Real.exp (H - T) + + cost * ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) ≤ + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨Cw, hCw, hkernel⟩ := movingPatternKernelBudget_spectatorScale ψ n r₀ k + A lo hi B D hA hhi + let K := (F + 1) * ((k : ℝ) ^ 4 + 1) + let C := max (max Cnorm Cw) + (max ((((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K) (((2 ^ n : ℕ) : ℝ) * (k : ℝ) ^ 4)) + have hCwC : Cw ≤ C := (le_max_right _ _).trans (le_max_left _ _) + have hC : 1 ≤ C := hCw.trans hCwC + have hCn : Cnorm ≤ C := (le_max_left _ _).trans (le_max_left _ _) + have hCs : (((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K ≤ C := + (le_max_left _ _).trans (le_max_right _ _) + have hCd : ((2 ^ n : ℕ) : ℝ) * (k : ℝ) ^ 4 ≤ C := + (le_max_right _ _).trans (le_max_right _ _) + filter_upwards [bulk_collision_deletion_rate C hC, eventually_ge_atTop (1 : ℝ)] with L hrate hL + dsimp only + intro p S deleted Z amp H T hp hZ0 hZ hdel hH hamp0 hamp hT hlow + let m := spectatorBulkCount k L + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let cost := amp * (∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * W + have hL0 : 0 ≤ L := by linarith + have hK : 0 ≤ K := by dsimp only [K]; positivity + have hFk : F * (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4] + have hkK : (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [mul_nonneg hF (pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4)] + have hm := spectatorBulkCount_upper k L hL0 + have hmK : (m : ℝ) ≤ K * L := hm.trans (mul_le_mul_of_nonneg_right hkK hL0) + have hampK : amp ≤ Real.exp (K * L) := hamp.trans (Real.exp_le_exp.mpr (by + exact (mul_le_mul_of_nonneg_left hm hF).trans + (by nlinarith [mul_le_mul_of_nonneg_right hFk hL0]))) + have hspec := moving_spectator_linear_cost n m p K L amp hK hL0 hamp0 hmK hampK hp + have hspec' : amp * (∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) ≤ + Real.exp (C * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + apply hspec.trans + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hCs hL0) (Real.exp_nonneg _) + have hW : W ≤ Real.exp (C * L ^ 2) := by + apply (bulkKernelPair_smooth_le_budget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D).trans + exact (hkernel L hL).trans (Real.exp_le_exp.mpr + (mul_le_mul_of_nonneg_right hCwC (sq_nonneg L))) + have hcost0 : 0 ≤ cost := by dsimp only [cost, W]; positivity + have hcost : cost ≤ Real.exp (C * L ^ 2 + C * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + apply (mul_le_mul hspec' hW (sq_nonneg _) (Real.exp_nonneg _)).trans_eq + rw [← Real.exp_add, add_comm] + have hdim : (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ≤ C * L := by + simp only [Fintype.card_prod, card_treeLeafIndex, Fintype.card_fin, Nat.cast_mul] + exact (mul_le_mul_of_nonneg_left hm (Nat.cast_nonneg _)).trans + (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_right hCd hL0) + have hCnL := mul_le_mul_of_nonneg_right hCn hL0 + exact hrate (TreeLeafIndex n × Fin m) S deleted Z H T (Real.exp (Cnorm * L)) cost + hZ0 hZ hdel (Real.exp_nonneg _) hcost0 hdim + (Real.exp_le_exp.mpr hCnL) (hH.trans hCnL) hcost hT hlow + +/-- Collision and deletion errors uniformly over the moving Fourier window. -/ +theorem movingPattern_bad_event_rate_window (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H B D F Cnorm : ℝ) (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ lo hi : ℝ, lo ≤ hi → hi - lo ≤ Real.exp (H * m) → + ∀ (p : Fin m → ℕ) (S deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (Z : (TreeLeafIndex n × Fin m) → ℝ) (amp H T : ℝ), + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ j, 0 ≤ Z j) → (∀ j, Z j ≤ Real.exp H) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cnorm * L)) → H ≤ Cnorm * L → + 0 ≤ amp → amp ≤ Real.exp (F * m) → + Real.exp ((39 / 10000 : ℝ) * L) ≤ T → + (∀ j q, q ∈ S j → Real.exp T ≤ (q : ℝ)) → + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let cost := amp * (∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * W + cost * (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * Real.exp (H - T) + + cost * ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) ≤ + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨Cw, hCw, hkernel⟩ := movingPatternKernelBudget_spectatorScale_window ψ n r₀ k + A H B D hA hH + let K := (F + 1) * ((k : ℝ) ^ 4 + 1) + let C := max (max Cnorm Cw) + (max ((((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K) (((2 ^ n : ℕ) : ℝ) * (k : ℝ) ^ 4)) + have hCwC : Cw ≤ C := (le_max_right _ _).trans (le_max_left _ _) + have hC : 1 ≤ C := hCw.trans hCwC + have hCn : Cnorm ≤ C := (le_max_left _ _).trans (le_max_left _ _) + have hCs : (((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K ≤ C := + (le_max_left _ _).trans (le_max_right _ _) + have hCd : ((2 ^ n : ℕ) : ℝ) * (k : ℝ) ^ 4 ≤ C := + (le_max_right _ _).trans (le_max_right _ _) + filter_upwards [bulk_collision_deletion_rate C hC, eventually_ge_atTop (1 : ℝ)] with L hrate hL + dsimp only + intro lo hi hhi hwidth p S deleted Z amp H T hp hZ0 hZ hdel hH hamp0 hamp hT hlow + let m := spectatorBulkCount k L + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let cost := amp * (∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * W + have hL0 : 0 ≤ L := by linarith + have hK : 0 ≤ K := by dsimp only [K]; positivity + have hFk : F * (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4] + have hkK : (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [mul_nonneg hF (pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4)] + have hm := spectatorBulkCount_upper k L hL0 + have hmK : (m : ℝ) ≤ K * L := hm.trans (mul_le_mul_of_nonneg_right hkK hL0) + have hampK : amp ≤ Real.exp (K * L) := hamp.trans (Real.exp_le_exp.mpr (by + exact (mul_le_mul_of_nonneg_left hm hF).trans + (by nlinarith [mul_le_mul_of_nonneg_right hFk hL0]))) + have hspec := moving_spectator_linear_cost n m p K L amp hK hL0 hamp0 hmK hampK hp + have hspec' : amp * (∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) ≤ + Real.exp (C * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + apply hspec.trans + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hCs hL0) (Real.exp_nonneg _) + have hW : W ≤ Real.exp (C * L ^ 2) := by + apply (bulkKernelPair_smooth_le_budget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D).trans + exact (hkernel L hL lo hi hhi hwidth).trans (Real.exp_le_exp.mpr + (mul_le_mul_of_nonneg_right hCwC (sq_nonneg L))) + have hcost0 : 0 ≤ cost := by dsimp only [cost, W]; positivity + have hcost : cost ≤ Real.exp (C * L ^ 2 + C * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + apply (mul_le_mul hspec' hW (sq_nonneg _) (Real.exp_nonneg _)).trans_eq + rw [← Real.exp_add, add_comm] + have hdim : (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ≤ C * L := by + simp only [Fintype.card_prod, card_treeLeafIndex, Fintype.card_fin, Nat.cast_mul] + exact (mul_le_mul_of_nonneg_left hm (Nat.cast_nonneg _)).trans + (by simpa only [mul_assoc] using mul_le_mul_of_nonneg_right hCd hL0) + have hCnL := mul_le_mul_of_nonneg_right hCn hL0 + exact hrate (TreeLeafIndex n × Fin m) S deleted Z H T (Real.exp (Cnorm * L)) cost + hZ0 hZ hdel (Real.exp_nonneg _) hcost0 hdim + (Real.exp_le_exp.mpr hCnL) (hH.trans hCnL) hcost hT hlow + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..c39e591dc4979cce863c5a99546b042e7d17e1e7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkArithmetic.lean @@ -0,0 +1,96 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkFrozen +import OAI.NumberTheory.Ostmann.Arithmetic.BulkCollisionSupport + +namespace OAI + +/-! # Supported arithmetic of the original equality-pattern histories -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original pattern's Page and spectator factors separate on precisely +its selected bulk residues. The unchanged small and sampled data, denominator +independence and regular-list distinctness are derived from the constructor. -/ +theorem movingPattern_supported_arithmetic {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base value : Fin (N + 1) → ℕ) + (hv : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), value i = base i) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (hprime : ∀ i, (value i).Prime) + (hf : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).Frequencies (· ≠ 0)) + (hinj : Function.Injective (value ∘ movingPatternBulkEmbedding e slot)) + (hcross : ∀ i j, bulkIndexPredicate (movingPatternBulkEmbedding e slot) i ≠ + bulkIndexPredicate (movingPatternBulkEmbedding e slot) j → value i ≠ value j) + (hout : ∀ j p, p ∈ outside → (value (movingPatternBulkEmbedding e slot j)).Coprime p) + (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (D : ∀ i, Bool → (ZMod (p i))ˣ) + (z : TreeLeafIndex n × Fin m → (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hz : ∀ j, (value (movingPatternBulkEmbedding e slot j) : ZMod (∏ i, bulkResidueModuli r p i)) = + (z j : ZMod _)) + (input : PublishedProgressionInput) (Q : ℕ) (y : ℝ) : + let T := movingPatternFinBulkData e n m t small slot perm pattern + let hvalue := fun i => (hprime i).ne_zero + movingFrequencyPageAverage value outside F E T + (fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) + (.prime false) (.prime true)) R r input Q y * + ∏ i, movingSpectatorHaarAverage value (p i) (g i) (D i) T = + frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F E T childBound R r input Q y (bulkResidueEquiv r p hc z).1 * + ∏ i, frozenBulkSpectatorHaar base n m t (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (D i) perm (g i) + ((bulkResidueEquiv r p hc z).2 i) := by + have hfixed := fun b => movingPattern_nonbulk_values e tierB tierC slot base value hv + (small b) pattern (hsmall b) hB htier b + exact movingSupportedArithmetic_bulk_residues base value n m (movingPatternBulkEmbedding e slot) + hv t (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (fun b => (hfixed b).1) (fun b => (hfixed b).2) perm + (movingPatternFinBulkData e n m t small slot perm pattern) + (movingPatternFinBulkData_build e n m t small slot perm pattern) F E outside childBound pivotBound + (fun i => (hprime i).ne_zero) hf (fun _ _ _ i _ => hprime i) + (movingPatternFinBulkData_bulk_nodup e tierB tierC t small slot perm pattern hsmall hB htier) + hinj (fun _ _ _ i _ j _ h => hcross i j h) + (fun _ _ _ i _ hi p hp => by + obtain ⟨j, rfl⟩ := hi + exact hout j p hp) + R r (movingPatternFinBulkData_compensationAbsent e tierB tierC n m t small slot perm pattern hB htier) + hR hr p hc g hg D z hz input Q y + +/-- Bulk collisions are already zero under the original pattern coefficient, +so inserting the distinctness indicator precedes all changes of measure. -/ +theorem movingPattern_arithmetic_collision_gate {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (value : Fin (N + 1) → ℕ) (hprime : ∀ i, (value i).Prime) + (outside : List ℕ) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (nodes : Bool → List MovingFormulaNode) (R : ℤ) (r : ℕ) [NeZero r] + (input : PublishedProgressionInput) (Q : ℕ) (y : ℝ) (A : ℂ) : + let T := movingPatternFinBulkData e n m t small slot perm pattern + movingFrequencyPageAverage value outside F E T nodes R r input Q y * A = + if Function.Injective (value ∘ movingPatternBulkEmbedding e slot) then + movingFrequencyPageAverage value outside F E T nodes R r input Q y * A else 0 := by + exact movingFrequencyPageAverage_collision_gate value n m (movingPatternBulkEmbedding e slot) + (t false) (movingPatternFiniteSmall e n (small false)) (movingPatternFiniteSamples e n pattern false) + outside hprime F E (movingPatternFinBulkData e n m t small slot perm pattern) + (movingPatternFinBulkData_build e n m t small slot perm pattern false) nodes R r input Q y A + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkBudgets.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkBudgets.lean new file mode 100644 index 0000000000000000000000000000000000000000..92e7a622a8be67ae8eaf0bd92e45ad4d1fe6caa1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkBudgets.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkData +import OAI.NumberTheory.Ostmann.Arithmetic.MovingUnitSampleBound +import OAI.NumberTheory.Ostmann.Construction.WordTransferFullPeriod + +namespace OAI + +/-! # Concrete length and frequency budgets for the original pattern pair -/ + +namespace Ostmann +open scoped Classical + +theorem movingLeafLengthLE_map {A B : Type*} (f : A → B) (n : ℕ) + (x : TreeLeafTuple (List A) n) (r : ℕ) (hx : MovingLeafLengthLE n x r) : + MovingLeafLengthLE n (treeLeafMap (List.map f) n x) r := by + induction n with + | zero => simpa only [MovingLeafLengthLE, treeLeafMap, List.length_map] using hx + | succ n ih => exact ⟨ih x.1 hx.1, ih x.2 hx.2⟩ + +theorem bulkSlotLeaves_length {A : Type*} (n m : ℕ) + (slot : TreeLeafIndex n × Fin m → A) : + MovingLeafLengthLE n (bulkSlotLeaves n m slot) m := by + induction n with + | zero => simp [bulkSlotLeaves, MovingLeafLengthLE, treeLeafTupleEquiv] + | succ n ih => + change MovingLeafLengthLE n + (bulkSlotLeaves n m (fun j => slot (.inl j.1, j.2))) m ∧ + MovingLeafLengthLE n (bulkSlotLeaves n m (fun j => slot (.inr j.1, j.2))) m + exact ⟨ih _, ih _⟩ + +theorem movingPatternFinBulkData_size {B C : Type*} {N n m r : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, MovingLeafLengthLE n (small b) r) (b : Bool) : + (movingPatternFinBulkData e n m t small slot perm pattern b).SizeLE + (2 ^ n * (r + m + 4 * n + 4)) := by + rw [movingPatternFinBulkData_build] + apply buildMovingSlotData_size n (t b) _ _ _ r m + (movingLeafLengthLE_map _ n (small b) r (hsmall b)) + cases b <;> exact bulkSlotLeaves_length n m _ + +theorem movingPatternFinBulkData_regular_length {B C : Type*} {N n m r : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, MovingLeafLengthLE n (small b) r) (b : Bool) : + (movingPatternFinBulkData e n m t small slot perm pattern b).RegularLengthLE + (2 ^ n * (r + m + 4 * n)) := by + rw [movingPatternFinBulkData_build] + apply buildMovingSlotData_regular_length n (t b) _ _ _ r m + (movingLeafLengthLE_map _ n (small b) r (hsmall b)) + cases b <;> exact bulkSlotLeaves_length n m _ + +theorem movingPatternFinBulkData_follows {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) (b : Bool) : + (movingPatternFinBulkData e n m t small slot perm pattern b).Follows (t b) := by + rw [movingPatternFinBulkData_build] + exact buildMovingSlotData_follows _ _ _ _ _ + +/-- The literal frequency list controls every actual formula-node frequency. -/ +theorem MovingSlotData.Follows.frequencies_iff {A : Type*} {n : ℕ} + {T : MovingSlotData A n} {t : FrequencyTree ℤ n} (h : T.Follows t) (P : ℤ → Prop) : + T.Frequencies P ↔ ∀ s ∈ allFrequencyList n t, P s := by + induction T with + | leaf s L => + change s = t at h + subst s + simp only [MovingSlotData.Frequencies, allFrequencyList, List.mem_singleton, forall_eq] + | node s CL CR u l r hl hr => + rcases h with ⟨hs, hL, hR⟩ + simp only [MovingSlotData.Frequencies, hs, allFrequencyList, + List.mem_cons, List.mem_append, or_imp, forall_and, forall_eq, + hl hL, hr hR] + +/-- Frequency bounds are taken from the original histories, not from an +additional assumption on each pattern realization. -/ +theorem movingPatternFinBulkData_frequencies {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) (P : ℤ → Prop) + (hP : ∀ b, ∀ s ∈ allFrequencyList n (t b), P s) (b : Bool) : + (movingPatternFinBulkData e n m t small slot perm pattern b).Frequencies P := + ((movingPatternFinBulkData_follows e t small slot perm pattern b).frequencies_iff P).mpr (hP b) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkData.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkData.lean new file mode 100644 index 0000000000000000000000000000000000000000..12c3c445fb64f2d049d3b0b68f6fb22017668673 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkData.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFinite +import OAI.NumberTheory.Ostmann.Arithmetic.BulkSlotNodup +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenMovingSamples + +namespace OAI + +/-! # The original pattern pair in selected bulk coordinates -/ + +namespace Ostmann +open scoped Classical + +theorem bulkSlotLeaves_map {A B : Type*} (f : A → B) (n m : ℕ) + (slot : TreeLeafIndex n × Fin m → A) : + treeLeafMap (List.map f) n (bulkSlotLeaves n m slot) = + bulkSlotLeaves n m (f ∘ slot) := by + apply (treeLeafTupleEquiv (List B) n).injective + funext j + rw [treeLeafTupleEquiv_map] + simp only [bulkSlotLeaves, Equiv.apply_symm_apply, List.map_ofFn, Function.comp_def] + +def movingPatternBulkEmbedding {B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + {n m : ℕ} (slot : (TreeLeafIndex n × Fin m) ↪ B) : + (TreeLeafIndex n × Fin m) ↪ Fin (N + 1) where + toFun j := e.symm (.inl (slot j)) + inj' := fun _ _ h => slot.injective (Sum.inl.inj (e.symm.injective h)) + +def movingPatternFiniteSmall {B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (n : ℕ) (small : TreeLeafTuple (List B) n) : TreeLeafTuple (List (Fin (N + 1))) n := + treeLeafMap (List.map (fun b => e.symm (.inl b))) n small + +def movingPatternFiniteSamples {B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (n : ℕ) (pattern : Bool × MovingSampleIndex n → C) (side : Bool) : + MovingSampleSlots (Fin (N + 1)) n := + movingPatternSamples (Fin (N + 1)) n ((fun c => e.symm (.inr c)) ∘ pattern) side + +theorem movingPatternFinData_build {B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (side : Bool) : + movingPatternFinData e n t small bulk pattern side = + buildMovingSlotData n (t side) (movingPatternFiniteSmall e n (small side)) + (movingPatternFiniteSmall e n (bulk side)) + (movingPatternFiniteSamples e n pattern side) := by + unfold movingPatternFinData movingPatternSlotData + rw [buildMovingSlotData_map, treeLeafMap_list_comp, treeLeafMap_list_comp, + movingPatternSamples_map] + rfl + +noncomputable def movingPatternBulkLeaves {B : Type*} (n m : ℕ) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (side : Bool) : + TreeLeafTuple (List B) n := + if side then bulkSlotLeaves n m (slot ∘ perm.symm) else bulkSlotLeaves n m slot + +noncomputable def movingPatternFinBulkData {B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (n m : ℕ) (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) (side : Bool) : + MovingSlotData (Fin (N + 1)) n := + movingPatternFinData e n t small (movingPatternBulkLeaves n m slot perm) pattern side + +theorem movingPatternFinBulkData_build {B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (n m : ℕ) (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) (side : Bool) : + movingPatternFinBulkData e n m t small slot perm pattern side = + buildMovingSlotData n (t side) (movingPatternFiniteSmall e n (small side)) + (if side then bulkSlotLeaves n m (movingPatternBulkEmbedding e slot ∘ perm.symm) + else bulkSlotLeaves n m (movingPatternBulkEmbedding e slot)) + (movingPatternFiniteSamples e n pattern side) := by + rw [movingPatternFinBulkData, movingPatternFinData_build] + cases side <;> + simp only [movingPatternFiniteSmall, movingPatternBulkLeaves, Bool.false_eq_true, + ite_false, ite_true, bulkSlotLeaves_map] + <;> rfl + +theorem movingPatternFiniteSamples_levels {B C : Type*} {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (n : ℕ) (pattern : Bool × MovingSampleIndex n → C) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) (side : Bool) : + (movingPatternFiniteSamples e n pattern side).Levels ((Sum.elim tierB tierC) ∘ e) := by + apply movingSampleCoordinates_levels + intro i + simpa only [Function.comp_apply, Equiv.apply_symm_apply, Sum.elim_inr] using htier (side, i) + +theorem movingPatternFinBulkData_levels {B C : Type*} {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (n m : ℕ) (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (side : Bool) : + (movingPatternFinBulkData e n m t small slot perm pattern side).Levels + ((Sum.elim tierB tierC) ∘ e) := + movingPatternFinData_levels e tierB tierC n t small _ pattern + (fun _ i _ => hB i) (fun _ i _ => hB i) htier side + +theorem movingPatternFinBulkData_compensationAbsent {B C : Type*} {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (n m : ℕ) (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (side : Bool) (j : TreeLeafIndex n × Fin m) : + (movingPatternFinBulkData e n m t small slot perm pattern side).CompensationAbsent + (movingPatternBulkEmbedding e slot j) := by + apply MovingSlotData.compensationAbsent_of_levels ((Sum.elim tierB tierC) ∘ e) _ + (movingPatternFinBulkData_levels e tierB tierC n m t small slot perm pattern hB htier side) + change n ≤ Sum.elim tierB tierC (e (e.symm (.inl (slot j)))) + simpa only [Equiv.apply_symm_apply, Sum.elim_inl] using hB (slot j) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkFrozen.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkFrozen.lean new file mode 100644 index 0000000000000000000000000000000000000000..86837d794c026b0d4f313f02bc90d0fc36ee28ec --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkFrozen.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkData +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSupportedArithmetic + +namespace OAI + +/-! # The original pattern has fixed nonbulk data under bulk resampling -/ + +namespace Ostmann +open scoped Classical + +theorem movingPatternBulkEmbedding_external_mem {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (slot : (TreeLeafIndex n × Fin m) ↪ B) (b : B) : + e.symm (.inl b) ∈ Set.range (movingPatternBulkEmbedding e slot) ↔ b ∈ Set.range slot := by + constructor + · rintro ⟨j, hj⟩ + exact ⟨j, Sum.inl.inj (e.symm.injective hj)⟩ + · rintro ⟨j, rfl⟩ + exact ⟨j, rfl⟩ + +theorem movingPatternBulkEmbedding_internal_absent {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (slot : (TreeLeafIndex n × Fin m) ↪ B) (c : C) : + e.symm (.inr c) ∉ Set.range (movingPatternBulkEmbedding e slot) := by + rintro ⟨j, hj⟩ + have h := e.symm.injective hj + cases h + +theorem movingPatternFiniteSmall_absent {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (small : TreeLeafTuple (List B) n) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) : + ∀ i ∈ flattenMovingSlots n (movingPatternFiniteSmall e n small), + i ∉ Set.range (movingPatternBulkEmbedding e slot) := by + intro i hi + rw [movingPatternFiniteSmall, flattenMovingSlots_map] at hi + obtain ⟨b, hb, rfl⟩ := List.mem_map.mp hi + exact fun h => hsmall b hb ((movingPatternBulkEmbedding_external_mem e slot b).mp h) + +theorem movingPattern_nonbulk_values {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (base value : Fin (N + 1) → ℕ) + (hv : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), value i = base i) + (small : TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (side : Bool) : + movingSlotValues value n (movingPatternFiniteSmall e n small) = + movingSlotValues base n (movingPatternFiniteSmall e n small) ∧ + (movingPatternFiniteSamples e n pattern side).values value = + (movingPatternFiniteSamples e n pattern side).values base := by + apply frozenMoving_nonbulk_values ((Sum.elim tierB tierC) ∘ e) base value + (movingPatternBulkEmbedding e slot) n _ hv _ _ + (movingPatternFiniteSmall_absent e slot small hsmall) + (movingPatternFiniteSamples_levels e tierB tierC n pattern htier side) + intro j + change n ≤ Sum.elim tierB tierC (e (e.symm (.inl (slot j)))) + simpa only [Equiv.apply_symm_apply, Sum.elim_inl] using hB (slot j) + +theorem movingPatternFinBulkData_bulk_nodup {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) : + ∀ b, ∀ L ∈ (movingPatternFinBulkData e n m t small slot perm pattern b).regularLists, + (L.filter (bulkIndexPredicate (movingPatternBulkEmbedding e slot))).Nodup := by + let lift := movingPatternBulkEmbedding e slot + let tier := (Sum.elim tierB tierC) ∘ e + have hgrade (i) (hi : bulkIndexPredicate lift i = true) : n ≤ tier i := by + obtain ⟨j, rfl⟩ := (bulkIndexPredicate_eq_true lift i).mp hi + change n ≤ Sum.elim tierB tierC (e (e.symm (.inl (slot j)))) + simpa only [Equiv.apply_symm_apply, Sum.elim_inl] using hB (slot j) + have hs (b) (i) (hi : i ∈ flattenMovingSlots n (movingPatternFiniteSmall e n (small b))) : + bulkIndexPredicate lift i = false := + (bulkIndexPredicate_eq_false lift i).mpr (movingPatternFiniteSmall_absent e slot _ (hsmall b) i hi) + have hst (b) (i) (hi : i ∈ flattenMovingSlots n (movingPatternFiniteSmall e n (small b))) : + n ≤ tier i := by + rw [movingPatternFiniteSmall, flattenMovingSlots_map] at hi + obtain ⟨j, _, rfl⟩ := List.mem_map.mp hi + simpa only [tier, Function.comp_apply, Equiv.apply_symm_apply, Sum.elim_inl] using hB j + intro b + rw [movingPatternFinBulkData_build] + cases b + · exact buildMovingSlotData_bulk_nodup n m (bulkIndexPredicate lift) tier lift + (fun j => (bulkIndexPredicate_eq_true lift _).mpr ⟨j, rfl⟩) hgrade + (t false) (movingPatternFiniteSmall e n (small false)) + (movingPatternFiniteSamples e n pattern false) (hs false) (hst false) + (movingPatternFiniteSamples_levels e tierB tierC n pattern htier false) + · exact buildMovingSlotData_bulk_nodup n m (bulkIndexPredicate lift) tier + (perm.symm.toEmbedding.trans lift) + (fun j => (bulkIndexPredicate_eq_true lift _).mpr ⟨perm.symm j, rfl⟩) hgrade + (t true) (movingPatternFiniteSmall e n (small true)) + (movingPatternFiniteSamples e n pattern true) (hs true) (hst true) + (movingPatternFiniteSamples_levels e tierB tierC n pattern htier true) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkFubini.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkFubini.lean new file mode 100644 index 0000000000000000000000000000000000000000..c338a179cad4b45db377e79f6d32f3764c014646 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkFubini.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFrozenMultiplier + +namespace OAI + +/-! # The signed bulk sum under the actual compensated pattern law -/ + +namespace Ostmann +open scoped Classical BigOperators + +def movingPatternExternalLaw {A B C : Type*} {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (ν : B → A → ℝ) : Fin (N + 1) → A → ℝ := + fun i => Sum.elim ν (fun _ _ => 1) (e i) + +theorem movingPatternExternalLaw_product {A B C : Type*} [Fintype B] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (ν : B → A → ℝ) (x : Fin (N + 1) → A) : + (∏ i, movingPatternExternalLaw e ν i (x i)) = + ∏ b, ν b (x (e.symm (.inl b))) := by + have h := e.prod_comp (fun j => Sum.elim ν (fun _ _ => 1) j (x (e.symm j))) + simpa only [Equiv.symm_apply_apply, Fintype.prod_sum_type, Sum.elim_inl, + Sum.elim_inr, Finset.prod_const_one, mul_one, movingPatternExternalLaw] using h + +noncomputable def movingPatternBulkMultiplier {A B C : Type*} [Fintype A] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (x : Fin (N + 1) → A) : ℂ := + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * + movingPatternFlagProduct e prime n t small bulk pattern rep x + +theorem movingPatternBulkMultiplier_frozen {A B C : Type*} [Fintype A] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (x y : TreeLeafIndex n × Fin m → A) + (a : {i : Fin (N + 1) // i ∉ Set.range (movingPatternBulkEmbedding e slot)} → A) : + movingPatternBulkMultiplier e μ prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) x a) = + movingPatternBulkMultiplier e μ prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) y a) := by + unfold movingPatternBulkMultiplier + rw [movingPairCompensatedMass_bulk_frozen e μ prime slot pattern x y a, + movingPatternFlagProduct_bulk_frozen e prime t small slot perm pattern rep x y a] + +theorem movingPattern_original_bulk_fubini {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (G : (Fin (N + 1) → A) → ℂ) (seed : TreeLeafIndex n × Fin m → A) : + let bulk := movingPatternBulkLeaves n m slot perm + let lift := movingPatternBulkEmbedding e slot + let law := movingPatternExternalLaw e ν + (∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small bulk pattern rep x) = + ∑ a : {i : Fin (N + 1) // i ∉ Set.range lift} → A, + ((∏ i : {i : Fin (N + 1) // i ∉ Set.range lift}, law i (a i) : ℝ) : ℂ) * + (movingPatternBulkMultiplier e μ prime n t small bulk pattern rep (joinBulkNonbulk lift seed a) * + ∑ x : TreeLeafIndex n × Fin m → A, + ((∏ j, ν (slot j) (x j) : ℝ) : ℂ) * + movingPatternInjectionGuard e G (joinBulkNonbulk lift x a)) := by + dsimp only + let lift := movingPatternBulkEmbedding e slot + let law := movingPatternExternalLaw e ν + let bulk := movingPatternBulkLeaves n m slot perm + let M := movingPatternBulkMultiplier e μ prime n t small bulk pattern rep + have heq : (∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small bulk pattern rep x) = + ∑ x, ((∏ i, law i (x i) : ℝ) : ℂ) * (M x * movingPatternInjectionGuard e G x) := by + apply Finset.sum_congr rfl + intro x _ + rw [show (∏ i, law i (x i)) = ∏ b, ν b (x (e.symm (.inl b))) from + movingPatternExternalLaw_product e ν x] + unfold movingOriginalPatternWeight M movingPatternBulkMultiplier + ring + rw [heq] + have hsplit := finite_prior_selected_fubini lift law + (fun x => M x * movingPatternInjectionGuard e G x) + simp only [finite_univ_canonical] at hsplit ⊢ + rw [hsplit] + apply Finset.sum_congr rfl + intro a _ + congr 1 + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + have hm := movingPatternBulkMultiplier_frozen e μ prime t small slot perm pattern rep x seed a + change M (joinBulkNonbulk lift x a) = M (joinBulkNonbulk lift seed a) at hm + rw [hm] + have hlaw (j : TreeLeafIndex n × Fin m) : law (lift j) (x j) = ν (slot j) (x j) := by + change Sum.elim ν (fun _ _ => 1) (e (e.symm (.inl (slot j)))) (x j) = _ + rw [Equiv.apply_symm_apply] + rfl + simp only [hlaw] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkIdentity.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..3cc612ab32e6342cd7c5ae632a76b17a5f36dea9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkIdentity.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternIntegrand +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkArithmetic + +namespace OAI + +/-! # Return the separated bulk kernel to the original supported histories -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- An exact identity for every original prime tuple. Its bulk collision +indicator is derived from the original regular-product support, before any +prime replacement or change of normalization. -/ +theorem movingPattern_bulk_supported_identity {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base value : Fin (N + 1) → ℕ) + (hv : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), value i = base i) + (hprime : ∀ i, (value i).Prime) (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) + (hcross : ∀ i j, bulkIndexPredicate (movingPatternBulkEmbedding e slot) i ≠ + bulkIndexPredicate (movingPatternBulkEmbedding e slot) j → value i ≠ value j) + (hout : ∀ j p, p ∈ outside → (value (movingPatternBulkEmbedding e slot j)).Coprime p) + (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (z : TreeLeafIndex n × Fin m → (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hz : ∀ j, (value (movingPatternBulkEmbedding e slot j) : ZMod (∏ i, bulkResidueModuli r p i)) = + (z j : ZMod _)) + (P : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes value (fun i => (hprime i).ne_zero) + childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPageAverage value outside F E data nodes R r P Q y * + ∏ i, movingSpectatorHaarAverage value (p i) (g i) (twist i) data) = + if Function.Injective (value ∘ movingPatternBulkEmbedding e slot) then + movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + (fun j => Real.log (value (movingPatternBulkEmbedding e slot j) : ℝ)) * + (frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Q y (bulkResidueEquiv r p hc z).1 * + ∏ i, frozenBulkSpectatorHaar base n m t (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (twist i) perm (g i) + ((bulkResidueEquiv r p hc z).2 i)) + else 0 := by + intro data nodes + by_cases hinj : Function.Injective (value ∘ movingPatternBulkEmbedding e slot) + · rw [ite_eq_left hinj] + rw [movingPatternBulkIntegrand_nat e tierB tierC t small slot perm pattern hB htier + childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + base value hv (fun i => (hprime i).ne_zero) hfreq] + congr 1 + exact movingPattern_supported_arithmetic e tierB tierC t small slot perm pattern hsmall hB htier + base value hv F E outside childBound pivotBound hprime + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq) + hinj hcross hout R r hR hr p hc g hg twist z hz P Q y + · rw [ite_eq_right hinj] + have hzero := movingPattern_arithmetic_collision_gate e t small slot perm pattern value hprime + outside F E nodes R r P Q y (∏ i, movingSpectatorHaarAverage value (p i) (g i) (twist i) data) + dsimp only at hzero + rw [ite_eq_right hinj] at hzero + rw [hzero, mul_zero] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkKernel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..c791686627bdaf80d0821998ee970042d04d1d5a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkKernel.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkLog +import OAI.NumberTheory.Ostmann.Arithmetic.IndexedBulkKernelComparison + +namespace OAI + +/-! # Prime-to-Page comparison for the actual pattern's sharp bulk kernel -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The sharp real kernel is constructed here. Compensation independence, +all frequency bounds and both polynomial length budgets come from the actual +pattern constructor, including its prescribed bulk permutation. -/ +theorem PublishedProgressionInput.movingPattern_kernel_integral_comparison + (P : PublishedProgressionInput) {B C : Type*} {N n m r₀ : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (hsmall : ∀ b, MovingLeafLengthLE n (small b) r₀) + (base : Fin (N + 1) → ℝ) (childBound pivotBound : ℕ → ℕ) + (j₀ : TreeLeafIndex n × Fin m) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L R : ℝ) + {Q : ℕ} (hQ : 2 ≤ Q) + (q a : TreeLeafIndex n × Fin m → ℕ) (u v : TreeLeafIndex n × Fin m → ℝ) + (hq : ∀ i, 1 ≤ q i) (hqQ : ∀ i, q i ≤ Q) (ha : ∀ i, (a i).Coprime (q i)) + (hu : ∀ i, 1 ≤ u i) (huv : ∀ i, u i ≤ v i) (hshort : ∀ i, v i ≤ u i + 1) + (hmass : ∀ i, ∑ p ∈ primeLogCellSet (q i) (a i) (u i) (v i), (p : ℝ)⁻¹ ≤ 2) : + let T := movingPatternFinBulkData e n m t small slot perm pattern + let lift := movingPatternBulkEmbedding e slot + let S := selectedBulkSet lift + let hcomp := movingPatternBulkSet_compensationAbsent e tierB tierC t small slot perm pattern hB htier + let hV := movingPatternFinBulkData_frequencies e t small slot perm pattern (fun s => |(s : ℝ)| ≤ V) hfreq + let f := bulkLogKernelPairIntegrand base S childBound pivotBound T hcomp + (lift j₀) ((mem_selectedBulkSet lift _).mpr ⟨j₀, rfl⟩) + ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hout L R + let K := f.pullBulk base lift + ‖(∫ y, K y ∂Measure.pi (fun i => primeLogCellMeasure (q i) (a i) (u i) (v i))) - + ∫ y, K y ∂Measure.pi (fun i => primeGiantMeasure P Q (q i) (a i) (u i) (v i))‖ ≤ + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * + ∑ i, bulkKernelPairComparisonBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 Bφ Dφ * + bulkPrimeErrorFactor P Q (u i) := by + dsimp only + let f := bulkLogKernelPairIntegrand base (selectedBulkSet (movingPatternBulkEmbedding e slot)) + childBound pivotBound (movingPatternFinBulkData e n m t small slot perm pattern) + (movingPatternBulkSet_compensationAbsent e tierB tierC t small slot perm pattern hB htier) + (movingPatternBulkEmbedding e slot j₀) + ((mem_selectedBulkSet _ _).mpr ⟨j₀, rfl⟩) ψ X lo hi V hlo hhi + (movingPatternFinBulkData_frequencies e t small slot perm pattern (fun s => |(s : ℝ)| ≤ V) hfreq) + φ G Bφ Dφ hBφ hDφ hφ hlip hout L R + exact P.bulk_kernel_integral_comparison_indexed base + (selectedBulkSet (movingPatternBulkEmbedding e slot)) (movingPatternBulkEmbedding e slot) + (fun j => (mem_selectedBulkSet _ _).mpr ⟨j, rfl⟩) childBound pivotBound + (movingPatternFinBulkData e n m t small slot perm pattern) + (movingPatternFinBulkData_compensationAbsent e tierB tierC n m t small slot perm pattern hB htier) + ψ X lo hi V hlo hhi + (movingPatternFinBulkData_frequencies e t small slot perm pattern (fun s => |(s : ℝ)| ≤ V) hfreq) + φ G Bφ Dφ hBφ hDφ hφ hlip hout _ _ + (movingPatternFinBulkData_size e t small slot perm pattern hsmall) + (movingPatternFinBulkData_regular_length e t small slot perm pattern hsmall) + L R f (fun _ => rfl) hQ q a u v hq hqQ ha hu huv hshort hmass + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkLog.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkLog.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c75d4357af8d15ad3d4b37db58d2c22e96dd6d9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkLog.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkBudgets +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenMovingSamples +import OAI.NumberTheory.Ostmann.Arithmetic.RealBulkKernelPair +import OAI.NumberTheory.Ostmann.Arithmetic.BulkCoordinateInsertion + +namespace OAI + +/-! # The real bulk coordinates evaluate to the original pattern primes -/ + +namespace Ostmann +open scoped Classical + +noncomputable def selectedBulkSet {σ J : Type*} [Fintype σ] (slot : J ↪ σ) : Finset σ := + Finset.univ.filter (fun i => i ∈ Set.range slot) + +@[simp] theorem mem_selectedBulkSet {σ J : Type*} [Fintype σ] (slot : J ↪ σ) (i : σ) : + i ∈ selectedBulkSet slot ↔ i ∈ Set.range slot := by + simp only [selectedBulkSet, Finset.mem_filter, Finset.mem_univ, true_and] + +theorem selectedBulkLogValues {σ J : Type*} [Fintype σ] + (base : σ → ℝ) (slot : J ↪ σ) (y : J → ℝ) : + bulkLogValues base (selectedBulkSet slot) (bulkCoordinateInsert base slot y) = + Function.extend slot (fun j => Real.exp (y j)) base := by + funext i + by_cases hi : i ∈ Set.range slot + · obtain ⟨j, rfl⟩ := hi + have hs : slot j ∈ selectedBulkSet slot := (mem_selectedBulkSet slot _).mpr ⟨j, rfl⟩ + rw [slot.injective.extend_apply] + simp only [bulkLogValues, hs, ite_true, bulkCoordinateInsert_at] + · rw [Function.extend_apply' _ base i hi] + simp only [bulkLogValues, mem_selectedBulkSet, hi, ite_false] + +theorem selectedBulkLogValues_nat {σ J : Type*} [Fintype σ] + (base value : σ → ℕ) (slot : J ↪ σ) + (hv : ∀ i ∉ Set.range slot, value i = base i) (hp : ∀ j, 0 < value (slot j)) : + bulkLogValues (fun i => (base i : ℝ)) (selectedBulkSet slot) + (bulkCoordinateInsert (fun i => (base i : ℝ)) slot (fun j => Real.log (value (slot j) : ℝ))) = + fun i => (value i : ℝ) := by + rw [selectedBulkLogValues] + funext i + by_cases hi : i ∈ Set.range slot + · obtain ⟨j, rfl⟩ := hi + rw [slot.injective.extend_apply, Real.exp_log (by exact_mod_cast hp j)] + · rw [Function.extend_apply' _ _ i hi, hv i hi] + +theorem movingPatternBulkSet_compensationAbsent {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) : + ∀ b i, i ∈ selectedBulkSet (movingPatternBulkEmbedding e slot) → + (movingPatternFinBulkData e n m t small slot perm pattern b).CompensationAbsent i := by + intro b i hi + obtain ⟨j, rfl⟩ := (mem_selectedBulkSet _ _).mp hi + exact movingPatternFinBulkData_compensationAbsent e tierB tierC n m t small slot perm pattern hB htier b j + +/-- At original prime tuples the real extension has exactly the original +sharp gates and Fourier windows. This includes every boundary point. -/ +theorem movingPattern_bulk_kernel_nat {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (base value : Fin (N + 1) → ℕ) + (hv : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), value i = base i) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (hf : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (ψ : SchwartzMap ℝ ℂ) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (L R : ℝ) : + let T := movingPatternFinBulkData e n m t small slot perm pattern + realValueKernelPair + (bulkLogValues (fun i => (base i : ℝ)) (selectedBulkSet (movingPatternBulkEmbedding e slot)) + (bulkCoordinateInsert (fun i => (base i : ℝ)) (movingPatternBulkEmbedding e slot) + (fun j => Real.log (value (movingPatternBulkEmbedding e slot j) : ℝ)))) + childBound pivotBound T ψ X lo hi hlo hhi φ G L R = + movingRealKernelPair value T + (fun b => (T b).formulaNodes value hvalue childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hf b) + (.prime false) (.prime true)) ψ X lo hi hlo hhi φ G L R := by + dsimp only + rw [selectedBulkLogValues_nat base value (movingPatternBulkEmbedding e slot) hv + (fun j => Nat.pos_of_ne_zero (hvalue _))] + exact realValueKernelPair_nat value hvalue childBound pivotBound _ _ ψ X lo hi hlo hhi φ G L R + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkMajorant.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkMajorant.lean new file mode 100644 index 0000000000000000000000000000000000000000..1383a6337be6cdb7349b48c0eadc7a767325d0ee --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkMajorant.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMean + +namespace OAI + +/-! # Integrating nonuniform errors under the original pattern law -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_flagged_pointwise_bound {A B C : Type*} + [Fintype B] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (x : Fin (N + 1) → A) : + ‖movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small bulk pattern rep x‖ ≤ + (‖G x‖ * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + productPrior (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x := by + have h := movingPattern_flagged_weight_bound e μ ν prime n t small bulk pattern rep E hprime hμ hν hbound + (fun _ => G x) ‖G x‖ (norm_nonneg _) (fun _ => le_rfl) x + by_cases hi : Function.Injective (fun c => x (e.symm (.inr c))) <;> + simpa only [movingOriginalPatternWeight, movingPatternInjectionGuard, hi, ite_true, ite_false] using h + +/-- A variable bound for the literal signed bulk mean is integrated against +the original external and representative priors. In particular the large +pointwise spectator error is averaged, rather than replaced by its supremum. -/ +theorem movingPattern_signed_bulk_majorant {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) (hE : 0 ≤ E) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hnmass : ∀ j, ∑ a, ν j a = 1) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : (Fin (N + 1) → A) → ℝ) + (hG : ∀ x, ‖movingPatternBulkMean e ν slot G x‖ ≤ D x) + (seed : TreeLeafIndex n × Fin m → A) : + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep x‖ ≤ + ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * + ∑ x, productPrior law x * D x := by + intro law + let κ := (2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C) + have hκ : 0 ≤ κ := mul_nonneg (by positivity) (pow_nonneg hE _) + have hlaw (i : Fin (N + 1)) (a : A) : 0 ≤ law i a := by + dsimp only [law] + cases e i with + | inl b => exact hν b a + | inr c => exact hμ _ a + rw [movingPattern_original_bulk_mean_eq e μ ν prime hnmass t small slot perm pattern rep G seed] + calc + _ ≤ ∑ x, (D x * κ) * productPrior law x := norm_sum_le_of_le _ (fun x _ => + (movingPattern_flagged_pointwise_bound e μ ν prime n t small + (movingPatternBulkLeaves n m slot perm) pattern rep E hprime hμ hν hbound + (movingPatternBulkMean e ν slot G) x).trans + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right (hG x) hκ) + (productPrior_nonneg law hlaw x))) + _ = κ * ∑ x, productPrior law x * D x := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkMean.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..474cc4d0f9c8dcea5a5225b0884eeba118e55c13 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkMean.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkFubini +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFlagBound + +namespace OAI + +/-! # Lifting signed cancellation in the original bulk mean -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingPatternBulkMean {A B C : Type*} [Fintype A] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (ν : B → A → ℝ) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (G : (Fin (N + 1) → A) → ℂ) + (x : Fin (N + 1) → A) : ℂ := + ∑ z : TreeLeafIndex n × Fin m → A, ((∏ j, ν (slot j) (z j) : ℝ) : ℂ) * + G (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) + +theorem movingPatternBulkMean_join {A B C : Type*} [Fintype A] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (ν : B → A → ℝ) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (G : (Fin (N + 1) → A) → ℂ) + (z : TreeLeafIndex n × Fin m → A) + (a : {i : Fin (N + 1) // i ∉ Set.range (movingPatternBulkEmbedding e slot)} → A) : + movingPatternBulkMean e ν slot G (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z a) = + ∑ w : TreeLeafIndex n × Fin m → A, ((∏ j, ν (slot j) (w j) : ℝ) : ℂ) * + G (joinBulkNonbulk (movingPatternBulkEmbedding e slot) w a) := by + have h : (fun i : {i : Fin (N + 1) // i ∉ Set.range (movingPatternBulkEmbedding e slot)} => + joinBulkNonbulk (movingPatternBulkEmbedding e slot) z a i) = a := by + funext i + exact joinBulkNonbulk_nonbulk _ z a i + unfold movingPatternBulkMean + rw [h] + +theorem movingPatternInjectionGuard_join {A B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (G : (Fin (N + 1) → A) → ℂ) (z : TreeLeafIndex n × Fin m → A) + (a : {i : Fin (N + 1) // i ∉ Set.range (movingPatternBulkEmbedding e slot)} → A) : + movingPatternInjectionGuard e G (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z a) = + if Function.Injective (fun c => a ⟨e.symm (.inr c), movingPatternBulkEmbedding_internal_absent e slot c⟩) + then G (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z a) else 0 := by + have h : (fun c => joinBulkNonbulk (movingPatternBulkEmbedding e slot) z a (e.symm (.inr c))) = + (fun c => a ⟨e.symm (.inr c), movingPatternBulkEmbedding_internal_absent e slot c⟩) := by + funext c + exact joinBulkNonbulk_nonbulk _ z a + ⟨e.symm (.inr c), movingPatternBulkEmbedding_internal_absent e slot c⟩ + unfold movingPatternInjectionGuard + rw [h] + +private theorem movingPatternBulkMean_guard_average {A B C : Type*} [Fintype A] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (ν : B → A → ℝ) + (hmass : ∀ j, ∑ a, ν j a = 1) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (G : (Fin (N + 1) → A) → ℂ) + (a : {i : Fin (N + 1) // i ∉ Set.range (movingPatternBulkEmbedding e slot)} → A) : + (∑ z : TreeLeafIndex n × Fin m → A, ((∏ j, ν (slot j) (z j) : ℝ) : ℂ) * + movingPatternInjectionGuard e (movingPatternBulkMean e ν slot G) + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z a)) = + ∑ z : TreeLeafIndex n × Fin m → A, ((∏ j, ν (slot j) (z j) : ℝ) : ℂ) * + movingPatternInjectionGuard e G (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z a) := by + have hmR : (∑ z : TreeLeafIndex n × Fin m → A, ∏ j, ν (slot j) (z j)) = 1 := by + rw [← Fintype.prod_sum] + simp only [hmass, Finset.prod_const_one] + have hm : (∑ z : TreeLeafIndex n × Fin m → A, ((∏ j, ν (slot j) (z j) : ℝ) : ℂ)) = 1 := by + exact_mod_cast hmR + simp_rw [movingPatternInjectionGuard_join, movingPatternBulkMean_join] + by_cases h : Function.Injective + (fun c => a ⟨e.symm (.inr c), movingPatternBulkEmbedding_internal_absent e slot c⟩) + · simp only [h, ite_true] + rw [← Finset.sum_mul, hm, one_mul] + · simp only [h, ite_false, mul_zero, Finset.sum_const_zero] + +/-- Averaging only selected bulk coordinates preserves the original signed +pattern expression, including the class-injectivity guard. -/ +theorem movingPattern_original_bulk_mean_eq {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (hmass : ∀ j, ∑ a, ν j a = 1) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (G : (Fin (N + 1) → A) → ℂ) (seed : TreeLeafIndex n × Fin m → A) : + (∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep x) = + ∑ x, movingOriginalPatternWeight e μ ν prime n pattern (movingPatternBulkMean e ν slot G) x * + movingPatternFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep x := by + rw [movingPattern_original_bulk_fubini e μ ν prime t small slot perm pattern rep G seed, + movingPattern_original_bulk_fubini e μ ν prime t small slot perm pattern rep + (movingPatternBulkMean e ν slot G) seed] + apply Finset.sum_congr rfl + intro a _ + rw [movingPatternBulkMean_guard_average e ν hmass slot G a] + +/-- A bound proved for the actual signed bulk mean lifts to the full original +pattern law with only its depth-dependent representative-prior cost. -/ +theorem movingPattern_signed_bulk_mean_bound {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) + (hG : ∀ x, ‖movingPatternBulkMean e ν slot G x‖ ≤ D) + (seed : TreeLeafIndex n × Fin m → A) : + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep x‖ ≤ + D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) := by + rw [movingPattern_original_bulk_mean_eq e μ ν prime hnmass t small slot perm pattern rep G seed] + exact movingPattern_flagged_mean_bound e μ ν prime n t small _ pattern rep E hprime hμ hν + hmass hnmass hbound _ D hD hG + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkMultiplier.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkMultiplier.lean new file mode 100644 index 0000000000000000000000000000000000000000..fc3e5b0f80fb2a5c32cd37ec2ec6490dff05758a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternBulkMultiplier.lean @@ -0,0 +1,28 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMean + +namespace OAI + +/-! # Retaining factors independent of the selected bulk draws -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPatternBulkMean_weight {A B C : Type*} [Fintype A] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (ν : B → A → ℝ) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (W G : (Fin (N + 1) → A) → ℂ) + (hW : ∀ x z, W (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) = W x) + (x : Fin (N + 1) → A) : + movingPatternBulkMean e ν slot (fun x => W x * G x) x = + W x * movingPatternBulkMean e ν slot G x := by + unfold movingPatternBulkMean + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro z _ + dsimp only + rw [hW x z] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternCellError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternCellError.lean new file mode 100644 index 0000000000000000000000000000000000000000..037fc209cd288da253008eb83e3888cef10f8ec2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternCellError.lean @@ -0,0 +1,173 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCost +import OAI.NumberTheory.Ostmann.Arithmetic.BulkWeightedErrorRate + +namespace OAI + +/-! # Weighted cell error at the original pattern and spectator scales -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +/-- The sharp kernel and every pointwise spectator factor fit one uniform +weighted comparison bound at the manuscript's actual linear bulk size. -/ +theorem PublishedProgressionInput.movingPattern_cell_error_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi B D F Cnorm : ℝ) (hA : 0 ≤ A) (hhi : lo ≤ hi) (hF : 0 ≤ F) : + ∃ C : ℝ, 1 ≤ C ∧ Cnorm ≤ C ∧ ∀ᶠ L : ℝ in atTop, + let m := spectatorBulkCount k L + ∀ (Cell : Type) [Fintype Cell] (M Q : ℕ) [NeZero M], 2 ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 10000 : ℝ) * L) → + ∀ (p : Fin m → ℕ) (Z : (TreeLeafIndex n × Fin m) → ℝ) + (a : ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) → ℂ) (amp T : ℝ), + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ j, 0 ≤ Z j) → (∀ j, Z j ≤ Real.exp (C * L)) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) → + 0 ≤ amp → amp ≤ Real.exp (F * m) → + (∀ z, ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) → + Real.exp ((39 / 10000 : ℝ) * L) ≤ T → + ∀ u : (TreeLeafIndex n × Fin m) → Cell → ℝ, (∀ j c, T ≤ u j c) → + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, + ∑ z : (TreeLeafIndex n × Fin m) → (ZMod M)ˣ, ‖a z‖ * + (2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkKernelPairComparisonBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D * + bulkPrimeErrorFactor P Q (u j (c j))) ≤ + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) := by + obtain ⟨C₀, hC₀, hkernel⟩ := movingPatternKernelBudget_spectatorScale ψ n r₀ k A lo hi B D hA hhi + let K := (F + 1) * ((k : ℝ) ^ 4 + 1) + let C := max C₀ ((((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K) + -- The dimension is also charged in the same constant. + let C' := max (max C (((2 ^ n : ℕ) : ℝ) * (k : ℝ) ^ 4)) Cnorm + have hK : 0 ≤ K := by dsimp only [K]; positivity + have hC₀C : C₀ ≤ C' := (le_max_left _ _).trans ((le_max_left _ _).trans (le_max_left _ _)) + have hC' : 1 ≤ C' := hC₀.trans hC₀C + refine ⟨C', hC', le_max_right _ _, ?_⟩ + filter_upwards [P.bulk_weighted_error_rate C' hC', eventually_ge_atTop (1 : ℝ)] with L hrate hL + dsimp only + intro Cell _ M Q _ hQ hQlog p Z a amp T hp hZ0 hZ hcell hunit hamp0 hamp ha hT u hu + let m := spectatorBulkCount k L + have hL0 : 0 ≤ L := by linarith + have hm := spectatorBulkCount_upper k L hL0 + have hFK : F * (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4] + have hKk : (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [mul_nonneg hF (pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4)] + have hmK : (m : ℝ) ≤ K * L := hm.trans (mul_le_mul_of_nonneg_right hKk hL0) + have hampK : amp ≤ Real.exp (K * L) := hamp.trans (Real.exp_le_exp.mpr (by + exact (mul_le_mul_of_nonneg_left hm hF).trans (by nlinarith [mul_le_mul_of_nonneg_right hFK hL0]))) + let bound := amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) + have hbound0 : 0 ≤ bound := mul_nonneg hamp0 (Finset.prod_nonneg fun i _ => by positivity) + have hbound : bound ≤ Real.exp (C' * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + apply (moving_spectator_linear_cost n m p K L amp hK hL0 hamp0 hmK hampK hp).trans + apply Real.exp_le_exp.mpr + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg _) + apply mul_le_mul_of_nonneg_right _ hL0 + exact (le_max_right C₀ _).trans ((le_max_left C _).trans (le_max_left _ _)) + have hdim : (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ≤ C' * L := by + simp only [Fintype.card_prod, card_treeLeafIndex, Fintype.card_fin, Nat.cast_mul] + calc + _ ≤ (2 ^ n : ℕ) * ((k : ℝ) ^ 4 * L) := + mul_le_mul_of_nonneg_left hm (Nat.cast_nonneg _) + _ ≤ C' * L := by + rw [← mul_assoc] + exact mul_le_mul_of_nonneg_right ((le_max_right _ _).trans (le_max_left _ _)) hL0 + have hbudget := hkernel L hL + have hbudget' : bulkKernelPairComparisonBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D ≤ + Real.exp (C' * L ^ 2) := + hbudget.trans (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hC₀C (sq_nonneg L))) + have hb := @hrate (TreeLeafIndex n × Fin m) Cell inferInstance inferInstance M Q + inferInstance hQ hQlog Z a bound + (bulkKernelPairComparisonBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D) + T hZ0 hbound0 (bulkKernelPairComparisonBudget_nonneg _ _ _ _ _ _ _ _ _ _) + hdim hZ hcell hunit hbound hbudget' ha hT u hu + simpa only [finite_univ_canonical] using hb + +/-- The cell threshold is uniform over the moving Fourier window. -/ +theorem PublishedProgressionInput.movingPattern_cell_error_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H B D F Cnorm : ℝ) (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) : + ∃ C : ℝ, 1 ≤ C ∧ Cnorm ≤ C ∧ ∀ᶠ L : ℝ in atTop, + let m := spectatorBulkCount k L + ∀ lo hi : ℝ, lo ≤ hi → hi - lo ≤ Real.exp (H * m) → + ∀ (Cell : Type) [Fintype Cell] (M Q : ℕ) [NeZero M], 2 ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 10000 : ℝ) * L) → + ∀ (p : Fin m → ℕ) (Z : (TreeLeafIndex n × Fin m) → ℝ) + (a : ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) → ℂ) (amp T : ℝ), + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ j, 0 ≤ Z j) → (∀ j, Z j ≤ Real.exp (C * L)) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) → + 0 ≤ amp → amp ≤ Real.exp (F * m) → + (∀ z, ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) → + Real.exp ((39 / 10000 : ℝ) * L) ≤ T → + ∀ u : (TreeLeafIndex n × Fin m) → Cell → ℝ, (∀ j c, T ≤ u j c) → + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, + ∑ z : (TreeLeafIndex n × Fin m) → (ZMod M)ˣ, ‖a z‖ * + (2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkKernelPairComparisonBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D * + bulkPrimeErrorFactor P Q (u j (c j))) ≤ + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) := by + obtain ⟨C₀, hC₀, hkernel⟩ := movingPatternKernelBudget_spectatorScale_window ψ n r₀ k A H B D hA hH + let K := (F + 1) * ((k : ℝ) ^ 4 + 1) + let C := max C₀ ((((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K) + -- The dimension is also charged in the same constant. + let C' := max (max C (((2 ^ n : ℕ) : ℝ) * (k : ℝ) ^ 4)) Cnorm + have hK : 0 ≤ K := by dsimp only [K]; positivity + have hC₀C : C₀ ≤ C' := (le_max_left _ _).trans ((le_max_left _ _).trans (le_max_left _ _)) + have hC' : 1 ≤ C' := hC₀.trans hC₀C + refine ⟨C', hC', le_max_right _ _, ?_⟩ + filter_upwards [P.bulk_weighted_error_rate C' hC', eventually_ge_atTop (1 : ℝ)] with L hrate hL + dsimp only + intro lo hi hhi hwidth Cell _ M Q _ hQ hQlog p Z a amp T hp hZ0 hZ hcell hunit hamp0 hamp ha hT u hu + let m := spectatorBulkCount k L + have hL0 : 0 ≤ L := by linarith + have hm := spectatorBulkCount_upper k L hL0 + have hFK : F * (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4] + have hKk : (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [mul_nonneg hF (pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4)] + have hmK : (m : ℝ) ≤ K * L := hm.trans (mul_le_mul_of_nonneg_right hKk hL0) + have hampK : amp ≤ Real.exp (K * L) := hamp.trans (Real.exp_le_exp.mpr (by + exact (mul_le_mul_of_nonneg_left hm hF).trans (by nlinarith [mul_le_mul_of_nonneg_right hFK hL0]))) + let bound := amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) + have hbound0 : 0 ≤ bound := mul_nonneg hamp0 (Finset.prod_nonneg fun i _ => by positivity) + have hbound : bound ≤ Real.exp (C' * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + apply (moving_spectator_linear_cost n m p K L amp hK hL0 hamp0 hmK hampK hp).trans + apply Real.exp_le_exp.mpr + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg _) + apply mul_le_mul_of_nonneg_right _ hL0 + exact (le_max_right C₀ _).trans ((le_max_left C _).trans (le_max_left _ _)) + have hdim : (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ≤ C' * L := by + simp only [Fintype.card_prod, card_treeLeafIndex, Fintype.card_fin, Nat.cast_mul] + calc + _ ≤ (2 ^ n : ℕ) * ((k : ℝ) ^ 4 * L) := + mul_le_mul_of_nonneg_left hm (Nat.cast_nonneg _) + _ ≤ C' * L := by + rw [← mul_assoc] + exact mul_le_mul_of_nonneg_right ((le_max_right _ _).trans (le_max_left _ _)) hL0 + have hbudget := hkernel L hL lo hi hhi hwidth + have hbudget' : bulkKernelPairComparisonBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D ≤ + Real.exp (C' * L ^ 2) := + hbudget.trans (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hC₀C (sq_nonneg L))) + have hb := @hrate (TreeLeafIndex n × Fin m) Cell inferInstance inferInstance M Q + inferInstance hQ hQlog Z a bound + (bulkKernelPairComparisonBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D) + T hZ0 hbound0 (bulkKernelPairComparisonBudget_nonneg _ _ _ _ _ _ _ _ _ _) + hdim hZ hcell hunit hbound hbudget' ha hT u hu + simpa only [finite_univ_canonical] using hb + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternCoefficientMass.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternCoefficientMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e65821aabee276e23e2a943e01e16648854d206 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternCoefficientMass.lean @@ -0,0 +1,134 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternExternalPrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternArithmeticComparison + +namespace OAI + +/-! # The original pattern coefficients as a finite signed linear functional -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingOriginalPatternWeight_eq_coefficient_mul {A B C : Type*} [Fintype B] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (n : ℕ) (pattern : Bool × MovingSampleIndex n → C) + (G : (Fin (N + 1) → A) → ℂ) (x : Fin (N + 1) → A) : + movingOriginalPatternWeight e μ ν prime n pattern G x = + movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) x * G x := by + unfold movingOriginalPatternWeight movingPatternInjectionGuard + split_ifs <;> ring + +/-- Only the internal classes cost a factor of the upper prime cutoff. This +bound is used solely for the negligible giant-comparison errors. -/ +theorem movingPattern_coefficient_norm_le {A B C : Type*} [Fintype B] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (n : ℕ) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (E U : ℝ) (hE : 0 ≤ E) (_hU : 0 ≤ U) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hsize : ∀ a, (prime a : ℝ) ≤ U) (x : Fin (N + 1) → A) : + ‖movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) x‖ ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * + productPrior (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x := by + let w := movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) x + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let R := ∏ c : C, (prime (x (e.symm (.inr c))) : ℝ) + let κ := (2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C) + have hκ : 0 ≤ κ := by dsimp only [κ]; positivity + have hprior : 0 ≤ productPrior law x := productPrior_nonneg law (by + intro i a + dsimp only [law] + cases e i <;> simp only [Sum.elim_inl, Sum.elim_inr] + · exact hν _ a + · exact hμ _ a) x + have hR : 0 < R := Finset.prod_pos (fun c _ => by exact_mod_cast (hprime _).pos) + have hRupper : R ≤ U ^ Fintype.card C := by + calc + R ≤ ∏ _c : C, U := Finset.prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) (fun _ _ => hsize _) + _ = _ := by simp + have hb := movingPattern_fin_prior_bound e μ ν prime n pattern rep E hprime hμ hν hbound + (movingPatternInjectionGuard e (fun _ => 1)) 1 zero_le_one + (movingPatternInjectionGuard_norm e (fun _ => 1) 1 zero_le_one (fun _ => by simp)) x + have hscalar : (∏ c : C, internalLineScalar true (prime (x (e.symm (.inr c))))) = R⁻¹ := by + simp only [internalLineScalar, ite_true, R, Finset.prod_inv_distrib] + change ‖w‖ * _ ≤ 1 * κ * productPrior law x at hb + rw [hscalar, one_mul] at hb + have hm := mul_le_mul_of_nonneg_right hb hR.le + rw [mul_assoc, inv_mul_cancel₀ hR.ne', mul_one] at hm + calc + ‖w‖ ≤ (κ * productPrior law x) * R := hm + _ ≤ (κ * productPrior law x) * U ^ Fintype.card C := + mul_le_mul_of_nonneg_left hRupper (mul_nonneg hκ hprior) + _ = _ := by ring + +theorem movingPattern_coefficient_mass_le {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (n : ℕ) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (E U : ℝ) (hE : 0 ≤ E) (hU : 0 ≤ U) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hμmass : ∀ j, ∑ a, μ j a = 1) (hνmass : ∀ j, ∑ a, ν j a = 1) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) (hsize : ∀ a, (prime a : ℝ) ≤ U) : + (∑ x, ‖movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) x‖) ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) := by + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + have hlaw (i) : ∑ a, law i a = 1 := by + dsimp only [law] + cases e i with + | inl b => exact hνmass b + | inr c => exact hμmass _ + calc + _ ≤ ∑ x, ((((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * + productPrior law x) := Finset.sum_le_sum (fun x _ => + movingPattern_coefficient_norm_le e μ ν prime n pattern rep E U hE hU hprime hμ hν hbound hsize x) + _ = _ := by rw [← Finset.mul_sum, productPrior_mass law hlaw, mul_one] + +/-- A uniform giant-comparison error is charged against the original +coefficient mass. The ideal signed mean stays inside its norm. -/ +theorem movingPattern_comparison_norm {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (E U ε : ℝ) (hE : 0 ≤ E) (hU : 0 ≤ U) (hε : 0 ≤ ε) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hμmass : ∀ j, ∑ a, μ j a = 1) (hνmass : ∀ j, ∑ a, ν j a = 1) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) (hsize : ∀ a, (prime a : ℝ) ≤ U) + (actual ideal : (Fin (N + 1) → A) → ℂ) + (hcompare : ∀ x, movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) x ≠ 0 → + ‖actual x - ideal x‖ ≤ ε) : + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern actual x‖ ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * ε + + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern ideal x‖ := by + let w := movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) + have herror : ‖∑ x, w x * (actual x - ideal x)‖ ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * ε := by + calc + _ ≤ ∑ x, ‖w x‖ * ε := (norm_sum_le _ _).trans (Finset.sum_le_sum (fun x _ => by + rw [norm_mul] + by_cases hw : w x = 0 + · simp only [hw, norm_zero, zero_mul, le_refl] + · exact mul_le_mul_of_nonneg_left (hcompare x hw) (norm_nonneg _))) + _ = (∑ x, ‖w x‖) * ε := (Finset.sum_mul _ _ _).symm + _ ≤ _ := mul_le_mul_of_nonneg_right + (movingPattern_coefficient_mass_le e μ ν prime n pattern rep E U hE hU + hprime hμ hν hμmass hνmass hbound hsize) hε + have heq : (∑ x, w x * actual x) = + (∑ x, w x * (actual x - ideal x)) + ∑ x, w x * ideal x := by + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro x _ + ring + have ha : (∑ x, movingOriginalPatternWeight e μ ν prime n pattern actual x) = + ∑ x, w x * actual x := Finset.sum_congr rfl (fun x _ => + movingOriginalPatternWeight_eq_coefficient_mul e μ ν prime n pattern actual x) + have hi : (∑ x, movingOriginalPatternWeight e μ ν prime n pattern ideal x) = + ∑ x, w x * ideal x := Finset.sum_congr rfl (fun x _ => + movingOriginalPatternWeight_eq_coefficient_mul e μ ν prime n pattern ideal x) + rw [ha, hi, heq] + exact (norm_add_le _ _).trans (add_le_add herror (le_refl _)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternCostRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternCostRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..78467f243c6815cb73439bb840ac454bd2aabd56 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternCostRate.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternUniformBudget +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticErrorRates + +namespace OAI + +/-! # The actual equality-pattern cost fits the source's error budget -/ + +namespace Ostmann +open Filter + +/-- All equality patterns and representative-prior losses contribute only a +fixed-depth exponential in L when p times its prior is at most exp(C L). -/ +theorem movingPattern_total_cost_le_exp (n : ℕ) (C L : ℝ) (hC : 1 ≤ C) (hL : 1 ≤ L) : + (2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) * + (max 2 (Real.exp (C * L))) ^ (4 * n * 2 ^ n) ≤ + Real.exp ((((4 * n * 2 ^ n) ^ 2 + 4 * n * 2 ^ n : ℕ) : ℝ) * C * L) := by + let J := 4 * n * 2 ^ n + have hCL : 1 ≤ C * L := by + calc + 1 = (1 : ℝ) * 1 := by norm_num + _ ≤ C * L := mul_le_mul hC hL (by norm_num) (by linarith) + have he : (2 : ℝ) ≤ Real.exp (C * L) := by + have h := Real.add_one_le_exp (C * L) + linarith + rw [max_eq_right he] + calc + _ ≤ (Real.exp (C * L)) ^ (J ^ 2) * (Real.exp (C * L)) ^ J := + mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (by norm_num) he _) (by positivity) + _ = Real.exp (((J ^ 2 + J : ℕ) : ℝ) * C * L) := by + rw [← pow_add, ← Real.exp_nat_mul] + congr 1 + ring + +/-- The proved pattern count can be inserted into the actual internal-prime +saving, together with the large pointwise spectator factor from (8.21). -/ +theorem movingPattern_internal_error_rate (n : ℕ) (C B c : ℝ) + (hC : 1 ≤ C) (_hB : 0 ≤ B) (hc : 0 < c) : + ∀ᶠ L : ℝ in atTop, + ((2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) * + (max 2 (Real.exp (C * L))) ^ (4 * n * 2 ^ n)) * + Real.exp (B * L ^ 2 + B * L * Real.exp ((1 / 1000 : ℝ) * L)) * + Real.exp (-c * Real.exp ((1 / 100 : ℝ) * L)) ≤ + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + let K : ℝ := ((4 * n * 2 ^ n) ^ 2 + 4 * n * 2 ^ n : ℕ) + let D := B + K * C + filter_upwards [internal_prime_error D c hc, eventually_ge_atTop (1 : ℝ)] with L hrate hL + have hK : 0 ≤ K := by positivity + have hC0 : 0 ≤ C := by linarith + have hpow : L ≤ L ^ 2 := by nlinarith + have hKL : K * C * L ≤ K * C * L ^ 2 := + mul_le_mul_of_nonneg_left hpow (mul_nonneg hK hC0) + have hrest : B * L * Real.exp ((1 / 1000 : ℝ) * L) ≤ + D * L * Real.exp ((1 / 1000 : ℝ) * L) := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg _) + apply mul_le_mul_of_nonneg_right _ (by linarith) + dsimp only [D] + linarith [mul_nonneg hK hC0] + have hexp : K * C * L + (B * L ^ 2 + B * L * Real.exp ((1 / 1000 : ℝ) * L)) ≤ + D * L ^ 2 + D * L * Real.exp ((1 / 1000 : ℝ) * L) := by + dsimp only [D] at * + nlinarith + apply le_trans _ hrate + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg _) + calc + _ ≤ Real.exp (K * C * L) * Real.exp (B * L ^ 2 + B * L * Real.exp ((1 / 1000 : ℝ) * L)) := + mul_le_mul_of_nonneg_right (movingPattern_total_cost_le_exp n C L hC hL) (Real.exp_nonneg _) + _ ≤ _ := by rw [← Real.exp_add]; exact Real.exp_le_exp.mpr hexp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..93f913ea1612eb6cbd4ab2a1599955bff5b16726 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalArithmetic.lean @@ -0,0 +1,210 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalPrimeRanges +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalIdealRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPriorArithmetic + +namespace OAI + +/-! # The full per-pattern diagonal bound under its original signed prime priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_diagonal_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (_hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (active : Fin (movingPatternRegularSlots e n m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG center : ℝ), + let reg := (movingPatternRegularSlots e n m small slot).get + let data := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + MovingLeafLengthLE n small r₀ → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + Function.Injective p → + (∀ q ∈ outside, ∃ i, p i = q) → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + ∀ (tier : primes → ℕ) (lower cutoff : ℕ), + Nfreq ≤ lower → Nfreq < cutoff → cutoff ≤ lower → + (∀ j, j < n → ∀ q, μ j q ≠ 0 → tier q = j) → + (∀ j q, ν j q ≠ 0 → tier q = tierB j) → + (∀ j q, μ j q ≠ 0 → lower < (q : ℕ)) → + (∀ j q, ν j q ≠ 0 → lower < (q : ℕ)) → + (∀ q : primes, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ lower) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (movingOriginalPatternDiagonalObservable e t small slot pattern primes hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq reg active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e n m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + Uall ^ Fintype.card Cidx) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + diagonalOuterMajorant Bφ Dφ diagonal * ((2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG) := by + filter_upwards [P.movingPattern_diagonal_ideal_integral_rate ψ n r₀ k A Wwin Bφ Dφ Cmass + hA hWwin hCmass hBφ hDφ, + P.movingPattern_original_diagonal_prime_ranges ψ n r₀ k A Wwin Bφ Dφ hA hWwin hBφ hDφ] + with L hideal hcompare + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D + small slot pattern rep primes hprimes _ childBound pivotBound hfreq f outside _ p _ hc _ + Dq sets X j₀ φ G u v deleted initial μ ν active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + hinjp houtp hNupper hcenterlow hrGlow tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let m := spectatorBulkCount k L + let slots := movingPatternRegularSlots e n m small slot + let reg := slots.get + have hsmall' : ∀ b : Bool, ∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot := + fun _ => hsmall + have hsmallLen' : ∀ b : Bool, MovingLeafLengthLE n small r₀ := fun _ => hsmallLen + have hfreqN (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList n (t b)) : s.natAbs ≤ Nfreq := by + rw [ht] at hs + exact hN s (allFrequencyList_subtype_mem Sfreq n _ s hs) + have hsupport (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) := + movingPattern_prior_arithmetic_support e μ ν (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) pattern rep tier tierB tierC + hμtier hνtier hB htier Sfreq Nfreq lower ft (fun s hs => ⟨hS s hs, hN s hs⟩) + hNlo hμlo hνlo p (fun i => Fact.out) (fun i => (hprange i).2) t + (fun _ => small) slot (Equiv.refl _) hfreq hfreqN x hx + have hfreqp (i : Fin m) (b : Bool) : movingGiantFrequencyUnits (p i) n (t b) := + movingGiantFrequencyUnits_of_bounds (t b) (fun s hs => + ⟨hfreq b s hs, (hfreqN b s hs).trans_lt (hNcut.trans_le (hprange i).1)⟩) + have hIdeal := hideal lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq Vleaf D + (fun _ => small) slot pattern rep primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + outside p hc (fun i _ => Dq i) sets (giantProgressionCutoff L) X j₀ φ G u v deleted initial μ ν + (Fin slots.length) reg active Jleft Jright diagonal Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter hsmall' hB htier hsmallLen' ht hS hN (fun _ s _ => hleaf s) hD hdiv hm + hp hfreqp + (fun x hx i _ => (hsupport x hx).1 i) + (fun x hx i _ j _ => (hsupport x hx).2.1 i (e.symm (.inl j))) + (fun x hx i c => (hsupport x hx).2.1 i (e.symm (.inr c))) hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.1) + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.2.1) + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.2.2) + have hf (s : ℤ) : ‖f s‖ ≤ 1 := (hleaf s).trans (by split_ifs <;> norm_num) + have hspect (i : Fin m) (z : ZMod (p i)) : ‖normalizedResidueTransform (sets i) z‖ ≤ (p i : ℝ) := + normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z + have hc := hcompare Bidx Cidx N e tierB tierC t small slot pattern rep primes hprimes μ ν p + hinjp (fun i => normalizedResidueTransform (sets i)) Dq active sreg setsReg f outside + childBound pivotBound Sfreq ft Nfreq hfreq X lo hi hlo hhi φ G Jleft Jright diagonal + Eprior Uall uG vG rG sG center hμ0 hν0 hμmass hνmass hEprior (by linarith) + hμbound hvalues hB htier hfreqN hf (fun i => normalizedResidueTransform_zero (sets i)) + hspect houtp hNupper hwindow hpupper hφ hlip hφout hcenterlow huvG hvG hcenter + hrGlow hrsG hsG ht (fun s hs => ⟨hS s hs, hN s hs⟩) tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hsmallLen hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + exact hc.trans (add_le_add (le_refl _) hIdeal) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalConditions.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalConditions.lean new file mode 100644 index 0000000000000000000000000000000000000000..7850f57e040c736c550953667bf2e6b45139fb8b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalConditions.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSeparatedConditions +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternRegularUnits +import OAI.NumberTheory.Ostmann.Characters.NormalizedResidueFamily + +namespace OAI + +/-! # The complete diagonal arithmetic data under the original prime priors -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +theorem movingPattern_diagonal_conditions (input : PublishedProgressionInput) + (n r₀ k : ℕ) (Cfreq : ℝ) (hCfreq : 0 ≤ Cfreq) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (A B C : Type) [Fintype A] [Fintype B] [Fintype C] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (tier : A → ℕ) (tierB : B → ℕ) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (S : Finset ℤ) (V : ℕ) (t : FrequencyTree (S × S) n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (p : Fin m → ℕ) (lo cutoff : ℕ) (E : ℝ) + (sreg : ℤ) (sets : ∀ q : ℕ, Finset (ZMod q)), + let R := frequencyModelBase S n t + let Pi := fun x => movingPatternInternalPrimes e prime x + let M := fun x => ∏ b, movingArithmeticModuli (R ^ (n - 1 + 2)) p (Pi x) Finset.univ b + let Reg := fun x => MovingSlotReversal.naturalProduct (fun i => prime (x i)) + (movingPatternRegularSlots e n m small slot) + Function.Injective prime → + (∀ j a, 0 ≤ μ j a) → (∀ j a, 0 ≤ ν j a) → + (∀ j a, (prime a : ℝ) * μ j a ≤ E) → + (∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → (∀ b, n ≤ tierB b) → + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) → (V : ℝ) ≤ Real.exp (Cfreq * m) → + V ≤ lo → V < cutoff → cutoff ≤ lo → + (∀ j a, μ j a ≠ 0 → lo < prime a) → + (∀ j a, ν j a ≠ 0 → lo < prime a) → + (∀ a, (prime a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, (p i).Prime ∧ cutoff ≤ p i ∧ p i ≤ lo ∧ + (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + MovingLeafLengthLE n small r₀ → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → prime a ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → prime a ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ V → + (∀ q, q.Prime → (sets q).Nonempty ∧ (sets q).card < q) → + ∀ x : Fin (N + 1) → A, + movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) x ≠ 0 → + let t₀ := fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t) + let slots := movingPatternRegularSlots e n m small slot + let T := movingPatternFinBulkData e n m t₀ (fun _ => small) slot (Equiv.refl _) pattern + ∀ (outside : List ℕ), + (∀ b, movingRegularOutsidePairwise (fun i => prime (x i)) outside (T b)) → + let : ∀ j : Fin slots.length, Fact (prime (x (slots.get j))).Prime := + fun _ => ⟨hprime _⟩ + (∀ i j, (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e i) ≠ + (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e j) → + prime (x i) ≠ prime (x j)) ∧ + (∀ i, V < prime (x i)) ∧ + (∀ i, IsCoprime (prime (x i) : ℤ) (R : ℤ)) ∧ + (∀ i, (R ^ (n - 1 + 2)).Coprime (prime (x i))) ∧ + (∀ i j, (prime (x j) : ZMod (p i)) ≠ 0) ∧ + (Reg x).Coprime (M x) ∧ Reg x * M x ≤ giantProgressionCutoff L ∧ + pageAtModulus (Reg x * M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) ∧ + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus (R ^ (n - 1 + 2)) (selectedPageZero input (giantProgressionCutoff L)) ∧ + Pairwise (fun i j : Fin slots.length => + (prime (x (slots.get i))).Coprime (prime (x (slots.get j)))) ∧ + (∀ i : Fin slots.length, (sreg : ZMod (prime (x (slots.get i)))) ≠ 0) ∧ + (∀ i : Fin slots.length, + (movingRegularOther (fun j => prime (x j)) outside slots i : + ZMod (prime (x (slots.get i)))) ≠ 0) ∧ + (∀ i : Fin slots.length, normalizedResidueFamily sets (prime (x (slots.get i))) 0 = 0) ∧ + (∀ i : Fin slots.length, + (∑ z : ZMod (prime (x (slots.get i))), + ‖normalizedResidueFamily sets (prime (x (slots.get i))) z‖ ^ 2) = + prime (x (slots.get i))) := by + filter_upwards [movingPattern_separated_giant_conditions input n r₀ k Cfreq hCfreq] + with L hbase + dsimp only + intro A B C _ _ _ N e prime hprime tier tierB μ ν pattern rep S V t small slot p lo cutoff E + sreg sets hinj hμ hν hbound hμtier hνtier hB hS hV hVlo hVcut hcutlo hμlo hνlo + hupper hp hsmall hdeleteμ hdeletep hdeleteν hsreg hsregV hsets x hx outside hgood + have hb := hbase A B C N e prime tier tierB μ ν pattern rep S V t small slot p lo cutoff E + hinj hprime hμ hν hbound hμtier hνtier hB hS hV hVlo hVcut hcutlo hμlo hνlo hupper + hp hsmall hdeleteμ hdeletep hdeleteν x hx + dsimp only at hb + rcases hb with ⟨hsep, hlarge, hcop, hrcop, hres, hfull, hregcop, hpageReg, hpage, _⟩ + let t₀ := fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t) + let slots := movingPatternRegularSlots e n (spectatorBulkCount k L) small slot + let : ∀ j : Fin slots.length, Fact (prime (x (slots.get j))).Prime := fun _ => ⟨hprime _⟩ + refine ⟨hsep, hlarge, hcop, hrcop, hres, hregcop, hfull, hpageReg, hpage, ?_, ?_, ?_, ?_, ?_⟩ + · exact movingPattern_regular_pairwise e t₀ small slot pattern (fun i => prime (x i)) + outside false (hgood false) + · exact movingPattern_regular_frequency_unit (fun i => prime (x i)) (fun _ => hprime _) + slots V hlarge sreg hsreg hsregV + · exact movingPattern_regular_other_unit e t₀ small slot pattern (fun i => prime (x i)) + (fun _ => hprime _) outside false (hgood false) + · intro i + exact normalizedResidueFamily_zero sets _ + · intro i + exact normalizedResidueFamily_energy sets _ (hsets _ (hprime _)).1 (hsets _ (hprime _)).2 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalHaarComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalHaarComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..c7aada60c86cbf51b423a22e3a572b87d04787db --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalHaarComparison.lean @@ -0,0 +1,158 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedIntegralCRT +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternArithmeticData +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedSeparatedDiagonalRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingLeafAmplitude + +namespace OAI + +/-! # The literal mixed diagonal comparison for sampled pattern trees -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_pattern_diagonal_haar_rate + (input : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (Afreq Wwin Bφ Dφ : ℝ) (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B C J : Type) [Fintype C] [Fintype J] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) (x : Fin (N + 1) → primes) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (reg : J → ℕ) [∀ j, Fact (reg j).Prime] + (active : J → Bool) (sreg : ℤ) (other : ∀ j, ZMod (reg j)) + (greg : ∀ j, ZMod (reg j) → ℂ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (R : ℤ) (r : ℕ) [NeZero r] (P : Finset ℕ) [∀ q : P, Fact q.val.Prime] + [∀ b, NeZero (movingArithmeticModuli r p P Finset.univ b)] + [NeZero (∏ b, movingArithmeticModuli r p P Finset.univ b)] + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (V : ℕ) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) (diagonal : Bool), + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let M := ∏ b, movingArithmeticModuli r p P Finset.univ b + let Reg := MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) + (∀ b, n ≤ tierB b) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → value i ≠ value j) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ V) → (∀ i, V < value i) → + (∀ s, ‖f s‖ ≤ 1) → (∀ i, g i 0 = 0) → (∀ i z, ‖g i z‖ ≤ (p i : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + (∀ b, (T b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ i, IsCoprime (value i : ℤ) R) → + (∀ i j, (value j : ZMod (p i)) ≠ 0) → (∀ i, V < p i) → + P = Finset.univ.image (fun c : C => value (e.symm (.inr c))) → + Function.Injective (fun c : C => value (e.symm (.inr c))) → + Pairwise (fun a b => (movingArithmeticModuli r p P Finset.univ a).Coprime + (movingArithmeticModuli r p P Finset.univ b)) → + Reg = ∏ j, reg j → Reg.Coprime M → Reg * M ≤ giantProgressionCutoff L → + pageAtModulus (Reg * M) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus M (selectedPageZero input (giantProgressionCutoff L)) → + pageAtModulus M (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus r (selectedPageZero input (giantProgressionCutoff L)) → + (∀ b, movingRegularOutsidePairwise value outside (T b)) → + Pairwise (fun i j => (reg i).Coprime (reg j)) → + (∀ i, (∏ j, reg j).Coprime (p i)) → + (∀ i, (sreg : ZMod (reg i)) ≠ 0) → (∀ i, other i ≠ 0) → + (∀ i, greg i 0 = 0) → (∀ i, (∑ z : ZMod (reg i), ‖greg i z‖ ^ 2) = reg i) → + (V : ℝ) ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ z, |φ z| ≤ Bφ) → (∀ z w, |φ z - φ w| ≤ Dφ * |z - w|) → + (∀ z, 1 ≤ |z| → φ z = 0) → + ∀ u v a b center : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → u ≤ v → v ≤ u + 1 → v ≤ center + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ a → a ≤ b → b ≤ a + 1 → + ‖complexPrimeInterval 1 0 a b (fun y => complexIntegerInterval 1 0 u v center (fun z => + movingOriginalSupportedOuterPair p value outside childBound pivotBound + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g (fun _ => Dq) Finset.univ + ψ X lo hi φ G Jleft Jright diagonal T t ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (((∏ j, if active j then (1 : ℝ) else 1 - (reg j : ℝ)⁻¹) : ℝ) : ℂ)) * + movingPatternPrimeObservable e t (fun _ => small) slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x) * + (Real.exp (z - center) : ℂ) / (y : ℂ)) * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t (fun _ => small) (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [input.moving_original_supported_separated_diagonal_prime_rate ψ n r₀ k + Afreq Wwin Bφ Dφ hAfreq hWwin hBφ hDφ] with L hL + dsimp only + intro B C J _ _ N e tierB tierC t small slot pattern primes hprimes x p _ g Dq + reg _ active sreg other greg f outside childBound pivotBound R r _ P _ _ _ hfreq V + X lo hi hlo hhi φ G Jleft Jright diagonal + let m := spectatorBulkCount k L + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let hf := movingPatternFinBulkData_frequencies e t (fun _ => small) slot (Equiv.refl _) + pattern (· ≠ 0) hfreq + let nodes := fun b => (T b).formulaNodes value (fun i => (hprimes _ (x i).property).ne_zero) + childBound pivotBound (hf b) (.prime false) (.prime true) + let M := ∏ b, movingArithmeticModuli r p P Finset.univ b + intro hB htier hdisjoint hV hlarge hfnorm hg hgnorm hout hR hprecision hsmallR hres hspecLarge hP hinj hc + hRegEq hcop hfull hpageReg hpage houtside hreg hqs hsreg hother hgreg henergy + hVA hwindow hpupper hφ hlip hφout u v a b center hcenter huv hv hvcenter ha hab hb + have hprime (i) : (value i).Prime := hprimes _ (x i).property + have hVN (side) : (T side).Frequencies (fun s => s.natAbs ≤ V) := + movingPatternFinBulkData_frequencies e t (fun _ => small) slot (Equiv.refl _) pattern _ hV side + have hVR (side) : (T side).Frequencies (fun s => |(s : ℝ)| ≤ (V : ℝ)) := + (hVN side).mono (fun s hs => by + simpa only [Nat.cast_natAbs, Int.cast_abs] using (show (s.natAbs : ℝ) ≤ V by exact_mod_cast hs)) + have hsmall (side) := (T side).small_frequency_units value hprime V hlarge (hf side) (hVN side) + have hfmod (side) := (T side).small_frequency_residues value hprime V hlarge (hf side) (hVN side) + have hden (side i) : (T side).ModularDenominators value (p i) := by + apply (T side).modularDenominators_of_units value (p i) (hres i) + exact movingPatternFinBulkData_frequencies e t (fun _ => small) slot (Equiv.refl _) + pattern (fun s => (s : ZMod (p i)) ≠ 0) + (fun b s hs => intCast_ne_zero_of_natAbs_lt (p i) s (hfreq b s hs) + ((hV b s hs).trans_lt (hspecLarge i))) side + have hcover := movingPatternFinBulkData_internal_cover e tierB tierC t (fun _ => small) + slot (Equiv.refl _) pattern hB htier (fun q : primes => (q : ℕ)) x + have hcoverP (side o) (ho : o ∈ (T side).occurrences) (j) (hj : j ∈ o.current.compensationSlots) : + value j ∈ P := by + rw [hP] + exact hcover side o ho j hj + have hperiod := movingArithmeticModuli_periods r p P Finset.univ R (n + 1) hprecision + + have hweight (side) : ‖movingDataWeight (fun {_} _ => f) (fun {_} _ _ _ _ => 1) (T side)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (fun {_} _ => f) (fun s _ => hfnorm s) (T side) + have hregular (side) : MovingSlotReversal.naturalProduct value (T side).regularSlots = ∏ j, reg j := + (movingPatternFinBulkData_regular_product e t small slot pattern value side).trans hRegEq + have hqpos : 1 ≤ (∏ j, reg j) * M := by + apply Nat.one_le_iff_ne_zero.mpr + exact mul_ne_zero (Finset.prod_ne_zero_iff.mpr (fun j _ => (Fact.out : (reg j).Prime).ne_zero)) + (NeZero.ne M) + have hh := hL (Fin (N + 1)) J p ((Sum.elim tierB tierC) ∘ e) value hprime hdisjoint outside + childBound pivotBound T hf t + (movingPatternFinBulkData_follows e t (fun _ => small) slot (Equiv.refl _) pattern) + (movingPatternFinBulkData_levels e tierB tierC n m t (fun _ => small) slot (Equiv.refl _) pattern hB htier) + (movingPatternFinBulkData_regular_coherent e t (fun _ => small) slot (Equiv.refl _) pattern) + hsmall hfmod (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g hg (fun _ => Dq) + R hR hsmallR (fun side i => hden side i) hout reg hregular active sreg other greg + X lo hi hlo hhi φ G Jleft Jright hφ hlip hφout diagonal V hVR (Nat.cast_nonneg _) hVA hwindow hpupper + M inferInstance hperiod.1 (fun side o ho j hj => hperiod.2.1 _ (hcoverP side o ho j hj)) + (fun i => hperiod.2.2 i (Finset.mem_univ i)) + (by simpa only [hRegEq] using hcop) + ((∏ j, reg j) * M) hqpos (by simpa only [hRegEq] using hfull) rfl + houtside hreg hqs (by simpa only [hRegEq] using hpageReg) + hsreg hother hgreg henergy u v a b center hcenter huv hv hvcenter ha hab hb hweight hgnorm + rw [movingPatternPrimeObservable_outer_integral_crt e t (fun _ => small) slot (Equiv.refl _) + pattern primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input (giantProgressionCutoff L) + ψ X lo hi hlo hhi φ G x P hP hinj hR hprecision hcoverP hc hpage] + exact hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalIdealRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalIdealRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..b86448097a7701e3c1b7899cc721f24ac6082e44 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalIdealRate.lean @@ -0,0 +1,181 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedIntegratedRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalIntegralScale +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedHarmonicIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # The actual two-prime arithmetic bound integrated over its giant cells -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_diagonal_ideal_integral_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Jidx : Type) [Fintype Jidx] (reg : Jidx → Fin (N + 1)) (active : Jidx → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG center : ℝ), + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (Fw true) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := fun xg y => movingPatternPrimeObservable e t small slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + let W := movingDiagonalOuterWeight (fun q : primes => (q : ℕ)) reg active φ Jleft Jright Bφ Dφ diagonal + let obs := fun xg y x => W xg y x * raw xg y x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i b j, + j ∈ flattenMovingSlots n (small b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (fun x => ∫ xg in Set.Ioc uG vG, ∫ y in Set.Ioc rG sG, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp xg) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * raw xg y x) * + (Real.exp (xg - center) : ℂ) / (y : ℂ)) x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + diagonalOuterMajorant Bφ Dφ diagonal * ((2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG) := by + filter_upwards [P.movingPattern_same_assignment_mixed_prime_integral_rate ψ n r₀ k + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq Fw outside _ p _ hc _ twist sets + Qfreq X j₀ φ G u v deleted initial μ ν Jidx _ reg active Jleft Jright diagonal Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq n ft + let raw := fun xg y => movingPatternPrimeObservable e t small slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y + ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + let W := movingDiagonalOuterWeight (fun q : primes => (q : ℕ)) reg active φ + Jleft Jright Bφ Dφ diagonal + have hh := hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq Vleaf D + small slot pattern rep primes hprimes childBound pivotBound hfreq Fw outside p hc twist sets + Qfreq X j₀ φ G u v deleted initial μ ν W Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues + (movingDiagonalOuterWeight_measurable (fun q : primes => (q : ℕ)) reg active φ + Jleft Jright Bφ Dφ hBφ hDφ hφ hlip hφout diagonal) + (fun xg y x => movingDiagonalOuterWeight_norm (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) reg active φ Jleft Jright Bφ Dφ hBφ hDφ hφ hlip hφout + diagonal xg y x) + (fun xg y x z => movingDiagonalOuterWeight_bulk (fun q : primes => (q : ℕ)) reg active + (movingPatternBulkEmbedding e slot) hfixed φ Jleft Jright Bφ Dφ diagonal xg y x z) + hdisjoint hcross hfmod + exact movingPattern_diagonal_integral_norm e (fun q : primes => (q : ℕ)) μ ν pattern + reg active φ Jleft Jright Bφ Dφ diagonal raw + (movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern) + uG vG rG sG center _ hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalMaskedPriors.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalMaskedPriors.lean new file mode 100644 index 0000000000000000000000000000000000000000..d00695ad1a78da0d923b0c5e48f8a3b1d501a537 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalMaskedPriors.lean @@ -0,0 +1,190 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalMaskedShell +import OAI.NumberTheory.Ostmann.Construction.HarmonicFamilyBounds +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModelRange + +namespace OAI + +/-! # The masked diagonal bound for the original selected harmonic laws -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_diagonal_selected_masked_priors_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ c K : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hc : 0 < c) (hK : 0 ≤ K) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cmass := K + 1 + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (_rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (Qμ : ℕ → Finset ℕ) (Qν : Bidx → Finset ℕ) + (active : Fin (movingPatternRegularSlots e n m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let Eprior := Real.exp (Cmass * L) + let Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ := fun _ {_} _ => f + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots n ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → + (∀ b : Bool, MovingLeafLengthLE n ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active j = false → + (movingPatternRegularSlots e n m small slot).get j ∉ + Set.range (movingPatternBulkEmbedding e slot)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + (∀ j, j < n → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (movingOriginalPatternDiagonalObservable e t small slot pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e n m small slot).get active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e n m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + have hfamily := selected_harmonic_family_bounds c K hc hK + let Cmass := K + 1 + have hCmass : 1 ≤ Cmass := hfamily.1 + filter_upwards [P.movingPattern_diagonal_whole_shell_masked_rate C hM ψ n r₀ k + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ, + movingFrequencyModel_bulk_range n k A hA, + eventually_ge_atTop (max 1 (-Real.log c))] with L hrate hmod hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound f outside p _ Dq sets + primeLo cutoff tier X j₀ φ G global Qμ Qν active sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen ht hS hN hleaf hD hdiv hm hp + hsets hsetsp hpupper hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange hactive houtcover hinjp huBig hrBig + hNfreq hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let α := Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) + let β := Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) + let Vint := Real.exp ((1 / 100 : ℝ) * L) + let Uall := Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) + obtain ⟨hμ0, hν0, hμsum, hνsum, hμbound, hμα, hνα, hμβ, hμmin⟩ := + hfamily.2 L hL primes Bidx Qμ Qν hμP hνP hμmass hνmass hμrange hνrange + have htiers := selected_harmonic_family_tiers primes Bidx n Qμ Qν tier tierB hμtier hνtier + have hL0 : 0 ≤ L := le_trans (by norm_num) ((le_max_left _ _).trans hL) + have hμlo (j) (q : primes) (hq : μ j q ≠ 0) : primeLo < (q : ℕ) := by + have hr := hμmin j q hq + have hh : Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ + Real.exp (Real.exp ((1 / 100 : ℝ) * L)) := + Real.exp_le_exp.mpr (Real.exp_le_exp.mpr (by linarith only [hL0])) + exact_mod_cast (hloReal.trans_le (hh.trans hr)) + have hνlo (j) (q : primes) (hq : ν j q ≠ 0) : primeLo < (q : ℕ) := by + exact_mod_cast (hloReal.trans_le (hνrange j q (primeSubsetPrior_support primes (Qν j) q hq))) + have hUlog : Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) := by + dsimp only [Uall] + rw [Real.log_exp] + exact Real.exp_le_exp.mpr (by linarith only [hL0]) + have hUup : Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + exact Real.exp_le_exp.mpr (by simpa only [Uall, Real.log_exp] using hUlog) + obtain ⟨hrpos, hMpos, hcop, hMQ⟩ := hmod Sfreq Nfreq ft p hS hN hNfreq + (fun i => Fact.out) hinjp (fun i => hNcut.trans_le (hpband i).1) hpupper + let : NeZero (frequencyModelBase Sfreq n ft ^ (n - 1 + 2)) := ⟨Nat.ne_of_gt hrpos⟩ + let : NeZero (∏ i, bulkResidueModuli (frequencyModelBase Sfreq n ft ^ (n - 1 + 2)) p i) := + ⟨Nat.ne_of_gt hMpos⟩ + by_cases htier : ∀ i, movingSampleTier (rep (pattern i)).val.2 = movingSampleTier i.2 + · + exact hrate lo hi hlo hhi hwindow Bidx Cidx N e tierB (fun c => movingSampleTier (rep c).val.2) t Sfreq ft Nfreq Vleaf D + small slot pattern rep primes hprimes childBound pivotBound f outside p hcop Dq sets + primeLo cutoff tier X j₀ φ G global μ ν active (Real.exp (Cmass * L)) α β Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp + hsets hsetsp hpupper hMQ hφ hlip hφout hShell hdel hout + (fun j => congrArg (primeSubsetPrior primes) (hν j)) + hμ0 hν0 hμsum hνsum (Real.one_le_exp_iff.mpr (mul_nonneg (by linarith only [hCmass]) hL0)) + (Real.exp_pos _).le (Real.exp_pos _).le (Real.exp_pos _) (Real.one_le_exp_iff.mpr (Real.exp_pos _).le) + hμbound hμα hνα (fun c => hμβ _) (fun c => hμmin _) hupper hactive houtcover hinjp huBig hrBig + hNfreq le_rfl le_rfl le_rfl rfl hUlog hUup htiers.1 htiers.2 hNlo hNcut hcutlo hμlo hνlo + hupper hpband + (fun z hz q hq j a ha heq => hdeleteμ z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qμ j) a ha)) hdeletep + (fun z hz q hq j a ha heq => hdeleteν z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qν j) a ha)) hsreg hsregN hsetsReg + · have hz (H : (Fin (N + 1) → primes) → ℂ) (x) : + movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern H x = 0 := + movingPattern_zero_of_inconsistent_tiers e μ ν (fun q : primes => (q : ℕ)) + pattern rep tier htiers.1 htier H x + dsimp only [μ, ν] at hz + simp only [hz, Finset.sum_const_zero, norm_zero] + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro z hz + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hz + exact pairFrequencySupportBound_nonneg D f + positivity + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalMaskedShell.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalMaskedShell.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6456b1cea85bffedf4747591f2079f3cebe7554 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalMaskedShell.lean @@ -0,0 +1,199 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalSharp +import OAI.NumberTheory.Ostmann.Arithmetic.WholeShellArithmeticCells +import OAI.NumberTheory.Ostmann.Construction.FrozenPrimeDeletions + +namespace OAI + +/-! # The mixed diagonal bound with the restored compensation mask -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_diagonal_whole_shell_masked_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (active : Fin (movingPatternRegularSlots e n m small slot).length → Bool) + (Eprior αall βint Vint Uall : ℝ) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ := fun _ {_} _ => f + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots n ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b : Bool, MovingLeafLengthLE n ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, ν (slot j) = primeSubsetPrior primes (S \ global)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 1 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → + (movingPatternRegularSlots e n m small slot).get j ∉ + Set.range (movingPatternBulkEmbedding e slot)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Eprior ≤ Real.exp (Cmass * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) → + (∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (∀ j a, μ j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ j a, ν j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (movingOriginalPatternDiagonalObservable e t small slot pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e n m small slot).get active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e n m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + (Real.exp (Cmass * L)) ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + filter_upwards [P.movingPattern_original_diagonal_sharp ψ n r₀ k + A Wwin Bφ Dφ Cmass Cmass hA hWwin hCmass hBφ hDφ hCmass, + whole_shell_arithmetic_cells C Cmass hM hCmass] with L hrate hcells + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound f outside _ p _ hc _ Dq sets + primeLo cutoff tier X j₀ φ G global μ ν active Eprior αall βint Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp + hsets hsetsp hpupper hMQ hφ hlip hφout hShell hdel hout hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hactive houtcover hinjp huBig hrBig + hNfreq hEup hαup hβup hVeq hUlog _hUup hμtier hνtier hNlo hNcut hcutlo hμlo hνlo + hupper hpband hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let m := spectatorBulkCount k L + let a : ℝ := (4 / 1000) * L + let b : ℝ := (6 / 1000) * L + let u := fun (_ : TreeLeafIndex n × Fin m) => wholeShellLower a b + let v := fun (_ : TreeLeafIndex n × Fin m) => wholeShellUpper a b + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp a) (Real.exp b) + let deleted := fun x : Fin (N + 1) → primes => global ∪ + frozenPrimeDeletions (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside + obtain ⟨hcard, hunit, hlow, huv, hshort, hsep, hMcell, hsupport, hmass⟩ := + hcells M hMQ + have hDcard (x) : ((deleted x).card : ℝ) ≤ Real.exp (Cmass * L) := by + have hh : (deleted x).card ≤ global.card + (N + 1) + outside.length := by + have ht := (Finset.card_union_le global _).trans + (Nat.add_le_add_left (frozenPrimeDeletions_card_le + (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside) global.card) + simpa only [Fintype.card_fin, Nat.add_assoc] using ht + exact (Nat.cast_le.mpr hh).trans hdel + have hsub (j) : S \ global ⊆ primeCellSupport M + (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) := by + rw [hsupport]; exact Finset.sdiff_subset + have hretain (x) (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted x ⊆ S \ global := by + rw [hsupport] + intro q hq + exact Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hq).1, + fun hg => (Finset.mem_sdiff.mp hq).2 (Finset.mem_union_left _ hg)⟩ + have hmem (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList n (t b)) : s ∈ Sfreq := by + rw [ht] at hs + exact allFrequencyList_subtype_mem Sfreq n (frequencyPairProjection Sfreq n b ft) s hs + have hfreq (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList n (t b)) : s ≠ 0 := + hS s (hmem b s hs) + have hV (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList n (t b)) : + |(s : ℝ)| ≤ Real.exp (A * m) := by + have hn : (s.natAbs : ℝ) ≤ Nfreq := by exact_mod_cast hN s (hmem b s hs) + exact (show |(s : ℝ)| ≤ Nfreq by simpa only [Nat.cast_natAbs, Int.cast_abs] using hn).trans hNfreq + exact hrate lo hi hlo hhi hwindow Bidx Cidx (Fin (wholePrimeGridCount b)) N e tierB tierC + t Sfreq ft Nfreq Vleaf D small slot pattern rep primes hprimes childBound pivotBound hfreq f + outside p hc Dq sets X j₀ φ G u v (fun x _ => deleted x) (fun _ => S \ global) + μ ν active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter (hsmall false) hB htier (hsmallLen false) + ht hS hN (fun s => hleaf false s []) hD hdiv hm hp hV + hsets hsetsp hpupper hMQ hφ hlip hφout hcard (fun _ => hunit) (fun _ => hlow) + (fun _ => huv) (fun _ => hshort) (fun _ => hsep) (fun _ => hMcell) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hShell) (fun x _ _ => hDcard x) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hmass) + (fun x _ _ i hi => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_base (fun i => (x i : ℕ)) _ outside i hi)) hout + (fun x _ _ q hq => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_outside (fun i => (x i : ℕ)) _ outside q hq)) + (⟨0, wholePrimeGridCount_pos b⟩, 1) hsub (fun x _ => hretain x) hν + hμ0 hν0 hμmass hνmass (le_trans (by norm_num) hEprior) hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hactive + hinjp houtcover hNfreq huBig hrBig tier primeLo cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hpband hdeleteμ hdeletep hdeleteν + hsreg hsregN hsetsReg hEup hUlog hαup hβup hVeq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalObservable.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalObservable.lean new file mode 100644 index 0000000000000000000000000000000000000000..a4230c27ba6a8289238390a020bf49eec990ab94 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalObservable.lean @@ -0,0 +1,41 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkData +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedOuterFactor +import OAI.NumberTheory.Ostmann.Construction.RegularGiantMultiplier + +namespace OAI + +/-! # The original diagonal observable on the finite pattern sample space -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingOriginalPatternDiagonalObservable {B C J : Type*} [Fintype J] + {N n m : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (reg : J → Fin (N + 1)) (active : J → Bool) (sreg : ℤ) + (other : (Fin (N + 1) → primes) → J → ℤ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (x : Fin (N + 1) → primes) : ℂ := by + let value := fun i => (x i : ℕ) + let : ∀ j, Fact (value (reg j)).Prime := fun j => ⟨hprimes _ (x (reg j)).property⟩ + exact complexPrimeInterval 1 0 a b (fun y => complexIntegerInterval 1 0 u v center (fun z => + movingOriginalSupportedOuterPair p value outside childBound pivotBound + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g (fun _ => Dq) Finset.univ + ψ X lo hi φ G Jleft Jright diagonal + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern) + t ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier (fun j => value (reg j)) active sreg + (fun j => (other x j : ZMod (value (reg j)))) (fun j => greg (value (reg j))) + ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ : ℂ))) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalPrimeRanges.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalPrimeRanges.lean new file mode 100644 index 0000000000000000000000000000000000000000..da8f771bf360afaddeab4c944f3111d093e6a4b7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalPrimeRanges.lean @@ -0,0 +1,141 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternOriginalDiagonalNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalConditions + +namespace OAI + +/-! # The original signed diagonal bound from actual prime ranges and conductor deletion -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_diagonal_prime_ranges + (input : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (Afreq Wwin Bφ Dφ : ℝ) (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B C : Type) [Fintype B] [Fintype C] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (pattern : Bool × MovingSampleIndex n → C) + (_rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] (_hinjp : Function.Injective p) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (active : Fin (movingPatternRegularSlots e n m small slot).length → Bool) + (sreg : ℤ) (sets : ∀ q : ℕ, Finset (ZMod q)) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (S : Finset ℤ) (ft : FrequencyTree (S × S) n) + [NeZero (frequencyModelBase S n ft ^ (n - 1 + 2))] (V : ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) (diagonal : Bool) + (E U u v a b center : ℝ), + let reg := (movingPatternRegularSlots e n m small slot).get + let other := fun (x : Fin (N + 1) → primes) => + movingRegularOther (fun i => (x i : ℕ)) outside (movingPatternRegularSlots e n m small slot) + let greg := normalizedResidueFamily sets + let R : ℤ := frequencyModelBase S n ft + let r := frequencyModelBase S n ft ^ (n - 1 + 2) + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ E → 0 ≤ U → (∀ j (q : primes), (q : ℝ) * μ j q ≤ E) → + (∀ q : primes, (q : ℝ) ≤ U) → + (∀ b, n ≤ tierB b) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ V) → + (∀ s, ‖f s‖ ≤ 1) → (∀ i, g i 0 = 0) → (∀ i z, ‖g i z‖ ≤ (p i : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + (V : ℝ) ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ z, |φ z| ≤ Bφ) → (∀ z w, |φ z - φ w| ≤ Dφ * |z - w|) → + (∀ z, 1 ≤ |z| → φ z = 0) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → u ≤ v → v ≤ u + 1 → v ≤ center + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ a → a ≤ b → b ≤ a + 1 → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b ft)) → + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) → + ∀ (tier : primes → ℕ) (lower cutoff : ℕ), + V ≤ lower → V < cutoff → cutoff ≤ lower → + (∀ j, j < n → ∀ q, μ j q ≠ 0 → tier q = j) → + (∀ j q, ν j q ≠ 0 → tier q = tierB j) → + (∀ j q, μ j q ≠ 0 → lower < (q : ℕ)) → + (∀ j q, ν j q ≠ 0 → lower < (q : ℕ)) → + (∀ q : primes, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ lower) → + MovingLeafLengthLE n small r₀ → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ V → + (∀ q, q.Prime → (sets q).Nonempty ∧ (sets q).card < q) → + let actual := movingOriginalPatternDiagonalObservable e t small slot pattern primes hprimes + p g Dq reg active sreg other greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center + let integral := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * + movingPatternPrimeObservable e t (fun _ => small) slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x) * + (Real.exp (z - center) : ℂ) / (y : ℂ) + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern actual x‖ ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern integral x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t (fun _ => small) (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ := by + filter_upwards [input.movingPattern_original_diagonal_norm ψ n r₀ k Afreq Wwin Bφ Dφ + hAfreq hWwin hBφ hDφ, movingPattern_diagonal_conditions input n r₀ k Afreq hAfreq] + with L hnorm hconditions + dsimp only + intro B C _ _ N e tierB tierC t small slot pattern rep primes hprimes μ ν p _ hinjp + g Dq active sreg sets f outside childBound pivotBound S ft _ V hfreq + X lo hi hlo hhi φ G Jleft Jright diagonal E U u v a b center + hμ hν hμmass hνmass hE hU hbound hsize hB htier hV hf hg hgnorm hout + hVA hwindow hpupper hφ hlip hφout hcenter huv hv hvcenter ha hab hb + ht hS tier lower cutoff hVlo hVcut hcutlo hμtier hνtier hμlo hνlo hupper + hp hsmall hdeleteμ hdeletep hdeleteν hsreg hsregV hsets + let m := spectatorBulkCount k L + let R := frequencyModelBase S n ft + let r := R ^ (n - 1 + 2) + let slots := movingPatternRegularSlots e n m small slot + let reg := slots.get + let other := fun (x : Fin (N + 1) → primes) => movingRegularOther (fun i => (x i : ℕ)) outside slots + have hR (b : Bool) : + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern b).frequencyProduct ∣ + (R : ℤ) := by + simpa only [ht, R] using + movingPattern_frequencyProduct_dvd e S ft (fun _ => small) slot (Equiv.refl _) pattern b + have hrp (i) : r.Coprime (p i) := by + exact ((prime_coprime_frequencyModelBase S V (p i) n Fact.out + (hVcut.trans_le (hp i).1) hS ft).pow_right _).symm + apply hnorm B C (Fin slots.length) N e tierB tierC t small slot pattern rep primes hprimes μ ν + p hinjp g Dq reg active sreg other (normalizedResidueFamily sets) f outside + childBound pivotBound (R : ℤ) r V hfreq X lo hi hlo hhi φ G Jleft Jright diagonal + E U u v a b center hμ hν hμmass hνmass hE hU hbound hsize hB htier hV hf hg hgnorm hout + hR (frequencyModelModulus_precision R n) hrp (fun i => hVcut.trans_le (hp i).1) + hVA hwindow hpupper hφ hlip hφout hcenter huv hv hvcenter ha hab hb + · intro x + exact naturalProduct_eq_finprod (fun i => (x i : ℕ)) slots + · intro x hx hgood + have hh := hconditions primes B C N e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) tier tierB μ ν pattern rep S V ft small slot p lower cutoff E + sreg sets Subtype.val_injective hμ hν hbound hμtier hνtier hB hS hVA hVlo hVcut hcutlo + hμlo hνlo hupper (fun i => ⟨Fact.out, (hp i).1, (hp i).2, hpupper i⟩) hsmall + hdeleteμ hdeletep hdeleteν hsreg hsregV hsets x hx outside + have hteq : tierC = fun c => movingSampleTier (rep c).val.2 := by + funext c + have hh := htier (rep c).val + simpa only [(rep c).property] using hh + simpa only [← ht, ← hteq] using hh (by simpa only [← ht] using hgood) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff161372b0e673f10595b7098d062e2261add7f1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalProduct.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedRegularProduct + +namespace OAI + +/-! # The original diagonal observable with its genuine common-product multiplier -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalPatternDiagonalObservable_primeProduct {B C : Type*} + {N n m : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (x : Fin (N + 1) → primes) : + let slots := movingPatternRegularSlots e n m small slot + let value := fun i => (x i : ℕ) + movingOriginalPatternDiagonalObservable e t small slot pattern primes hprimes p g Dq + slots.get (fun _ => true) s + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside slots) greg f outside + childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center x = + complexPrimeInterval 1 0 a b (fun y => complexIntegerInterval 1 0 u v center (fun z => + movingOriginalSupportedOuterPair p value outside childBound pivotBound + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g (fun _ => Dq) Finset.univ + ψ X lo hi φ G Jleft Jright diagonal + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern) + t ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ * + (‖primeProductTransform greg (outside.prod * ⌊Real.exp z⌋₊ * ⌊Real.exp y⌋₊) + (MovingSlotReversal.naturalProduct value slots) s‖ ^ 2 : ℝ))) := by + dsimp only + unfold movingOriginalPatternDiagonalObservable + dsimp only + apply congrArg (complexPrimeInterval 1 0 a b) + funext y + apply congrArg (complexIntegerInterval 1 0 u v center) + funext z + exact movingOriginalSupportedOuterPair_regular_product e t small slot pattern + (fun i => (x i : ℕ)) (fun i => hprimes _ (x i).property) outside p g (fun _ => Dq) + greg s childBound pivotBound (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) + ψ X lo hi φ G Jleft Jright diagonal ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalSelectedPriors.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalSelectedPriors.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a61bc07df0e6b6534f323f349799b09807466e3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalSelectedPriors.lean @@ -0,0 +1,186 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalWholeShell +import OAI.NumberTheory.Ostmann.Construction.HarmonicFamilyBounds +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModelRange + +namespace OAI + +/-! # The original diagonal bound for actual selected harmonic laws -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_diagonal_selected_priors_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ c K : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hc : 0 < c) (hK : 0 ≤ K) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cmass := K + 1 + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (_rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (Qμ : ℕ → Finset ℕ) (Qν : Bidx → Finset ℕ) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let Eprior := Real.exp (Cmass * L) + let Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ := fun _ {_} _ => f + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots n ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → + (∀ b : Bool, MovingLeafLengthLE n ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + (∀ j, j < n → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (movingOriginalPatternDiagonalObservable e t small slot pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e n m small slot).get (fun _ => true) sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e n m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + have hfamily := selected_harmonic_family_bounds c K hc hK + let Cmass := K + 1 + have hCmass : 1 ≤ Cmass := hfamily.1 + filter_upwards [P.movingPattern_diagonal_whole_shell_rate C hM ψ n r₀ k + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ, + movingFrequencyModel_bulk_range n k A hA, + eventually_ge_atTop (max 1 (-Real.log c))] with L hrate hmod hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound f outside p _ Dq sets + primeLo cutoff tier X j₀ φ G global Qμ Qν sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen ht hS hN hleaf hD hdiv hm hp + hsets hsetsp hpupper hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp huBig hrBig + hNfreq hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let α := Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) + let β := Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) + let Vint := Real.exp ((1 / 100 : ℝ) * L) + let Uall := Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) + obtain ⟨hμ0, hν0, hμsum, hνsum, hμbound, hμα, hνα, hμβ, hμmin⟩ := + hfamily.2 L hL primes Bidx Qμ Qν hμP hνP hμmass hνmass hμrange hνrange + have htiers := selected_harmonic_family_tiers primes Bidx n Qμ Qν tier tierB hμtier hνtier + have hL0 : 0 ≤ L := le_trans (by norm_num) ((le_max_left _ _).trans hL) + have hμlo (j) (q : primes) (hq : μ j q ≠ 0) : primeLo < (q : ℕ) := by + have hr := hμmin j q hq + have hh : Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ + Real.exp (Real.exp ((1 / 100 : ℝ) * L)) := + Real.exp_le_exp.mpr (Real.exp_le_exp.mpr (by linarith only [hL0])) + exact_mod_cast (hloReal.trans_le (hh.trans hr)) + have hνlo (j) (q : primes) (hq : ν j q ≠ 0) : primeLo < (q : ℕ) := by + exact_mod_cast (hloReal.trans_le (hνrange j q (primeSubsetPrior_support primes (Qν j) q hq))) + have hUlog : Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) := by + dsimp only [Uall] + rw [Real.log_exp] + exact Real.exp_le_exp.mpr (by linarith only [hL0]) + have hUup : Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + exact Real.exp_le_exp.mpr (by simpa only [Uall, Real.log_exp] using hUlog) + obtain ⟨hrpos, hMpos, hcop, hMQ⟩ := hmod Sfreq Nfreq ft p hS hN hNfreq + (fun i => Fact.out) hinjp (fun i => hNcut.trans_le (hpband i).1) hpupper + let : NeZero (frequencyModelBase Sfreq n ft ^ (n - 1 + 2)) := ⟨Nat.ne_of_gt hrpos⟩ + let : NeZero (∏ i, bulkResidueModuli (frequencyModelBase Sfreq n ft ^ (n - 1 + 2)) p i) := + ⟨Nat.ne_of_gt hMpos⟩ + by_cases htier : ∀ i, movingSampleTier (rep (pattern i)).val.2 = movingSampleTier i.2 + · + exact hrate lo hi hlo hhi hwindow Bidx Cidx N e tierB (fun c => movingSampleTier (rep c).val.2) t Sfreq ft Nfreq Vleaf D + small slot pattern rep primes hprimes childBound pivotBound f outside p hcop Dq sets + primeLo cutoff tier X j₀ φ G global μ ν (Real.exp (Cmass * L)) α β Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp + hsets hsetsp hpupper hMQ hφ hlip hφout hShell hdel hout + (fun j => congrArg (primeSubsetPrior primes) (hν j)) + hμ0 hν0 hμsum hνsum (Real.one_le_exp_iff.mpr (mul_nonneg (by linarith only [hCmass]) hL0)) + (Real.exp_pos _).le (Real.exp_pos _).le (Real.exp_pos _) (Real.one_le_exp_iff.mpr (Real.exp_pos _).le) + hμbound hμα hνα (fun c => hμβ _) (fun c => hμmin _) hupper houtcover hinjp huBig hrBig + hNfreq le_rfl le_rfl le_rfl rfl hUlog hUup htiers.1 htiers.2 hNlo hNcut hcutlo hμlo hνlo + hupper hpband + (fun z hz q hq j a ha heq => hdeleteμ z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qμ j) a ha)) hdeletep + (fun z hz q hq j a ha heq => hdeleteν z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qν j) a ha)) hsreg hsregN hsetsReg + · have hz (H : (Fin (N + 1) → primes) → ℂ) (x) : + movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern H x = 0 := + movingPattern_zero_of_inconsistent_tiers e μ ν (fun q : primes => (q : ℕ)) + pattern rep tier htiers.1 htier H x + dsimp only [μ, ν] at hz + simp only [hz, Finset.sum_const_zero, norm_zero] + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro z hz + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hz + exact pairFrequencySupportBound_nonneg D f + positivity + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalSharp.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalSharp.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4c0e984ebbb65e5b8fbfe0804f797925eeb548e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalSharp.lean @@ -0,0 +1,197 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalNumericalRate + +namespace OAI + +/-! # The sharp original-prior diagonal estimate after absorbing the comparison errors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_diagonal_sharp + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass Cprior : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) (hCprior : 1 ≤ Cprior) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (_hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (active : Fin (movingPatternRegularSlots e n m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG center : ℝ), + let reg := (movingPatternRegularSlots e n m small slot).get + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + MovingLeafLengthLE n small r₀ → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + Function.Injective p → + (∀ q ∈ outside, ∃ i, p i = q) → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + ∀ (tier : primes → ℕ) (lower cutoff : ℕ), + Nfreq ≤ lower → Nfreq < cutoff → cutoff ≤ lower → + (∀ j, j < n → ∀ q, μ j q ≠ 0 → tier q = j) → + (∀ j q, ν j q ≠ 0 → tier q = tierB j) → + (∀ j q, μ j q ≠ 0 → lower < (q : ℕ)) → + (∀ j q, ν j q ≠ 0 → lower < (q : ℕ)) → + (∀ q : primes, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ lower) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + Eprior ≤ Real.exp (Cprior * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (movingOriginalPatternDiagonalObservable e t small slot pattern primes hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq reg active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e n m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + (Real.exp (Cprior * L)) ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀ * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + filter_upwards [P.movingPattern_original_diagonal_arithmetic_rate ψ n r₀ k A Wwin Bφ Dφ Cmass + hA hWwin hCmass hBφ hDφ, + movingPattern_diagonal_pointwise_rate ψ n r₀ k A Wwin Bφ Dφ Cprior Cmass + hA hWwin hBφ hDφ hCprior (by linarith)] with L hmain hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D + small slot pattern rep primes hprimes _ childBound pivotBound hfreq f outside _ p _ hc _ + Dq sets X j₀ φ G u v deleted initial μ ν active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + hinjp houtp hNupper hcenterlow hrGlow tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg hEup hUlog hαup hβup hVeq + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let amp := 2 * (‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data true)‖) + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let K := (((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀ * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + have hh := hmain lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq Vleaf D + small slot pattern rep primes hprimes childBound pivotBound hfreq f outside p hc Dq sets X j₀ φ G + u v deleted initial μ ν active sreg setsReg Jleft Jright diagonal Eprior αall βint Vint Uall + uG vG rG sG center huG hrG huvG hrsG hvG hsG hcenter hsmall hB htier hsmallLen ht hS hN hleaf + hD hdiv hm hp hV hsets hsetsp hpupper hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell + hSS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall + hβint hVint hUall hμbound hμall hνall hμmax hμmin hvalues hfixed hinjp houtp hNupper hcenterlow + hrGlow tier lower cutoff hNlo hNcut hcutlo hμtier hνtier hμlo hνlo hupper hprange + hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + have hone (b : Bool) : ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data b)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (fun {_} _ => f) + (fun s _ => (hleaf s).trans (by split_ifs <;> norm_num)) (data b) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hamp : amp ≤ 4 := by + have h := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + dsimp only [amp] + linarith + have hK : 0 ≤ K := by + have hf := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hs : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro a ha + obtain ⟨b, _, rfl⟩ := List.mem_map.mp ha + exact pairFrequencySupportBound_nonneg D b + dsimp only [K, A₀] + positivity + apply hrate p (Fintype.card Cidx) Eprior Uall αall βint amp lo hi rG K _ diagonal + (movingPattern_class_card_le n pattern rep) hEprior hEup hUall hUlog hαall hαup hβint hβup + hamp0 hamp hhi hwindow hpupper hrGlow hK + simpa only [hVeq, add_assoc] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalWholeShell.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalWholeShell.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2306b0401098c8f8150a60e65bb3d92655470cb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternDiagonalWholeShell.lean @@ -0,0 +1,195 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalSharp +import OAI.NumberTheory.Ostmann.Arithmetic.WholeShellArithmeticCells +import OAI.NumberTheory.Ostmann.Construction.FrozenPrimeDeletions + +namespace OAI + +/-! # The original mixed diagonal bound on the entire bulk shell -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_diagonal_whole_shell_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ := fun _ {_} _ => f + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots n ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b : Bool, MovingLeafLengthLE n ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, ν (slot j) = primeSubsetPrior primes (S \ global)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 1 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Eprior ≤ Real.exp (Cmass * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) → + (∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (∀ j a, μ j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ j a, ν j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (movingOriginalPatternDiagonalObservable e t small slot pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e n m small slot).get (fun _ => true) sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e n m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + (Real.exp (Cmass * L)) ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + filter_upwards [P.movingPattern_original_diagonal_sharp ψ n r₀ k + A Wwin Bφ Dφ Cmass Cmass hA hWwin hCmass hBφ hDφ hCmass, + whole_shell_arithmetic_cells C Cmass hM hCmass] with L hrate hcells + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound f outside _ p _ hc _ Dq sets + primeLo cutoff tier X j₀ φ G global μ ν Eprior αall βint Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp + hsets hsetsp hpupper hMQ hφ hlip hφout hShell hdel hout hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues houtcover hinjp huBig hrBig + hNfreq hEup hαup hβup hVeq hUlog _hUup hμtier hνtier hNlo hNcut hcutlo hμlo hνlo + hupper hpband hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let m := spectatorBulkCount k L + let a : ℝ := (4 / 1000) * L + let b : ℝ := (6 / 1000) * L + let u := fun (_ : TreeLeafIndex n × Fin m) => wholeShellLower a b + let v := fun (_ : TreeLeafIndex n × Fin m) => wholeShellUpper a b + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp a) (Real.exp b) + let deleted := fun x : Fin (N + 1) → primes => global ∪ + frozenPrimeDeletions (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside + obtain ⟨hcard, hunit, hlow, huv, hshort, hsep, hMcell, hsupport, hmass⟩ := + hcells M hMQ + have hDcard (x) : ((deleted x).card : ℝ) ≤ Real.exp (Cmass * L) := by + have hh : (deleted x).card ≤ global.card + (N + 1) + outside.length := by + have ht := (Finset.card_union_le global _).trans + (Nat.add_le_add_left (frozenPrimeDeletions_card_le + (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside) global.card) + simpa only [Fintype.card_fin, Nat.add_assoc] using ht + exact (Nat.cast_le.mpr hh).trans hdel + have hsub (j) : S \ global ⊆ primeCellSupport M + (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) := by + rw [hsupport]; exact Finset.sdiff_subset + have hretain (x) (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted x ⊆ S \ global := by + rw [hsupport] + intro q hq + exact Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hq).1, + fun hg => (Finset.mem_sdiff.mp hq).2 (Finset.mem_union_left _ hg)⟩ + have hmem (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList n (t b)) : s ∈ Sfreq := by + rw [ht] at hs + exact allFrequencyList_subtype_mem Sfreq n (frequencyPairProjection Sfreq n b ft) s hs + have hfreq (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList n (t b)) : s ≠ 0 := + hS s (hmem b s hs) + have hV (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList n (t b)) : + |(s : ℝ)| ≤ Real.exp (A * m) := by + have hn : (s.natAbs : ℝ) ≤ Nfreq := by exact_mod_cast hN s (hmem b s hs) + exact (show |(s : ℝ)| ≤ Nfreq by simpa only [Nat.cast_natAbs, Int.cast_abs] using hn).trans hNfreq + exact hrate lo hi hlo hhi hwindow Bidx Cidx (Fin (wholePrimeGridCount b)) N e tierB tierC + t Sfreq ft Nfreq Vleaf D small slot pattern rep primes hprimes childBound pivotBound hfreq f + outside p hc Dq sets X j₀ φ G u v (fun x _ => deleted x) (fun _ => S \ global) + μ ν (fun _ => true) sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter (hsmall false) hB htier (hsmallLen false) + ht hS hN (fun s => hleaf false s []) hD hdiv hm hp hV + hsets hsetsp hpupper hMQ hφ hlip hφout hcard (fun _ => hunit) (fun _ => hlow) + (fun _ => huv) (fun _ => hshort) (fun _ => hsep) (fun _ => hMcell) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hShell) (fun x _ _ => hDcard x) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hmass) + (fun x _ _ i hi => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_base (fun i => (x i : ℕ)) _ outside i hi)) hout + (fun x _ _ q hq => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_outside (fun i => (x i : ℕ)) _ outside q hq)) + (⟨0, wholePrimeGridCount_pos b⟩, 1) hsub (fun x _ => hretain x) hν + hμ0 hν0 hμmass hνmass (le_trans (by norm_num) hEprior) hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues (fun _ h => by cases h) + hinjp houtcover hNfreq huBig hrBig tier primeLo cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hpband hdeleteμ hdeletep hdeleteν + hsreg hsregN hsetsReg hEup hUlog hαup hβup hVeq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternEnumeration.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..c00685da5bcfb01035f4f2ae70e92fef3b151543 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternEnumeration.lean @@ -0,0 +1,33 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternUniformBudget + +namespace OAI + +/-! # A concrete finite enumeration for every equality pattern -/ + +namespace Ostmann +open scoped Classical + +/-- The same ambient coordinate budget covers every quotient pattern. -/ +theorem movingPattern_enumeration (B : Type) [Fintype B] (b : B) (n : ℕ) : + ∃ (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (_e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s), + ∀ s, N s + 1 ≤ Fintype.card B + 4 * n * 2 ^ n := by + let N := fun s : Setoid (Bool × MovingSampleIndex n) => Fintype.card (B ⊕ Quotient s) - 1 + have hpos (s : Setoid (Bool × MovingSampleIndex n)) : 0 < Fintype.card (B ⊕ Quotient s) := by + let : Nonempty (B ⊕ Quotient s) := ⟨Sum.inl b⟩ + exact Fintype.card_pos + have heq (s : Setoid (Bool × MovingSampleIndex n)) : + Fintype.card (B ⊕ Quotient s) = N s + 1 := by + dsimp only [N] + have hp := hpos s + omega + let e := fun s : Setoid (Bool × MovingSampleIndex n) => (Fintype.equivFinOfCardEq (heq s)).symm + refine ⟨N, e, ?_⟩ + intro s + rw [← heq s, Fintype.card_sum] + apply Nat.add_le_add_left + simpa only [card_movingSamplePairIndex] using Fintype.card_quotient_le s + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternExternalPrior.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternExternalPrior.lean new file mode 100644 index 0000000000000000000000000000000000000000..097d6ac29bfa960f56f7742567a75291e40be92c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternExternalPrior.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePatternBudget +import OAI.NumberTheory.Ostmann.Construction.FiniteProductPrior +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticLineIntegration + +namespace OAI + +/-! # Original external priors joined to the internal equality-pattern law + +Only internal occurrences incur the repetition loss; the bound is uniform +in the number of external and protected bulk coordinates. +-/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_external_prior_bound {A B C : Type*} [Fintype B] [Fintype C] + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) (n : ℕ) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (B ⊕ C → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (x : B ⊕ C → A) : + ‖((∏ b, ν b (x (.inl b)) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (.inr (pattern i)))) : ℂ) * G x‖ * + (∏ c, (prime (x (.inr c)) : ℝ)⁻¹) ≤ + (D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + ∏ i : B ⊕ C, + (Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) i) (x i) := by + let ext : B → A := fun b => x (.inl b) + let inside : C → A := fun c => x (.inr c) + have hx : Sum.elim ext inside = x := by + funext i + cases i <;> rfl + have h := movingPairCompensatedMass_pattern_bound μ prime n pattern rep E hprime hμ hbound + (fun y => G (Sum.elim ext y)) D hD (fun y => hG _) inside + rw [hx] at h + have he : 0 ≤ ∏ b, ν b (ext b) := Finset.prod_nonneg (fun b _ => hν b _) + have hh := mul_le_mul_of_nonneg_left h he + rw [Fintype.prod_sum_type] + simp only [Sum.elim_inl, Sum.elim_inr] + rw [norm_mul, norm_mul, Complex.norm_real, Real.norm_of_nonneg he] + simp only [norm_mul] at hh + convert hh using 1 <;> dsimp only [ext, inside, Function.comp_def] <;> ring + +/-- The same original-law bound in the exact finite coordinates of the +symbolic-line comparison. External coordinates do not enter the loss. -/ +theorem movingPattern_fin_prior_bound {A B C : Type*} [Fintype B] [Fintype C] + {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) (n : ℕ) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (x : Fin (N + 1) → A) : + ‖((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * G x‖ * + (∏ c, internalLineScalar true (prime (x (e.symm (.inr c))))) ≤ + (D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x := by + let y : B ⊕ C → A := x ∘ e.symm + have hy : y ∘ e = x := by funext i; exact congrArg x (e.symm_apply_apply i) + have h := movingPattern_external_prior_bound μ ν prime n pattern rep E hprime hμ hν hbound + (fun z => G (z ∘ e)) D hD (fun z => hG _) y + rw [hy] at h + have hp := e.prod_comp (fun j => + (Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) j) (y j)) + simp only [y, Function.comp_apply, Equiv.symm_apply_apply] at hp + dsimp only [y, Function.comp_apply] at h + rw [← hp] at h + simpa only [y, Function.comp_apply, internalLineScalar, ite_true, productPrior] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFinite.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFinite.lean new file mode 100644 index 0000000000000000000000000000000000000000..01d8f3b567d19497f0d9bd5245f1d8732cc56bef --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFinite.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleOccurrence +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOccurrenceRelabel +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternExternalPrior + +namespace OAI + +/-! # Finite coordinates for the actual internal-pattern tree pair -/ + +namespace Ostmann +open scoped Classical + +theorem movingPairRepresentative_map_nonempty {σ τ : Type*} (f : σ → τ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (i : σ) + (base : MovingPairRepresentativeOccurrences T i) : + Nonempty (MovingPairRepresentativeOccurrences (fun b => (T b).map f) (f i)) := by + let o := (T base.1).occurrences.get base.2.val + have ho : o.map f ∈ ((T base.1).map f).occurrences := by + rw [MovingSlotData.occurrences_map] + exact List.mem_map.mpr ⟨o, List.get_mem _ _, rfl⟩ + have hi : f i ∈ (o.map f).current.compensationSlots := + List.mem_map.mpr ⟨i, base.2.property, rfl⟩ + obtain ⟨k, hk, hko⟩ := List.mem_iff_getElem.mp ho + refine ⟨⟨base.1, ⟨⟨k, hk⟩, ?_⟩⟩⟩ + simpa only [List.get_eq_getElem, hko] using hi + +def movingPatternFinData {B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (side : Bool) : MovingSlotData (Fin (N + 1)) n := + (movingPatternSlotData n (t side) (small side) (bulk side) pattern side).map e.symm + +theorem movingPatternFinData_levels {B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (tierB : B → ℕ) (tierC : C → ℕ) (n : ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) (side : Bool) : + (movingPatternFinData e n t small bulk pattern side).Levels ((Sum.elim tierB tierC) ∘ e) := by + apply (MovingSlotData.levels_map e.symm (Sum.elim tierB tierC) ((Sum.elim tierB tierC) ∘ e) + (fun i => by simp only [Function.comp_apply, Equiv.apply_symm_apply]) _).mpr + exact movingPatternSlotData_levels tierB tierC n (t side) (small side) (bulk side) pattern (hsmall side) (hbulk side) htier side + +/-- The base row is selected from a proved original occurrence, then mapped +into the finite coordinate system used by polynomial comparison. -/ +noncomputable def movingPatternFinRepresentative {B C : Type*} {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (n : ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (c : C) : + MovingPairRepresentativeOccurrences (movingPatternFinData e n t small bulk pattern) + (e.symm (.inr c)) := + Classical.choice (movingPairRepresentative_map_nonempty e.symm _ (.inr c) + (movingPatternRepresentative n t small bulk pattern rep c)) + +/-- Original class injectivity and separation from external slots imply the +unique-prime condition required by the simultaneous line comparison. -/ +theorem movingPatternFin_unique {A B C : Type*} {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hinj : Function.Injective prime) + (x : Fin (N + 1) → A) + (hclasses : Function.Injective (fun c => x (e.symm (.inr c)))) + (hcross : ∀ b c, prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (c : C) (i : Fin (N + 1)) (hi : prime (x i) = prime (x (e.symm (.inr c)))) : + i = e.symm (.inr c) := by + obtain ⟨j, rfl⟩ := e.symm.surjective i + cases j with + | inl b => exact False.elim (hcross b c hi) + | inr d => exact congrArg (fun c => e.symm (.inr c)) (hclasses (hinj hi)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFlagBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFlagBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..50df2360afcb50ce1dc03fb4bbad6ae6b16b2526 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFlagBound.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternArithmeticComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternUniformBudget + +namespace OAI + +/-! # The remaining symbolic factor retains the representative-prior bound -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_flagged_weight_bound {A B C : Type*} [Fintype B] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (x : Fin (N + 1) → A) : + ‖movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small bulk pattern rep x‖ ≤ + (D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x := by + have h := movingPattern_fin_prior_bound e μ ν prime n pattern rep E hprime hμ hν hbound + (movingPatternInjectionGuard e G) D hD (movingPatternInjectionGuard_norm e G D hD hG) x + change ‖movingOriginalPatternWeight e μ ν prime n pattern G x‖ * + (∏ c, internalLineScalar true (prime (x (e.symm (.inr c))))) ≤ _ at h + apply le_trans _ h + rw [norm_mul] + apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) + unfold movingPatternFlagProduct + rw [norm_prod] + apply Finset.prod_le_prod₀ + · intro c _ + exact norm_nonneg _ + · intro c _ + rw [Complex.norm_real, Real.norm_of_nonneg (internalLineFlagWeight_nonneg _ _ _)] + exact internalLineFlagWeight_le_scalar _ _ _ + +/-- After normalization, all the symbolic internal factors cost only the +number of internal draws. There is no factor counting the external slots. -/ +theorem movingPattern_flagged_mean_bound {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) : + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small bulk pattern rep x‖ ≤ + D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) := by + let law := fun i : Fin (N + 1) => + Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + have hlaw (i) : ∑ a, law i a = 1 := by + dsimp only [law] + cases e i with + | inl b => exact hnmass b + | inr c => exact hmass _ + calc + _ ≤ ∑ x, (D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + productPrior law x := norm_sum_le_of_le _ (fun x _ => + movingPattern_flagged_weight_bound e μ ν prime n t small bulk pattern rep E + hprime hμ hν hbound G D hD hG x) + _ = _ := by rw [← Finset.mul_sum, productPrior_mass law hlaw, mul_one] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFrequencyModulus.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFrequencyModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..06ca4697f9d9305a492783c39ba029bf7beac3de --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFrequencyModulus.lean @@ -0,0 +1,43 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.FrequencyModelModulus +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkData + +namespace OAI + +/-! # The actual pattern denominator satisfies the frequency-model requirements -/ + +namespace Ostmann +open scoped Classical + +theorem movingPattern_frequencyProduct_dvd {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (S : Finset ℤ) (t : FrequencyTree (S × S) n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (b : Bool) : + (movingPatternFinBulkData e n m + (fun side => frequencyTreeMap Subtype.val n (frequencyPairProjection S n side t)) + small slot perm pattern b).frequencyProduct ∣ (frequencyModelBase S n t : ℤ) := by + apply Int.natAbs_dvd.mp + apply Int.natCast_dvd_natCast.mpr + rw [movingPatternFinBulkData_build, buildMovingSlotData_frequencyProduct_abs] + cases b + · exact dvd_mul_right _ _ + · exact dvd_mul_left _ _ + +theorem prime_coprime_frequencyModelBase (S : Finset ℤ) (N p n : ℕ) + (hp : p.Prime) (hpN : N < p) (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) + (t : FrequencyTree (S × S) n) : p.Coprime (frequencyModelBase S n t) := by + have h (b : Bool) : p.Coprime (historyFrequencyProduct S n (frequencyPairProjection S n b t)) := by + have hb := prime_coprime_historyFrequencyModulus S N p hp hpN hS n 0 + (frequencyPairProjection S n b t) + exact Nat.Coprime.of_dvd_right (dvd_pow_self _ (by decide : (0 + 2 : ℕ) ≠ 0)) hb + exact (h false).mul_right (h true) + +theorem frequencyModelModulus_bound (S : Finset ℤ) (N n : ℕ) + (hN : ∀ s ∈ S, s.natAbs ≤ N) (t : FrequencyTree (S × S) n) : + frequencyModelBase S n t ^ (n - 1 + 2) ≤ + N ^ (2 * (2 ^ (n + 1) - 1) * (n - 1 + 2)) := by + exact (Nat.pow_le_pow_left (frequencyModelBase_le S n N t hN) _).trans_eq (pow_mul _ _ _).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFrozenMultiplier.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFrozenMultiplier.lean new file mode 100644 index 0000000000000000000000000000000000000000..0bffdc75669011f1e9990a0db188880f3fb8601b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFrozenMultiplier.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternArithmeticComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkFrozen +import OAI.NumberTheory.Ostmann.Construction.SelectedPrimeFubini + +namespace OAI + +/-! # Symbolic internal factors are constant under selected bulk resampling -/ + +namespace Ostmann +open scoped Classical BigOperators + +def movingPatternFeasible {B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) : Prop := + let T := movingPatternFinData e n t small bulk pattern + let base := movingPatternFinRepresentative e n t small bulk pattern rep + ∀ c, lineFeasibleFlags true (fun s => arithmeticTestFlag (lineTestPolynomials + (movingIndexedLine T (e.symm (.inr c)) (base c)) ⟨(base c).1, (base c).2.val⟩ s = 0)) + +/-- The only value-dependent part of the symbolic factor is one reciprocal +prime per class. All feasibility decisions are formal polynomial identities. -/ +theorem movingPatternFlagProduct_eq {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (x : Fin (N + 1) → A) : + movingPatternFlagProduct e prime n t small bulk pattern rep x = + if movingPatternFeasible e n t small bulk pattern rep then + ∏ c : C, ((prime (x (e.symm (.inr c))) : ℝ)⁻¹ : ℂ) else 0 := by + by_cases h : movingPatternFeasible e n t small bulk pattern rep + · rw [ite_eq_left h] + unfold movingPatternFlagProduct + apply Finset.prod_congr rfl + intro c _ + simp only [internalLineFlagWeight, h c, ite_true, internalLineScalar, Complex.ofReal_inv] + · rw [ite_eq_right h] + obtain ⟨c, hc⟩ := not_forall.mp h + unfold movingPatternFlagProduct + apply Finset.prod_eq_zero (Finset.mem_univ c) + simp only [internalLineFlagWeight, hc, ite_false, Complex.ofReal_zero] + +theorem movingPatternFlagProduct_congr {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (x y : Fin (N + 1) → A) (h : ∀ c, x (e.symm (.inr c)) = y (e.symm (.inr c))) : + movingPatternFlagProduct e prime n t small bulk pattern rep x = + movingPatternFlagProduct e prime n t small bulk pattern rep y := by + rw [movingPatternFlagProduct_eq, movingPatternFlagProduct_eq] + simp only [h] + +/-- In the exact Fubini decomposition of the original law, these factors +belong wholly to the fixed nonbulk coefficient. -/ +theorem movingPatternFlagProduct_bulk_frozen {A B C : Type*} [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (x y : TreeLeafIndex n × Fin m → A) + (a : {i : Fin (N + 1) // i ∉ Set.range (movingPatternBulkEmbedding e slot)} → A) : + movingPatternFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) x a) = + movingPatternFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) y a) := by + apply movingPatternFlagProduct_congr + intro c + exact (joinBulkNonbulk_nonbulk _ x a + ⟨e.symm (.inr c), movingPatternBulkEmbedding_internal_absent e slot c⟩).trans + (joinBulkNonbulk_nonbulk _ y a + ⟨e.symm (.inr c), movingPatternBulkEmbedding_internal_absent e slot c⟩).symm + +theorem movingPairCompensatedMass_bulk_frozen {A B C : Type*} [Fintype A] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (prime : A → ℕ) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (pattern : Bool × MovingSampleIndex n → C) + (x y : TreeLeafIndex n × Fin m → A) + (a : {i : Fin (N + 1) // i ∉ Set.range (movingPatternBulkEmbedding e slot)} → A) : + movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => joinBulkNonbulk (movingPatternBulkEmbedding e slot) x a (e.symm (.inr (pattern i))))) = + movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => joinBulkNonbulk (movingPatternBulkEmbedding e slot) y a (e.symm (.inr (pattern i))))) := by + congr 2 + funext i + exact (joinBulkNonbulk_nonbulk _ x a + ⟨e.symm (.inr (pattern i)), movingPatternBulkEmbedding_internal_absent e slot (pattern i)⟩).trans + (joinBulkNonbulk_nonbulk _ y a + ⟨e.symm (.inr (pattern i)), movingPatternBulkEmbedding_internal_absent e slot (pattern i)⟩).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFrozenNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFrozenNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d91f849c19ba5778cc25c357e12f304a785cf00 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternFrozenNorm.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenUnitArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSpectatorUnits +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkFrozen + +namespace OAI + +/-! # The retained arithmetic norm for the actual same-assignment pattern -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_same_assignment_norm {B C I : Type*} [Fintype I] {N₀ n m : ℕ} + (e : Fin (N₀ + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (S : Finset ℤ) (t : FrequencyTree (S × S) n) (R N V : ℕ) + [NeZero (R ^ (n - 1 + 2))] + (hS : ∀ s ∈ S, s ≠ 0) (hN : ∀ s ∈ S, s.natAbs ≤ N) + (hR : ∀ b (j : Fin (2 ^ n - 1)), + (singleTreeNodeFrequencies S n (frequencyPairProjection S n b t) j.val).root.natAbs ∣ R) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b i, i ∈ flattenMovingSlots n (small b) → i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N₀ + 1) → ℕ) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), IsCoprime (base i : ℤ) (R : ℤ)) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N₀ + 1)) k → ℤ → ℂ) + (hF : ∀ b s regular, ‖F b (.leaf s regular) s‖ ≤ if s.natAbs ≤ V then 1 else 0) + (D : ℝ) (hD : 0 ≤ D) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) (hm : 0 < m) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + [NeZero (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli (R ^ (n - 1 + 2)) p i).Coprime + (bulkResidueModuli (R ^ (n - 1 + 2)) p j))) (hp : ∀ i, 3 ≤ p i) + (hfreq : ∀ i b, movingGiantFrequencyUnits (p i) n + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t))) + (hsmallp : ∀ i b j, j ∈ flattenMovingSlots n (small b) → + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) + (hasamples : ∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (henergy : ∀ i, ∑ x : ZMod (p i), ‖g i x‖ ^ 2 ≤ (p i : ℝ)) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (outside : List ℕ) (childBound : ℕ → ℕ) + (input : PublishedProgressionInput) (Q : ℕ) (Y : ℝ) (hY : 0 ≤ Y) + (Ybulk : TreeLeafIndex n × Fin m → ℝ) (hYbulk : ∀ j, 0 ≤ Ybulk j) : + let ts := fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t) + let data := movingPatternFinBulkData e n m ts small slot (Equiv.refl _) pattern + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F (fun _ _ _ _ _ => 1) data childBound R (R ^ (n - 1 + 2)) input Q Y + let spec := fun i => frozenBulkSpectatorHaar base n m ts + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) (Equiv.refl _) (g i) + let M := ∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i + let A := fun z => freq (bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).2 i) + (Fintype.card (TreeLeafIndex n × Fin m → (ZMod M)ˣ) : ℝ)⁻¹ * + (∑ z : TreeLeafIndex n × Fin m → (ZMod M)ˣ, + ‖A z * ∏ j, pageGiantWeight input Q M (z j).val.val (Ybulk j)‖) ≤ + ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * Fintype.card I)) * + (frequencyLeafWeight (pairedFrequencyLeaf S V) n t * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod) := by + intro ts data freq spec M A + have hslot (j : TreeLeafIndex n × Fin m) : + n ≤ ((Sum.elim tierB tierC) ∘ e) (movingPatternBulkEmbedding e slot j) := by + change n ≤ Sum.elim tierB tierC (e (e.symm (.inl (slot j)))) + simpa only [Equiv.apply_symm_apply, Sum.elim_inl] using hB (slot j) + have hd : data = fun b => buildMovingSlotData n (ts b) (movingPatternFiniteSmall e n (small b)) + (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot)) (movingPatternFiniteSamples e n pattern b) := by + funext b + dsimp only [data] + rw [movingPatternFinBulkData_build] + cases b <;> rfl + have h := frozenUnitArithmeticMean_le base ((Sum.elim tierB tierC) ∘ e) S n m R N V t + hS hN hR (movingPatternBulkEmbedding e slot) (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) hslot + (fun b => movingPatternFiniteSmall_absent e slot (small b) (hsmall b)) + (movingPatternFiniteSamples_levels e tierB tierC n pattern htier) hbase F hF D hD hdiv hm p hc hp hfreq + (fun i b => movingPatternFiniteSmall_unit e base (small b) (hsmallp i b)) + (fun i => movingPatternFiniteSamples_units e base pattern (hasamples i)) + g hg henergy twist outside childBound input Q Y hY Ybulk hYbulk + dsimp only [A, freq, spec, M] + rw [hd] + unfold frozenUnitArithmeticMean at h + dsimp only at h + simp only [finite_univ_canonical, Fintype.card_eq_nat_card] at h ⊢ + apply le_trans (le_of_eq ?_) h + congr 1 + apply Finset.sum_congr rfl + intro z _ + congr 1 + exact mul_right_comm _ _ _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantBounds.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..b5d2482ae94a0ff957ca28f3a14df90184dd830a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantBounds.lean @@ -0,0 +1,148 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternModulusRange +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkBudgets +import OAI.NumberTheory.Ostmann.Construction.SpectatorBulkScale + +namespace OAI + +/-! # Concrete logarithmic bounds for the original giant comparison -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +theorem giantProgressionCutoff_log_le {M : ℕ} {L : ℝ} + (hM : 0 < M) (hbound : M ≤ giantProgressionCutoff L) : + Real.log (M : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) := by + have hupper : (M : ℝ) ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + apply (Nat.cast_le.mpr hbound).trans + have h := Nat.floor_le (Real.exp_nonneg (Real.exp ((12 / 10000 : ℝ) * (10 * L)))) + simpa only [giantProgressionCutoff, bulkProgressionCutoff, + show (12 / 10000 : ℝ) * (10 * L) = (12 / 1000 : ℝ) * L by ring] using h + have hlog := Real.log_le_log (show (0 : ℝ) < M by exact_mod_cast hM) hupper + simpa only [Real.log_exp] using hlog + +theorem naturalProduct_exp_bound {σ : Type*} (value : σ → ℕ) (A : ℝ) + (hvalue : ∀ i, (value i : ℝ) ≤ Real.exp A) (slots : List σ) : + (MovingSlotReversal.naturalProduct value slots : ℝ) ≤ Real.exp (slots.length * A) := by + induction slots with + | nil => simp [MovingSlotReversal.naturalProduct] + | cons i slots ih => + simp only [MovingSlotReversal.naturalProduct, List.map_cons, List.prod_cons, Nat.cast_mul] + apply (mul_le_mul (hvalue i) ih (Nat.cast_nonneg _) (Real.exp_nonneg _)).trans_eq + rw [← Real.exp_add, List.length_cons, Nat.cast_add, Nat.cast_one] + congr 1 + ring + +theorem naturalProduct_log_bound {σ : Type*} (value : σ → ℕ) (A : ℝ) + (hpos : ∀ i, value i ≠ 0) (hvalue : ∀ i, (value i : ℝ) ≤ Real.exp A) (slots : List σ) : + Real.log (MovingSlotReversal.naturalProduct value slots : ℝ) ≤ slots.length * A := by + have hn : MovingSlotReversal.naturalProduct value slots ≠ 0 := by + apply List.prod_ne_zero + intro hz + obtain ⟨i, _, hi⟩ := List.mem_map.mp hz + exact hpos i hi + have hp : (0 : ℝ) < MovingSlotReversal.naturalProduct value slots := by + exact_mod_cast Nat.pos_of_ne_zero hn + have h := Real.log_le_log hp (naturalProduct_exp_bound value A hvalue slots) + simpa only [Real.log_exp] using h + +/-- A list containing linearly many primes in the actual nongiant range +satisfies the logarithmic budget used by the giant progression theorem. -/ +theorem naturalProduct_giant_log_range (K : ℝ) (hK : 0 ≤ K) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type) (value : σ → ℕ) (slots : List σ), + (∀ i, value i ≠ 0) → (slots.length : ℝ) ≤ K * L → + (∀ i, (value i : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + Real.log (MovingSlotReversal.naturalProduct value slots : ℝ) ≤ + Real.exp ((12 / 1000 : ℝ) * L) := by + filter_upwards [arithmetic_exponent_absorption (11 / 1000) (12 / 1000) 0 K 1 0 + (by norm_num) (by norm_num) (by norm_num) (by norm_num)] with L hL + intro σ value slots hpos hlen hvalue + have hlog := naturalProduct_log_bound value (Real.exp ((11 / 1000 : ℝ) * L)) hpos hvalue slots + have hlen' := mul_le_mul_of_nonneg_right hlen (Real.exp_nonneg ((11 / 1000 : ℝ) * L)) + simp only [pow_zero, mul_one, zero_mul, Real.exp_zero, one_mul] at hL + exact (hlog.trans hlen').trans (by linarith) + +/-- The common regular product of both histories uses only the original +small and bulk leaves. Its logarithmic budget follows from their lengths. -/ +theorem movingPattern_regular_giant_log_range (n r₀ k : ℕ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B C : Type) (N : ℕ) (e : Fin (N + 1) ≃ B ⊕ C) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (value : Fin (N + 1) → ℕ), + MovingLeafLengthLE n small r₀ → (∀ i, value i ≠ 0) → + (∀ i, (value i : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + Real.log (MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) : ℝ) ≤ + Real.exp ((12 / 1000 : ℝ) * L) := by + let K : ℝ := (2 ^ n : ℕ) * ((r₀ : ℝ) + (k : ℝ) ^ 4) + have hK : 0 ≤ K := by dsimp only [K]; positivity + filter_upwards [naturalProduct_giant_log_range K hK, eventually_ge_atTop (1 : ℝ)] + with L hL hlarge + dsimp only + intro B C N e small slot value hsmall hpos hvalue + apply hL (Fin (N + 1)) value _ hpos _ hvalue + have hsmall' := moving_flatten_length_le n (movingPatternFiniteSmall e n small) r₀ + (movingLeafLengthLE_map _ n small r₀ hsmall) + have hbulk := moving_flatten_length_le n + (bulkSlotLeaves n (spectatorBulkCount k L) (movingPatternBulkEmbedding e slot)) + (spectatorBulkCount k L) (bulkSlotLeaves_length n _ _) + have hlen := Nat.cast_le (α := ℝ).mpr (Nat.add_le_add hsmall' hbulk) + have hm := spectatorBulkCount_upper k L (by linarith) + have hr := mul_le_mul_of_nonneg_left hlarge (Nat.cast_nonneg r₀) + have hh := mul_le_mul_of_nonneg_left (add_le_add hr hm) + (show (0 : ℝ) ≤ (2 ^ n : ℕ) by positivity) + rw [List.length_append, Nat.cast_add] + push_cast at hlen + apply hlen.trans + simpa only [K, mul_one, Nat.cast_pow, Nat.cast_ofNat, mul_add, add_mul, mul_assoc] using hh + +/-- The frequency modulus used by the actual pair of histories has a fixed +polynomial degree in the frequency cutoff. -/ +theorem frequencyModelModulus_exp_bound (S : Finset ℤ) (N n : ℕ) + (t : FrequencyTree (S × S) n) (A : ℝ) + (hN : ∀ s ∈ S, s.natAbs ≤ N) (hA : (N : ℝ) ≤ Real.exp A) : + ((frequencyModelBase S n t ^ (n - 1 + 2) : ℕ) : ℝ) ≤ + Real.exp ((2 * (2 ^ (n + 1) - 1) * (n - 1 + 2) : ℕ) * A) := by + calc + _ ≤ (N : ℝ) ^ (2 * (2 ^ (n + 1) - 1) * (n - 1 + 2)) := by + exact_mod_cast frequencyModelModulus_bound S N n hN t + _ ≤ (Real.exp A) ^ (2 * (2 ^ (n + 1) - 1) * (n - 1 + 2)) := + pow_le_pow_left₀ (Nat.cast_nonneg N) hA _ + _ = _ := (Real.exp_nat_mul _ _).symm + +/-- The paired frequency modulus, the actual internal prime image, and the +selected spectators all fit the giant cutoff at the manuscript scales. -/ +theorem movingPattern_actual_modulus_range (n k : ℕ) (Cfreq : ℝ) (hCfreq : 0 ≤ Cfreq) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (S : Finset ℤ) (N : ℕ) (t : FrequencyTree (S × S) n) + (p : Fin m → ℕ) (P : Finset ℕ), + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) → (N : ℝ) ≤ Real.exp (Cfreq * m) → + P.card ≤ 4 * n * 2 ^ n → + (∀ q ∈ P, q.Prime ∧ (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, (p i).Prime ∧ (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + let M := ∏ b, movingArithmeticModuli (frequencyModelBase S n t ^ (n - 1 + 2)) + p P Finset.univ b + M ≤ giantProgressionCutoff L ∧ Real.log (M : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) := by + let D : ℕ := 2 * (2 ^ (n + 1) - 1) * (n - 1 + 2) + filter_upwards [movingArithmeticModuli_giant_range n ((D : ℝ) * Cfreq) ((k : ℝ) ^ 4) + (by positivity) (by positivity), eventually_ge_atTop (0 : ℝ)] with L hL hL0 + dsimp only + intro S N t p P hS hN hcard hP hp + let r := frequencyModelBase S n t ^ (n - 1 + 2) + have hr : (r : ℝ) ≤ Real.exp (((D : ℝ) * Cfreq) * spectatorBulkCount k L) := by + simpa only [mul_assoc, D, r] using frequencyModelModulus_exp_bound S N n t + (Cfreq * spectatorBulkCount k L) (fun s hs => (hS s hs).2) hN + have hbound := hL (spectatorBulkCount k L) r p P (spectatorBulkCount_upper k L hL0) + hcard hr (fun q hq => (hP q hq).2) (fun i => (hp i).2) + refine ⟨hbound, giantProgressionCutoff_log_le ?_ hbound⟩ + apply Nat.pos_of_ne_zero + apply Finset.prod_ne_zero_iff.mpr + intro b _ + exact movingArithmeticModuli_ne_zero r p P Finset.univ + (pow_ne_zero _ (Nat.ne_of_gt (frequencyModelBase_pos S n t (fun s hs => (hS s hs).1)))) + (fun q hq => (hP q hq).1) (fun i _ => (hp i).1) b + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantConditions.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantConditions.lean new file mode 100644 index 0000000000000000000000000000000000000000..e50c07e68f037d24836da639a92321bac40e1333 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantConditions.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantBounds +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternUniformBudget + +namespace OAI + +/-! # Supplying the giant arithmetic conditions from the original prime priors -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +/-- All assignment-dependent conditions of the giant comparison follow from +actual prime ranges, original-prior support, and the prescribed conductor +prime deletion. No arithmetic comparison is assumed in this statement. -/ +theorem movingPattern_giant_conditions (input : PublishedProgressionInput) + (n r₀ k : ℕ) (Cfreq : ℝ) (hCfreq : 0 ≤ Cfreq) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (A B C : Type) [Fintype A] [Fintype B] [Fintype C] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (tier : A → ℕ) (tierB : B → ℕ) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (S : Finset ℤ) (V : ℕ) (t : FrequencyTree (S × S) n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (p : Fin m → ℕ) (lo cutoff : ℕ) (E : ℝ), + let R := frequencyModelBase S n t + let Pi := fun x => movingPatternInternalPrimes e prime x + let M := fun x => ∏ b, movingArithmeticModuli (R ^ (n - 1 + 2)) p (Pi x) Finset.univ b + Function.Injective prime → (∀ a, (prime a).Prime) → + (∀ j a, 0 ≤ μ j a) → (∀ j a, 0 ≤ ν j a) → + (∀ j a, (prime a : ℝ) * μ j a ≤ E) → + (∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → (∀ b, n ≤ tierB b) → + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) → (V : ℝ) ≤ Real.exp (Cfreq * m) → + V ≤ lo → V < cutoff → cutoff ≤ lo → + (∀ j a, μ j a ≠ 0 → lo < prime a) → + (∀ j a, ν j a ≠ 0 → lo < prime a) → + (∀ a, (prime a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, (p i).Prime ∧ cutoff ≤ p i ∧ p i ≤ lo ∧ + (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + MovingLeafLengthLE n small r₀ → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → prime a ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + ∀ x : Fin (N + 1) → A, + movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) x ≠ 0 → + (∀ i j, (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e i) ≠ + (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e j) → + prime (x i) ≠ prime (x j)) ∧ + (∀ i, V < prime (x i)) ∧ + (∀ i, IsCoprime (prime (x i) : ℤ) (R : ℤ)) ∧ + (∀ i, (R ^ (n - 1 + 2)).Coprime (prime (x i))) ∧ + (∀ i j, (prime (x j) : ZMod (p i)) ≠ 0) ∧ + M x ≤ giantProgressionCutoff L ∧ + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus (R ^ (n - 1 + 2)) (selectedPageZero input (giantProgressionCutoff L)) ∧ + Real.log (M x : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) ∧ + Real.log (MovingSlotReversal.naturalProduct (fun i => prime (x i)) + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) : ℝ) ≤ + Real.exp ((12 / 1000 : ℝ) * L) := by + filter_upwards [movingPattern_actual_modulus_range n k Cfreq hCfreq, + movingPattern_regular_giant_log_range n r₀ k] with L hmod hreg + dsimp only + intro A B C _ _ _ N e prime tier tierB μ ν pattern rep S V t small slot p lo cutoff E + hinj hprime hμ hν hbound hμtier hνtier hB hS hV hVlo hVcut hcutlo hμlo hνlo hupper + hp hsmall hdeleteμ hdeletep x hx + let m := spectatorBulkCount k L + let R := frequencyModelBase S n t + let Pi := movingPatternInternalPrimes e prime x + have hprior := movingPattern_nonzero_prior e μ ν prime pattern rep E hprime hμ hν hbound + (fun _ => 1) x hx + have hlarge := movingPattern_prior_lower e μ ν prime pattern rep lo hμlo hνlo x hprior + obtain ⟨hsep, hsize, hcop, hrcop, hres⟩ := movingPattern_prior_giant_support e μ ν prime hinj + hprime pattern rep tier tierB hμtier hνtier hB S V lo t hS hVlo hμlo hνlo p + (fun i => (hp i).1) (fun i => (hp i).2.2.1) E hμ hν hbound x hx + have hPi : ∀ q ∈ Pi, q.Prime ∧ (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) := by + intro q hq + obtain ⟨c, _, rfl⟩ := Finset.mem_image.mp hq + exact ⟨hprime _, hupper _⟩ + have hcard : Pi.card ≤ 4 * n * 2 ^ n := by + calc + Pi.card ≤ (Finset.univ : Finset C).card := Finset.card_image_le + _ = Fintype.card C := Finset.card_univ + _ ≤ 4 * n * 2 ^ n := movingPattern_class_card_le n pattern rep + have hm := hmod S V t p Pi hS hV hcard hPi (fun i => ⟨(hp i).1, (hp i).2.2.2⟩) + have hpage := frequencyModel_page_projection S n V cutoff t hS hVcut Pi p + (selectedPageZero input (giantProgressionCutoff L)) + (by + intro q hq + obtain ⟨c, _, rfl⟩ := Finset.mem_image.mp hq + exact ⟨hprime _, hcutlo.trans (hlarge _).le⟩) + (fun i => ⟨(hp i).1, (hp i).2.1⟩) + (by + intro z hz q hq hmem + obtain ⟨c, _, hqc⟩ := Finset.mem_image.mp hmem + have hpc := movingPattern_internal_prior_nonzero e μ ν prime pattern (fun _ => 1) x hx + (rep c).val + rw [(rep c).property] at hpc + exact hdeleteμ z hz q hq _ _ hpc hqc) + (fun z hz q hq i => (hdeletep z hz q hq i).symm) + have hr := hreg B C N e small slot (fun i => prime (x i)) hsmall + (fun i => (hprime _).ne_zero) (fun i => hupper _) + exact ⟨hsep, hsize, hcop, hrcop, hres, hm.1, hpage, hm.2, hr⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantErrorRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantErrorRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..4baf1e984c7d2b5c03129cf8fc87331d42416ab7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantErrorRate.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCostRate + +namespace OAI + +/-! # The giant comparison error after the actual coefficient mass -/ + +namespace Ostmann +open Filter + +/-- The upper prime cutoff costs one factor per internal class. Even at the +full permitted small-prime scale, the two giant errors remain negligible. -/ +theorem movingPattern_giant_error_rate (n : ℕ) (C : ℝ) (hC : 1 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ c : ℕ, c ≤ 4 * n * 2 ^ n → ∀ E U : ℝ, + 0 ≤ E → E ≤ Real.exp (C * L) → 0 ≤ U → U ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) → + ((2 : ℝ) ^ c * E ^ (4 * n * 2 ^ n - c) * U ^ c) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) ≤ + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + let J := 4 * n * 2 ^ n + let K : ℝ := ((J ^ 2 + J : ℕ) : ℝ) * C + let H : ℝ := K + J + 1 + have hK : 0 ≤ K := by dsimp only [K]; positivity + have hH : 0 ≤ H := by dsimp only [H]; positivity + filter_upwards [arithmetic_error_absorption (12 / 1000) (1225 / 100000) (2 / 1000) + H 1 1 (by norm_num) (by norm_num) (by norm_num) (by norm_num), + eventually_ge_atTop (1 : ℝ)] with L herr hL c hc E U hE hEC hU hUC + have hL0 : 0 ≤ L := by linarith + have hExp : 1 ≤ Real.exp ((12 / 1000 : ℝ) * L) := + Real.one_le_exp_iff.mpr (by positivity) + have hprior : (2 : ℝ) ^ c * E ^ (J - c) ≤ Real.exp (K * L) := by + calc + _ ≤ (max 2 E) ^ J := movingPattern_loss_le n c hc E hE + _ ≤ (max 2 (Real.exp (C * L))) ^ J := + pow_le_pow_left₀ (by positivity) (max_le_max_left _ hEC) J + _ ≤ (2 : ℝ) ^ (J ^ 2) * (max 2 (Real.exp (C * L))) ^ J := + le_mul_of_one_le_left (by positivity) (one_le_pow₀ (by norm_num)) + _ ≤ _ := movingPattern_total_cost_le_exp n C L hC hL + have hU' : U ^ c ≤ Real.exp ((J : ℝ) * Real.exp ((12 / 1000 : ℝ) * L)) := by + calc + _ ≤ (Real.exp (Real.exp ((12 / 1000 : ℝ) * L))) ^ c := pow_le_pow_left₀ hU hUC c + _ ≤ (Real.exp (Real.exp ((12 / 1000 : ℝ) * L))) ^ J := + pow_le_pow_right₀ (Real.one_le_exp_iff.mpr (Real.exp_pos _).le) hc + _ = _ := (Real.exp_nat_mul _ J).symm + let mass := (2 : ℝ) ^ c * E ^ (J - c) * U ^ c + have hmass0 : 0 ≤ mass := by dsimp only [mass]; positivity + have hmass : mass ≤ Real.exp (K * L + (J : ℝ) * Real.exp ((12 / 1000 : ℝ) * L)) := by + simpa only [Real.exp_add] using mul_le_mul hprior hU' (pow_nonneg hU _) (Real.exp_nonneg _) + have htwo : (2 : ℝ) ≤ Real.exp L := by linarith [Real.add_one_le_exp L] + have hdouble : 2 * mass ≤ Real.exp (H * L + H * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + apply (mul_le_mul htwo hmass hmass0 (Real.exp_nonneg _)).trans + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + have hJL : (J : ℝ) ≤ (J : ℝ) * L := le_mul_of_one_le_right (Nat.cast_nonneg _) hL + have hHJ : (J : ℝ) ≤ H := by dsimp only [H]; linarith + have hJHL : (J : ℝ) ≤ H * L := hJL.trans (mul_le_mul_of_nonneg_right hHJ hL0) + have he := mul_le_mul_of_nonneg_right hJHL (Real.exp_nonneg ((12 / 1000 : ℝ) * L)) + dsimp only [H] at * + nlinarith + have hsmall : Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + apply Real.exp_le_exp.mpr + have hh : (1225 / 100000 : ℝ) * L ≤ (125 / 10000 : ℝ) * L := by linarith + linarith [Real.exp_le_exp.mpr hh] + change mass * _ ≤ _ + calc + _ ≤ (2 * mass) * Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + have h := mul_le_mul_of_nonneg_left hsmall hmass0 + nlinarith only [h] + _ ≤ _ := (mul_le_mul_of_nonneg_right hdouble (Real.exp_nonneg _)).trans + (by simpa only [pow_one, one_mul, neg_mul] using herr) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..2f5e91b2eb02bf74c940aa27c4e6658259a8432c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantSupport.lean @@ -0,0 +1,120 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeSupport +import OAI.NumberTheory.Ostmann.ZeroDensity.PageConductorProjection + +namespace OAI + +/-! # Range separation and conductor deletion for the actual giant comparison -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_prior_lower {A B C : Type*} {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (lo : ℕ) + (hμ : ∀ j a, μ j a ≠ 0 → lo < prime a) + (hν : ∀ j a, ν j a ≠ 0 → lo < prime a) + (x : Fin (N + 1) → A) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ∀ i, lo < prime (x i) := by + intro i + have hi := Finset.prod_ne_zero_iff.mp hx i (Finset.mem_univ _) + cases he : e i with + | inl b => exact hν b (x i) (by simpa only [he, Sum.elim_inl] using hi) + | inr c => exact hμ _ (x i) (by simpa only [he, Sum.elim_inr] using hi) + +/-- The original prior supplies all prime-range and frequency-unit conditions +for the giant comparison, including the protected bulk coordinates. -/ +theorem movingPattern_prior_giant_support {A B C I : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (hinj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (tier : A → ℕ) (tierB : B → ℕ) + (hμtier : ∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) + (hνtier : ∀ j a, ν j a ≠ 0 → tier a = tierB j) (hB : ∀ b, n ≤ tierB b) + (S : Finset ℤ) (V lo : ℕ) (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) (hVlo : V ≤ lo) + (hμlo : ∀ j a, μ j a ≠ 0 → lo < prime a) + (hνlo : ∀ j a, ν j a ≠ 0 → lo < prime a) + (p : I → ℕ) (hp : ∀ i, (p i).Prime) (hplo : ∀ i, p i ≤ lo) + (E : ℝ) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (x : Fin (N + 1) → A) + (hx : movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) x ≠ 0) : + let R := frequencyModelBase S n t + (∀ i j, (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e i) ≠ + (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e j) → + prime (x i) ≠ prime (x j)) ∧ + (∀ i, V < prime (x i)) ∧ + (∀ i, IsCoprime (prime (x i) : ℤ) (R : ℤ)) ∧ + (∀ i, (R ^ (n - 1 + 2)).Coprime (prime (x i))) ∧ + (∀ i j, (prime (x j) : ZMod (p i)) ≠ 0) := by + intro R + have hprior := movingPattern_nonzero_prior e μ ν prime pattern rep E hprime hμ hν hbound + (fun _ => 1) x hx + have hlarge := movingPattern_prior_lower e μ ν prime pattern rep lo hμlo hνlo x hprior + have hlargeV (i) : V < prime (x i) := hVlo.trans_lt (hlarge i) + have hcop := movingPattern_prior_frequency_coprime e μ ν prime hprime pattern rep S V t hS + (fun j a ha => hVlo.trans_lt (hμlo j a ha)) + (fun j a ha => hVlo.trans_lt (hνlo j a ha)) x hprior + refine ⟨(movingPattern_prior_prime_separation e μ ν pattern rep tier tierB prime hinj + hμtier hνtier hB x hprior).1, hlargeV, ?_, ?_, ?_⟩ + · intro i + rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast, Int.natAbs_natCast] + exact hcop i + · intro i + exact ((hcop i).pow_right _).symm + · intro i j hz + have hd := (ZMod.natCast_eq_zero_iff (prime (x j)) (p i)).mp hz + have heq := (Nat.prime_dvd_prime_iff_eq (hp i) (hprime _)).mp hd + have hlt := (hplo i).trans_lt (hlarge j) + omega + +/-- Deleting the selected large conductor prime confines the actual Page +correction to the history-frequency modulus, including all its powers. -/ +theorem frequencyModel_page_projection {I : Type*} [Fintype I] + (S : Finset ℤ) (n V cutoff : ℕ) (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) (hcut : V < cutoff) + (P : Finset ℕ) (p : I → ℕ) (z : Option PrimitiveRealZero) + (hP : ∀ q ∈ P, q.Prime ∧ cutoff ≤ q) (hp : ∀ i, (p i).Prime ∧ cutoff ≤ p i) + (hdeleteP : ∀ e, z = some e → ∀ q, deletedConductorPrime e.modulus cutoff = some q → q ∉ P) + (hdeletep : ∀ e, z = some e → ∀ q, deletedConductorPrime e.modulus cutoff = some q → ∀ i, q ≠ p i) : + pageAtModulus (∏ b, movingArithmeticModuli (frequencyModelBase S n t ^ (n - 1 + 2)) + p P Finset.univ b) z = pageAtModulus (frequencyModelBase S n t ^ (n - 1 + 2)) z := by + let R := frequencyModelBase S n t ^ (n - 1 + 2) + let C := (∏ q ∈ P, q) ^ 2 * ∏ i, p i + have heq : (∏ b, movingArithmeticModuli R p P Finset.univ b) = R * C := + movingArithmeticModuli_product R p P Finset.univ + change pageAtModulus (∏ b, movingArithmeticModuli R p P Finset.univ b) z = _ + rw [heq] + apply pageAtModulus_mul_eq z R C cutoff + · intro q hq hd + by_contra hh + have hVq : V < q := hcut.trans_le (Nat.le_of_not_lt hh) + have hc := (prime_coprime_frequencyModelBase S V q n hq hVq hS t).pow_right (n - 1 + 2) + exact (hq.coprime_iff_not_dvd.mp hc) hd + · intro q hq hd + rcases hq.dvd_mul.mp hd with hleft | hright + · obtain ⟨a, ha, hqa⟩ := (hq.prime.dvd_finsetProd_iff (fun a : ℕ => a)).mp + (hq.dvd_of_dvd_pow hleft) + have he := (Nat.prime_dvd_prime_iff_eq hq (hP a ha).1).mp hqa + simpa only [he] using (hP a ha).2 + · obtain ⟨i, _, hqi⟩ := (hq.prime.dvd_finsetProd_iff p).mp hright + have he := (Nat.prime_dvd_prime_iff_eq hq (hp i).1).mp hqi + simpa only [he] using (hp i).2 + · intro e he q hq hd + have hprime := (deletedConductorPrime_spec hq).1 + rcases hprime.dvd_mul.mp hd with hleft | hright + · obtain ⟨a, ha, hqa⟩ := (hprime.prime.dvd_finsetProd_iff (fun a : ℕ => a)).mp + (hprime.dvd_of_dvd_pow hleft) + have heq := (Nat.prime_dvd_prime_iff_eq hprime (hP a ha).1).mp hqa + exact hdeleteP e he q hq (heq.symm ▸ ha) + · obtain ⟨i, _, hqi⟩ := (hprime.prime.dvd_finsetProd_iff p).mp hright + exact hdeletep e he q hq i ((Nat.prime_dvd_prime_iff_eq hprime (hp i).1).mp hqi) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantVariation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantVariation.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e7ac042fc30a6eb1100b1a62bd2fba3f4d839ad --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGiantVariation.lean @@ -0,0 +1,132 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelGain +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCost + +namespace OAI + +/-! # Uniform giant variation cost at the selected-prime scales -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingFourierVariationBudget_mono_frequency (ψ : 𝓢(ℝ, ℂ)) + (V W lo hi : ℝ) (n : ℕ) (hV : 0 ≤ V) (hVW : V ≤ W) (hhi : lo ≤ hi) : + movingFourierVariationBudget ψ V lo hi n ≤ movingFourierVariationBudget ψ W lo hi n := by + have hB := (norm_nonneg (ψ 0)).trans (ψ.norm_le_seminorm ℝ 0) + have hD := schwartz_profile_lip_nonneg ψ + have hwidth := sub_nonneg.mpr hhi + unfold movingFourierVariationBudget + gcongr + +/-- The manuscript's bottom window has logarithmic height `Δ + O(1)`. -/ +theorem movingWindow_width_le_exp (Δ C A m hi : ℝ) (hm : 1 ≤ m) + (hΔ : Δ ≤ A * m) (hhi : hi ≤ Real.exp (Δ + C)) : + hi - Real.exp Δ ≤ Real.exp ((A + |C|) * m) := by + have hCm : C ≤ |C| * m := (le_abs_self C).trans + (le_mul_of_one_le_right (abs_nonneg C) hm) + apply (show hi - Real.exp Δ ≤ hi by linarith [Real.exp_pos Δ]).trans + apply hhi.trans + exact Real.exp_le_exp.mpr (by nlinarith) + +/-- The complete pointwise cost needed for both giant integrations is bounded +before choosing the Fourier window, its frequencies, or the spectator primes. -/ +theorem movingPattern_pointwise_cost_budget (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin B D : ℝ) (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ L : ℝ, 1 ≤ L → + let m := spectatorBulkCount k L + ∀ (p : Fin m → ℕ) (V lo hi : ℝ), 0 ≤ V → V ≤ Real.exp (A * m) → + lo ≤ hi → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 * + (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ 2 + C * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + obtain ⟨Cw, hCw, hkernel⟩ := movingPatternKernelBudget_spectatorScale_window + ψ n r₀ k A Wwin B D hA hWwin + let K := (k : ℝ) ^ 4 + 4 + let Cs := (((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K + let C := max Cw Cs + have hK : 4 ≤ K := by + dsimp only [K] + linarith [pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4] + have hCwC : Cw ≤ C := le_max_left _ _ + have hCsC : Cs ≤ C := le_max_right _ _ + refine ⟨C, hCw.trans hCwC, ?_⟩ + intro L hL + dsimp only + intro p V lo hi hV hVA hhi hwidth hp + let m := spectatorBulkCount k L + have hL0 : 0 ≤ L := by linarith + have hm : (m : ℝ) ≤ K * L := (spectatorBulkCount_upper k L hL0).trans + (mul_le_mul_of_nonneg_right (by dsimp only [K]; linarith) hL0) + have hKL : 4 ≤ K * L := by nlinarith + have hamp : (4 : ℝ) ≤ Real.exp (K * L) := by + linarith [Real.add_one_le_exp (K * L)] + have hspec := moving_spectator_linear_cost n m p K L 4 (by linarith) hL0 (by norm_num) hm hamp hp + have hprod : (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 = ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) := by + rw [← Finset.prod_pow] + apply Finset.prod_congr rfl + intro i _ + rw [← pow_mul, pow_succ] + have hspec' : 4 * (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 ≤ + Real.exp (C * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + rw [hprod] + apply hspec.trans + apply Real.exp_le_exp.mpr + change Cs * L * Real.exp ((1 / 1000 : ℝ) * L) ≤ _ + apply mul_le_mul + · exact mul_le_mul_of_nonneg_right hCsC hL0 + · exact Real.exp_le_exp.mpr (by nlinarith) + · exact Real.exp_nonneg _ + · exact mul_nonneg (by linarith [hCw.trans hCwC]) hL0 + have hvar := movingFourierVariationBudget_mono_frequency ψ V (Real.exp (A * m)) lo hi n hV hVA hhi + have hsmooth : + (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ 2) := by + have hpow : + (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 := by + rw [mul_pow, mul_pow] + exact mul_le_mul_of_nonneg_right + (pow_le_pow_left₀ (movingFourierVariationBudget_nonneg ψ V lo hi n hV hhi) hvar 2) + (sq_nonneg _) + exact hpow.trans ((bulkKernelPair_smooth_le_budget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D).trans + ((hkernel L hL lo hi hhi hwidth).trans + (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hCwC (sq_nonneg L))))) + calc + _ ≤ Real.exp (C * L * Real.exp ((1 / 1000 : ℝ) * L)) * Real.exp (C * L ^ 2) := + mul_le_mul hspec' hsmooth (sq_nonneg _) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add, add_comm] + +/-- The giant comparison uses a weaker upper scale than the spectator cost. -/ +theorem movingPattern_giant_variation_budget (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin B D : ℝ) (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ L : ℝ, 1 ≤ L → + let m := spectatorBulkCount k L + ∀ (p : Fin m → ℕ) (V lo hi : ℝ), 0 ≤ V → V ≤ Real.exp (A * m) → + lo ≤ hi → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 2 * (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 * + (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ 2 + C * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + obtain ⟨C, hC, hb⟩ := movingPattern_pointwise_cost_budget ψ n r₀ k A Wwin B D hA hWwin + refine ⟨C, hC, ?_⟩ + intro L hL + dsimp only + intro p V lo hi hV hVA hhi hwidth hp + apply le_trans _ (le_trans (hb L hL p V lo hi hV hVA hhi hwidth hp) ?_) + · exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (by norm_num : (2 : ℝ) ≤ 4) (sq_nonneg _)) + (sq_nonneg _) + · apply Real.exp_le_exp.mpr + apply add_le_add (le_refl _) + exact mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (by linarith)) + (mul_nonneg (by linarith) (by linarith)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e54670a006752962a5863ef141b421c23f7425e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodArithmetic.lean @@ -0,0 +1,226 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMatchedPrimeRanges +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGoodIdealIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPriorArithmetic + +namespace OAI + +/-! # Signed cancellation for the literal original good-matching pattern -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_good_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (_hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG center : ℝ), + let reg := (movingPatternRegularSlots e (n + 2) m small slot).get + let data := movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ ((n + 2) + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + MovingLeafLengthLE (n + 2) small r₀ → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) + (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + Function.Injective p → + (∀ q ∈ outside, ∃ i, p i = q) → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + ∀ (tier : primes → ℕ) (lower cutoff : ℕ), + Nfreq ≤ lower → Nfreq < cutoff → cutoff ≤ lower → + (∀ j, j < (n + 2) → ∀ q, μ j q ≠ 0 → tier q = j) → + (∀ j q, ν j q ≠ 0 → tier q = tierB j) → + (∀ j q, μ j q ≠ 0 → lower < (q : ℕ)) → + (∀ j q, ν j q ≠ 0 → lower < (q : ℕ)) → + (∀ q : primes, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ lower) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq reg active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + Uall ^ Fintype.card Cidx) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + diagonalOuterMajorant Bφ Dφ diagonal * ((2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((Real.exp (-gain * m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hideal⟩ := + P.movingPattern_good_ideal_integral_rate_window ψ n r₀ k A Wwin Bφ Dφ F Cmass gain + hA hWwin hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hideal, + P.movingPattern_original_matched_prime_ranges ψ (n + 2) r₀ k A Wwin Bφ Dφ hA hWwin hBφ hDφ] + with L hideal hcompare + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes _ childBound pivotBound hfreq f outside _ p _ hc _ + Dq sets β X j₀ φ G u v deleted initial μ ν active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter hsmall hB htier hsmallLen ht hS hN hf hm hp hV hsets hsetsp hpupper + hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + hinjp houtp hNupper hcenterlow hrGlow tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq (n + 2) ft + let r := R ^ ((n + 2) - 1 + 2) + let slots := movingPatternRegularSlots e (n + 2) m small slot + let reg := slots.get + have hsmall' : ∀ b : Bool, ∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot := + fun _ => hsmall + have hsmallLen' : ∀ b : Bool, MovingLeafLengthLE (n + 2) small r₀ := fun _ => hsmallLen + have hfreqN (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : s.natAbs ≤ Nfreq := by + rw [ht] at hs + exact hN s (allFrequencyList_subtype_mem Sfreq (n + 2) _ s hs) + have hsupport (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) := + movingPattern_prior_arithmetic_support e μ ν (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) pattern rep tier tierB tierC + hμtier hνtier hB htier Sfreq Nfreq lower ft (fun s hs => ⟨hS s hs, hN s hs⟩) + hNlo hμlo hνlo p (fun i => Fact.out) (fun i => (hprange i).2) t + (fun _ => small) slot perm hfreq hfreqN x hx + have hfreqp (i : Fin m) (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : + s.natAbs < p i := (hfreqN b s hs).trans_lt (hNcut.trans_le (hprange i).1) + have hR (b : Bool) : + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern b).frequencyProduct ∣ (R : ℤ) := by + simpa only [ht, R] using movingPattern_frequencyProduct_dvd e Sfreq ft (fun _ => small) slot perm pattern b + have hIdeal := hideal lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t + (fun _ => small) slot perm pattern rep primes hprimes childBound pivotBound hfreq + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) outside (R : ℤ) r p hc (fun i _ => Dq i) sets β + (giantProgressionCutoff L) X j₀ φ G u v deleted initial μ ν (Fin slots.length) reg active + Jleft Jright diagonal Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter hm hsmall' hB htier hsmallLen' hR + (frequencyModelModulus_precision R (n + 2)) hV hp hfreqp + (fun x hx i _ j _ => (hsupport x hx).2.1 i (e.symm (.inl j))) + (fun x hx i c => (hsupport x hx).2.1 i (e.symm (.inr c))) + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.1) + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.2.1) + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.2.2) + have hspect (i : Fin m) (z : ZMod (p i)) : ‖normalizedResidueTransform (sets i) z‖ ≤ (p i : ℝ) := + normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z + have hCmp := hcompare Bidx Cidx N e tierB tierC t small slot perm pattern rep primes hprimes μ ν p + hinjp (fun i => normalizedResidueTransform (sets i)) Dq active sreg setsReg f outside + childBound pivotBound Sfreq ft Nfreq hfreq X lo hi hlo hhi φ G Jleft Jright diagonal + Eprior Uall uG vG rG sG center hμ0 hν0 hμmass hνmass hEprior (by linarith) + hμbound hvalues hB htier hfreqN hf (fun i => normalizedResidueTransform_zero (sets i)) + hspect houtp hNupper hwindow hpupper hφ hlip hφout hcenterlow huvG hvG hcenter + hrGlow hrsG hsG ht (fun s hs => ⟨hS s hs, hN s hs⟩) tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hsmallLen hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + exact hCmp.trans (add_le_add (le_refl _) hIdeal) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodIdealIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodIdealIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..e261c5523e7a6280b28b298117a120a250dbe2f1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodIdealIntegral.lean @@ -0,0 +1,183 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowWeightedIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalIntegralScale +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedHarmonicIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # The original outer cutoff and regular density in the good matching estimate -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_good_ideal_integral_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Jidx : Type) [Fintype Jidx] (reg : Jidx → Fin (N + 1)) (active : Jidx → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall uG vG rG sG center : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := fun xg y => movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + let W := movingDiagonalOuterWeight (fun q : primes => (q : ℕ)) reg active φ Jleft Jright Bφ Dφ diagonal + let obs := fun xg y x => W xg y x * raw xg y x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ∫ xg in Set.Ioc uG vG, ∫ y in Set.Ioc rG sG, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp xg) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * raw xg y x) * (Real.exp (xg - center) : ℂ) / (y : ℂ)) x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + diagonalOuterMajorant Bφ Dφ diagonal * ((2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_weighted_mixed_integral_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq X j₀ φ G u v deleted initial + μ ν Jidx _ reg active Jleft Jright diagonal Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let raw := fun xg y => movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + let W := movingDiagonalOuterWeight (fun q : primes => (q : ℕ)) reg active φ + Jleft Jright Bφ Dφ diagonal + have hh := hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern rep primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq X j₀ φ G + u v deleted initial μ ν W Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues + (movingDiagonalOuterWeight_measurable (fun q : primes => (q : ℕ)) reg active φ + Jleft Jright Bφ Dφ hBφ hDφ hφ hlip hφout diagonal) + (fun xg y x => movingDiagonalOuterWeight_norm (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) reg active φ Jleft Jright Bφ Dφ hBφ hDφ hφ hlip hφout + diagonal xg y x) + (fun xg y x z => movingDiagonalOuterWeight_bulk (fun q : primes => (q : ℕ)) reg active + (movingPatternBulkEmbedding e slot) hfixed φ Jleft Jright Bφ Dφ diagonal xg y x z) + hdisjoint hcross hfmod + exact movingPattern_diagonal_integral_norm e (fun q : primes => (q : ℕ)) μ ν pattern + reg active φ Jleft Jright Bφ Dφ diagonal raw + (movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern) + uG vG rG sG center _ hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodMaskedPriors.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodMaskedPriors.lean new file mode 100644 index 0000000000000000000000000000000000000000..0009867d863f6c8a9c2ce87320a201b6a44704c6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodMaskedPriors.lean @@ -0,0 +1,195 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGoodMaskedShell +import OAI.NumberTheory.Ostmann.Construction.HarmonicFamilyBounds +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModelRange +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModelPage + +namespace OAI + +/-! # The original diagonal bound for actual selected harmonic laws -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_good_selected_masked_priors_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ c K gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hc : 0 < c) (hK : 0 ≤ K) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cmass := K + 1 + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (_rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (Qμ : ℕ → Finset ℕ) (Qν : Bidx → Finset ℕ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let Eprior := Real.exp (Cmass * L) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots (n + 2) ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → + (∀ b : Bool, MovingLeafLengthLE (n + 2) ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active j = false → + (movingPatternRegularSlots e (n + 2) m small slot).get j ∉ + Set.range (movingPatternBulkEmbedding e slot)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + (∀ j, j < (n + 2) → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (movingOriginalPatternMatchedObservable e t small slot perm pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e (n + 2) m small slot).get active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (Real.exp (-gain * m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + have hfamily := selected_harmonic_family_bounds c K hc hK + let Cmass := K + 1 + have hCmass : 1 ≤ Cmass := hfamily.1 + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hmain⟩ := + P.movingPattern_good_masked_whole_shell_rate C hM ψ n r₀ k A Wwin Bφ Dφ Cmass gain + hA hWwin hCmass hBφ hDφ + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hmain, movingFrequencyModel_bulk_range (n + 2) k A hA, + eventually_ge_atTop (max 1 (-Real.log c))] with L hrate hmod hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB t Sfreq ft Nfreq small slot perm pattern rep + primes hprimes _ childBound pivotBound f outside p _ Dq sets β + primeLo cutoff tier X j₀ φ G global Qμ Qν active sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange hactive houtcover hinjp huBig hrBig + hNfreq hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsreg hsregN hsetsReg + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let α := Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) + let βint := Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) + let Vint := Real.exp ((1 / 100 : ℝ) * L) + let Uall := Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) + obtain ⟨hμ0, hν0, hμsum, hνsum, hμbound, hμα, hνα, hμβ, hμmin⟩ := + hfamily.2 L hL primes Bidx Qμ Qν hμP hνP hμmass hνmass hμrange hνrange + have htiers := selected_harmonic_family_tiers primes Bidx (n + 2) Qμ Qν tier tierB hμtier hνtier + have hL0 : 0 ≤ L := le_trans (by norm_num) ((le_max_left _ _).trans hL) + have hμlo (j) (q : primes) (hq : μ j q ≠ 0) : primeLo < (q : ℕ) := by + have hr := hμmin j q hq + have hh : Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ + Real.exp (Real.exp ((1 / 100 : ℝ) * L)) := + Real.exp_le_exp.mpr (Real.exp_le_exp.mpr (by linarith only [hL0])) + exact_mod_cast (hloReal.trans_le (hh.trans hr)) + have hνlo (j) (q : primes) (hq : ν j q ≠ 0) : primeLo < (q : ℕ) := by + exact_mod_cast (hloReal.trans_le (hνrange j q (primeSubsetPrior_support primes (Qν j) q hq))) + have hUlog : Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) := by + dsimp only [Uall] + rw [Real.log_exp] + exact Real.exp_le_exp.mpr (by linarith only [hL0]) + have hUup : Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + exact Real.exp_le_exp.mpr (by simpa only [Uall, Real.log_exp] using hUlog) + obtain ⟨hrpos, hMpos, hcop, hMQ⟩ := hmod Sfreq Nfreq ft p hS hN hNfreq + (fun i => Fact.out) hinjp (fun i => hNcut.trans_le (hpband i).1) hpupper + let : NeZero (frequencyModelBase Sfreq (n + 2) ft ^ ((n + 2) - 1 + 2)) := ⟨Nat.ne_of_gt hrpos⟩ + let : NeZero (∏ i, bulkResidueModuli (frequencyModelBase Sfreq (n + 2) ft ^ ((n + 2) - 1 + 2)) p i) := + ⟨Nat.ne_of_gt hMpos⟩ + have hpage := frequencyModel_bulk_page_projection Sfreq (n + 2) Nfreq cutoff ft + (fun s hs => ⟨hS s hs, hN s hs⟩) hNcut p (selectedPageZero P (bulkProgressionCutoff L)) + (fun i => ⟨Fact.out, (hpband i).1⟩) + (fun z hz q hq i => (hdeletebulk z hz q hq i).symm) + by_cases htier : ∀ i, movingSampleTier (rep (pattern i)).val.2 = movingSampleTier i.2 + · + exact hrate lo hi hlo hhi hwindow Bidx Cidx N e tierB (fun c => movingSampleTier (rep c).val.2) t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes childBound pivotBound f outside p hcop Dq sets β + primeLo cutoff tier X j₀ φ G global μ ν active (Real.exp (Cmass * L)) α βint Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hMQ hpage hφ hlip hφout hShell hdel hout + (fun j => congrArg (primeSubsetPrior primes) (hν j)) + hμ0 hν0 hμsum hνsum (Real.one_le_exp_iff.mpr (mul_nonneg (by linarith only [hCmass]) hL0)) + (Real.exp_pos _).le (Real.exp_pos _).le (Real.exp_pos _) (Real.one_le_exp_iff.mpr (Real.exp_pos _).le) + hμbound hμα hνα (fun c => hμβ _) (fun c => hμmin _) hupper hactive houtcover hinjp huBig hrBig + hNfreq le_rfl le_rfl le_rfl rfl hUlog hUup htiers.1 htiers.2 hNlo hNcut hcutlo hμlo hνlo + hupper hpband + (fun z hz q hq j a ha heq => hdeleteμ z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qμ j) a ha)) hdeletep + (fun z hz q hq j a ha heq => hdeleteν z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qν j) a ha)) hsreg hsregN hsetsReg + · have hz (H : (Fin (N + 1) → primes) → ℂ) (x) : + movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern H x = 0 := + movingPattern_zero_of_inconsistent_tiers e μ ν (fun q : primes => (q : ℕ)) + pattern rep tier htiers.1 htier H x + dsimp only [μ, ν] at hz + simp only [hz, Finset.sum_const_zero, norm_zero] + positivity + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodMaskedShell.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodMaskedShell.lean new file mode 100644 index 0000000000000000000000000000000000000000..ca82586c0a88941867ee80de53be53aad440aa92 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodMaskedShell.lean @@ -0,0 +1,220 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGoodSharp +import OAI.NumberTheory.Ostmann.Arithmetic.WholeShellArithmeticCells +import OAI.NumberTheory.Ostmann.Construction.FrozenPrimeDeletions + +namespace OAI + +/-! # The original mixed diagonal bound on the entire bulk shell -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_good_masked_whole_shell_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (Eprior αall βint Vint Uall : ℝ) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots (n + 2) ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b : Bool, MovingLeafLengthLE (n + 2) ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) + (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, ν (slot j) = primeSubsetPrior primes (S \ global)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 1 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → + (movingPatternRegularSlots e (n + 2) m small slot).get j ∉ + Set.range (movingPatternBulkEmbedding e slot)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Eprior ≤ Real.exp (Cmass * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) → + (∀ j, j < (n + 2) → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (∀ j a, μ j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ j a, ν j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (movingOriginalPatternMatchedObservable e t small slot perm pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e (n + 2) m small slot).get active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + (Real.exp (Cmass * L)) ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (Real.exp (-gain * m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hmain⟩ := + P.movingPattern_original_good_sharp ψ n r₀ k A Wwin Bφ Dφ 1 Cmass Cmass gain + hA hWwin (by norm_num) hCmass hBφ hDφ hCmass + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hmain, whole_shell_arithmetic_cells C Cmass hM hCmass] with L hrate hcells + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB tierC t Sfreq ft Nfreq small slot perm pattern rep + primes hprimes _ childBound pivotBound f outside _ p _ hc _ Dq sets β + primeLo cutoff tier X j₀ φ G global μ ν active Eprior αall βint Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hMQ hpage hφ hlip hφout hShell hdel hout hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hactive houtcover hinjp huBig hrBig + hNfreq hEup hαup hβup hVeq hUlog _hUup hμtier hνtier hNlo hNcut hcutlo hμlo hνlo + hupper hpband hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let m := spectatorBulkCount k L + let a : ℝ := (4 / 1000) * L + let b : ℝ := (6 / 1000) * L + let u := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellLower a b + let v := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellUpper a b + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp a) (Real.exp b) + let deleted := fun x : Fin (N + 1) → primes => global ∪ + frozenPrimeDeletions (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside + obtain ⟨hcard, hunit, hlow, huv, hshort, hsep, hMcell, hsupport, hmass⟩ := + hcells M hMQ + have hDcard (x) : ((deleted x).card : ℝ) ≤ Real.exp (Cmass * L) := by + have hh : (deleted x).card ≤ global.card + (N + 1) + outside.length := by + have ht := (Finset.card_union_le global _).trans + (Nat.add_le_add_left (frozenPrimeDeletions_card_le + (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside) global.card) + simpa only [Fintype.card_fin, Nat.add_assoc] using ht + exact (Nat.cast_le.mpr hh).trans hdel + have hsub (j) : S \ global ⊆ primeCellSupport M + (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) := by + rw [hsupport]; exact Finset.sdiff_subset + have hretain (x) (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted x ⊆ S \ global := by + rw [hsupport] + intro q hq + exact Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hq).1, + fun hg => (Finset.mem_sdiff.mp hq).2 (Finset.mem_union_left _ hg)⟩ + have hmem (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : s ∈ Sfreq := by + rw [ht] at hs + exact allFrequencyList_subtype_mem Sfreq (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft) s hs + have hfreq (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : s ≠ 0 := + hS s (hmem b s hs) + have hV (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : + |(s : ℝ)| ≤ Real.exp (A * m) := by + have hn : (s.natAbs : ℝ) ≤ Nfreq := by exact_mod_cast hN s (hmem b s hs) + exact (show |(s : ℝ)| ≤ Nfreq by simpa only [Nat.cast_natAbs, Int.cast_abs] using hn).trans hNfreq + have hone (side : Bool) : + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern side)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one _ (fun s _ => hf s) _ + have hamp : 2 * (‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern false)‖ * + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern true)‖) ≤ + Real.exp (1 * (m : ℝ)) := by + have hn := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm + have he := Real.add_one_le_exp (1 * (m : ℝ)) + nlinarith only [hn, hmR, he] + exact hrate lo hi hlo hhi hwindow Bidx Cidx (Fin (wholePrimeGridCount b)) N e tierB tierC + t Sfreq ft Nfreq small slot perm pattern rep primes hprimes childBound pivotBound hfreq f + outside p hc Dq sets β X j₀ φ G u v (fun x _ => deleted x) (fun _ => S \ global) + μ ν active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter (hsmall false) hB htier (hsmallLen false) + ht hS hN hf hm hp hV + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout hcard (fun _ => hunit) (fun _ => hlow) + (fun _ => huv) (fun _ => hshort) (fun _ => hsep) (fun _ => hMcell) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hShell) (fun x _ _ => hDcard x) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hmass) + (fun x _ _ i hi => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_base (fun i => (x i : ℕ)) _ outside i hi)) hout + (fun x _ _ q hq => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_outside (fun i => (x i : ℕ)) _ outside q hq)) + (⟨0, wholePrimeGridCount_pos b⟩, 1) hsub (fun x _ => hretain x) hν + hμ0 hν0 hμmass hνmass (le_trans (by norm_num) hEprior) hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hactive + hinjp houtcover hNfreq huBig hrBig tier primeLo cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hpband hdeleteμ hdeletep hdeleteν + hsreg hsregN hsetsReg hEup hUlog hαup hβup hVeq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodSelectedPriors.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodSelectedPriors.lean new file mode 100644 index 0000000000000000000000000000000000000000..2d98b1d5a6fbab6b4f6b28632dcf6f5e82ef23dc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodSelectedPriors.lean @@ -0,0 +1,191 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGoodWholeShell +import OAI.NumberTheory.Ostmann.Construction.HarmonicFamilyBounds +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModelRange +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModelPage + +namespace OAI + +/-! # The original diagonal bound for actual selected harmonic laws -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_good_selected_priors_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ c K gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hc : 0 < c) (hK : 0 ≤ K) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cmass := K + 1 + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (_rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (Qμ : ℕ → Finset ℕ) (Qν : Bidx → Finset ℕ) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let Eprior := Real.exp (Cmass * L) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots (n + 2) ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → + (∀ b : Bool, MovingLeafLengthLE (n + 2) ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + (∀ j, j < (n + 2) → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (movingOriginalPatternMatchedObservable e t small slot perm pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e (n + 2) m small slot).get (fun _ => true) sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (Real.exp (-gain * m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + have hfamily := selected_harmonic_family_bounds c K hc hK + let Cmass := K + 1 + have hCmass : 1 ≤ Cmass := hfamily.1 + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hmain⟩ := + P.movingPattern_good_whole_shell_rate C hM ψ n r₀ k A Wwin Bφ Dφ Cmass gain + hA hWwin hCmass hBφ hDφ + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hmain, movingFrequencyModel_bulk_range (n + 2) k A hA, + eventually_ge_atTop (max 1 (-Real.log c))] with L hrate hmod hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB t Sfreq ft Nfreq small slot perm pattern rep + primes hprimes _ childBound pivotBound f outside p _ Dq sets β + primeLo cutoff tier X j₀ φ G global Qμ Qν sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp huBig hrBig + hNfreq hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsreg hsregN hsetsReg + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let α := Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) + let βint := Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) + let Vint := Real.exp ((1 / 100 : ℝ) * L) + let Uall := Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) + obtain ⟨hμ0, hν0, hμsum, hνsum, hμbound, hμα, hνα, hμβ, hμmin⟩ := + hfamily.2 L hL primes Bidx Qμ Qν hμP hνP hμmass hνmass hμrange hνrange + have htiers := selected_harmonic_family_tiers primes Bidx (n + 2) Qμ Qν tier tierB hμtier hνtier + have hL0 : 0 ≤ L := le_trans (by norm_num) ((le_max_left _ _).trans hL) + have hμlo (j) (q : primes) (hq : μ j q ≠ 0) : primeLo < (q : ℕ) := by + have hr := hμmin j q hq + have hh : Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ + Real.exp (Real.exp ((1 / 100 : ℝ) * L)) := + Real.exp_le_exp.mpr (Real.exp_le_exp.mpr (by linarith only [hL0])) + exact_mod_cast (hloReal.trans_le (hh.trans hr)) + have hνlo (j) (q : primes) (hq : ν j q ≠ 0) : primeLo < (q : ℕ) := by + exact_mod_cast (hloReal.trans_le (hνrange j q (primeSubsetPrior_support primes (Qν j) q hq))) + have hUlog : Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) := by + dsimp only [Uall] + rw [Real.log_exp] + exact Real.exp_le_exp.mpr (by linarith only [hL0]) + have hUup : Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + exact Real.exp_le_exp.mpr (by simpa only [Uall, Real.log_exp] using hUlog) + obtain ⟨hrpos, hMpos, hcop, hMQ⟩ := hmod Sfreq Nfreq ft p hS hN hNfreq + (fun i => Fact.out) hinjp (fun i => hNcut.trans_le (hpband i).1) hpupper + let : NeZero (frequencyModelBase Sfreq (n + 2) ft ^ ((n + 2) - 1 + 2)) := ⟨Nat.ne_of_gt hrpos⟩ + let : NeZero (∏ i, bulkResidueModuli (frequencyModelBase Sfreq (n + 2) ft ^ ((n + 2) - 1 + 2)) p i) := + ⟨Nat.ne_of_gt hMpos⟩ + have hpage := frequencyModel_bulk_page_projection Sfreq (n + 2) Nfreq cutoff ft + (fun s hs => ⟨hS s hs, hN s hs⟩) hNcut p (selectedPageZero P (bulkProgressionCutoff L)) + (fun i => ⟨Fact.out, (hpband i).1⟩) + (fun z hz q hq i => (hdeletebulk z hz q hq i).symm) + by_cases htier : ∀ i, movingSampleTier (rep (pattern i)).val.2 = movingSampleTier i.2 + · + exact hrate lo hi hlo hhi hwindow Bidx Cidx N e tierB (fun c => movingSampleTier (rep c).val.2) t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes childBound pivotBound f outside p hcop Dq sets β + primeLo cutoff tier X j₀ φ G global μ ν (Real.exp (Cmass * L)) α βint Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hMQ hpage hφ hlip hφout hShell hdel hout + (fun j => congrArg (primeSubsetPrior primes) (hν j)) + hμ0 hν0 hμsum hνsum (Real.one_le_exp_iff.mpr (mul_nonneg (by linarith only [hCmass]) hL0)) + (Real.exp_pos _).le (Real.exp_pos _).le (Real.exp_pos _) (Real.one_le_exp_iff.mpr (Real.exp_pos _).le) + hμbound hμα hνα (fun c => hμβ _) (fun c => hμmin _) hupper houtcover hinjp huBig hrBig + hNfreq le_rfl le_rfl le_rfl rfl hUlog hUup htiers.1 htiers.2 hNlo hNcut hcutlo hμlo hνlo + hupper hpband + (fun z hz q hq j a ha heq => hdeleteμ z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qμ j) a ha)) hdeletep + (fun z hz q hq j a ha heq => hdeleteν z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qν j) a ha)) hsreg hsregN hsetsReg + · have hz (H : (Fin (N + 1) → primes) → ℂ) (x) : + movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern H x = 0 := + movingPattern_zero_of_inconsistent_tiers e μ ν (fun q : primes => (q : ℕ)) + pattern rep tier htiers.1 htier H x + dsimp only [μ, ν] at hz + simp only [hz, Finset.sum_const_zero, norm_zero] + positivity + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodSharp.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodSharp.lean new file mode 100644 index 0000000000000000000000000000000000000000..22b054f1ede40dc89249e0c2617ccc5d210cdd87 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodSharp.lean @@ -0,0 +1,195 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGoodArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalNumericalRate + +namespace OAI + +/-! # Absorbing all comparison errors in the original good-matching bound -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_good_sharp + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass Cprior gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) (hCprior : 1 ≤ Cprior) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (_hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG center : ℝ), + let reg := (movingPatternRegularSlots e (n + 2) m small slot).get + let data := movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + MovingLeafLengthLE (n + 2) small r₀ → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) + (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + Function.Injective p → + (∀ q ∈ outside, ∃ i, p i = q) → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + ∀ (tier : primes → ℕ) (lower cutoff : ℕ), + Nfreq ≤ lower → Nfreq < cutoff → cutoff ≤ lower → + (∀ j, j < (n + 2) → ∀ q, μ j q ≠ 0 → tier q = j) → + (∀ j q, ν j q ≠ 0 → tier q = tierB j) → + (∀ j q, μ j q ≠ 0 → lower < (q : ℕ)) → + (∀ j q, ν j q ≠ 0 → lower < (q : ℕ)) → + (∀ q : primes, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ lower) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + Eprior ≤ Real.exp (Cprior * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq reg active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + (Real.exp (Cprior * L)) ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hmain⟩ := + P.movingPattern_original_good_arithmetic_rate ψ n r₀ k A Wwin Bφ Dφ F Cmass gain + hA hWwin hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hmain, + movingPattern_diagonal_pointwise_rate ψ (n + 2) r₀ k A Wwin Bφ Dφ Cprior Cmass + hA hWwin hBφ hDφ hCprior (by linarith)] with L hmain hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes _ childBound pivotBound hfreq f outside _ p _ hc _ + Dq sets β X j₀ φ G u v deleted initial μ ν active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter hsmall hB htier hsmallLen ht hS hN hf hm hp hV hsets hsetsp hpupper + hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + hinjp houtp hNupper hcenterlow hrGlow tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg hEup hUlog hαup hβup hVeq + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern + let amp := 2 * (‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data true)‖) + have hh := hmain lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes childBound pivotBound hfreq f outside p hc Dq sets β X j₀ φ G + u v deleted initial μ ν active sreg setsReg Jleft Jright diagonal Eprior αall βint Vint Uall + uG vG rG sG center huG hrG huvG hrsG hvG hsG hcenter hsmall hB htier hsmallLen ht hS hN hf + hm hp hV hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall hμbound hμall hνall hμmax hμmin hvalues + hfixed hinjp houtp hNupper hcenterlow hrGlow tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + have hone (b : Bool) : ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data b)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (fun {_} _ => f) (fun s _ => hf s) (data b) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hamp4 : amp ≤ 4 := by + have h := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + dsimp only [amp] + linarith + apply hrate p (Fintype.card Cidx) Eprior Uall αall βint amp lo hi rG (Real.exp (-gain * m)) _ diagonal + (movingPattern_class_card_le (n + 2) pattern rep) hEprior hEup hUall hUlog hαall hαup hβint hβup + hamp0 hamp4 hhi hwindow hpupper hrGlow (Real.exp_nonneg _) + simpa only [hVeq, add_assoc] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodWholeShell.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodWholeShell.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d887197182a3753c2f5a39173535e1de8dfe539 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternGoodWholeShell.lean @@ -0,0 +1,216 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGoodSharp +import OAI.NumberTheory.Ostmann.Arithmetic.WholeShellArithmeticCells +import OAI.NumberTheory.Ostmann.Construction.FrozenPrimeDeletions + +namespace OAI + +/-! # The original mixed diagonal bound on the entire bulk shell -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_good_whole_shell_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots (n + 2) ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b : Bool, MovingLeafLengthLE (n + 2) ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) + (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, ν (slot j) = primeSubsetPrior primes (S \ global)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 1 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Eprior ≤ Real.exp (Cmass * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) → + (∀ j, j < (n + 2) → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (∀ j a, μ j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ j a, ν j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (movingOriginalPatternMatchedObservable e t small slot perm pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e (n + 2) m small slot).get (fun _ => true) sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + (Real.exp (Cmass * L)) ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (Real.exp (-gain * m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hmain⟩ := + P.movingPattern_original_good_sharp ψ n r₀ k A Wwin Bφ Dφ 1 Cmass Cmass gain + hA hWwin (by norm_num) hCmass hBφ hDφ hCmass + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hmain, whole_shell_arithmetic_cells C Cmass hM hCmass] with L hrate hcells + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB tierC t Sfreq ft Nfreq small slot perm pattern rep + primes hprimes _ childBound pivotBound f outside _ p _ hc _ Dq sets β + primeLo cutoff tier X j₀ φ G global μ ν Eprior αall βint Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hMQ hpage hφ hlip hφout hShell hdel hout hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues houtcover hinjp huBig hrBig + hNfreq hEup hαup hβup hVeq hUlog _hUup hμtier hνtier hNlo hNcut hcutlo hμlo hνlo + hupper hpband hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let m := spectatorBulkCount k L + let a : ℝ := (4 / 1000) * L + let b : ℝ := (6 / 1000) * L + let u := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellLower a b + let v := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellUpper a b + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp a) (Real.exp b) + let deleted := fun x : Fin (N + 1) → primes => global ∪ + frozenPrimeDeletions (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside + obtain ⟨hcard, hunit, hlow, huv, hshort, hsep, hMcell, hsupport, hmass⟩ := + hcells M hMQ + have hDcard (x) : ((deleted x).card : ℝ) ≤ Real.exp (Cmass * L) := by + have hh : (deleted x).card ≤ global.card + (N + 1) + outside.length := by + have ht := (Finset.card_union_le global _).trans + (Nat.add_le_add_left (frozenPrimeDeletions_card_le + (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside) global.card) + simpa only [Fintype.card_fin, Nat.add_assoc] using ht + exact (Nat.cast_le.mpr hh).trans hdel + have hsub (j) : S \ global ⊆ primeCellSupport M + (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) := by + rw [hsupport]; exact Finset.sdiff_subset + have hretain (x) (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted x ⊆ S \ global := by + rw [hsupport] + intro q hq + exact Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hq).1, + fun hg => (Finset.mem_sdiff.mp hq).2 (Finset.mem_union_left _ hg)⟩ + have hmem (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : s ∈ Sfreq := by + rw [ht] at hs + exact allFrequencyList_subtype_mem Sfreq (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft) s hs + have hfreq (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : s ≠ 0 := + hS s (hmem b s hs) + have hV (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : + |(s : ℝ)| ≤ Real.exp (A * m) := by + have hn : (s.natAbs : ℝ) ≤ Nfreq := by exact_mod_cast hN s (hmem b s hs) + exact (show |(s : ℝ)| ≤ Nfreq by simpa only [Nat.cast_natAbs, Int.cast_abs] using hn).trans hNfreq + have hone (side : Bool) : + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern side)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one _ (fun s _ => hf s) _ + have hamp : 2 * (‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern false)‖ * + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern true)‖) ≤ + Real.exp (1 * (m : ℝ)) := by + have hn := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm + have he := Real.add_one_le_exp (1 * (m : ℝ)) + nlinarith only [hn, hmR, he] + exact hrate lo hi hlo hhi hwindow Bidx Cidx (Fin (wholePrimeGridCount b)) N e tierB tierC + t Sfreq ft Nfreq small slot perm pattern rep primes hprimes childBound pivotBound hfreq f + outside p hc Dq sets β X j₀ φ G u v (fun x _ => deleted x) (fun _ => S \ global) + μ ν (fun _ => true) sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter (hsmall false) hB htier (hsmallLen false) + ht hS hN hf hm hp hV + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout hcard (fun _ => hunit) (fun _ => hlow) + (fun _ => huv) (fun _ => hshort) (fun _ => hsep) (fun _ => hMcell) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hShell) (fun x _ _ => hDcard x) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hmass) + (fun x _ _ i hi => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_base (fun i => (x i : ℕ)) _ outside i hi)) hout + (fun x _ _ q hq => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_outside (fun i => (x i : ℕ)) _ outside q hq)) + (⟨0, wholePrimeGridCount_pos b⟩, 1) hsub (fun x _ => hretain x) hν + hμ0 hν0 hμmass hνmass (le_trans (by norm_num) hEprior) hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues (fun _ h => by cases h) + hinjp houtcover hNfreq huBig hrBig tier primeLo cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hpband hdeleteμ hdeletep hdeleteν + hsreg hsregN hsetsReg hEup hUlog hαup hβup hVeq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogCellError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogCellError.lean new file mode 100644 index 0000000000000000000000000000000000000000..27ebe348dfa1d58482fd2c8066aec37812c4072b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogCellError.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogKernelCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCost +import OAI.NumberTheory.Ostmann.Arithmetic.BulkWeightedErrorRate + +namespace OAI + +/-! # Cell error with terminal log cutoffs retained -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +/-- The cell threshold is uniform over the moving Fourier window. -/ +theorem PublishedProgressionInput.movingPattern_half_log_cell_error_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H B D F Cnorm Dlog : ℝ) (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) + (hDlog : 0 ≤ Dlog) (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ n) : + ∃ C : ℝ, 1 ≤ C ∧ Cnorm ≤ C ∧ ∀ᶠ L : ℝ in atTop, + let m := spectatorBulkCount k L + ∀ lo hi : ℝ, lo ≤ hi → hi - lo ≤ Real.exp (H * m) → + ∀ (Cell : Type) [Fintype Cell] (M Q : ℕ) [NeZero M], 2 ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 10000 : ℝ) * L) → + ∀ (p : Fin m → ℕ) (Z : (TreeLeafIndex n × Fin m) → ℝ) + (a : ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) → ℂ) (amp T : ℝ) (rlog : ℕ), + rlog ≤ 2 ^ n * (r₀ + m + 4 * n) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ j, 0 ≤ Z j) → (∀ j, Z j ≤ Real.exp (C * L)) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) → + 0 ≤ amp → amp ≤ Real.exp (F * m) → + (∀ z, ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) → + Real.exp ((39 / 10000 : ℝ) * L) ≤ T → + ∀ u : (TreeLeafIndex n × Fin m) → Cell → ℝ, (∀ j c, T ≤ u j c) → + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, + ∑ z : (TreeLeafIndex n × Fin m) → (ZMod M)ˣ, ‖a z‖ * + (2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkLogWeightedKernelPairBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 tlog rlog B D Dlog * + bulkPrimeErrorFactor P Q (u j (c j))) ≤ + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) := by + obtain ⟨C₀, hC₀, hkernel⟩ := movingPatternHalfLogKernelBudget_spectatorScale_window ψ n r₀ k A H B D Dlog hA hH hDlog + let K := (F + 1) * ((k : ℝ) ^ 4 + 1) + let C := max C₀ ((((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K) + -- The dimension is also charged in the same constant. + let C' := max (max C (((2 ^ n : ℕ) : ℝ) * (k : ℝ) ^ 4)) Cnorm + have hK : 0 ≤ K := by dsimp only [K]; positivity + have hC₀C : C₀ ≤ C' := (le_max_left _ _).trans ((le_max_left _ _).trans (le_max_left _ _)) + have hC' : 1 ≤ C' := hC₀.trans hC₀C + refine ⟨C', hC', le_max_right _ _, ?_⟩ + filter_upwards [P.bulk_weighted_error_rate C' hC', eventually_ge_atTop (1 : ℝ)] with L hrate hL + dsimp only + intro lo hi hhi hwidth Cell _ M Q _ hQ hQlog p Z a amp T rlog hrlog hp hZ0 hZ hcell hunit hamp0 hamp ha hT u hu + let m := spectatorBulkCount k L + have hL0 : 0 ≤ L := by linarith + have hm := spectatorBulkCount_upper k L hL0 + have hFK : F * (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4] + have hKk : (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [mul_nonneg hF (pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4)] + have hmK : (m : ℝ) ≤ K * L := hm.trans (mul_le_mul_of_nonneg_right hKk hL0) + have hampK : amp ≤ Real.exp (K * L) := hamp.trans (Real.exp_le_exp.mpr (by + exact (mul_le_mul_of_nonneg_left hm hF).trans (by nlinarith [mul_le_mul_of_nonneg_right hFK hL0]))) + let bound := amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) + have hbound0 : 0 ≤ bound := mul_nonneg hamp0 (Finset.prod_nonneg fun i _ => by positivity) + have hbound : bound ≤ Real.exp (C' * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + apply (moving_spectator_linear_cost n m p K L amp hK hL0 hamp0 hmK hampK hp).trans + apply Real.exp_le_exp.mpr + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg _) + apply mul_le_mul_of_nonneg_right _ hL0 + exact (le_max_right C₀ _).trans ((le_max_left C _).trans (le_max_left _ _)) + have hdim : (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ≤ C' * L := by + simp only [Fintype.card_prod, card_treeLeafIndex, Fintype.card_fin, Nat.cast_mul] + calc + _ ≤ (2 ^ n : ℕ) * ((k : ℝ) ^ 4 * L) := + mul_le_mul_of_nonneg_left hm (Nat.cast_nonneg _) + _ ≤ C' * L := by + rw [← mul_assoc] + exact mul_le_mul_of_nonneg_right ((le_max_right _ _).trans (le_max_left _ _)) hL0 + have hbudget := hkernel L hL lo hi hhi hwidth tlog rlog htlog hrlog + have hbudget' : bulkLogWeightedKernelPairBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 tlog rlog B D Dlog ≤ + Real.exp (C' * L ^ 2) := + hbudget.trans (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hC₀C (sq_nonneg L))) + have hb := @hrate (TreeLeafIndex n × Fin m) Cell inferInstance inferInstance M Q + inferInstance hQ hQlog Z a bound + (bulkLogWeightedKernelPairBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 tlog rlog B D Dlog) + T hZ0 hbound0 (by + have he : 0 ≤ Real.exp 2 - 1 := sub_nonneg.mpr (Real.one_le_exp (by norm_num)) + unfold bulkLogWeightedKernelPairBudget + positivity) + hdim hZ hcell hunit hbound hbudget' ha hT u hu + simpa only [finite_univ_canonical] using hb + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..9895a7b72c9d195c3335fd10e2c118b266a4ac9a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodArithmetic.lean @@ -0,0 +1,242 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWeightedMatchedRanges +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogGoodIdealIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPriorArithmetic + +namespace OAI + +/-! # Signed cancellation for the literal original good-matching pattern -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_original_good_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (_hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG center : ℝ), + let reg := (movingPatternRegularSlots e (n + 2) m small slot).get + let data := movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ ((n + 2) + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + MovingLeafLengthLE (n + 2) small r₀ → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) + (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + Function.Injective p → + (∀ q ∈ outside, ∃ i, p i = q) → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + ∀ (tier : primes → ℕ) (lower cutoff : ℕ), + Nfreq ≤ lower → Nfreq < cutoff → cutoff ≤ lower → + (∀ j, j < (n + 2) → ∀ q, μ j q ≠ 0 → tier q = j) → + (∀ j q, ν j q ≠ 0 → tier q = tierB j) → + (∀ j q, μ j q ≠ 0 → lower < (q : ℕ)) → + (∀ j q, ν j q ≠ 0 → lower < (q : ℕ)) → + (∀ q : primes, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ lower) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq reg active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center x) x‖ ≤ + (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + Uall ^ Fintype.card Cidx) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + diagonalOuterMajorant Bφ Dφ diagonal * ((2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((Real.exp (-gain * m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hideal⟩ := + P.movingPattern_half_log_good_ideal_integral_rate_window ψ n r₀ k A Wwin Bφ Dφ F Cmass gain + hA hWwin hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hideal, + P.movingPattern_weighted_matched_prime_ranges ψ (n + 2) r₀ k A Wwin Bφ Dφ hA hWwin hBφ hDφ] + with L hideal hcompare + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes _ childBound pivotBound hfreq f outside _ p _ hc _ + Dq sets β X j₀ φ G u v deleted initial μ ν logSlots cb active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hsmall hB htier hsmallLen ht hS hN hf hm hp hV hsets hsetsp hpupper + hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + hinjp houtp hNupper hcenterlow hrGlow tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq (n + 2) ft + let r := R ^ ((n + 2) - 1 + 2) + let slots := movingPatternRegularSlots e (n + 2) m small slot + let reg := slots.get + have hsmall' : ∀ b : Bool, ∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot := + fun _ => hsmall + have hsmallLen' : ∀ b : Bool, MovingLeafLengthLE (n + 2) small r₀ := fun _ => hsmallLen + have hfreqN (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : s.natAbs ≤ Nfreq := by + rw [ht] at hs + exact hN s (allFrequencyList_subtype_mem Sfreq (n + 2) _ s hs) + have hsupport (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) := + movingPattern_prior_arithmetic_support e μ ν (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) pattern rep tier tierB tierC + hμtier hνtier hB htier Sfreq Nfreq lower ft (fun s hs => ⟨hS s hs, hN s hs⟩) + hNlo hμlo hνlo p (fun i => Fact.out) (fun i => (hprange i).2) t + (fun _ => small) slot perm hfreq hfreqN x hx + have hfreqp (i : Fin m) (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : + s.natAbs < p i := (hfreqN b s hs).trans_lt (hNcut.trans_le (hprange i).1) + have hR (b : Bool) : + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern b).frequencyProduct ∣ (R : ℤ) := by + simpa only [ht, R] using movingPattern_frequencyProduct_dvd e Sfreq ft (fun _ => small) slot perm pattern b + have hIdeal := hideal lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t + (fun _ => small) slot perm pattern rep primes hprimes childBound pivotBound hfreq + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) outside (R : ℤ) r p hc (fun i _ => Dq i) sets β + (giantProgressionCutoff L) X j₀ φ G u v deleted initial μ ν logSlots cb (Fin slots.length) reg active + Jleft Jright diagonal Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hm hsmall' hB htier hsmallLen' hR + (frequencyModelModulus_precision R (n + 2)) hV hp hfreqp + (fun x hx i _ j _ => (hsupport x hx).2.1 i (e.symm (.inl j))) + (fun x hx i c => (hsupport x hx).2.1 i (e.symm (.inr c))) + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.1) + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.2.1) + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.2.2) + have hspect (i : Fin m) (z : ZMod (p i)) : ‖normalizedResidueTransform (sets i) z‖ ≤ (p i : ℝ) := + normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z + let wgt : (Fin (N + 1) → primes) → ℂ := fun x => + ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) + have hwgt (x : Fin (N + 1) → primes) : ‖wgt x‖ ≤ 1 := by + dsimp only [wgt] + rw [Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (Finset.prod_nonneg (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).1))] + exact Finset.prod_le_one₀ (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).1) + (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).2) + have hCmp := hcompare Bidx Cidx N e tierB tierC t small slot perm pattern rep primes hprimes μ ν p + hinjp (fun i => normalizedResidueTransform (sets i)) Dq active sreg setsReg f outside + childBound pivotBound Sfreq ft Nfreq hfreq X lo hi hlo hhi φ G Jleft Jright diagonal + Eprior Uall uG vG rG sG center wgt hwgt hμ0 hν0 hμmass hνmass hEprior (by linarith) + hμbound hvalues hB htier hfreqN hf (fun i => normalizedResidueTransform_zero (sets i)) + hspect houtp hNupper hwindow hpupper hφ hlip hφout hcenterlow huvG hvG hcenter + hrGlow hrsG hsG ht (fun s hs => ⟨hS s hs, hN s hs⟩) tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hsmallLen hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + have hmul (a b c d e : ℂ) : (a * (b * c)) * d / e = b * (a * c * d / e) := by ring + simp_rw [movingPatternLogPrimeObservable_eq, hmul, integral_const_mul] at hIdeal + exact hCmp.trans (add_le_add (le_refl _) hIdeal) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodIdealIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodIdealIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f624bcce221be9f77abe0f863566a2f56107541 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodIdealIntegral.lean @@ -0,0 +1,188 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogWindowIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalIntegralScale +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedHarmonicIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # The original outer cutoff and regular density in the good matching estimate -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_good_ideal_integral_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (Jidx : Type) [Fintype Jidx] (reg : Jidx → Fin (N + 1)) (active : Jidx → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall uG vG rG sG center : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := fun xg y => movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let W := movingDiagonalOuterWeight (fun q : primes => (q : ℕ)) reg active φ Jleft Jright Bφ Dφ diagonal + let obs := fun xg y x => W xg y x * raw xg y x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ∫ xg in Set.Ioc uG vG, ∫ y in Set.Ioc rG sG, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp xg) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * raw xg y x) * (Real.exp (xg - center) : ℂ) / (y : ℂ)) x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + diagonalOuterMajorant Bφ Dφ diagonal * ((2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_half_log_weighted_mixed_integral_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq X j₀ φ G u v deleted initial + μ ν logSlots cb Jidx _ reg active Jleft Jright diagonal Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let raw := fun xg y => movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let W := movingDiagonalOuterWeight (fun q : primes => (q : ℕ)) reg active φ + Jleft Jright Bφ Dφ diagonal + have hh := hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern rep primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq X j₀ φ G + u v deleted initial μ ν logSlots cb W Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues + (movingDiagonalOuterWeight_measurable (fun q : primes => (q : ℕ)) reg active φ + Jleft Jright Bφ Dφ hBφ hDφ hφ hlip hφout diagonal) + (fun xg y x => movingDiagonalOuterWeight_norm (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) reg active φ Jleft Jright Bφ Dφ hBφ hDφ hφ hlip hφout + diagonal xg y x) + (fun xg y x z => movingDiagonalOuterWeight_bulk (fun q : primes => (q : ℕ)) reg active + (movingPatternBulkEmbedding e slot) hfixed φ Jleft Jright Bφ Dφ diagonal xg y x z) + hdisjoint hcross hfmod + exact movingPattern_diagonal_integral_norm e (fun q : primes => (q : ℕ)) μ ν pattern + reg active φ Jleft Jright Bφ Dφ diagonal raw + (movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern) + uG vG rG sG center _ hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodMaskedPriors.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodMaskedPriors.lean new file mode 100644 index 0000000000000000000000000000000000000000..e931c3852438c1ee4a591feaddff687ba42bc189 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodMaskedPriors.lean @@ -0,0 +1,201 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogGoodMaskedShell +import OAI.NumberTheory.Ostmann.Construction.HarmonicFamilyBounds +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModelRange +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModelPage + +namespace OAI + +/-! # The original diagonal bound for actual selected harmonic laws -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_good_selected_masked_priors_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ c K gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hc : 0 < c) (hK : 0 ≤ K) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cmass := K + 1 + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (_rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (Qμ : ℕ → Finset ℕ) (Qν : Bidx → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let Eprior := Real.exp (Cmass * L) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots (n + 2) ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → + (∀ b : Bool, MovingLeafLengthLE (n + 2) ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active j = false → + (movingPatternRegularSlots e (n + 2) m small slot).get j ∉ + Set.range (movingPatternBulkEmbedding e slot)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + (∀ j, j < (n + 2) → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable e t small slot perm pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e (n + 2) m small slot).get active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center x) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (Real.exp (-gain * m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + have hfamily := selected_harmonic_family_bounds c K hc hK + let Cmass := K + 1 + have hCmass : 1 ≤ Cmass := hfamily.1 + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hmain⟩ := + P.movingPattern_half_log_good_masked_whole_shell_rate C hM ψ n r₀ k A Wwin Bφ Dφ Cmass gain + hA hWwin hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hmain, movingFrequencyModel_bulk_range (n + 2) k A hA, + eventually_ge_atTop (max 1 (-Real.log c))] with L hrate hmod hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB t Sfreq ft Nfreq small slot perm pattern rep + primes hprimes _ childBound pivotBound f outside p _ Dq sets β + primeLo cutoff tier X j₀ φ G global Qμ Qν logSlots cb active sreg setsReg Jleft Jright diagonal uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange hactive houtcover hinjp huBig hrBig + hNfreq hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsreg hsregN hsetsReg + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let α := Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) + let βint := Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) + let Vint := Real.exp ((1 / 100 : ℝ) * L) + let Uall := Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) + obtain ⟨hμ0, hν0, hμsum, hνsum, hμbound, hμα, hνα, hμβ, hμmin⟩ := + hfamily.2 L hL primes Bidx Qμ Qν hμP hνP hμmass hνmass hμrange hνrange + have htiers := selected_harmonic_family_tiers primes Bidx (n + 2) Qμ Qν tier tierB hμtier hνtier + have hL0 : 0 ≤ L := le_trans (by norm_num) ((le_max_left _ _).trans hL) + have hμlo (j) (q : primes) (hq : μ j q ≠ 0) : primeLo < (q : ℕ) := by + have hr := hμmin j q hq + have hh : Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ + Real.exp (Real.exp ((1 / 100 : ℝ) * L)) := + Real.exp_le_exp.mpr (Real.exp_le_exp.mpr (by linarith only [hL0])) + exact_mod_cast (hloReal.trans_le (hh.trans hr)) + have hνlo (j) (q : primes) (hq : ν j q ≠ 0) : primeLo < (q : ℕ) := by + exact_mod_cast (hloReal.trans_le (hνrange j q (primeSubsetPrior_support primes (Qν j) q hq))) + have hUlog : Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) := by + dsimp only [Uall] + rw [Real.log_exp] + exact Real.exp_le_exp.mpr (by linarith only [hL0]) + have hUup : Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + exact Real.exp_le_exp.mpr (by simpa only [Uall, Real.log_exp] using hUlog) + obtain ⟨hrpos, hMpos, hcop, hMQ⟩ := hmod Sfreq Nfreq ft p hS hN hNfreq + (fun i => Fact.out) hinjp (fun i => hNcut.trans_le (hpband i).1) hpupper + let : NeZero (frequencyModelBase Sfreq (n + 2) ft ^ ((n + 2) - 1 + 2)) := ⟨Nat.ne_of_gt hrpos⟩ + let : NeZero (∏ i, bulkResidueModuli (frequencyModelBase Sfreq (n + 2) ft ^ ((n + 2) - 1 + 2)) p i) := + ⟨Nat.ne_of_gt hMpos⟩ + have hpage := frequencyModel_bulk_page_projection Sfreq (n + 2) Nfreq cutoff ft + (fun s hs => ⟨hS s hs, hN s hs⟩) hNcut p (selectedPageZero P (bulkProgressionCutoff L)) + (fun i => ⟨Fact.out, (hpband i).1⟩) + (fun z hz q hq i => (hdeletebulk z hz q hq i).symm) + by_cases htier : ∀ i, movingSampleTier (rep (pattern i)).val.2 = movingSampleTier i.2 + · + exact hrate lo hi hlo hhi hwindow Bidx Cidx N e tierB (fun c => movingSampleTier (rep c).val.2) t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes childBound pivotBound f outside p hcop Dq sets β + primeLo cutoff tier X j₀ φ G global μ ν logSlots cb active (Real.exp (Cmass * L)) α βint Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hMQ hpage hφ hlip hφout hShell hdel hout + (fun j => congrArg (primeSubsetPrior primes) (hν j)) + hμ0 hν0 hμsum hνsum (Real.one_le_exp_iff.mpr (mul_nonneg (by linarith only [hCmass]) hL0)) + (Real.exp_pos _).le (Real.exp_pos _).le (Real.exp_pos _) (Real.one_le_exp_iff.mpr (Real.exp_pos _).le) + hμbound hμα hνα (fun c => hμβ _) (fun c => hμmin _) hupper hactive houtcover hinjp huBig hrBig + hNfreq le_rfl le_rfl le_rfl rfl hUlog hUup htiers.1 htiers.2 hNlo hNcut hcutlo hμlo hνlo + hupper hpband + (fun z hz q hq j a ha heq => hdeleteμ z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qμ j) a ha)) hdeletep + (fun z hz q hq j a ha heq => hdeleteν z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qν j) a ha)) hsreg hsregN hsetsReg + · have hz (H : (Fin (N + 1) → primes) → ℂ) (x) : + movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern H x = 0 := + movingPattern_zero_of_inconsistent_tiers e μ ν (fun q : primes => (q : ℕ)) + pattern rep tier htiers.1 htier H x + dsimp only [μ, ν] at hz + simp only [hz, Finset.sum_const_zero, norm_zero] + positivity + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodMaskedShell.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodMaskedShell.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c17adb826e3201035b8f95560fc4a8802cd1f74 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodMaskedShell.lean @@ -0,0 +1,226 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogGoodSharp +import OAI.NumberTheory.Ostmann.Arithmetic.WholeShellArithmeticCells +import OAI.NumberTheory.Ostmann.Construction.FrozenPrimeDeletions + +namespace OAI + +/-! # The original mixed diagonal bound on the entire bulk shell -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_good_masked_whole_shell_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (Eprior αall βint Vint Uall : ℝ) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots (n + 2) ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b : Bool, MovingLeafLengthLE (n + 2) ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) + (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, ν (slot j) = primeSubsetPrior primes (S \ global)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 1 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → + (movingPatternRegularSlots e (n + 2) m small slot).get j ∉ + Set.range (movingPatternBulkEmbedding e slot)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Eprior ≤ Real.exp (Cmass * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) → + (∀ j, j < (n + 2) → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (∀ j a, μ j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ j a, ν j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable e t small slot perm pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e (n + 2) m small slot).get active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center x) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + (Real.exp (Cmass * L)) ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (Real.exp (-gain * m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hmain⟩ := + P.movingPattern_half_log_original_good_sharp ψ n r₀ k A Wwin Bφ Dφ 1 Cmass Cmass gain + hA hWwin (by norm_num) hCmass hBφ hDφ hCmass Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hmain, whole_shell_arithmetic_cells C Cmass hM hCmass] with L hrate hcells + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB tierC t Sfreq ft Nfreq small slot perm pattern rep + primes hprimes _ childBound pivotBound f outside _ p _ hc _ Dq sets β + primeLo cutoff tier X j₀ φ G global μ ν logSlots cb active Eprior αall βint Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hMQ hpage hφ hlip hφout hShell hdel hout hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hactive houtcover hinjp huBig hrBig + hNfreq hEup hαup hβup hVeq hUlog _hUup hμtier hνtier hNlo hNcut hcutlo hμlo hνlo + hupper hpband hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let m := spectatorBulkCount k L + let a : ℝ := (4 / 1000) * L + let b : ℝ := (6 / 1000) * L + let u := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellLower a b + let v := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellUpper a b + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp a) (Real.exp b) + let deleted := fun x : Fin (N + 1) → primes => global ∪ + frozenPrimeDeletions (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside + obtain ⟨hcard, hunit, hlow, huv, hshort, hsep, hMcell, hsupport, hmass⟩ := + hcells M hMQ + have hDcard (x) : ((deleted x).card : ℝ) ≤ Real.exp (Cmass * L) := by + have hh : (deleted x).card ≤ global.card + (N + 1) + outside.length := by + have ht := (Finset.card_union_le global _).trans + (Nat.add_le_add_left (frozenPrimeDeletions_card_le + (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside) global.card) + simpa only [Fintype.card_fin, Nat.add_assoc] using ht + exact (Nat.cast_le.mpr hh).trans hdel + have hsub (j) : S \ global ⊆ primeCellSupport M + (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) := by + rw [hsupport]; exact Finset.sdiff_subset + have hretain (x) (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted x ⊆ S \ global := by + rw [hsupport] + intro q hq + exact Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hq).1, + fun hg => (Finset.mem_sdiff.mp hq).2 (Finset.mem_union_left _ hg)⟩ + have hmem (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : s ∈ Sfreq := by + rw [ht] at hs + exact allFrequencyList_subtype_mem Sfreq (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft) s hs + have hfreq (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : s ≠ 0 := + hS s (hmem b s hs) + have hV (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : + |(s : ℝ)| ≤ Real.exp (A * m) := by + have hn : (s.natAbs : ℝ) ≤ Nfreq := by exact_mod_cast hN s (hmem b s hs) + exact (show |(s : ℝ)| ≤ Nfreq by simpa only [Nat.cast_natAbs, Int.cast_abs] using hn).trans hNfreq + have hone (side : Bool) : + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern side)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one _ (fun s _ => hf s) _ + have hamp : 2 * (‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern false)‖ * + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern true)‖) ≤ + Real.exp (1 * (m : ℝ)) := by + have hn := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm + have he := Real.add_one_le_exp (1 * (m : ℝ)) + nlinarith only [hn, hmR, he] + exact hrate lo hi hlo hhi hwindow Bidx Cidx (Fin (wholePrimeGridCount b)) N e tierB tierC + t Sfreq ft Nfreq small slot perm pattern rep primes hprimes childBound pivotBound hfreq f + outside p hc Dq sets β X j₀ φ G u v (fun x _ => deleted x) (fun _ => S \ global) + μ ν logSlots cb active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hvcenter (hsmall false) hB htier (hsmallLen false) + ht hS hN hf hm hp hV + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout hcard (fun _ => hunit) (fun _ => hlow) + (fun _ => huv) (fun _ => hshort) (fun _ => hsep) (fun _ => hMcell) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hShell) (fun x _ _ => hDcard x) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hmass) + (fun x _ _ i hi => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_base (fun i => (x i : ℕ)) _ outside i hi)) hout + (fun x _ _ q hq => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_outside (fun i => (x i : ℕ)) _ outside q hq)) + (⟨0, wholePrimeGridCount_pos b⟩, 1) hsub (fun x _ => hretain x) hν + hμ0 hν0 hμmass hνmass (le_trans (by norm_num) hEprior) hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hactive + hinjp houtcover hNfreq huBig hrBig tier primeLo cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hpband hdeleteμ hdeletep hdeleteν + hsreg hsregN hsetsReg hEup hUlog hαup hβup hVeq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodSharp.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodSharp.lean new file mode 100644 index 0000000000000000000000000000000000000000..0724e1dc51dba0cd513a99347b8831ada15d7880 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogGoodSharp.lean @@ -0,0 +1,201 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogGoodArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalNumericalRate + +namespace OAI + +/-! # Absorbing all comparison errors in the original good-matching bound -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_original_good_sharp + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass Cprior gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) (hCprior : 1 ≤ Cprior) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (_hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG center : ℝ), + let reg := (movingPatternRegularSlots e (n + 2) m small slot).get + let data := movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + MovingLeafLengthLE (n + 2) small r₀ → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) + (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + Function.Injective p → + (∀ q ∈ outside, ∃ i, p i = q) → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + ∀ (tier : primes → ℕ) (lower cutoff : ℕ), + Nfreq ≤ lower → Nfreq < cutoff → cutoff ≤ lower → + (∀ j, j < (n + 2) → ∀ q, μ j q ≠ 0 → tier q = j) → + (∀ j q, ν j q ≠ 0 → tier q = tierB j) → + (∀ j q, μ j q ≠ 0 → lower < (q : ℕ)) → + (∀ j q, ν j q ≠ 0 → lower < (q : ℕ)) → + (∀ q : primes, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ lower) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + Eprior ≤ Real.exp (Cprior * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq reg active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center x) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + (Real.exp (Cprior * L)) ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hmain⟩ := + P.movingPattern_half_log_original_good_arithmetic_rate ψ n r₀ k A Wwin Bφ Dφ F Cmass gain + hA hWwin hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hmain, + movingPattern_diagonal_pointwise_rate ψ (n + 2) r₀ k A Wwin Bφ Dφ Cprior Cmass + hA hWwin hBφ hDφ hCprior (by linarith)] with L hmain hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes _ childBound pivotBound hfreq f outside _ p _ hc _ + Dq sets β X j₀ φ G u v deleted initial μ ν logSlots cb active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hsmall hB htier hsmallLen ht hS hN hf hm hp hV hsets hsetsp hpupper + hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + hinjp houtp hNupper hcenterlow hrGlow tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg hEup hUlog hαup hβup hVeq + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern + let amp := 2 * (‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data true)‖) + have hh := hmain lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes childBound pivotBound hfreq f outside p hc Dq sets β X j₀ φ G + u v deleted initial μ ν logSlots cb active sreg setsReg Jleft Jright diagonal Eprior αall βint Vint Uall + uG vG rG sG center hslots huG hrG huvG hrsG hvG hsG hcenter hsmall hB htier hsmallLen ht hS hN hf + hm hp hV hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall hμbound hμall hνall hμmax hμmin hvalues + hfixed hinjp houtp hNupper hcenterlow hrGlow tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + have hone (b : Bool) : ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data b)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (fun {_} _ => f) (fun s _ => hf s) (data b) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hamp4 : amp ≤ 4 := by + have h := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + dsimp only [amp] + linarith + apply hrate p (Fintype.card Cidx) Eprior Uall αall βint amp lo hi rG (Real.exp (-gain * m)) _ diagonal + (movingPattern_class_card_le (n + 2) pattern rep) hEprior hEup hUall hUlog hαall hαup hβint hβup + hamp0 hamp4 hhi hwindow hpupper hrGlow (Real.exp_nonneg _) + simpa only [hVeq, add_assoc] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogKernelCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogKernelCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..0c82fae3a6febce29937f8ee6efccaf1b92b5084 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogKernelCost.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.BulkHalfLogBudgetComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelCost + +namespace OAI + +/-! # Fixed-depth cost of the terminal logarithmic cutoffs -/ + +namespace Ostmann +open scoped SchwartzMap + +/-- Retaining all terminal log weights preserves the quadratic budget, +uniformly in their centers and in the moving Fourier window. -/ +theorem movingPatternHalfLogKernelBudget_spectatorScale_window + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (A H B D Dlog : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hDlog : 0 ≤ Dlog) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ L : ℝ, 1 ≤ L → + let m := spectatorBulkCount k L + ∀ lo hi : ℝ, lo ≤ hi → hi - lo ≤ Real.exp (H * m) → + ∀ t rlog : ℕ, t ≤ 4 * 2 ^ n → rlog ≤ 2 ^ n * (r₀ + m + 4 * n) → + bulkLogWeightedKernelPairBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 t rlog B D Dlog ≤ + Real.exp (C * L ^ 2) := by + obtain ⟨C₀, hC₀, hb⟩ := + movingPatternKernelBudget_spectatorScale_window ψ n r₀ k A H B D hA hH + let a := 2 + Dlog * (Real.exp 2 - 1) + let K := 2 * a ^ (4 * 2 ^ n) + have ha : 1 ≤ a := by + have he : 0 ≤ Real.exp 2 - 1 := sub_nonneg.mpr (Real.one_le_exp (by norm_num)) + dsimp only [a] + nlinarith [mul_nonneg hDlog he] + have hK : 0 ≤ K := by dsimp only [K]; positivity + refine ⟨C₀ + K, by linarith, ?_⟩ + intro L hL + dsimp only + intro lo hi hhi hwindow t rlog ht hrlog + have hbudget := bulkHalfLogWeightedKernelPairBudget_le ψ (Real.exp (A * spectatorBulkCount k L)) + lo hi n (2 ^ n * (r₀ + spectatorBulkCount k L + 4 * n + 4)) + (2 ^ n * (r₀ + spectatorBulkCount k L + 4 * n)) 0 t rlog B D Dlog hDlog ht hrlog + have hfactor : 2 * a ^ t ≤ K := + mul_le_mul_of_nonneg_left (pow_le_pow_right₀ ha ht) (by norm_num) + have hbase := bulkKernelPairComparisonBudget_nonneg ψ + (Real.exp (A * spectatorBulkCount k L)) lo hi n + (2 ^ n * (r₀ + spectatorBulkCount k L + 4 * n + 4)) + (2 ^ n * (r₀ + spectatorBulkCount k L + 4 * n)) 0 B D + apply hbudget.trans + calc + _ ≤ K * Real.exp (C₀ * L ^ 2) := mul_le_mul hfactor (hb L hL lo hi hhi hwindow) hbase hK + _ ≤ Real.exp K * Real.exp (C₀ * L ^ 2) := + mul_le_mul_of_nonneg_right (by linarith [Real.add_one_le_exp K]) (Real.exp_nonneg _) + _ = Real.exp (K + C₀ * L ^ 2) := (Real.exp_add _ _).symm + _ ≤ Real.exp ((C₀ + K) * L ^ 2) := by + apply Real.exp_le_exp.mpr + have hsq : 1 ≤ L ^ 2 := by nlinarith + nlinarith [mul_le_mul_of_nonneg_left hsq hK] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeInitialNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeInitialNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..ffdfa79ad4276333ad180fc334aa107005635044 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeInitialNormRate.lean @@ -0,0 +1,182 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogTwoPrimeNormRate +import OAI.NumberTheory.Ostmann.Construction.NestedPrimePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeNorm + +namespace OAI + +/-! # Retaining the norm bound under the initial bulk law -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_half_log_initial_two_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex n × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (initial j) (x j) : ℝ) : ℂ) * + movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + have hconditional := P.movingPattern_half_log_original_two_prime_norm_rate ψ n r₀ k + A Wwin Bφ Dφ F Cmass hA hWwin hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + filter_upwards [hconditional, movingPattern_bad_event_rate_window ψ n r₀ k + A Wwin Bφ Dφ F (Cmass + 1) hA hWwin hF, + P.original_harmonic_box_rate Cmass hCmass, eventually_ge_atTop (2000 : ℝ)] + with L hconditional hbad hnormal hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted logSlots cb + hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hbd := hbad lo hi hhi hwindow p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hdeletedBound := hconditional lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq xg y X A₀ + j₀ φ G XL U u v deleted logSlots cb hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ + hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout + hA₀ hlocal c₀ + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * W + have hpoint (x : (TreeLeafIndex n × Fin m) → primes) : + ‖movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ cost := + movingPatternLogTwoPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb + hxg hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hcollision : 0 ≤ cost * (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * + Real.exp ((Cmass + 1) * L - Real.exp ((39 / 10000 : ℝ) * L)) := by + dsimp only [cost, W, amp] + positivity + have hreturnCost := (le_add_of_nonneg_left hcollision).trans hbd + have hcost0 : 0 ≤ cost := by dsimp only [cost, W, amp]; positivity + have hfinal := @nested_prime_prior_three_errors (TreeLeafIndex n × Fin m) + inferInstance primes S initial deleted hS hsub hretain (fun j => (hnorm j).1) + (fun x => movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb x) + cost (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L))) + (Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcost0 hpoint + (by simpa only [finite_univ_canonical, m, S, M] using hdeletedBound) + (by simpa only [finite_univ_canonical, cost, W, m, Z] using hreturnCost) + simpa only [finite_univ_canonical, m, S, M] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeIntegratedRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeIntegratedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e252334a8ad83d7a78b63184a705aebb8ac7515 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeIntegratedRate.lean @@ -0,0 +1,212 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogTwoPrimeSameNormArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHarmonicIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # The actual two-prime arithmetic bound integrated over its giant cells -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_same_assignment_two_prime_integral_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG : ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (Fw true) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := fun xg y => movingPatternLogTwoPrimeObservable e t small slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i b j, + j ∈ flattenMovingSlots n (small b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (fun x => ∫ xg in Set.Ioc uG vG, ∫ y in Set.Ioc rG sG, + obs xg y x / ((xg : ℂ) * (y : ℂ))) x * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + (((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))))) / (uG * rG) := by + filter_upwards [P.movingPattern_half_log_same_assignment_two_prime_arithmetic_rate ψ n r₀ k + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog, + eventually_ge_atTop (0 : ℝ)] with L hrate hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq Fw outside _ p _ hc _ twist sets + Qfreq X j₀ φ G u v deleted initial μ ν Eprior αall βint Vint Uall uG vG rG sG logSlots cb + hslots huG hrG huvG hrsG hvG hsG + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq n ft + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let obs := fun xg y => movingPatternLogTwoPrimeObservable e t small slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let amp := 4 * (‖movingDataWeight (Fw false) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (Fw true) (fun _ _ _ _ => 1) (data true)‖) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let bound := ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) + have hmean (xg : ℝ) (hxg : xg ∈ Set.Ioc uG vG) (y : ℝ) (hy : y ∈ Set.Ioc rG sG) : + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (obs xg y) x * movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) n t small + (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ bound := by + exact hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes childBound pivotBound hfreq Fw outside p hc twist sets Qfreq xg y X j₀ φ G + (Real.exp xg) (Real.exp y) u v deleted initial μ ν Eprior αall βint Vint Uall logSlots cb + hslots hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp (by linarith [hxg.1]) (by linarith [hy.1]) + hpupper hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hSS hdel hmass + hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint + hVint hUall hμbound hμall hνall hμmax hμmin hvalues + (hdisjoint xg hxg y hy) (hcross xg hxg y hy) (hfmod xg hxg y hy) + have hA₀ : 0 ≤ A₀ := by + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro z hz + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hz + exact pairFrequencySupportBound_nonneg D f + exact mul_nonneg (by positivity) (mul_nonneg hleaf0 hprod) + have hcost : 0 ≤ cost := by dsimp only [cost, amp]; positivity + have herr := movingInternalArithmeticError_nonneg n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + (Real.one_le_exp (mul_nonneg hA (Nat.cast_nonneg m))) hUall hαall hβint hVint.le + have hbound : 0 ≤ bound := by dsimp only [bound]; positivity + apply movingPattern_prime_harmonic_integral_bound e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) μ ν t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) + pattern (fun x xg y => obs xg y x) _ uG vG rG sG bound huG hrG huvG hrsG hvG hsG + hbound (fun _ => cost) (fun _ => hcost) _ hmean + · intro x + exact movingPatternLogTwoPrimeObservable_measurable e t small slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq ψ X lo hi hlo hhi φ G Bφ Dφ hBφ hDφ hφ hlip hφout logSlots cb x + · intro x xg hxg y hy + exact movingPatternLogTwoPrimeObservable_norm e tierB tierC t small slot (Equiv.refl _) pattern + hB htier primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G + Bφ Dφ hBφ hDφ hφ hlip hφout (Real.exp xg) (Real.exp y) logSlots cb + (by linarith [hxg.1]) (by linarith [hy.1]) (fun i => (p i : ℝ)) (fun _ => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..0e6e9ce70c4a4955576aa757c1737903af419c16 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeNormRate.lean @@ -0,0 +1,189 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeNormBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogCellError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBadEventRate +import OAI.NumberTheory.Ostmann.Construction.OriginalHarmonicRate +import OAI.NumberTheory.Ostmann.ZeroDensity.BulkProgressionCutoff + +namespace OAI + +/-! # The original-prior norm estimate at the manuscript scales -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_half_log_original_two_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨Cerr, hCerr, hCnorm, hcellRate⟩ := + P.movingPattern_half_log_cell_error_rate_window ψ n r₀ k A Wwin Bφ Dφ F (Cmass + 1) Dlog + hA hWwin hF hDlog tlog htlog + obtain ⟨Tcell, _, hcellTwo⟩ := P.short_prime_cell_mass_two + have hlarge : ∀ᶠ L : ℝ in atTop, Tcell ≤ Real.exp ((39 / 10000 : ℝ) * L) := + (Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num))).eventually + (eventually_ge_atTop Tcell) + filter_upwards [hcellRate, movingPattern_bad_event_rate_window ψ n r₀ k + A Wwin Bφ Dφ F (Cmass + 1) hA hWwin hF, + P.original_harmonic_box_rate Cmass hCmass, hlarge, eventually_ge_atTop (2000 : ℝ)] + with L herror hbad hnormal hlarge hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted logSlots cb + hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime base n m t + (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (twist i) perm + (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hZ (j) : Z j ≤ Real.exp (Cerr * L) := (hnorm j).2.1.trans + (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hCnorm (by linarith))) + have hunit : (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) := + bulkResidueModulus_unit_card hMQ (Nat.floor_le (Real.exp_nonneg _)) + have ha (z) : ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) := by + exact moving_frozen_prime_residue_coefficient_norm base (movingPatternBulkEmbedding e slot) outside + Fw Ew n m data childBound R r P Qfreq xg y hxg hy p sets hsets hsetsp + t _ _ twist perm (bulkResidueEquiv r p hc z).1 (bulkResidueEquiv r p hc z).2 + have he := herror lo hi hhi hwindow Cell M (bulkProgressionCutoff L) hQ.1 hQ.2 p Z a amp + (Real.exp ((39 / 10000 : ℝ) * L)) (2 ^ n * (r₀ + m + 4 * n)) le_rfl + hpupper hZ0 hZ hcard hunit hamp0 hamp ha le_rfl u hulow + have hbd := hbad lo hi hhi hwindow p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hb := P.movingPattern_log_two_prime_norm_bound e tierB tierC t small slot perm pattern + hsmall hB htier base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r + hR hr p hc (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) twist (bulkProgressionCutoff L) Qfreq xg y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb Dlog hDlog hloglip (2 ^ n * (r₀ + m + 4 * n)) hslots + r₀ hsmallLen hxg hy hQ.1 hMQ u v hu huv hshort + (fun j c z => hcellTwo M z.val.val (u j c) (v j c) (hlarge.trans (hulow j c)) (hshort j c)) + c₀ hS (fun j => unitPrimeCells_separated M (u j) (v j) (hsep j)) deleted + (fun j => (hnorm j).1.ne') hdelbase hout hdelout (fun i => (p i : ℝ)) + (fun i => Nat.cast_nonneg _) (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) + A₀ hA₀ ((Cmass + 1) * L) (Real.exp ((39 / 10000 : ℝ) * L)) + hlocal (fun j => (hnorm j).2.2) (fun j => (hnorm j).2.1) + (fun j q hq => hlow j q (Finset.mem_sdiff.mp hq).1) + dsimp only at hb + have hh := add_le_add (le_refl + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m))) (add_le_add he hbd) + apply hb.trans + simpa only [add_assoc, W, amp, Z, a, spec, freq, data, M, S] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeOriginalNormArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeOriginalNormArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..04af38981d4014eeae1207630c0fb85ec270c3ad --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeOriginalNormArithmetic.lean @@ -0,0 +1,193 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogTwoPrimeSelectedNormRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate + +namespace OAI + +/-! # The norm estimate with the original internal and external priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_original_two_prime_norm_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + 0 ≤ A₀ → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + let freq := frozenBulkFrequencyPrime (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) + outside Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime (fun i => (x i : ℕ)) n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + ∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern obs x * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot perm) pattern x‖ ≤ + ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + filter_upwards [P.movingPattern_half_log_selected_two_prime_norm_rate ψ n r₀ k + A Wwin Bφ Dφ F Cmass hA hWwin hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted initial + μ ν Eprior αall βint Vint Uall logSlots cb hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper + hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout + hA₀ hlocal c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let obs := movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb + let cost := (4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hpoint (x) : ‖obs x‖ ≤ cost := + movingPatternLogTwoPrimeObservable_norm e tierB tierC t small slot perm pattern hB htier + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb + hxg hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hminor (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ‖movingPatternBulkMean e ν slot obs x‖ ≤ + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + exact hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern primes hprimes x + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq xg y X A₀ j₀ φ G XL U u v (deleted x) logSlots cb + hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS (hdel x hx) hmass (hdelbase x hx) hout (hdelout x hx) + hA₀ (hlocal x hx) c₀ initial hsub (hretain x hx) ν hν + have hfinal := movingPrimePattern_signed_arithmetic_on_support e (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) tierB tierC t small + (movingPatternBulkLeaves n m slot perm) pattern rep + (fun b j _ => hB j) (fun b j _ => hB j) htier + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hUall + (movingPatternFinBulkData_size e t small slot perm pattern hsmallLen) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hV) + (fun q => by + simpa only [Int.cast_natCast, abs_of_nonneg (show (0 : ℝ) ≤ (q : ℕ) from Nat.cast_nonneg _)] + using hvalues q) + μ ν hμ0 hν0 hμmass hνmass Eprior αall βint Vint hEprior hαall hβint hVint + hμbound hμall hνall hμmax hμmin obs cost (by dsimp only [cost]; positivity) + hpoint hdisjoint hcross hfmod m slot perm rfl + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hminor + (fun _ => Classical.arbitrary primes) + simpa only [movingInternalArithmeticError, obs, cost, data, m] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeSameNormArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeSameNormArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..7de7a957e491df3aa0a6871ea608aae90ad2a2c0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeSameNormArithmetic.lean @@ -0,0 +1,202 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogTwoPrimeOriginalNormArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNormalizedNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFrequencyModulus +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate + +namespace OAI + +/-! # The norm estimate with the original internal and external priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_same_assignment_two_prime_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (Fw true) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternLogTwoPrimeObservable e t small slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i b j, + j ∈ flattenMovingSlots n (small b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern obs x * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + filter_upwards [P.movingPattern_half_log_original_two_prime_norm_arithmetic_rate ψ n r₀ k + A Wwin Bφ Dφ 2 Cmass hA hWwin (by norm_num) hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq Fw outside _ p _ hc _ twist sets + Qfreq xg y X j₀ φ G XL U u v deleted initial μ ν Eprior αall βint Vint Uall logSlots cb + hslots hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq n ft + have hR (b : Bool) : (movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern b).frequencyProduct ∣ (R : ℤ) := by + simpa only [ht, R] using movingPattern_frequencyProduct_dvd e Sfreq ft small slot (Equiv.refl _) pattern b + have hroots (b : Bool) (j : Fin (2 ^ n - 1)) : + (singleTreeNodeFrequencies Sfreq n (frequencyPairProjection Sfreq n b ft) j.val).root.natAbs ∣ R := + frequencyModelBase_roots Sfreq n ft b j + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + have hone (b : Bool) : ‖movingDataWeight (Fw b) (fun _ _ _ _ => 1) (data b)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (Fw b) (fun s regular => + (hleaf b s regular).trans (by split_ifs <;> norm_num)) (data b) + have hamp : 4 * (‖movingDataWeight (Fw false) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (Fw true) (fun _ _ _ _ => 1) (data true)‖) ≤ Real.exp ((2 : ℝ) * m) := by + have hpair := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm + have he : (2 : ℝ) ≤ Real.exp (m : ℝ) := by linarith [Real.add_one_le_exp (m : ℝ)] + calc + _ ≤ 4 := by linarith + _ ≤ (Real.exp (m : ℝ)) ^ 2 := by nlinarith [Real.exp_pos (m : ℝ)] + _ = _ := by simpa only [Nat.cast_ofNat] using (Real.exp_nat_mul (m : ℝ) 2).symm + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + have hA₀ : 0 ≤ A₀ := by + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro x hx + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hx + exact pairFrequencySupportBound_nonneg D f + exact mul_nonneg (by positivity) (mul_nonneg hleaf0 hprod) + have hlocal (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) + (z : (TreeLeafIndex n × Fin m) → ℝ) (hz : ∀ j, 0 ≤ z j) := + movingPattern_normalized_same_assignment_prime_norm e tierB tierC Sfreq ft R Nfreq Vleaf + hS hN hroots small slot pattern hsmall hB htier (fun i => (x i : ℕ)) (hbase x hx) + Fw hleaf D hD hdiv hm p hc hp + (by simpa only [ht] using hfreqp) (hsmallp x hx) (hsamplesp x hx) + sets hsets hsetsp twist outside childBound P Qfreq (bulkProgressionCutoff L) xg y hxg hy z hz + have h := hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot (Equiv.refl _) pattern rep + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p hc twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted initial μ ν + Eprior αall βint Vint Uall logSlots cb hslots hsmall hB htier hsmallLen hR (frequencyModelModulus_precision R n) + hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell + hSS hdel hmass hdelbase hout hdelout hA₀ + (by + intro x hx + dsimp only + intro z hz + have hz' := hlocal x hx z hz + simpa only [A₀, m, ht, finite_univ_canonical, Fintype.card_eq_nat_card, Nat.card_fin] using hz') + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + exact h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeSelectedNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeSelectedNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba2a8f95d530ed90020f0dec8c019acf16a416bd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogTwoPrimeSelectedNormRate.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogTwoPrimeInitialNormRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeObservable + +namespace OAI + +/-! # Norm estimate for the original selected-coordinate mean -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_half_log_selected_two_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (base : Fin (N + 1) → primes) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyPrime (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime (fun i => (base i : ℕ)) n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (base i : ℕ) ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex n × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ∀ ν : Bidx → primes → ℝ, + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + ‖movingPatternBulkMean e ν slot + (movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb) base‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + filter_upwards [P.movingPattern_half_log_initial_two_prime_norm_rate ψ n r₀ k A Wwin Bφ Dφ F Cmass + hA hWwin hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern primes hprimes base + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted logSlots cb + hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain ν hν + rw [movingPatternBulkMean_logTwoPrimeObservable] + · exact hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern + (fun i => (base i : ℕ)) primes hprimes (fun i _ => hprimes _ (base i).property) + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted logSlots cb + hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain + · exact hν + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac8ee7d110d575590e9c2933b0d4eeabb83a9a87 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowArithmetic.lean @@ -0,0 +1,211 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogWindowSelectedRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMultiplier + +namespace OAI + +/-! # The complete arithmetic bound under the original union-of-cells prior -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_weighted_arithmetic_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (W : (Fin (N + 1) → primes) → ℂ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb + let obs := fun x => W x * raw x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, ‖W x‖ ≤ 1) → + (∀ x z, W (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) = W x) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_half_log_selected_prime_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted initial + μ ν logSlots cb W Eprior αall βint Vint Uall hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hW hWbulk hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let raw := movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb + let obs := fun x => W x * raw x + let cost := (2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + have hraw (x) : ‖raw x‖ ≤ cost := + movingPatternLogPrimeObservable_norm e tierB tierC t small slot perm pattern hB htier + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hpoint (x) : ‖obs x‖ ≤ cost := by + change ‖W x * raw x‖ ≤ cost + rw [norm_mul] + exact (mul_le_mul_of_nonneg_right (hW x) (norm_nonneg _)).trans (by simpa using hraw x) + have hminor (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ‖movingPatternBulkMean e ν slot obs x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + rw [movingPatternBulkMean_weight e ν slot W raw hWbulk x, norm_mul] + apply (mul_le_mul_of_nonneg_right (hW x) (norm_nonneg _)).trans + simp only [one_mul] + exact hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern primes hprimes x + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X j₀ φ G XL U u v (deleted x) logSlots cb + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp (hsmallp x hx) (hsamplesp x hx) + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS (hdel x hx) hmass (hdelbase x hx) hout (hdelout x hx) + c₀ initial hsub (hretain x hx) ν hν + have hfinal := movingPattern_signed_arithmetic_on_support e (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) tierB tierC t small + (movingPatternBulkLeaves (n + 2) m slot perm) pattern rep + (fun b j _ => hB j) (fun b j _ => hB j) htier + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hUall + (movingPatternFinBulkData_size e t small slot perm pattern hsmallLen) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hV) + (fun q => by + simpa only [Int.cast_natCast, abs_of_nonneg (show (0 : ℝ) ≤ (q : ℕ) from Nat.cast_nonneg _)] + using hvalues q) + μ ν hμ0 hν0 hμmass hνmass Eprior αall βint Vint hEprior hαall hβint hVint + hμbound hμall hνall hμmax hμmin obs cost (by dsimp only [cost]; positivity) + hpoint hdisjoint hcross hfmod m slot perm rfl + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hminor + (fun _ => Classical.arbitrary primes) + simpa only [movingInternalArithmeticError, obs, raw, cost, data, m] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowInitialRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowInitialRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..81b6d4d4e9401f2da76e1c3ac75ef0ef8eccdc2a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowInitialRate.lean @@ -0,0 +1,181 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogWindowPrimeRate +import OAI.NumberTheory.Ostmann.Construction.NestedPrimePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeNorm + +namespace OAI + +/-! # Signed cancellation under the initial, unconditioned bulk law -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_initial_prime_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) → + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ‖∑ x : (TreeLeafIndex (n + 2) × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (initial j) (x j) : ℝ) : ℂ) * + movingPatternLogPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hconditional⟩ := + P.movingPattern_half_log_original_prime_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hconditional, movingPattern_bad_event_rate_window ψ (n + 2) r₀ k + A H Bφ Dφ F (Cmass + 1) hA hH hF, + P.original_harmonic_box_rate Cmass hCmass, eventually_ge_atTop (2000 : ℝ)] + with L hconditional hbad hnormal hL + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted logSlots cb + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hbd := hbad lo hi hhi hwidth p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hdeletedBound := hconditional lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X + j₀ φ G XL U u v deleted logSlots cb hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * W + have hpoint (x : (TreeLeafIndex (n + 2) × Fin m) → primes) : + ‖movingPatternLogPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ cost := + movingPatternLogPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hcollision : 0 ≤ cost * (Fintype.card (TreeLeafIndex (n + 2) × Fin m) : ℝ) ^ 2 * + Real.exp ((Cmass + 1) * L - Real.exp ((39 / 10000 : ℝ) * L)) := by + dsimp only [cost, W, amp] + positivity + have hreturnCost := (le_add_of_nonneg_left hcollision).trans hbd + have hcost0 : 0 ≤ cost := by dsimp only [cost, W, amp]; positivity + have hfinal := @nested_prime_prior_three_errors (TreeLeafIndex (n + 2) × Fin m) + inferInstance primes S initial deleted hS hsub hretain (fun j => (hnorm j).1) + (fun x => movingPatternLogPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb x) + cost (Real.exp (-gain * m)) (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L))) + (Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcost0 hpoint + (by simpa only [finite_univ_canonical, m, S, M] using hdeletedBound) + (by simpa only [finite_univ_canonical, cost, W, m, Z] using hreturnCost) + simpa only [finite_univ_canonical, m, S, M] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..91309997221685627dc75305ca1f1c848a1045dd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowIntegral.lean @@ -0,0 +1,213 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogWindowArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedHarmonicIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # Signed quartet cancellation under both giant-cell integrals -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_weighted_mixed_integral_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (W : ℝ → ℝ → (Fin (N + 1) → primes) → ℂ) + (Eprior αall βint Vint Uall uG vG rG sG center : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := fun xg y => movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let obs := fun xg y x => W xg y x * raw xg y x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, Measurable (fun z : ℝ × ℝ => W z.1 z.2 x)) → + (∀ xg y x, ‖W xg y x‖ ≤ 1) → + (∀ xg y x z, W xg y (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) = W xg y x) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ∫ xg in Set.Ioc uG vG, ∫ y in Set.Ioc rG sG, + obs xg y x * (Real.exp (xg - center) : ℂ) / (y : ℂ)) x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + (2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_half_log_weighted_arithmetic_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq X j₀ φ G u v deleted initial + μ ν logSlots cb W Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hWmeas hW hWbulk hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let raw := fun xg y => movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let obs := fun xg y x => W xg y x * raw xg y x + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + let bound := ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) + have hmean (xg : ℝ) (hxg : xg ∈ Set.Ioc uG vG) (y : ℝ) (hy : y ∈ Set.Ioc rG sG) : + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (obs xg y) x * movingPatternHaarProduct e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) (n + 2) t small + (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ bound := by + exact hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern rep primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X j₀ φ G + (Real.exp xg) (Real.exp y) u v deleted initial μ ν logSlots cb (W xg y) Eprior αall βint Vint Uall + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp (by linarith [hy.1]) hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues (hW xg y) (hWbulk xg y) + (hdisjoint xg hxg y hy) (hcross xg hxg y hy) (hfmod xg hxg y hy) + have hcost : 0 ≤ cost := by dsimp only [cost, amp]; positivity + have herr := movingInternalArithmeticError_nonneg (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + (Real.one_le_exp (mul_nonneg hA (Nat.cast_nonneg m))) hUall hαall hβint hVint.le + have hbound : 0 ≤ bound := by dsimp only [bound]; positivity + apply movingPattern_mixed_harmonic_integral_bound e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) μ ν t small (movingPatternBulkLeaves (n + 2) m slot perm) + pattern (fun x xg y => obs xg y x) _ uG vG rG sG center bound huG hrG huvG hrsG hvG hsG hcenter + hbound (fun _ => cost) (fun _ => hcost) _ hmean + · intro x + exact (hWmeas x).mul (movingPatternLogPrimeObservable_measurable e t small slot perm pattern + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + ψ X lo hi hlo hhi φ G Bφ Dφ hBφ hDφ hφ hlip hφout logSlots cb x) + · intro x xg hxg y hy + have hh := movingPatternLogPrimeObservable_norm e tierB tierC t small slot perm pattern + hB htier primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout (Real.exp xg) (Real.exp y) logSlots cb + (by linarith [hy.1]) (fun i => (p i : ℝ)) (fun _ => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + change ‖W xg y x * raw xg y x‖ ≤ cost + rw [norm_mul] + exact (mul_le_mul (hW xg y x) hh (norm_nonneg _) (by norm_num)).trans_eq (one_mul _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowPrimeRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowPrimeRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..130b27959dbde050d8621dd9c72320fd574624d5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowPrimeRate.lean @@ -0,0 +1,198 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogMixedPrimeSignedBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowPrimeGain +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogCellError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBadEventRate +import OAI.NumberTheory.Ostmann.Construction.OriginalHarmonicRate +import OAI.NumberTheory.Ostmann.ZeroDensity.BulkProgressionCutoff + +namespace OAI + +/-! # One original-prior signed bulk estimate at the manuscript scales -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The three arithmetic costs are combined for the literal original prime +mean. The only analytic input is the published progression theorem; local +cancellation is proved from the balanced spectator sets and their mixed +Fourier bounds. All prime normalizers are those before idealization. -/ +theorem PublishedProgressionInput.movingPattern_half_log_original_prime_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) → + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ‖∑ x : (TreeLeafIndex (n + 2) × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternLogPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, δ, hε, hε1, hδ, cutoff, hcutoff, hgain⟩ := + exists_movingPatternPrimeGain_window ψ n r₀ A H Bφ Dφ F gain hA hH + obtain ⟨Cerr, hCerr, hCnorm, hcellRate⟩ := + P.movingPattern_half_log_cell_error_rate_window ψ (n + 2) r₀ k A H Bφ Dφ F (Cmass + 1) Dlog hA hH hF hDlog tlog htlog + obtain ⟨Tcell, _, hcellTwo⟩ := P.short_prime_cell_mass_two + have hlarge : ∀ᶠ L : ℝ in atTop, Tcell ≤ Real.exp ((39 / 10000 : ℝ) * L) := + (Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num))).eventually + (eventually_ge_atTop Tcell) + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hcellRate, movingPattern_bad_event_rate_window ψ (n + 2) r₀ k + A H Bφ Dφ F (Cmass + 1) hA hH hF, + P.original_harmonic_box_rate Cmass hCmass, hlarge, eventually_ge_atTop (2000 : ℝ)] + with L herror hbad hnormal hlarge hL + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted logSlots cb + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq y + let spec := fun i => frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) (twist i) perm + (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hg := hgain m hm lo hi hhi hwidth Bidx Cidx N e base t small pattern p hp + (fun i b s hs => ⟨hfreq b s hs, hfreqp i b s hs⟩) hsmallp hsamplesp + twist perm hgood sets hdlo hdhi hsets hsetsp β hβ hbias amp hamp0 hamp + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hZ (j) : Z j ≤ Real.exp (Cerr * L) := (hnorm j).2.1.trans + (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hCnorm (by linarith))) + have hunit : (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) := + bulkResidueModulus_unit_card hMQ (Nat.floor_le (Real.exp_nonneg _)) + have ha (z) : ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1)) := by + exact moving_frozen_residue_coefficient_norm base (movingPatternBulkEmbedding e slot) outside + Fw Ew (n + 2) m data childBound R r P Qfreq y hy p sets hsets hsetsp + t _ _ twist perm (bulkResidueEquiv r p hc z).1 (bulkResidueEquiv r p hc z).2 + have he := herror lo hi hhi hwidth Cell M (bulkProgressionCutoff L) hQ.1 hQ.2 p Z a amp + (Real.exp ((39 / 10000 : ℝ) * L)) (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) le_rfl hpupper hZ0 hZ hcard hunit hamp0 hamp ha le_rfl u hulow + have hbd := hbad lo hi hhi hwidth p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hb := P.movingPattern_log_mixed_prime_signed_bound e tierB tierC t small slot perm pattern + hsmall hB htier base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r + hR hr p hc (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) twist (bulkProgressionCutoff L) Qfreq y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb Dlog hDlog hloglip + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) hslots r₀ hsmallLen hy hQ.1 hMQ hpage u v hu huv hshort + (fun j c z => hcellTwo M z.val.val (u j c) (v j c) (hlarge.trans (hulow j c)) (hshort j c)) + c₀ hS (fun j => unitPrimeCells_separated M (u j) (v j) (hsep j)) deleted + (fun j => (hnorm j).1.ne') hdelbase hout hdelout (fun i => (p i : ℝ)) + (fun i => Nat.cast_nonneg _) (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) + δ hδ.le ((Cmass + 1) * L) (Real.exp ((39 / 10000 : ℝ) * L)) + hg.1 (fun j => (hnorm j).2.2) (fun j => (hnorm j).2.1) + (fun j q hq => hlow j q (Finset.mem_sdiff.mp hq).1) + dsimp only at hb + calc + _ ≤ _ := hb + _ ≤ Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + have hh := add_le_add (add_le_add hg.2 he) hbd + simpa only [add_assoc, W, amp, Z, a, spec, freq, data, M, S] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowSelectedRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowSelectedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..39dd7569e6dff2f2340013886fca7d3cf0501e34 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHalfLogWindowSelectedRate.lean @@ -0,0 +1,123 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogWindowInitialRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeObservable + +namespace OAI + +/-! # The published prime estimate in the original selected-coordinate mean -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_half_log_selected_prime_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (base : Fin (N + 1) → primes) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((base (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ i c, ((base (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (base i : ℕ) ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ∀ ν : Bidx → primes → ℝ, + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + ‖movingPatternBulkMean e ν slot + (movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb) base‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_half_log_initial_prime_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern primes hprimes base + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted logSlots cb + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain ν hν + rw [movingPatternBulkMean_logPrimeObservable] + · exact hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern + (fun i => (base i : ℕ)) primes hprimes (fun i _ => hprimes _ (base i).property) + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X j₀ φ G XL U u v deleted logSlots cb + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain + · exact hν + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHarmonicIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHarmonicIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5ba01d41b4b16611f78d511aa194567e64ab12b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternHarmonicIntegral.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCoefficientMass +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternProducts +import OAI.NumberTheory.Ostmann.Arithmetic.HarmonicPairIntegral + +namespace OAI + +/-! # Passing the signed original-pattern bound through both giant cells -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators + +theorem movingPattern_prime_harmonic_integral_bound {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (G : (Fin (N + 1) → A) → ℝ → ℝ → ℂ) + (hG : ∀ x, Measurable (Function.uncurry (G x))) + (u v r s D : ℝ) (hu : 1 ≤ u) (hr : 1 ≤ r) + (huv : u ≤ v) (hrs : r ≤ s) (hv : v ≤ u + 1) (hs : s ≤ r + 1) (hD : 0 ≤ D) + (K : (Fin (N + 1) → A) → ℝ) (hK : ∀ x, 0 ≤ K x) + (hbound : ∀ x a, a ∈ Set.Ioc u v → ∀ b, b ∈ Set.Ioc r s → ‖G x a b‖ ≤ K x) + (hmean : ∀ a ∈ Set.Ioc u v, ∀ b ∈ Set.Ioc r s, + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern (fun x => G x a b) x * + movingPatternPrimeHaarProduct e prime hprime n t small bulk pattern x‖ ≤ D) : + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern + (fun x => ∫ a in Set.Ioc u v, ∫ b in Set.Ioc r s, + G x a b / ((a : ℂ) * (b : ℂ))) x * + movingPatternPrimeHaarProduct e prime hprime n t small bulk pattern x‖ ≤ D / (u * r) := by + let w := movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) + let H := movingPatternPrimeHaarProduct e prime hprime n t small bulk pattern + have hpoint (a : ℝ) (ha : a ∈ Set.Ioc u v) (b : ℝ) (hb : b ∈ Set.Ioc r s) : + ‖∑ x, w x * (G x a b * H x)‖ ≤ D := by + have he (x) : movingOriginalPatternWeight e μ ν prime n pattern (fun x => G x a b) x * H x = + w x * (G x a b * H x) := by + rw [movingOriginalPatternWeight_eq_coefficient_mul] + exact mul_assoc _ _ _ + have hm := hmean a ha b hb + change ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern (fun x => G x a b) x * H x‖ ≤ D at hm + simpa only [he] using hm + have h := finite_harmonic_pair_sum_norm u v r s D hu hr huv hrs hv hs hD w + (fun x a b => G x a b * H x) (fun x => (hG x).mul_const (H x)) + (fun x => K x * ‖H x‖) (fun x => mul_nonneg (hK x) (norm_nonneg _)) + (by + intro x a ha b hb + rw [norm_mul] + exact mul_le_mul_of_nonneg_right (hbound x a ha b hb) (norm_nonneg _)) hpoint + have he (x) : movingOriginalPatternWeight e μ ν prime n pattern + (fun x => ∫ a in Set.Ioc u v, ∫ b in Set.Ioc r s, + G x a b / ((a : ℂ) * (b : ℂ))) x * H x = + w x * ∫ a in Set.Ioc u v, ∫ b in Set.Ioc r s, + (G x a b * H x) / ((a : ℂ) * (b : ℂ)) := by + rw [movingOriginalPatternWeight_eq_coefficient_mul] + simp_rw [mul_div_right_comm, integral_mul_const] + exact mul_assoc _ _ _ + change ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern + (fun x => ∫ a in Set.Ioc u v, ∫ b in Set.Ioc r s, + G x a b / ((a : ℂ) * (b : ℂ))) x * H x‖ ≤ _ + simpa only [he] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternInitialNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternInitialNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..ba0a6785796d155ced7137bddff0dd35759f45c7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternInitialNormRate.lean @@ -0,0 +1,175 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNormRate +import OAI.NumberTheory.Ostmann.Construction.NestedPrimePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNorm + +namespace OAI + +/-! # Retaining the norm bound under the initial bulk law -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_initial_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P (bulkProgressionCutoff L) y + let spec := fun i => frozenBulkSpectatorHaar base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex n × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (initial j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U x‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + have hconditional := P.movingPattern_original_prime_norm_rate ψ n r₀ k + A lo hi Bφ Dφ F Cmass hA hlo hhi hF hCmass hBφ hDφ + filter_upwards [hconditional, movingPattern_bad_event_rate ψ n r₀ k + A lo hi Bφ Dφ F (Cmass + 1) hA hhi hF, + P.original_harmonic_box_rate Cmass hCmass, eventually_ge_atTop (2000 : ℝ)] + with L hconditional hbad hnormal hL + dsimp only + intro Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets y X A₀ j₀ φ G U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hbd := hbad p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hdeletedBound := hconditional Bidx Cidx Cell N e tierB tierC t small slot perm pattern + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p hc twist sets y X A₀ + j₀ φ G U u v deleted hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ + hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout + hA₀ hlocal c₀ + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * W + have hpoint (x : (TreeLeafIndex n × Fin m) → primes) : + ‖movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U x‖ ≤ cost := + movingPatternPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hcollision : 0 ≤ cost * (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * + Real.exp ((Cmass + 1) * L - Real.exp ((39 / 10000 : ℝ) * L)) := by + dsimp only [cost, W, amp] + positivity + have hreturnCost := (le_add_of_nonneg_left hcollision).trans hbd + have hcost0 : 0 ≤ cost := by dsimp only [cost, W, amp]; positivity + have hfinal := @nested_prime_prior_three_errors (TreeLeafIndex n × Fin m) + inferInstance primes S initial deleted hS hsub hretain (fun j => (hnorm j).1) + (fun x => movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U x) + cost (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L))) + (Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcost0 hpoint + (by simpa only [finite_univ_canonical, m, S, M] using hdeletedBound) + (by simpa only [finite_univ_canonical, cost, W, m, Z] using hreturnCost) + simpa only [finite_univ_canonical, m, S, M] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternInitialRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternInitialRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..90ebd7594d8f4cc937f00b002ccb9ca2d5a587ba --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternInitialRate.lean @@ -0,0 +1,175 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeRate +import OAI.NumberTheory.Ostmann.Construction.NestedPrimePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNorm + +namespace OAI + +/-! # Signed cancellation under the initial, unconditioned bulk law -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_initial_prime_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) → + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ‖∑ x : (TreeLeafIndex (n + 2) × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (initial j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hconditional⟩ := + P.movingPattern_original_prime_rate ψ n r₀ k A lo hi Bφ Dφ F Cmass gain + hA hlo hhi hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hconditional, movingPattern_bad_event_rate ψ (n + 2) r₀ k + A lo hi Bφ Dφ F (Cmass + 1) hA hhi hF, + P.original_harmonic_box_rate Cmass hCmass, eventually_ge_atTop (2000 : ℝ)] + with L hconditional hbad hnormal hL + dsimp only + intro Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β y X j₀ φ G U u v deleted + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hbd := hbad p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hdeletedBound := hconditional Bidx Cidx Cell N e tierB tierC t small slot perm pattern + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β y X + j₀ φ G U u v deleted hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * W + have hpoint (x : (TreeLeafIndex (n + 2) × Fin m) → primes) : + ‖movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U x‖ ≤ cost := + movingPatternPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hcollision : 0 ≤ cost * (Fintype.card (TreeLeafIndex (n + 2) × Fin m) : ℝ) ^ 2 * + Real.exp ((Cmass + 1) * L - Real.exp ((39 / 10000 : ℝ) * L)) := by + dsimp only [cost, W, amp] + positivity + have hreturnCost := (le_add_of_nonneg_left hcollision).trans hbd + have hcost0 : 0 ≤ cost := by dsimp only [cost, W, amp]; positivity + have hfinal := @nested_prime_prior_three_errors (TreeLeafIndex (n + 2) × Fin m) + inferInstance primes S initial deleted hS hsub hretain (fun j => (hnorm j).1) + (fun x => movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U x) + cost (Real.exp (-gain * m)) (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L))) + (Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcost0 hpoint + (by simpa only [finite_univ_canonical, m, S, M] using hdeletedBound) + (by simpa only [finite_univ_canonical, cost, W, m, Z] using hreturnCost) + simpa only [finite_univ_canonical, m, S, M] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternIntegrand.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternIntegrand.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d593f4871b25301bf5d5a49ded48c7182f662b9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternIntegrand.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelNorm + +namespace OAI + +/-! # The actual pattern's bounded bulk integrand -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℝ) (childBound pivotBound : ℕ → ℕ) + (j₀ : TreeLeafIndex n × Fin m) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +noncomputable def movingPatternBulkIntegrand : BulkIntegrand (TreeLeafIndex n × Fin m) := + (bulkLogKernelPairIntegrand base (selectedBulkSet (movingPatternBulkEmbedding e slot)) + childBound pivotBound (movingPatternFinBulkData e n m t small slot perm pattern) + (movingPatternBulkSet_compensationAbsent e tierB tierC t small slot perm pattern hB htier) + (movingPatternBulkEmbedding e slot j₀) ((mem_selectedBulkSet _ _).mpr ⟨j₀, rfl⟩) + ψ X lo hi V hlo hhi + (movingPatternFinBulkData_frequencies e t small slot perm pattern (fun s => |(s : ℝ)| ≤ V) hfreq) + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U).pullBulk base (movingPatternBulkEmbedding e slot) + +theorem movingPatternBulkIntegrand_norm (z : (TreeLeafIndex n × Fin m) → ℝ) : + ‖movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier base + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U z‖ ≤ + (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 := + movingPattern_kernel_norm_le e tierB tierC t small slot perm pattern hB htier + (bulkLogValues base (selectedBulkSet (movingPatternBulkEmbedding e slot)) + (bulkCoordinateInsert base (movingPatternBulkEmbedding e slot) z)) + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U + +theorem movingPatternBulkIntegrand_nat + (base₀ value : Fin (N + 1) → ℕ) + (hv : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), value i = base₀ i) + (hvalue : ∀ i, value i ≠ 0) + (hf : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) : + let T := movingPatternFinBulkData e n m t small slot perm pattern + movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base₀ i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U + (fun j => Real.log (value (movingPatternBulkEmbedding e slot j) : ℝ)) = + movingRealKernelPair value T + (fun b => (T b).formulaNodes value hvalue childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hf b) + (.prime false) (.prime true)) ψ X lo hi hlo hhi φ G L U := + movingPattern_bulk_kernel_nat e t small slot perm pattern base₀ value hv hvalue + childBound pivotBound hf ψ X lo hi hlo hhi φ G L U + +theorem PublishedProgressionInput.movingPatternBulkIntegrand_comparison + (P : PublishedProgressionInput) {r₀ : ℕ} + (hsmall : ∀ b, MovingLeafLengthLE n (small b) r₀) + {Q : ℕ} (hQ : 2 ≤ Q) + (q a : TreeLeafIndex n × Fin m → ℕ) (u v : TreeLeafIndex n × Fin m → ℝ) + (hq : ∀ i, 1 ≤ q i) (hqQ : ∀ i, q i ≤ Q) (ha : ∀ i, (a i).Coprime (q i)) + (hu : ∀ i, 1 ≤ u i) (huv : ∀ i, u i ≤ v i) (hshort : ∀ i, v i ≤ u i + 1) + (hmass : ∀ i, ∑ p ∈ primeLogCellSet (q i) (a i) (u i) (v i), (p : ℝ)⁻¹ ≤ 2) : + let K := movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier base + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U + ‖(∫ z, K z ∂Measure.pi (fun i => primeLogCellMeasure (q i) (a i) (u i) (v i))) - + ∫ z, K z ∂Measure.pi (fun i => primeGiantMeasure P Q (q i) (a i) (u i) (v i))‖ ≤ + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ i, + bulkKernelPairComparisonBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 Bφ Dφ * + bulkPrimeErrorFactor P Q (u i) := + P.movingPattern_kernel_integral_comparison e tierB tierC t small slot perm pattern hB htier hsmall + base childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U + hQ q a u v hq hqQ ha hu huv hshort hmass + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternInternalError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternInternalError.lean new file mode 100644 index 0000000000000000000000000000000000000000..8edc43900343aa949a68235e0759a9449c347bbf --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternInternalError.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantVariation +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # The internal-prime error for the literal moving pattern cost -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +/-- All internal class counts and moving windows share the same eventual +error bound. Only the original point-mass bounds on the priors are used. -/ +theorem movingPattern_internal_arithmetic_error_rate (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin B D E : ℝ) (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hE : 0 ≤ E) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (p : Fin m → ℕ) (c : ℕ) (U α β amp lo hi : ℝ), + c ≤ 4 * n * 2 ^ n → 1 ≤ U → + Real.log U ≤ Real.exp ((12 / 1000 : ℝ) * L) → + 0 ≤ α → α ≤ Real.exp (E * L - Real.exp ((39 / 10000 : ℝ) * L)) → + 0 ≤ β → β ≤ Real.exp (E * L - Real.exp ((1 / 100 : ℝ) * L)) → + 0 ≤ amp → amp ≤ 4 → lo ≤ hi → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + ((amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2) * + movingInternalArithmeticError n c (2 ^ n * (r₀ + m + 4 * n + 4)) + (Real.exp (A * m)) U α β (Real.exp ((1 / 100 : ℝ) * L)) ≤ + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨C, hC, hcost⟩ := movingPattern_pointwise_cost_budget ψ n r₀ k A Wwin B D hA hWwin + let H : ℝ := (2 ^ n : ℕ) * ((r₀ + 4 * n + 4 : ℕ) + (k : ℝ) ^ 4) + have hH : 0 ≤ H := by dsimp only [H]; positivity + have hAk : 0 ≤ A * (k : ℝ) ^ 4 := by positivity + filter_upwards [moving_internal_error_with_cost n (4 * n * 2 ^ n) + (A * (k : ℝ) ^ 4) H E 1 C hAk hH hE (by norm_num) (by linarith), + eventually_ge_atTop (1 : ℝ)] with L herr hL + dsimp only + intro p c U α β amp lo hi hc hU hUlog hα0 hα hβ0 hβ hamp0 hamp hhi hwidth hp + let m := spectatorBulkCount k L + let d := 2 ^ n * (r₀ + m + 4 * n + 4) + let F := Real.exp (A * m) + have hL0 : 0 ≤ L := by linarith + have hm := spectatorBulkCount_upper k L hL0 + have hF : 1 ≤ F := Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _)) + have hFreq : Real.log F ≤ A * (k : ℝ) ^ 4 * L := by + rw [Real.log_exp] + nlinarith [mul_le_mul_of_nonneg_left hm hA] + have hdeg : (d : ℝ) ≤ H * L := by + dsimp only [d, H] + push_cast + have hh := mul_le_mul_of_nonneg_left hm (show 0 ≤ (2 : ℝ) ^ n by positivity) + have hbase := mul_le_mul_of_nonneg_left hL (show 0 ≤ (2 : ℝ) ^ n * (r₀ + 4 * n + 4) by positivity) + nlinarith + have hs := herr d F U α β hF hU hα0 hα hβ0 hFreq hdeg hUlog hβ + have hmono := movingInternalArithmeticError_mono_card n c (4 * n * 2 ^ n) d F U α β + (Real.exp ((1 / 100 : ℝ) * L)) hc hF hU hα0 hβ0 (Real.exp_nonneg _) + have he0 := movingInternalArithmeticError_nonneg n (4 * n * 2 ^ n) d F U α β + (Real.exp ((1 / 100 : ℝ) * L)) hF hU hα0 hβ0 (Real.exp_nonneg _) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ F lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hcost0 : 0 ≤ cost := by dsimp only [cost]; positivity + have hprod : (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 = ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) := by + rw [← Finset.prod_pow] + apply Finset.prod_congr rfl + intro i _ + rw [← pow_mul, pow_succ] + have hcb : cost ≤ Real.exp (C * L ^ 2 + C * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + apply le_trans _ (hcost L hL p F lo hi (Real.exp_nonneg _) le_rfl hhi hwidth hp) + rw [hprod] + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right hamp (Finset.prod_nonneg fun _ _ => by positivity)) + (sq_nonneg _) + have hbudget : (1 : ℝ) ≤ (2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) * + (max 2 (Real.exp ((1 : ℝ) * L))) ^ (4 * n * 2 ^ n) := + one_le_mul_of_one_le_of_one_le (one_le_pow₀ (by norm_num)) + (one_le_pow₀ (le_trans (by norm_num) (le_max_left _ _))) + have hcb' := hcb.trans (le_mul_of_one_le_left (Real.exp_nonneg _) hbudget) + exact ((mul_le_mul_of_nonneg_left hmono hcost0).trans + (mul_le_mul_of_nonneg_right hcb' he0)).trans hs + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..90f8f556d99f2617a92ae21895687ef49e04d09b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelCost.lean @@ -0,0 +1,181 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.BulkKernelPairComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFourierBudget +import OAI.NumberTheory.Ostmann.Construction.SpectatorBulkScale + +namespace OAI + +/-! # Fixed-depth cost of the actual sharp pattern kernel -/ + +namespace Ostmann +open scoped SchwartzMap + +theorem movingFourierVariationBudget_nonneg (ψ : 𝓢(ℝ, ℂ)) + (V lo hi : ℝ) (n : ℕ) (hV : 0 ≤ V) (hhi : lo ≤ hi) : + 0 ≤ movingFourierVariationBudget ψ V lo hi n := by + have hB := (norm_nonneg (ψ 0)).trans (ψ.norm_le_seminorm ℝ 0) + have hD := schwartz_profile_lip_nonneg ψ + have hW := sub_nonneg.mpr hhi + unfold movingFourierVariationBudget + positivity + +/-- Both the polynomial root count and the smooth variation use the bounds +of the constructed pattern tree. The constant is independent of bulk size. -/ +theorem movingPatternKernelBudget_exp (ψ : 𝓢(ℝ, ℂ)) (n r₀ : ℕ) + (A lo hi B D : ℝ) (hA : 0 ≤ A) (hhi : lo ≤ hi) : + ∃ C : ℝ, 0 < C ∧ ∀ m : ℕ, + bulkKernelPairComparisonBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D ≤ + Real.exp (C * ((m : ℝ) + 1)) := by + obtain ⟨C, hC, hV⟩ := movingFourierVariationBudget_exp ψ n A lo hi hA hhi + let c := (2 ^ n + (2 ^ n - 1)) + (3 * (2 ^ n - 1) + 2 * 2 ^ n) + let a := 2 * c * (2 * n + 1) * 2 ^ n + let b := 2 * c * (2 * n * (2 ^ n * (r₀ + 4 * n + 4)) + + 2 ^ n * (r₀ + 4 * n)) + 1 + let K : ℝ := a + b + let H : ℝ := ((2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hK : 0 < K := by dsimp only [K, b]; positivity + have hH : 0 ≤ H := sq_nonneg _ + refine ⟨K + 2 * C + H, by positivity, ?_⟩ + intro m + have hm : 0 ≤ (m : ℝ) := Nat.cast_nonneg _ + have hcount : + 2 * (((2 ^ n + (2 ^ n - 1)) * (2 * (n * (2 ^ n * (r₀ + m + 4 * n + 4)) + 0) + + 2 ^ n * (r₀ + m + 4 * n))) + + ((3 * (2 ^ n - 1) + 2 * 2 ^ n) * (2 * (n * (2 ^ n * (r₀ + m + 4 * n + 4)) + 0) + + 2 ^ n * (r₀ + m + 4 * n)))) + 1 = a * m + b := by + dsimp only [a, b, c] + ring + have hroot : ((a * m + b : ℕ) : ℝ) ≤ Real.exp (K * ((m : ℝ) + 1)) := by + have hab : ((a * m + b : ℕ) : ℝ) ≤ K * ((m : ℝ) + 1) := by + push_cast + dsimp only [K] + nlinarith [mul_nonneg (Nat.cast_nonneg b : (0 : ℝ) ≤ b) hm] + exact hab.trans (by linarith [Real.add_one_le_exp (K * ((m : ℝ) + 1))]) + have hv0 := movingFourierVariationBudget_nonneg ψ (Real.exp (A * m)) lo hi n + (Real.exp_nonneg _) hhi + have hv2 := pow_le_pow_left₀ hv0 (hV m hm) 2 + have hh : H ≤ Real.exp (H * ((m : ℝ) + 1)) := by + have : H ≤ H * ((m : ℝ) + 1) := by nlinarith [mul_nonneg hH hm] + exact this.trans (by linarith [Real.add_one_le_exp (H * ((m : ℝ) + 1))]) + unfold bulkKernelPairComparisonBudget + rw [hcount, mul_pow] + change ((a * m + b : ℕ) : ℝ) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n ^ 2 * H) ≤ _ + calc + _ ≤ Real.exp (K * ((m : ℝ) + 1)) * + ((Real.exp (C * ((m : ℝ) + 1))) ^ 2 * Real.exp (H * ((m : ℝ) + 1))) := by + gcongr + _ = Real.exp ((K + 2 * C + H) * ((m : ℝ) + 1)) := by + rw [← Real.exp_nat_mul] + simp only [← Real.exp_add] + congr 1 + ring + +/-- The manuscript chooses a bulk length linear in `L` at fixed depth. +Consequently the complete sharp comparison budget fits the quadratic cost +used by the weighted prime-error estimate. -/ +theorem movingPatternKernelBudget_spectatorScale (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi B D : ℝ) (hA : 0 ≤ A) (hhi : lo ≤ hi) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ L : ℝ, 1 ≤ L → + let m := spectatorBulkCount k L + bulkKernelPairComparisonBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D ≤ + Real.exp (C * L ^ 2) := by + obtain ⟨C, hC, hb⟩ := movingPatternKernelBudget_exp ψ n r₀ A lo hi B D hA hhi + refine ⟨C * ((k : ℝ) ^ 4 + 1) + 1, ?_, ?_⟩ + · have : 0 ≤ C * ((k : ℝ) ^ 4 + 1) := by positivity + linarith + intro L hL + dsimp only + apply (hb _).trans + apply Real.exp_le_exp.mpr + have hL0 : 0 ≤ L := by linarith + have hm := spectatorBulkCount_upper k L hL0 + have hLsq : L ≤ L ^ 2 := by nlinarith + have hscale : (spectatorBulkCount k L : ℝ) + 1 ≤ ((k : ℝ) ^ 4 + 1) * L ^ 2 := by + have := mul_le_mul_of_nonneg_left hLsq (pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4) + nlinarith + have := mul_le_mul_of_nonneg_left hscale hC.le + nlinarith [sq_nonneg L] + +theorem movingPatternKernelBudget_exp_window (ψ : 𝓢(ℝ, ℂ)) (n r₀ : ℕ) + (A H B D : ℝ) (hA : 0 ≤ A) (hH : 0 ≤ H) : + ∃ C : ℝ, 0 < C ∧ ∀ m : ℕ, ∀ lo hi : ℝ, lo ≤ hi → + hi - lo ≤ Real.exp (H * m) → + bulkKernelPairComparisonBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D ≤ + Real.exp (C * ((m : ℝ) + 1)) := by + obtain ⟨C, hC, hV⟩ := movingFourierVariationBudget_exp_window ψ n A H hA hH + let c := (2 ^ n + (2 ^ n - 1)) + (3 * (2 ^ n - 1) + 2 * 2 ^ n) + let a := 2 * c * (2 * n + 1) * 2 ^ n + let b := 2 * c * (2 * n * (2 ^ n * (r₀ + 4 * n + 4)) + + 2 ^ n * (r₀ + 4 * n)) + 1 + let K : ℝ := a + b + let H : ℝ := ((2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hK : 0 < K := by dsimp only [K, b]; positivity + have hH : 0 ≤ H := sq_nonneg _ + refine ⟨K + 2 * C + H, by positivity, ?_⟩ + intro m lo hi hhi hwidth + have hm : 0 ≤ (m : ℝ) := Nat.cast_nonneg _ + have hcount : + 2 * (((2 ^ n + (2 ^ n - 1)) * (2 * (n * (2 ^ n * (r₀ + m + 4 * n + 4)) + 0) + + 2 ^ n * (r₀ + m + 4 * n))) + + ((3 * (2 ^ n - 1) + 2 * 2 ^ n) * (2 * (n * (2 ^ n * (r₀ + m + 4 * n + 4)) + 0) + + 2 ^ n * (r₀ + m + 4 * n)))) + 1 = a * m + b := by + dsimp only [a, b, c] + ring + have hroot : ((a * m + b : ℕ) : ℝ) ≤ Real.exp (K * ((m : ℝ) + 1)) := by + have hab : ((a * m + b : ℕ) : ℝ) ≤ K * ((m : ℝ) + 1) := by + push_cast + dsimp only [K] + nlinarith [mul_nonneg (Nat.cast_nonneg b : (0 : ℝ) ≤ b) hm] + exact hab.trans (by linarith [Real.add_one_le_exp (K * ((m : ℝ) + 1))]) + have hv0 := movingFourierVariationBudget_nonneg ψ (Real.exp (A * m)) lo hi n + (Real.exp_nonneg _) hhi + have hv2 := pow_le_pow_left₀ hv0 (hV m hm lo hi hhi hwidth) 2 + have hh : H ≤ Real.exp (H * ((m : ℝ) + 1)) := by + have : H ≤ H * ((m : ℝ) + 1) := by nlinarith [mul_nonneg hH hm] + exact this.trans (by linarith [Real.add_one_le_exp (H * ((m : ℝ) + 1))]) + unfold bulkKernelPairComparisonBudget + rw [hcount, mul_pow] + change ((a * m + b : ℕ) : ℝ) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n ^ 2 * H) ≤ _ + calc + _ ≤ Real.exp (K * ((m : ℝ) + 1)) * + ((Real.exp (C * ((m : ℝ) + 1))) ^ 2 * Real.exp (H * ((m : ℝ) + 1))) := by + gcongr + _ = Real.exp ((K + 2 * C + H) * ((m : ℝ) + 1)) := by + rw [← Real.exp_nat_mul] + simp only [← Real.exp_add] + congr 1 + ring + +theorem movingPatternKernelBudget_spectatorScale_window (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H B D : ℝ) (hA : 0 ≤ A) (hH : 0 ≤ H) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ L : ℝ, 1 ≤ L → + let m := spectatorBulkCount k L + ∀ lo hi : ℝ, lo ≤ hi → hi - lo ≤ Real.exp (H * m) → + bulkKernelPairComparisonBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D ≤ + Real.exp (C * L ^ 2) := by + obtain ⟨C, hC, hb⟩ := movingPatternKernelBudget_exp_window ψ n r₀ A H B D hA hH + refine ⟨C * ((k : ℝ) ^ 4 + 1) + 1, ?_, ?_⟩ + · have : 0 ≤ C * ((k : ℝ) ^ 4 + 1) := by positivity + linarith + intro L hL + dsimp only + intro lo hi hhi hwidth + apply (hb _ lo hi hhi hwidth).trans + apply Real.exp_le_exp.mpr + have hL0 : 0 ≤ L := by linarith + have hm := spectatorBulkCount_upper k L hL0 + have hLsq : L ≤ L ^ 2 := by nlinarith + have hscale : (spectatorBulkCount k L : ℝ) + 1 ≤ ((k : ℝ) ^ 4 + 1) * L ^ 2 := by + have := mul_le_mul_of_nonneg_left hLsq (pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4) + nlinarith + have := mul_le_mul_of_nonneg_left hscale hC.le + nlinarith [sq_nonneg L] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelGain.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelGain.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d3634694793d15ccc86c95dee0cb91f71a66970 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelGain.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelCost +import OAI.NumberTheory.Ostmann.Construction.SignedBulkGain + +namespace OAI + +/-! # The quartet gain absorbs the actual sharp-kernel main term -/ + +namespace Ostmann +open scoped SchwartzMap + +theorem bulkKernelPair_smooth_le_budget (ψ : 𝓢(ℝ, ℂ)) (V lo hi : ℝ) + (n d r e : ℕ) (B D : ℝ) : + (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + bulkKernelPairComparisonBudget ψ V lo hi n d r e B D := by + let c := 2 * (((2 ^ n + (2 ^ n - 1)) * (2 * (n * d + e) + r)) + + ((3 * (2 ^ n - 1) + 2 * 2 ^ n) * (2 * (n * d + e) + r))) + have hc : (1 : ℝ) ≤ ((c + 1 : ℕ) : ℝ) := by exact_mod_cast Nat.le_add_left 1 c + exact le_mul_of_one_le_left (sq_nonneg _) hc + +/-- The tolerance is selected after the fixed Fourier profile and frequency +cost, and before the bulk length. All sharp cutoffs are included in `W`. -/ +theorem exists_movingPatternKernelGain (ψ : 𝓢(ℝ, ℂ)) (n r₀ : ℕ) + (A lo hi B D F gain : ℝ) (hA : 0 ≤ A) (hhi : lo ≤ hi) : + ∃ C : ℝ, 0 < C ∧ ∀ m : ℕ, 1 ≤ m → ∀ amp δ : ℝ, + 0 ≤ amp → amp ≤ Real.exp (F * m) → 0 ≤ δ → + δ ≤ signedBulkGainTarget n (C + F) gain → + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (W * amp) * 4 ^ Fintype.card (TreeLeafIndex n × Fin m) * δ ^ m ≤ + Real.exp (-gain * m) := by + obtain ⟨C, hC, hcost⟩ := movingPatternKernelBudget_exp ψ n r₀ A lo hi B D hA hhi + refine ⟨2 * C, by positivity, ?_⟩ + intro m hm amp δ hamp hampBound hδ hgain + dsimp only + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hW : 0 ≤ W := sq_nonneg _ + have hm' : (1 : ℝ) ≤ m := by exact_mod_cast hm + have hWbound : W ≤ Real.exp (2 * C * m) := by + apply (bulkKernelPair_smooth_le_budget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D).trans + apply (hcost m).trans + exact Real.exp_le_exp.mpr (by nlinarith) + have hamp' : W * amp ≤ Real.exp ((2 * C + F) * m) := by + apply (mul_le_mul hWbound hampBound hamp (Real.exp_nonneg _)).trans_eq + rw [← Real.exp_add] + congr 1 + ring + have h := signedBulkGainTarget_bound n m (2 * C + F) gain 1 (W * amp) δ + (by norm_num) (mul_nonneg hW hamp) hδ hamp' hgain + simpa only [one_mul] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..31bccb2a17207355c34ee473e1a9514f44864c5d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelNorm.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkKernel + +namespace OAI + +/-! # Explicit size of the actual sharp bulk kernel -/ + +namespace Ostmann +open scoped Classical SchwartzMap + +/-- The bound used in prime replacement is explicit, rather than an +unspecified boundedness constant of the constructed integrand. -/ +theorem realValueKernelPair_norm_le {σ : Type*} + (value : σ → ℝ) (i : σ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) + (hcomp : ∀ b, (T b).CompensationAbsent i) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L R : ℝ) : + ‖realValueKernelPair value childBound pivotBound T ψ X lo hi hlo hhi φ G L R‖ ≤ + (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 := by + have hb (b) := realValueKernel_norm value i childBound pivotBound (T b) (hcomp b) + ψ X lo hi V hlo hhi (hV b) φ G B D hB hD hφ hlip hout L R + have hpos := (norm_nonneg _).trans (hb false) + rw [realValueKernelPair, norm_mul, Complex.norm_conj, pow_two] + exact mul_le_mul (hb false) (hb true) (norm_nonneg _) hpos + +theorem movingPattern_kernel_norm_le {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (value : Fin (N + 1) → ℝ) (childBound pivotBound : ℕ → ℕ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L R : ℝ) : + ‖realValueKernelPair value childBound pivotBound + (movingPatternFinBulkData e n m t small slot perm pattern) ψ X lo hi hlo hhi φ G L R‖ ≤ + (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 := + realValueKernelPair_norm_le value (movingPatternBulkEmbedding e slot j₀) childBound pivotBound _ + (fun b => movingPatternFinBulkData_compensationAbsent e tierB tierC n m t small slot perm pattern hB htier b j₀) + ψ X lo hi V hlo hhi + (movingPatternFinBulkData_frequencies e t small slot perm pattern (fun s => |(s : ℝ)| ≤ V) hfreq) + φ G Bφ Dφ hBφ hDφ hφ hlip hout L R + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelNormBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelNormBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..a1897ae160091bb25c125320caae889f6782da1e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternKernelNormBound.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternIntegrand +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkArithmetic +import OAI.NumberTheory.Ostmann.Construction.OriginalAbsoluteBulkBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternNormKernel + +namespace OAI + +/-! # The sharp pattern kernel under its original bulk prime law -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The original deleted prime kernel inherits its full arithmetic norm bound; +the approximation errors use the existing variation budget. -/ +theorem PublishedProgressionInput.movingPattern_norm_kernel_bound + (P : PublishedProgressionInput) {B C Cell : Type*} [Fintype Cell] + {N n m r₀ : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (hsmall : ∀ b, MovingLeafLengthLE n (small b) r₀) + (base : Fin (N + 1) → ℕ) (childBound pivotBound : ℕ → ℕ) + (j₀ : TreeLeafIndex n × Fin m) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, NeZero (p i)] + [NeZero (∏ i, bulkResidueModuli r p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (freq : ((TreeLeafIndex n × Fin m) → (ZMod r)ˣ) → ℂ) + (spec : ∀ i, ((TreeLeafIndex n × Fin m) → (ZMod (p i))ˣ) → ℂ) + (A : ℝ) (hA : 0 ≤ A) (hf : ∀ a, ‖freq a‖ ≤ A) + (Q : ℕ) (hQ : 2 ≤ Q) (hMQ : (∏ i, bulkResidueModuli r p i) ≤ Q) + (primes : Finset ℕ) (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (hu : ∀ j c, 1 ≤ u j c) (huv : ∀ j c, u j c ≤ v j c) + (hshort : ∀ j c, v j c ≤ u j c + 1) + (hmassCell : ∀ j c (a : (ZMod (∏ i, bulkResidueModuli r p i))ˣ), + ∑ q ∈ primeLogCellSet (∏ i, bulkResidueModuli r p i) a.val.val (u j c) (v j c), + (q : ℝ)⁻¹ ≤ 2) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hP : ∀ j, primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ primes) + (hsep : ∀ j (c d : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ), c ≠ d → + ¬Nat.ModEq (∏ i, bulkResidueModuli r p i) c.2.val.val d.2.val.val ∨ + v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hdeleted : ∀ j, (∑ q ∈ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted j, (q : ℝ)⁻¹) ≠ 0) + (A₀ : ℝ) (hA₀ : 0 ≤ A₀) (H T : ℝ) (Bspec : Fin m → ℝ) + (hBspec : ∀ i, 0 ≤ Bspec i) : + let K := movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let W₀ := ((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * Bφ ^ (2 ^ n - 1)) ^ 2 + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let label := fun (x : (TreeLeafIndex n × Fin m) → primes) j => primeCellLabel M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) c₀ (x j) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + let err := fun c : (TreeLeafIndex n × Fin m) → Cell => + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkKernelPairComparisonBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 Bφ Dφ * + bulkPrimeErrorFactor P Q (u j (c j)) + (∀ y : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ y j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ z, ‖a z * ∏ j, pageGiantWeight P Q M (z j).val.val (y j)‖ ≤ A₀) → + (∀ i z, ‖spec i z‖ ≤ Bspec i) → + (∀ j, Z j * ∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹ ≤ 2) → + (∀ j, Z j ≤ Real.exp H) → + (∀ j q, q ∈ S j \ deleted j → Real.exp T ≤ (q : ℝ)) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + (if Function.Injective x then a (fun j => (label x j).2) * + K (fun j => Real.log (x j : ℕ)) else 0)‖ ≤ + (W₀ * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, ∑ z, ‖a z‖ * err c + + (A * (∏ i, Bspec i) * W) * (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * + Real.exp (H - T) + + (A * (∏ i, Bspec i) * W) * ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) := by + intro K W W₀ M S Z label a err hlocal hspec hmass hZ hlow + have hW : 0 ≤ W := sq_nonneg _ + have hk : ∀ z, ‖K z‖ ≤ W := movingPatternBulkIntegrand_norm e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U + have hk₀ : ∀ z, ‖K z‖ ≤ W₀ := movingPatternBulkIntegrand_norm_window e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U + have herr (c : (TreeLeafIndex n × Fin m) → Cell) + (z : (TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : + ‖(∫ y, K y ∂Measure.pi (fun j => primeLogCellMeasure M (z j).val.val (u j (c j)) (v j (c j)))) - + ∫ y, K y ∂Measure.pi (fun j => primeGiantMeasure P Q M (z j).val.val (u j (c j)) (v j (c j)))‖ ≤ + err c := + P.movingPatternBulkIntegrand_comparison e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ + hBφ hDφ hφ hlip hout L U hsmall hQ (fun _ => ∏ i, bulkResidueModuli r p i) + (fun j => (z j).val.val) (fun j => u j (c j)) (fun j => v j (c j)) + (fun _ => Nat.pos_of_ne_zero (NeZero.ne _)) (fun _ => hMQ) + (fun j => ZMod.val_coe_unit_coprime (z j)) (fun j => hu j (c j)) + (fun j => huv j (c j)) (fun j => hshort j (c j)) (fun j => hmassCell j (c j) (z j)) + have hn (x : (TreeLeafIndex n × Fin m) → primes) : + ‖a (fun j => (label x j).2) * K (fun j => Real.log (x j : ℕ))‖ ≤ A * (∏ i, Bspec i) * W := by + rw [norm_mul] + apply mul_le_mul _ (hk _) (norm_nonneg _) (mul_nonneg hA (Finset.prod_nonneg fun i _ => hBspec i)) + change ‖freq _ * ∏ i, spec i _‖ ≤ _ + rw [norm_mul, norm_prod] + exact mul_le_mul (hf _) (Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + (fun i _ => hspec i _)) (Finset.prod_nonneg fun _ _ => norm_nonneg _) hA + have hb := original_absolute_bulk_bound primes M u v + (fun j c => lt_of_lt_of_le zero_lt_one (hu j c)) c₀ hP hsep deleted hdeleted + K a P Q W₀ A₀ (sq_nonneg _) hA₀ hk₀ + (by + intro y hy + have hy' := hlocal y hy + simp only [finite_univ_canonical, Fintype.card_eq_nat_card] at hy' ⊢ + exact hy') (fun c _ => err c) herr H T + (A * (∏ i, Bspec i) * W) + (mul_nonneg (mul_nonneg hA (Finset.prod_nonneg fun i _ => hBspec i)) hW) + have hh := hb hmass hZ hlow hn + simp only [finite_univ_canonical, Fintype.card_eq_nat_card] at hh ⊢ + exact hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLineComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLineComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..34bb060c084a22649d14ba4fd9b9a4a29702eb88 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLineComparison.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFinite +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDominatedLineComparison + +namespace OAI + +/-! # The original internal-pattern law in the simultaneous line comparison -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Apply the proved comparison to the actual pattern tree and its original +external priors. All occurrence rows and unique representatives are derived +from that constructor. The loss involves internal classes, not bulk size. -/ +theorem movingPattern_line_comparison {A B C : Type*} + [Fintype A] [Nonempty A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ b, (movingPatternFinData e n t small bulk pattern b).SizeLE d) + (hfreq : ∀ b, (movingPatternFinData e n t small bulk pattern b).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E α β V : ℝ) (hE : 0 ≤ E) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hmax : ∀ j a, μ j a ≤ α) (hnmax : ∀ j a, ν j a ≤ α) + (hpmax : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≤ β) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + V ≤ Real.log (prime a : ℝ)) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hclasses : ∀ x, G x ≠ 0 → Function.Injective (fun c => x (e.symm (.inr c)))) + (hcross : ∀ x, G x ≠ 0 → ∀ b c, + prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (hfmod : ∀ x, G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) : + let T := movingPatternFinData e n t small bulk pattern + let base := movingPatternFinRepresentative e n t small bulk pattern rep + let W := fun x : Fin (N + 1) → A => + ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * G x + ‖∑ x, W x * + ((∏ c, (movingSampledInternalProbability prime hprime T x (e.symm (.inr c)) : ℂ)) - + ∏ c, (internalLineFlagWeight true (prime (x (e.symm (.inr c)))) + (fun s => arithmeticTestFlag (lineTestPolynomials + (movingIndexedLine T (e.symm (.inr c)) (base c)) + ⟨(base c).1, (base c).2.val⟩ s = 0)) : ℂ))‖ ≤ + 2 * (D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + ((Fintype.card C * (2 + 2 * (2 ^ n - 1)) : ℕ) : ℝ) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β) := by + dsimp only + let T := movingPatternFinData e n t small bulk pattern + let prior := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let W := fun x : Fin (N + 1) → A => + ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * G x + have hnz (x) (hx : W x ≠ 0) : G x ≠ 0 := by + intro hz + exact hx (by simp only [W, hz, mul_zero]) + have hprior (i a) : 0 ≤ prior i a := by + dsimp only [prior] + cases e i with + | inl b => exact hν b a + | inr c => exact hμ _ a + have hmass' (i) : ∑ a, prior i a = 1 := by + dsimp only [prior] + cases e i with + | inl b => exact hnmass b + | inr c => exact hmass _ + have hmax' (i a) : prior i a ≤ α := by + dsimp only [prior] + cases e i with + | inl b => exact hnmax b a + | inr c => exact hmax _ a + have hpmax' (c a) : prior (e.symm (.inr c)) a ≤ β := by + simpa only [prior, Equiv.apply_symm_apply, Sum.elim_inr] using hpmax c a + have h := moving_dominated_line_product_comparison prime hpInj hprime T + ((Sum.elim tierB tierC) ∘ e) + (movingPatternFinData_levels e tierB tierC n t small bulk pattern hsmall hbulk htier) + (fun c => e.symm (.inr c)) (movingPatternFinRepresentative e n t small bulk pattern rep) + d F U hF hU hsize hfreq hvalues prior hprior hmass' α β V hα hβ hV hmax' hpmax' + (fun c a ha => hprimeSize c a (by + simpa only [prior, Equiv.apply_symm_apply, Sum.elim_inr] using ha)) W (D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) + (by positivity) + (fun x => movingPattern_fin_prior_bound e μ ν prime n pattern rep E hprime hμ hν hbound G D hD hG x) + (fun x hx => hdisjoint x (hnz x hx)) + (fun x hx c i hi => movingPatternFin_unique e prime hpInj x + (hclasses x (hnz x hx)) (hcross x (hnz x hx)) c i hi) + (fun x hx c b => hfmod x (hnz x hx) c b) + simpa only [movingPairOccurrenceIndex_card, Nat.cast_mul, Nat.cast_add, Nat.cast_ofNat] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLines.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLines.lean new file mode 100644 index 0000000000000000000000000000000000000000..78650ff18ee4034b04ececb9a16ca245f3bc40c2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLines.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Construction.SamplePatternCoordinates +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOccurrenceRelabel +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampledIndexedProbability + +namespace OAI + +/-! # Actual equality-pattern rows in the fixed coordinates of the line comparison -/ + +namespace Ostmann +open scoped Classical + +/-- The uniqueness and tier conditions of the fixed row system are consequences +of the exact equality-pattern coordinates. They are not additional arithmetic +assumptions about the original samples. -/ +theorem movingPatternLineProbability {I A : Type*} [Fintype I] + (s : Setoid I) {N n : ℕ} (hcard : Fintype.card (Quotient s) = N + 1) + (z : Quotient s → A) (hz : Function.Injective z) + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (T : Bool → MovingSlotData I n) (tier : I → ℕ) + (htier : ∀ i j, s i j → tier i = tier j) (hlevels : ∀ side, (T side).Levels tier) + (c : Fin (N + 1)) + (base : MovingPairRepresentativeOccurrences + (fun side => (T side).map (samplePatternLabels s hcard)) c) + (hf : ∀ side, (T side).Frequencies (fun a => + (a : ZMod (prime (samplePatternValues s hcard z c))) ≠ 0)) : + let v := fun i => prime (z (Quotient.mk'' i)) + let p := prime (samplePatternValues s hcard z c) + letI : Fact p.Prime := ⟨hprime _⟩ + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction p v (movingPrimeOccurrenceLine v T p j).a) + (fun j => MovingSlotReversal.naturalReduction p v (movingPrimeOccurrenceLine v T p j).b) = + movingSlotLineProbability (fun a => (prime a : ℤ)) prime hprime + (fun o => (movingIndexedOccurrence + (fun side => (T side).map (samplePatternLabels s hcard)) c base o).path) + (fun o => (movingIndexedOccurrence + (fun side => (T side).map (samplePatternLabels s hcard)) c base o).current) + true (samplePatternValues s hcard z) (samplePatternValues s hcard z c) := by + let x := samplePatternValues s hcard z + let labels := samplePatternLabels s hcard + let TT := fun side => (T side).map labels + let tt := samplePatternTier s hcard tier + let p := prime (x c) + let : Fact p.Prime := ⟨hprime _⟩ + have hx : Function.Injective (fun i => prime (x i)) := + hpInj.comp (samplePatternValues_injective s hcard z hz) + have hd (i j : Fin (N + 1)) (h : tt i ≠ tt j) : prime (x i) ≠ prime (x j) := by + intro he + exact h (congrArg tt (hx he)) + have hl (side : Bool) : (TT side).Levels tt := + (T side).levels_samplePattern s hcard tier htier (hlevels side) + have hff (side : Bool) : (TT side).Frequencies (fun a => (a : ZMod p) ≠ 0) := + ((T side).frequencies_map labels _).mpr (hf side) + have he := movingSampledIndexedProbability prime hprime x TT tt hd hl c base + (fun i h => hx h) hff + have hm := movingInternalBaseProbability_map labels (fun i => prime (x i)) T p + have hv : (fun i => prime (x i)) ∘ labels = (fun i => prime (z (Quotient.mk'' i))) := by + funext i + exact congrArg prime (samplePatternValues_labels s hcard z i) + rw [hv] at hm + exact hm.symm.trans he + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogCellError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogCellError.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0ff996a1bd52a9209797070652b8e16bfafc854 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogCellError.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogKernelCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCost +import OAI.NumberTheory.Ostmann.Arithmetic.BulkWeightedErrorRate + +namespace OAI + +/-! # Cell error with terminal log cutoffs retained -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +/-- The cell threshold is uniform over the moving Fourier window. -/ +theorem PublishedProgressionInput.movingPattern_log_cell_error_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H B D F Cnorm Dlog : ℝ) (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) + (hDlog : 0 ≤ Dlog) (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ n) : + ∃ C : ℝ, 1 ≤ C ∧ Cnorm ≤ C ∧ ∀ᶠ L : ℝ in atTop, + let m := spectatorBulkCount k L + ∀ lo hi : ℝ, lo ≤ hi → hi - lo ≤ Real.exp (H * m) → + ∀ (Cell : Type) [Fintype Cell] (M Q : ℕ) [NeZero M], 2 ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 10000 : ℝ) * L) → + ∀ (p : Fin m → ℕ) (Z : (TreeLeafIndex n × Fin m) → ℝ) + (a : ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) → ℂ) (amp T : ℝ) (rlog : ℕ), + rlog ≤ 2 ^ n * (r₀ + m + 4 * n) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ j, 0 ≤ Z j) → (∀ j, Z j ≤ Real.exp (C * L)) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) → + 0 ≤ amp → amp ≤ Real.exp (F * m) → + (∀ z, ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) → + Real.exp ((39 / 10000 : ℝ) * L) ≤ T → + ∀ u : (TreeLeafIndex n × Fin m) → Cell → ℝ, (∀ j c, T ≤ u j c) → + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, + ∑ z : (TreeLeafIndex n × Fin m) → (ZMod M)ˣ, ‖a z‖ * + (2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkLogWeightedKernelPairBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 tlog rlog B D Dlog * + bulkPrimeErrorFactor P Q (u j (c j))) ≤ + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) := by + obtain ⟨C₀, hC₀, hkernel⟩ := movingPatternLogKernelBudget_spectatorScale_window ψ n r₀ k A H B D Dlog hA hH hDlog + let K := (F + 1) * ((k : ℝ) ^ 4 + 1) + let C := max C₀ ((((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K) + -- The dimension is also charged in the same constant. + let C' := max (max C (((2 ^ n : ℕ) : ℝ) * (k : ℝ) ^ 4)) Cnorm + have hK : 0 ≤ K := by dsimp only [K]; positivity + have hC₀C : C₀ ≤ C' := (le_max_left _ _).trans ((le_max_left _ _).trans (le_max_left _ _)) + have hC' : 1 ≤ C' := hC₀.trans hC₀C + refine ⟨C', hC', le_max_right _ _, ?_⟩ + filter_upwards [P.bulk_weighted_error_rate C' hC', eventually_ge_atTop (1 : ℝ)] with L hrate hL + dsimp only + intro lo hi hhi hwidth Cell _ M Q _ hQ hQlog p Z a amp T rlog hrlog hp hZ0 hZ hcell hunit hamp0 hamp ha hT u hu + let m := spectatorBulkCount k L + have hL0 : 0 ≤ L := by linarith + have hm := spectatorBulkCount_upper k L hL0 + have hFK : F * (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4] + have hKk : (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [mul_nonneg hF (pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4)] + have hmK : (m : ℝ) ≤ K * L := hm.trans (mul_le_mul_of_nonneg_right hKk hL0) + have hampK : amp ≤ Real.exp (K * L) := hamp.trans (Real.exp_le_exp.mpr (by + exact (mul_le_mul_of_nonneg_left hm hF).trans (by nlinarith [mul_le_mul_of_nonneg_right hFK hL0]))) + let bound := amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) + have hbound0 : 0 ≤ bound := mul_nonneg hamp0 (Finset.prod_nonneg fun i _ => by positivity) + have hbound : bound ≤ Real.exp (C' * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + apply (moving_spectator_linear_cost n m p K L amp hK hL0 hamp0 hmK hampK hp).trans + apply Real.exp_le_exp.mpr + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg _) + apply mul_le_mul_of_nonneg_right _ hL0 + exact (le_max_right C₀ _).trans ((le_max_left C _).trans (le_max_left _ _)) + have hdim : (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ≤ C' * L := by + simp only [Fintype.card_prod, card_treeLeafIndex, Fintype.card_fin, Nat.cast_mul] + calc + _ ≤ (2 ^ n : ℕ) * ((k : ℝ) ^ 4 * L) := + mul_le_mul_of_nonneg_left hm (Nat.cast_nonneg _) + _ ≤ C' * L := by + rw [← mul_assoc] + exact mul_le_mul_of_nonneg_right ((le_max_right _ _).trans (le_max_left _ _)) hL0 + have hbudget := hkernel L hL lo hi hhi hwidth tlog rlog htlog hrlog + have hbudget' : bulkLogWeightedKernelPairBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 tlog rlog B D Dlog ≤ + Real.exp (C' * L ^ 2) := + hbudget.trans (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hC₀C (sq_nonneg L))) + have hb := @hrate (TreeLeafIndex n × Fin m) Cell inferInstance inferInstance M Q + inferInstance hQ hQlog Z a bound + (bulkLogWeightedKernelPairBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 tlog rlog B D Dlog) + T hZ0 hbound0 (by + have he : 0 ≤ Real.exp 2 - 1 := sub_nonneg.mpr (Real.one_le_exp (by norm_num)) + unfold bulkLogWeightedKernelPairBudget + positivity) + hdim hZ hcell hunit hbound hbudget' ha hT u hu + simpa only [finite_univ_canonical] using hb + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..983f360568c0f1f7b7c6b01bf2854213f3e9c67a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodArithmetic.lean @@ -0,0 +1,242 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWeightedMatchedRanges +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogGoodIdealIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPriorArithmetic + +namespace OAI + +/-! # Signed cancellation for the literal original good-matching pattern -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_original_good_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (_hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG center : ℝ), + let reg := (movingPatternRegularSlots e (n + 2) m small slot).get + let data := movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ ((n + 2) + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + MovingLeafLengthLE (n + 2) small r₀ → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) + (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + Function.Injective p → + (∀ q ∈ outside, ∃ i, p i = q) → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + ∀ (tier : primes → ℕ) (lower cutoff : ℕ), + Nfreq ≤ lower → Nfreq < cutoff → cutoff ≤ lower → + (∀ j, j < (n + 2) → ∀ q, μ j q ≠ 0 → tier q = j) → + (∀ j q, ν j q ≠ 0 → tier q = tierB j) → + (∀ j q, μ j q ≠ 0 → lower < (q : ℕ)) → + (∀ j q, ν j q ≠ 0 → lower < (q : ℕ)) → + (∀ q : primes, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ lower) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq reg active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center x) x‖ ≤ + (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + Uall ^ Fintype.card Cidx) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + diagonalOuterMajorant Bφ Dφ diagonal * ((2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((Real.exp (-gain * m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hideal⟩ := + P.movingPattern_log_good_ideal_integral_rate_window ψ n r₀ k A Wwin Bφ Dφ F Cmass gain + hA hWwin hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hideal, + P.movingPattern_weighted_matched_prime_ranges ψ (n + 2) r₀ k A Wwin Bφ Dφ hA hWwin hBφ hDφ] + with L hideal hcompare + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes _ childBound pivotBound hfreq f outside _ p _ hc _ + Dq sets β X j₀ φ G u v deleted initial μ ν logSlots cb active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hsmall hB htier hsmallLen ht hS hN hf hm hp hV hsets hsetsp hpupper + hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + hinjp houtp hNupper hcenterlow hrGlow tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq (n + 2) ft + let r := R ^ ((n + 2) - 1 + 2) + let slots := movingPatternRegularSlots e (n + 2) m small slot + let reg := slots.get + have hsmall' : ∀ b : Bool, ∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot := + fun _ => hsmall + have hsmallLen' : ∀ b : Bool, MovingLeafLengthLE (n + 2) small r₀ := fun _ => hsmallLen + have hfreqN (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : s.natAbs ≤ Nfreq := by + rw [ht] at hs + exact hN s (allFrequencyList_subtype_mem Sfreq (n + 2) _ s hs) + have hsupport (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) := + movingPattern_prior_arithmetic_support e μ ν (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) pattern rep tier tierB tierC + hμtier hνtier hB htier Sfreq Nfreq lower ft (fun s hs => ⟨hS s hs, hN s hs⟩) + hNlo hμlo hνlo p (fun i => Fact.out) (fun i => (hprange i).2) t + (fun _ => small) slot perm hfreq hfreqN x hx + have hfreqp (i : Fin m) (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : + s.natAbs < p i := (hfreqN b s hs).trans_lt (hNcut.trans_le (hprange i).1) + have hR (b : Bool) : + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern b).frequencyProduct ∣ (R : ℤ) := by + simpa only [ht, R] using movingPattern_frequencyProduct_dvd e Sfreq ft (fun _ => small) slot perm pattern b + have hIdeal := hideal lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t + (fun _ => small) slot perm pattern rep primes hprimes childBound pivotBound hfreq + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) outside (R : ℤ) r p hc (fun i _ => Dq i) sets β + (giantProgressionCutoff L) X j₀ φ G u v deleted initial μ ν logSlots cb (Fin slots.length) reg active + Jleft Jright diagonal Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hm hsmall' hB htier hsmallLen' hR + (frequencyModelModulus_precision R (n + 2)) hV hp hfreqp + (fun x hx i _ j _ => (hsupport x hx).2.1 i (e.symm (.inl j))) + (fun x hx i c => (hsupport x hx).2.1 i (e.symm (.inr c))) + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.1) + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.2.1) + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.2.2) + have hspect (i : Fin m) (z : ZMod (p i)) : ‖normalizedResidueTransform (sets i) z‖ ≤ (p i : ℝ) := + normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z + let wgt : (Fin (N + 1) → primes) → ℂ := fun x => + ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) + have hwgt (x : Fin (N + 1) → primes) : ‖wgt x‖ ≤ 1 := by + dsimp only [wgt] + rw [Complex.norm_real, Real.norm_eq_abs, + abs_of_nonneg (Finset.prod_nonneg (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).1))] + exact Finset.prod_le_one₀ (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).1) + (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).2) + have hCmp := hcompare Bidx Cidx N e tierB tierC t small slot perm pattern rep primes hprimes μ ν p + hinjp (fun i => normalizedResidueTransform (sets i)) Dq active sreg setsReg f outside + childBound pivotBound Sfreq ft Nfreq hfreq X lo hi hlo hhi φ G Jleft Jright diagonal + Eprior Uall uG vG rG sG center wgt hwgt hμ0 hν0 hμmass hνmass hEprior (by linarith) + hμbound hvalues hB htier hfreqN hf (fun i => normalizedResidueTransform_zero (sets i)) + hspect houtp hNupper hwindow hpupper hφ hlip hφout hcenterlow huvG hvG hcenter + hrGlow hrsG hsG ht (fun s hs => ⟨hS s hs, hN s hs⟩) tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hsmallLen hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + have hmul (a b c d e : ℂ) : (a * (b * c)) * d / e = b * (a * c * d / e) := by ring + simp_rw [movingPatternLogPrimeObservable_eq, hmul, integral_const_mul] at hIdeal + exact hCmp.trans (add_le_add (le_refl _) hIdeal) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodIdealIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodIdealIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..e8aadf0228bbdee71117b66c9ec53dd3410b32c5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodIdealIntegral.lean @@ -0,0 +1,188 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogWindowIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalIntegralScale +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedHarmonicIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # The original outer cutoff and regular density in the good matching estimate -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_good_ideal_integral_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (Jidx : Type) [Fintype Jidx] (reg : Jidx → Fin (N + 1)) (active : Jidx → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall uG vG rG sG center : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := fun xg y => movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let W := movingDiagonalOuterWeight (fun q : primes => (q : ℕ)) reg active φ Jleft Jright Bφ Dφ diagonal + let obs := fun xg y x => W xg y x * raw xg y x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ∫ xg in Set.Ioc uG vG, ∫ y in Set.Ioc rG sG, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp xg) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * raw xg y x) * (Real.exp (xg - center) : ℂ) / (y : ℂ)) x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + diagonalOuterMajorant Bφ Dφ diagonal * ((2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_log_weighted_mixed_integral_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq X j₀ φ G u v deleted initial + μ ν logSlots cb Jidx _ reg active Jleft Jright diagonal Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let raw := fun xg y => movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let W := movingDiagonalOuterWeight (fun q : primes => (q : ℕ)) reg active φ + Jleft Jright Bφ Dφ diagonal + have hh := hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern rep primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq X j₀ φ G + u v deleted initial μ ν logSlots cb W Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues + (movingDiagonalOuterWeight_measurable (fun q : primes => (q : ℕ)) reg active φ + Jleft Jright Bφ Dφ hBφ hDφ hφ hlip hφout diagonal) + (fun xg y x => movingDiagonalOuterWeight_norm (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) reg active φ Jleft Jright Bφ Dφ hBφ hDφ hφ hlip hφout + diagonal xg y x) + (fun xg y x z => movingDiagonalOuterWeight_bulk (fun q : primes => (q : ℕ)) reg active + (movingPatternBulkEmbedding e slot) hfixed φ Jleft Jright Bφ Dφ diagonal xg y x z) + hdisjoint hcross hfmod + exact movingPattern_diagonal_integral_norm e (fun q : primes => (q : ℕ)) μ ν pattern + reg active φ Jleft Jright Bφ Dφ diagonal raw + (movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern) + uG vG rG sG center _ hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodMaskedPriors.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodMaskedPriors.lean new file mode 100644 index 0000000000000000000000000000000000000000..7dbe096cb8260c0e7d79e8957ef35cd3f6025721 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodMaskedPriors.lean @@ -0,0 +1,201 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogGoodMaskedShell +import OAI.NumberTheory.Ostmann.Construction.HarmonicFamilyBounds +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModelRange +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModelPage + +namespace OAI + +/-! # The original diagonal bound for actual selected harmonic laws -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_good_selected_masked_priors_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ c K gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hc : 0 < c) (hK : 0 ≤ K) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cmass := K + 1 + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (_rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (Qμ : ℕ → Finset ℕ) (Qν : Bidx → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let Eprior := Real.exp (Cmass * L) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots (n + 2) ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → + (∀ b : Bool, MovingLeafLengthLE (n + 2) ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active j = false → + (movingPatternRegularSlots e (n + 2) m small slot).get j ∉ + Set.range (movingPatternBulkEmbedding e slot)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + (∀ j, j < (n + 2) → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable e t small slot perm pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e (n + 2) m small slot).get active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center x) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (Real.exp (-gain * m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + have hfamily := selected_harmonic_family_bounds c K hc hK + let Cmass := K + 1 + have hCmass : 1 ≤ Cmass := hfamily.1 + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hmain⟩ := + P.movingPattern_log_good_masked_whole_shell_rate C hM ψ n r₀ k A Wwin Bφ Dφ Cmass gain + hA hWwin hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hmain, movingFrequencyModel_bulk_range (n + 2) k A hA, + eventually_ge_atTop (max 1 (-Real.log c))] with L hrate hmod hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB t Sfreq ft Nfreq small slot perm pattern rep + primes hprimes _ childBound pivotBound f outside p _ Dq sets β + primeLo cutoff tier X j₀ φ G global Qμ Qν logSlots cb active sreg setsReg Jleft Jright diagonal uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange hactive houtcover hinjp huBig hrBig + hNfreq hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsreg hsregN hsetsReg + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let α := Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) + let βint := Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) + let Vint := Real.exp ((1 / 100 : ℝ) * L) + let Uall := Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) + obtain ⟨hμ0, hν0, hμsum, hνsum, hμbound, hμα, hνα, hμβ, hμmin⟩ := + hfamily.2 L hL primes Bidx Qμ Qν hμP hνP hμmass hνmass hμrange hνrange + have htiers := selected_harmonic_family_tiers primes Bidx (n + 2) Qμ Qν tier tierB hμtier hνtier + have hL0 : 0 ≤ L := le_trans (by norm_num) ((le_max_left _ _).trans hL) + have hμlo (j) (q : primes) (hq : μ j q ≠ 0) : primeLo < (q : ℕ) := by + have hr := hμmin j q hq + have hh : Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ + Real.exp (Real.exp ((1 / 100 : ℝ) * L)) := + Real.exp_le_exp.mpr (Real.exp_le_exp.mpr (by linarith only [hL0])) + exact_mod_cast (hloReal.trans_le (hh.trans hr)) + have hνlo (j) (q : primes) (hq : ν j q ≠ 0) : primeLo < (q : ℕ) := by + exact_mod_cast (hloReal.trans_le (hνrange j q (primeSubsetPrior_support primes (Qν j) q hq))) + have hUlog : Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) := by + dsimp only [Uall] + rw [Real.log_exp] + exact Real.exp_le_exp.mpr (by linarith only [hL0]) + have hUup : Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + exact Real.exp_le_exp.mpr (by simpa only [Uall, Real.log_exp] using hUlog) + obtain ⟨hrpos, hMpos, hcop, hMQ⟩ := hmod Sfreq Nfreq ft p hS hN hNfreq + (fun i => Fact.out) hinjp (fun i => hNcut.trans_le (hpband i).1) hpupper + let : NeZero (frequencyModelBase Sfreq (n + 2) ft ^ ((n + 2) - 1 + 2)) := ⟨Nat.ne_of_gt hrpos⟩ + let : NeZero (∏ i, bulkResidueModuli (frequencyModelBase Sfreq (n + 2) ft ^ ((n + 2) - 1 + 2)) p i) := + ⟨Nat.ne_of_gt hMpos⟩ + have hpage := frequencyModel_bulk_page_projection Sfreq (n + 2) Nfreq cutoff ft + (fun s hs => ⟨hS s hs, hN s hs⟩) hNcut p (selectedPageZero P (bulkProgressionCutoff L)) + (fun i => ⟨Fact.out, (hpband i).1⟩) + (fun z hz q hq i => (hdeletebulk z hz q hq i).symm) + by_cases htier : ∀ i, movingSampleTier (rep (pattern i)).val.2 = movingSampleTier i.2 + · + exact hrate lo hi hlo hhi hwindow Bidx Cidx N e tierB (fun c => movingSampleTier (rep c).val.2) t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes childBound pivotBound f outside p hcop Dq sets β + primeLo cutoff tier X j₀ φ G global μ ν logSlots cb active (Real.exp (Cmass * L)) α βint Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hMQ hpage hφ hlip hφout hShell hdel hout + (fun j => congrArg (primeSubsetPrior primes) (hν j)) + hμ0 hν0 hμsum hνsum (Real.one_le_exp_iff.mpr (mul_nonneg (by linarith only [hCmass]) hL0)) + (Real.exp_pos _).le (Real.exp_pos _).le (Real.exp_pos _) (Real.one_le_exp_iff.mpr (Real.exp_pos _).le) + hμbound hμα hνα (fun c => hμβ _) (fun c => hμmin _) hupper hactive houtcover hinjp huBig hrBig + hNfreq le_rfl le_rfl le_rfl rfl hUlog hUup htiers.1 htiers.2 hNlo hNcut hcutlo hμlo hνlo + hupper hpband + (fun z hz q hq j a ha heq => hdeleteμ z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qμ j) a ha)) hdeletep + (fun z hz q hq j a ha heq => hdeleteν z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qν j) a ha)) hsreg hsregN hsetsReg + · have hz (H : (Fin (N + 1) → primes) → ℂ) (x) : + movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern H x = 0 := + movingPattern_zero_of_inconsistent_tiers e μ ν (fun q : primes => (q : ℕ)) + pattern rep tier htiers.1 htier H x + dsimp only [μ, ν] at hz + simp only [hz, Finset.sum_const_zero, norm_zero] + positivity + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodMaskedShell.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodMaskedShell.lean new file mode 100644 index 0000000000000000000000000000000000000000..0974a26667c381e175aba9204bc821335373022d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodMaskedShell.lean @@ -0,0 +1,226 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogGoodSharp +import OAI.NumberTheory.Ostmann.Arithmetic.WholeShellArithmeticCells +import OAI.NumberTheory.Ostmann.Construction.FrozenPrimeDeletions + +namespace OAI + +/-! # The original mixed diagonal bound on the entire bulk shell -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_good_masked_whole_shell_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (Eprior αall βint Vint Uall : ℝ) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots (n + 2) ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b : Bool, MovingLeafLengthLE (n + 2) ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) + (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, ν (slot j) = primeSubsetPrior primes (S \ global)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 1 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → + (movingPatternRegularSlots e (n + 2) m small slot).get j ∉ + Set.range (movingPatternBulkEmbedding e slot)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Eprior ≤ Real.exp (Cmass * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) → + (∀ j, j < (n + 2) → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (∀ j a, μ j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ j a, ν j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable e t small slot perm pattern primes _hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq + (movingPatternRegularSlots e (n + 2) m small slot).get active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center x) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + (Real.exp (Cmass * L)) ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (Real.exp (-gain * m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hmain⟩ := + P.movingPattern_log_original_good_sharp ψ n r₀ k A Wwin Bφ Dφ 1 Cmass Cmass gain + hA hWwin (by norm_num) hCmass hBφ hDφ hCmass Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hmain, whole_shell_arithmetic_cells C Cmass hM hCmass] with L hrate hcells + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB tierC t Sfreq ft Nfreq small slot perm pattern rep + primes hprimes _ childBound pivotBound f outside _ p _ hc _ Dq sets β + primeLo cutoff tier X j₀ φ G global μ ν logSlots cb active Eprior αall βint Vint Uall sreg setsReg Jleft Jright diagonal uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hvcenter hsmall hB htier hsmallLen ht hS hN hf hm hp + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hMQ hpage hφ hlip hφout hShell hdel hout hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hactive houtcover hinjp huBig hrBig + hNfreq hEup hαup hβup hVeq hUlog _hUup hμtier hνtier hNlo hNcut hcutlo hμlo hνlo + hupper hpband hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + let m := spectatorBulkCount k L + let a : ℝ := (4 / 1000) * L + let b : ℝ := (6 / 1000) * L + let u := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellLower a b + let v := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellUpper a b + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp a) (Real.exp b) + let deleted := fun x : Fin (N + 1) → primes => global ∪ + frozenPrimeDeletions (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside + obtain ⟨hcard, hunit, hlow, huv, hshort, hsep, hMcell, hsupport, hmass⟩ := + hcells M hMQ + have hDcard (x) : ((deleted x).card : ℝ) ≤ Real.exp (Cmass * L) := by + have hh : (deleted x).card ≤ global.card + (N + 1) + outside.length := by + have ht := (Finset.card_union_le global _).trans + (Nat.add_le_add_left (frozenPrimeDeletions_card_le + (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside) global.card) + simpa only [Fintype.card_fin, Nat.add_assoc] using ht + exact (Nat.cast_le.mpr hh).trans hdel + have hsub (j) : S \ global ⊆ primeCellSupport M + (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) := by + rw [hsupport]; exact Finset.sdiff_subset + have hretain (x) (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted x ⊆ S \ global := by + rw [hsupport] + intro q hq + exact Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hq).1, + fun hg => (Finset.mem_sdiff.mp hq).2 (Finset.mem_union_left _ hg)⟩ + have hmem (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : s ∈ Sfreq := by + rw [ht] at hs + exact allFrequencyList_subtype_mem Sfreq (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft) s hs + have hfreq (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : s ≠ 0 := + hS s (hmem b s hs) + have hV (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList (n + 2) (t b)) : + |(s : ℝ)| ≤ Real.exp (A * m) := by + have hn : (s.natAbs : ℝ) ≤ Nfreq := by exact_mod_cast hN s (hmem b s hs) + exact (show |(s : ℝ)| ≤ Nfreq by simpa only [Nat.cast_natAbs, Int.cast_abs] using hn).trans hNfreq + have hone (side : Bool) : + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern side)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one _ (fun s _ => hf s) _ + have hamp : 2 * (‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern false)‖ * + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) + (movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern true)‖) ≤ + Real.exp (1 * (m : ℝ)) := by + have hn := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm + have he := Real.add_one_le_exp (1 * (m : ℝ)) + nlinarith only [hn, hmR, he] + exact hrate lo hi hlo hhi hwindow Bidx Cidx (Fin (wholePrimeGridCount b)) N e tierB tierC + t Sfreq ft Nfreq small slot perm pattern rep primes hprimes childBound pivotBound hfreq f + outside p hc Dq sets β X j₀ φ G u v (fun x _ => deleted x) (fun _ => S \ global) + μ ν logSlots cb active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hvcenter (hsmall false) hB htier (hsmallLen false) + ht hS hN hf hm hp hV + hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout hcard (fun _ => hunit) (fun _ => hlow) + (fun _ => huv) (fun _ => hshort) (fun _ => hsep) (fun _ => hMcell) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hShell) (fun x _ _ => hDcard x) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hmass) + (fun x _ _ i hi => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_base (fun i => (x i : ℕ)) _ outside i hi)) hout + (fun x _ _ q hq => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_outside (fun i => (x i : ℕ)) _ outside q hq)) + (⟨0, wholePrimeGridCount_pos b⟩, 1) hsub (fun x _ => hretain x) hν + hμ0 hν0 hμmass hνmass (le_trans (by norm_num) hEprior) hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hactive + hinjp houtcover hNfreq huBig hrBig tier primeLo cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hpband hdeleteμ hdeletep hdeleteν + hsreg hsregN hsetsReg hEup hUlog hαup hβup hVeq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodSharp.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodSharp.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b85b7ad708d0d7ca8e6fd8f9ea07c02cbe64454 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogGoodSharp.lean @@ -0,0 +1,201 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogGoodArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalNumericalRate + +namespace OAI + +/-! # Absorbing all comparison errors in the original good-matching bound -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_original_good_sharp + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass Cprior gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) (hCprior : 1 ≤ Cprior) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) (n + 2)) (Nfreq : ℕ) + (small : TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (_hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (active : Fin (movingPatternRegularSlots e (n + 2) m small slot).length → Bool) + (sreg : ℤ) (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG center : ℝ), + let reg := (movingPatternRegularSlots e (n + 2) m small slot).get + let data := movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + MovingLeafLengthLE (n + 2) small r₀ → + t = (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ s, ‖f s‖ ≤ 1) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus ((frequencyModelBase Sfreq (n + 2) ft) ^ ((n + 2) - 1 + 2)) + (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ j, active j = false → reg j ∉ Set.range (movingPatternBulkEmbedding e slot)) → + Function.Injective p → + (∀ q ∈ outside, ∃ i, p i = q) → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + ∀ (tier : primes → ℕ) (lower cutoff : ℕ), + Nfreq ≤ lower → Nfreq < cutoff → cutoff ≤ lower → + (∀ j, j < (n + 2) → ∀ q, μ j q ≠ 0 → tier q = j) → + (∀ j q, ν j q ≠ 0 → tier q = tierB j) → + (∀ j q, μ j q ≠ 0 → lower < (q : ℕ)) → + (∀ j q, ν j q ≠ 0 → lower < (q : ℕ)) → + (∀ q : primes, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ lower) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ Nfreq → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + Eprior ≤ Real.exp (Cprior * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p (fun i => normalizedResidueTransform (sets i)) Dq reg active sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots e (n + 2) m small slot)) + (normalizedResidueFamily setsReg) f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal uG vG rG sG center x) x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * + (Real.exp (Cprior * L)) ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hmain⟩ := + P.movingPattern_log_original_good_arithmetic_rate ψ n r₀ k A Wwin Bφ Dφ F Cmass gain + hA hWwin hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hmain, + movingPattern_diagonal_pointwise_rate ψ (n + 2) r₀ k A Wwin Bφ Dφ Cprior Cmass + hA hWwin hBφ hDφ hCprior (by linarith)] with L hmain hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes _ childBound pivotBound hfreq f outside _ p _ hc _ + Dq sets β X j₀ φ G u v deleted initial μ ν logSlots cb active sreg setsReg Jleft Jright diagonal + Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hsmall hB htier hsmallLen ht hS hN hf hm hp hV hsets hsetsp hpupper + hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hfixed + hinjp houtp hNupper hcenterlow hrGlow tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg hEup hUlog hαup hβup hVeq + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t (fun _ => small) slot perm pattern + let amp := 2 * (‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data true)‖) + have hh := hmain lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq + small slot perm pattern rep primes hprimes childBound pivotBound hfreq f outside p hc Dq sets β X j₀ φ G + u v deleted initial μ ν logSlots cb active sreg setsReg Jleft Jright diagonal Eprior αall βint Vint Uall + uG vG rG sG center hslots huG hrG huvG hrsG hvG hsG hcenter hsmall hB htier hsmallLen ht hS hN hf + hm hp hV hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hamp hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall hμbound hμall hνall hμmax hμmin hvalues + hfixed hinjp houtp hNupper hcenterlow hrGlow tier lower cutoff hNlo hNcut hcutlo + hμtier hνtier hμlo hνlo hupper hprange hdeleteμ hdeletep hdeleteν hsreg hsregN hsetsReg + have hone (b : Bool) : ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data b)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (fun {_} _ => f) (fun s _ => hf s) (data b) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hamp4 : amp ≤ 4 := by + have h := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + dsimp only [amp] + linarith + apply hrate p (Fintype.card Cidx) Eprior Uall αall βint amp lo hi rG (Real.exp (-gain * m)) _ diagonal + (movingPattern_class_card_le (n + 2) pattern rep) hEprior hEup hUall hUlog hαall hαup hβint hβup + hamp0 hamp4 hhi hwindow hpupper hrGlow (Real.exp_nonneg _) + simpa only [hVeq, add_assoc] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogIntegrand.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogIntegrand.lean new file mode 100644 index 0000000000000000000000000000000000000000..d49b04f16df5cd5293e74f332e96fb42f5781cb4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogIntegrand.lean @@ -0,0 +1,134 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternIntegrand +import OAI.NumberTheory.Ostmann.Arithmetic.IndexedBulkLogComparison +import OAI.NumberTheory.Ostmann.Arithmetic.BulkLogWeightedNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternNormKernel + +namespace OAI + +/-! # The actual pattern kernel with its retained bulk logarithmic weights -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℝ) (childBound pivotBound : ℕ → ℕ) + (j₀ : TreeLeafIndex n × Fin m) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + +noncomputable def movingPatternLogIntegrand : BulkIntegrand (TreeLeafIndex n × Fin m) := + (bulkLogKernelPairIntegrand base (selectedBulkSet (movingPatternBulkEmbedding e slot)) + childBound pivotBound (movingPatternFinBulkData e n m t small slot perm pattern) + (movingPatternBulkSet_compensationAbsent e tierB tierC t small slot perm pattern hB htier) + (movingPatternBulkEmbedding e slot j₀) ((mem_selectedBulkSet _ _).mpr ⟨j₀, rfl⟩) + ψ X lo hi V hlo hhi + (movingPatternFinBulkData_frequencies e t small slot perm pattern (fun s => |(s : ℝ)| ≤ V) hfreq) + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U).withLogCutoffs base + (selectedBulkSet (movingPatternBulkEmbedding e slot)) cb logSlots |>.pullBulk base (movingPatternBulkEmbedding e slot) + +theorem movingPatternLogIntegrand_norm_le (z : (TreeLeafIndex n × Fin m) → ℝ) : + ‖movingPatternLogIntegrand e tierB tierC t small slot perm pattern hB htier base + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U logSlots cb z‖ ≤ + ‖movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier base + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U z‖ := + BulkIntegrand.withLogCutoffs_norm_le _ base + (selectedBulkSet (movingPatternBulkEmbedding e slot)) cb logSlots + (bulkCoordinateInsert base (movingPatternBulkEmbedding e slot) z) + +theorem movingPatternLogIntegrand_norm (z : (TreeLeafIndex n × Fin m) → ℝ) : + ‖movingPatternLogIntegrand e tierB tierC t small slot perm pattern hB htier base + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U logSlots cb z‖ ≤ + (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 := by + apply le_trans (BulkIntegrand.withLogCutoffs_norm_le _ base + (selectedBulkSet (movingPatternBulkEmbedding e slot)) cb logSlots + (bulkCoordinateInsert base (movingPatternBulkEmbedding e slot) z)) + exact movingPatternBulkIntegrand_norm e tierB tierC t small slot perm pattern hB htier base + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U z + +theorem movingPatternLogIntegrand_norm_window (z : (TreeLeafIndex n × Fin m) → ℝ) : + ‖movingPatternLogIntegrand e tierB tierC t small slot perm pattern hB htier base + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U logSlots cb z‖ ≤ + ((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * Bφ ^ (2 ^ n - 1)) ^ 2 := + (movingPatternLogIntegrand_norm_le e tierB tierC t small slot perm pattern hB htier base + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U logSlots cb z).trans + (movingPatternBulkIntegrand_norm_window e tierB tierC t small slot perm pattern hB htier base + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U z) + +theorem movingPatternLogIntegrand_nat + (base₀ value : Fin (N + 1) → ℕ) + (hv : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), value i = base₀ i) + (hvalue : ∀ i, value i ≠ 0) + (hf : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) : + let T := movingPatternFinBulkData e n m t small slot perm pattern + movingPatternLogIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base₀ i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U logSlots cb + (fun j => Real.log (value (movingPatternBulkEmbedding e slot j) : ℝ)) = + ((∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingRealKernelPair value T + (fun b => (T b).formulaNodes value hvalue childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hf b) + (.prime false) (.prime true)) ψ X lo hi hlo hhi φ G L U := by + dsimp only + change ((_ : ℝ) : ℂ) * realValueKernelPair _ childBound pivotBound _ + ψ X lo hi hlo hhi φ G L U = _ + rw [selectedBulkLogValues_nat base₀ value (movingPatternBulkEmbedding e slot) hv + (fun j => Nat.pos_of_ne_zero (hvalue _))] + rw [realValueKernelPair_nat value hvalue childBound pivotBound _ + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hf)] + +theorem PublishedProgressionInput.movingPatternLogIntegrand_comparison + (P : PublishedProgressionInput) {r₀ : ℕ} + (hsmall : ∀ b, MovingLeafLengthLE n (small b) r₀) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (rlog : ℕ) (hslots : ∀ j, (logSlots j).length ≤ rlog) + {Q : ℕ} (hQ : 2 ≤ Q) + (q a : TreeLeafIndex n × Fin m → ℕ) (u v : TreeLeafIndex n × Fin m → ℝ) + (hq : ∀ i, 1 ≤ q i) (hqQ : ∀ i, q i ≤ Q) (ha : ∀ i, (a i).Coprime (q i)) + (hu : ∀ i, 1 ≤ u i) (huv : ∀ i, u i ≤ v i) (hshort : ∀ i, v i ≤ u i + 1) + (hmass : ∀ i, ∑ p ∈ primeLogCellSet (q i) (a i) (u i) (v i), (p : ℝ)⁻¹ ≤ 2) : + let K := movingPatternLogIntegrand e tierB tierC t small slot perm pattern hB htier base + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U logSlots cb + ‖(∫ z, K z ∂Measure.pi (fun i => primeLogCellMeasure (q i) (a i) (u i) (v i))) - + ∫ z, K z ∂Measure.pi (fun i => primeGiantMeasure P Q (q i) (a i) (u i) (v i))‖ ≤ + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ i, + bulkLogWeightedKernelPairBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 + tlog rlog Bφ Dφ Dlog * bulkPrimeErrorFactor P Q (u i) := by + let f := bulkLogKernelPairIntegrand base (selectedBulkSet (movingPatternBulkEmbedding e slot)) + childBound pivotBound (movingPatternFinBulkData e n m t small slot perm pattern) + (movingPatternBulkSet_compensationAbsent e tierB tierC t small slot perm pattern hB htier) + (movingPatternBulkEmbedding e slot j₀) + ((mem_selectedBulkSet _ _).mpr ⟨j₀, rfl⟩) ψ X lo hi V hlo hhi + (movingPatternFinBulkData_frequencies e t small slot perm pattern (fun s => |(s : ℝ)| ≤ V) hfreq) + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U + exact P.bulk_log_weighted_integral_comparison_indexed base + (selectedBulkSet (movingPatternBulkEmbedding e slot)) (movingPatternBulkEmbedding e slot) + (fun j => (mem_selectedBulkSet _ _).mpr ⟨j, rfl⟩) childBound pivotBound + (movingPatternFinBulkData e n m t small slot perm pattern) + (movingPatternFinBulkData_compensationAbsent e tierB tierC n m t small slot perm pattern hB htier) + ψ X lo hi V hlo hhi + (movingPatternFinBulkData_frequencies e t small slot perm pattern (fun s => |(s : ℝ)| ≤ V) hfreq) + φ G Bφ Dφ hBφ hDφ hφ hlip hout _ _ + (movingPatternFinBulkData_size e t small slot perm pattern hsmall) + (movingPatternFinBulkData_regular_length e t small slot perm pattern hsmall) + L U f (fun _ => rfl) logSlots cb Dlog hDlog hloglip rlog hslots + hQ q a u v hq hqQ ha hu huv hshort hmass + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogKernelCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogKernelCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..81cb5a14a3fdf69e286d4bc7859325eb1bd67ca2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogKernelCost.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.BulkLogBudgetComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelCost + +namespace OAI + +/-! # Fixed-depth cost of the terminal logarithmic cutoffs -/ + +namespace Ostmann +open scoped SchwartzMap + +/-- Retaining all terminal log weights preserves the quadratic budget, +uniformly in their centers and in the moving Fourier window. -/ +theorem movingPatternLogKernelBudget_spectatorScale_window + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (A H B D Dlog : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hDlog : 0 ≤ Dlog) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ L : ℝ, 1 ≤ L → + let m := spectatorBulkCount k L + ∀ lo hi : ℝ, lo ≤ hi → hi - lo ≤ Real.exp (H * m) → + ∀ t rlog : ℕ, t ≤ 2 * 2 ^ n → rlog ≤ 2 ^ n * (r₀ + m + 4 * n) → + bulkLogWeightedKernelPairBudget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 t rlog B D Dlog ≤ + Real.exp (C * L ^ 2) := by + obtain ⟨C₀, hC₀, hb⟩ := + movingPatternKernelBudget_spectatorScale_window ψ n r₀ k A H B D hA hH + let a := 2 + Dlog * (Real.exp 2 - 1) + let K := 2 * a ^ (2 * 2 ^ n) + have ha : 1 ≤ a := by + have he : 0 ≤ Real.exp 2 - 1 := sub_nonneg.mpr (Real.one_le_exp (by norm_num)) + dsimp only [a] + nlinarith [mul_nonneg hDlog he] + have hK : 0 ≤ K := by dsimp only [K]; positivity + refine ⟨C₀ + K, by linarith, ?_⟩ + intro L hL + dsimp only + intro lo hi hhi hwindow t rlog ht hrlog + have hbudget := bulkLogWeightedKernelPairBudget_le ψ (Real.exp (A * spectatorBulkCount k L)) + lo hi n (2 ^ n * (r₀ + spectatorBulkCount k L + 4 * n + 4)) + (2 ^ n * (r₀ + spectatorBulkCount k L + 4 * n)) 0 t rlog B D Dlog hDlog ht hrlog + have hfactor : 2 * a ^ t ≤ K := + mul_le_mul_of_nonneg_left (pow_le_pow_right₀ ha ht) (by norm_num) + have hbase := bulkKernelPairComparisonBudget_nonneg ψ + (Real.exp (A * spectatorBulkCount k L)) lo hi n + (2 ^ n * (r₀ + spectatorBulkCount k L + 4 * n + 4)) + (2 ^ n * (r₀ + spectatorBulkCount k L + 4 * n)) 0 B D + apply hbudget.trans + calc + _ ≤ K * Real.exp (C₀ * L ^ 2) := mul_le_mul hfactor (hb L hL lo hi hhi hwindow) hbase hK + _ ≤ Real.exp K * Real.exp (C₀ * L ^ 2) := + mul_le_mul_of_nonneg_right (by linarith [Real.add_one_le_exp K]) (Real.exp_nonneg _) + _ = Real.exp (K + C₀ * L ^ 2) := (Real.exp_add _ _).symm + _ ≤ Real.exp ((C₀ + K) * L ^ 2) := by + apply Real.exp_le_exp.mpr + have hsq : 1 ≤ L ^ 2 := by nlinarith + nlinarith [mul_le_mul_of_nonneg_left hsq hK] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogKernelNormBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogKernelNormBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..681658ca0ce845e85089a0729cad13a425c910df --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogKernelNormBound.lean @@ -0,0 +1,143 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogIntegrand +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkArithmetic +import OAI.NumberTheory.Ostmann.Construction.OriginalAbsoluteBulkBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternNormKernel + +namespace OAI + +/-! # The sharp pattern kernel under its original bulk prime law -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The original deleted prime kernel keeps its terminal log cutoffs. +The main arithmetic norm bound is unchanged; only the explicit comparison +error budget contains the additional logarithmic variation cost. -/ +theorem PublishedProgressionInput.movingPattern_log_norm_kernel_bound + (P : PublishedProgressionInput) {B C Cell : Type*} [Fintype Cell] + {N n m r₀ : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (hsmall : ∀ b, MovingLeafLengthLE n (small b) r₀) + (base : Fin (N + 1) → ℕ) (childBound pivotBound : ℕ → ℕ) + (j₀ : TreeLeafIndex n × Fin m) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb Dlog : ℝ) + (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (rlog : ℕ) (hslots : ∀ j, (logSlots j).length ≤ rlog) + (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, NeZero (p i)] + [NeZero (∏ i, bulkResidueModuli r p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (freq : ((TreeLeafIndex n × Fin m) → (ZMod r)ˣ) → ℂ) + (spec : ∀ i, ((TreeLeafIndex n × Fin m) → (ZMod (p i))ˣ) → ℂ) + (A : ℝ) (hA : 0 ≤ A) (hf : ∀ a, ‖freq a‖ ≤ A) + (Q : ℕ) (hQ : 2 ≤ Q) (hMQ : (∏ i, bulkResidueModuli r p i) ≤ Q) + (primes : Finset ℕ) (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (hu : ∀ j c, 1 ≤ u j c) (huv : ∀ j c, u j c ≤ v j c) + (hshort : ∀ j c, v j c ≤ u j c + 1) + (hmassCell : ∀ j c (a : (ZMod (∏ i, bulkResidueModuli r p i))ˣ), + ∑ q ∈ primeLogCellSet (∏ i, bulkResidueModuli r p i) a.val.val (u j c) (v j c), + (q : ℝ)⁻¹ ≤ 2) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hP : ∀ j, primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ primes) + (hsep : ∀ j (c d : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ), c ≠ d → + ¬Nat.ModEq (∏ i, bulkResidueModuli r p i) c.2.val.val d.2.val.val ∨ + v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hdeleted : ∀ j, (∑ q ∈ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted j, (q : ℝ)⁻¹) ≠ 0) + (A₀ : ℝ) (hA₀ : 0 ≤ A₀) (H T : ℝ) (Bspec : Fin m → ℝ) + (hBspec : ∀ i, 0 ≤ Bspec i) : + let K := movingPatternLogIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U logSlots cb + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let W₀ := ((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * Bφ ^ (2 ^ n - 1)) ^ 2 + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let label := fun (x : (TreeLeafIndex n × Fin m) → primes) j => primeCellLabel M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) c₀ (x j) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + let err := fun c : (TreeLeafIndex n × Fin m) → Cell => + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkLogWeightedKernelPairBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 tlog rlog Bφ Dφ Dlog * + bulkPrimeErrorFactor P Q (u j (c j)) + (∀ y : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ y j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ z, ‖a z * ∏ j, pageGiantWeight P Q M (z j).val.val (y j)‖ ≤ A₀) → + (∀ i z, ‖spec i z‖ ≤ Bspec i) → + (∀ j, Z j * ∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹ ≤ 2) → + (∀ j, Z j ≤ Real.exp H) → + (∀ j q, q ∈ S j \ deleted j → Real.exp T ≤ (q : ℝ)) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + (if Function.Injective x then a (fun j => (label x j).2) * + K (fun j => Real.log (x j : ℕ)) else 0)‖ ≤ + (W₀ * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, ∑ z, ‖a z‖ * err c + + (A * (∏ i, Bspec i) * W) * (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * + Real.exp (H - T) + + (A * (∏ i, Bspec i) * W) * ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) := by + intro K W W₀ M S Z label a err hlocal hspec hmass hZ hlow + have hW : 0 ≤ W := sq_nonneg _ + have hk : ∀ z, ‖K z‖ ≤ W := movingPatternLogIntegrand_norm e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U logSlots cb + have hk₀ : ∀ z, ‖K z‖ ≤ W₀ := movingPatternLogIntegrand_norm_window e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U logSlots cb + have herr (c : (TreeLeafIndex n × Fin m) → Cell) + (z : (TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : + ‖(∫ y, K y ∂Measure.pi (fun j => primeLogCellMeasure M (z j).val.val (u j (c j)) (v j (c j)))) - + ∫ y, K y ∂Measure.pi (fun j => primeGiantMeasure P Q M (z j).val.val (u j (c j)) (v j (c j)))‖ ≤ + err c := + P.movingPatternLogIntegrand_comparison e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ + hBφ hDφ hφ hlip hout L U logSlots cb hsmall Dlog hDlog hloglip rlog hslots hQ (fun _ => ∏ i, bulkResidueModuli r p i) + (fun j => (z j).val.val) (fun j => u j (c j)) (fun j => v j (c j)) + (fun _ => Nat.pos_of_ne_zero (NeZero.ne _)) (fun _ => hMQ) + (fun j => ZMod.val_coe_unit_coprime (z j)) (fun j => hu j (c j)) + (fun j => huv j (c j)) (fun j => hshort j (c j)) (fun j => hmassCell j (c j) (z j)) + have hn (x : (TreeLeafIndex n × Fin m) → primes) : + ‖a (fun j => (label x j).2) * K (fun j => Real.log (x j : ℕ))‖ ≤ A * (∏ i, Bspec i) * W := by + rw [norm_mul] + apply mul_le_mul _ (hk _) (norm_nonneg _) (mul_nonneg hA (Finset.prod_nonneg fun i _ => hBspec i)) + change ‖freq _ * ∏ i, spec i _‖ ≤ _ + rw [norm_mul, norm_prod] + exact mul_le_mul (hf _) (Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + (fun i _ => hspec i _)) (Finset.prod_nonneg fun _ _ => norm_nonneg _) hA + have hb := original_absolute_bulk_bound primes M u v + (fun j c => lt_of_lt_of_le zero_lt_one (hu j c)) c₀ hP hsep deleted hdeleted + K a P Q W₀ A₀ (sq_nonneg _) hA₀ hk₀ + (by + intro y hy + have hy' := hlocal y hy + simp only [finite_univ_canonical, Fintype.card_eq_nat_card] at hy' ⊢ + exact hy') (fun c _ => err c) herr H T + (A * (∏ i, Bspec i) * W) + (mul_nonneg (mul_nonneg hA (Finset.prod_nonneg fun i _ => hBspec i)) hW) + have hh := hb hmass hZ hlow hn + simp only [finite_univ_canonical, Fintype.card_eq_nat_card] at hh ⊢ + exact hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogLeafBridge.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogLeafBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..a856a6b064bbfeb8ac884c0d1d99347a28b5780f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogLeafBridge.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingLogPrimeAverage +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairedLogSlots +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkBudgets + +namespace OAI + +/-! # The actual initial leaf weights in the pattern prime observable -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (E : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (P : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (L U : ℝ) + (tier : Fin (N + 1) → ℕ) (k : ℕ) (cb cd : ℝ) + +/-- Exact identification with the retained-log observable. The outside +spectator profile is a scalar; every variable terminal factor remains inside. -/ +theorem movingPatternTwoPrimeObservable_log_leaf (x : Fin (N + 1) → primes) : + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t small slot perm pattern + movingPatternTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq + (fun b {_} T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F b T s) + E outside R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U x = + (logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ + (2 ^ n + 2 ^ n) : ℝ) * + movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q xg y + ψ X lo hi hlo hhi φ G L U (movingPairedLogSlots tier k T) cb x := by + intro value T + let nodes := fun b => (T b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + change movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPrimeAverage value outside + (fun b {_} T s => (movingBulkLeafLogWeight value tier k outside cb cd T : ℂ) * F b T s) + E T nodes R r P Q xg y * ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) T) = _ + rw [movingFrequencyPrimeAverage_bulk_log value tier k outside cb cd F E T nodes R] + rw [movingBulkPairLogWeight_eq_cutoff_product value tier + (fun i => (hprimes _ (x i).property).pos) k outside cb cd T] + change _ = (logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ + (2 ^ n + 2 ^ n) : ℝ) * + (((∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb + (movingPairedLogSlots tier k T j) : ℝ) : ℂ) * + (movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPrimeAverage value outside F E T nodes R r P Q xg y * + ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) T))) + unfold movingPairedLogSlots + ring + +end + +/-- The concrete pattern automatically meets the retained-log comparison's +terminal length bound. -/ +theorem movingPattern_log_slot_lengths {B C : Type*} {N n m r₀ : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (tier : Fin (N + 1) → ℕ) (k : ℕ) (hsmall : ∀ b, MovingLeafLengthLE n (small b) r₀) : + ∀ j, (movingPairedLogSlots tier k + (movingPatternFinBulkData e n m t small slot perm pattern) j).length ≤ + 2 ^ n * (r₀ + m + 4 * n) := + movingPairedLogSlots_length_le tier k _ _ + (movingPatternFinBulkData_regular_length e t small slot perm pattern hsmall) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogMixedPrimeSignedBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogMixedPrimeSignedBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..9d3b23d092dd9bda556792d3573fcde6739989e8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogMixedPrimeSignedBound.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogSeparatedBound +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSpectatorNorm + +namespace OAI + +/-! # Separate giant and bulk Page cutoffs in the signed prime estimate -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell : Type*} [Fintype Cell] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q Qfreq : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb Dlog : ℝ) + (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (rlog : ℕ) (hslots : ∀ j, (logSlots j).length ≤ rlog) + +include hsmall hB htier hR hr hg hV hBφ hDφ hφ hlip hφout j₀ hDlog hloglip hslots in +/-- The original Page/spectator kernel now has a signed bound under its +literal deleted prime prior. Its frequency and pointwise spectator bounds +are derived; the remaining local signed mean is exactly the quartet input. -/ +theorem PublishedProgressionInput.movingPattern_log_mixed_prime_signed_bound + [NeZero (∏ i, bulkResidueModuli r p i)] + (r₀ : ℕ) (hsmallLen : ∀ b, MovingLeafLengthLE n (small b) r₀) + (hy : 0 ≤ y) (hQ : 2 ≤ Q) (hMQ : (∏ i, bulkResidueModuli r p i) ≤ Q) + (hpage : pageAtModulus (∏ i, bulkResidueModuli r p i) (selectedPageZero P Q) = + pageAtModulus r (selectedPageZero P Q)) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (hu : ∀ j c, 1 ≤ u j c) (huv : ∀ j c, u j c ≤ v j c) + (hshort : ∀ j c, v j c ≤ u j c + 1) + (hmassCell : ∀ j c (a : (ZMod (∏ i, bulkResidueModuli r p i))ˣ), + ∑ q ∈ primeLogCellSet (∏ i, bulkResidueModuli r p i) a.val.val (u j c) (v j c), + (q : ℝ)⁻¹ ≤ 2) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hP : ∀ j, primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ primes) + (hsep : ∀ j (c d : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ), c ≠ d → + ¬Nat.ModEq (∏ i, bulkResidueModuli r p i) c.2.val.val d.2.val.val ∨ + v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hdeleted : ∀ j, (∑ q ∈ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted j, (q : ℝ)⁻¹) ≠ 0) + (hdeletedBase : ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) + (hout : ∀ q ∈ outside, q.Prime) (hdeletedOut : ∀ j q, q ∈ outside → q ∈ deleted j) + (Kspec : Fin m → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (δ : ℝ) (hδ : 0 ≤ δ) (H T : ℝ) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Qfreq y + let spec := fun i => frozenBulkSpectatorHaar base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (g i) + let A := 2 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + let err := fun c : (TreeLeafIndex n × Fin m) → Cell => + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkLogWeightedKernelPairBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 tlog rlog Bφ Dφ Dlog * + bulkPrimeErrorFactor P Q (u j (c j)) + (∀ i, ‖(Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, spec i z‖ ≤ δ) → + (∀ j, Z j * ∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹ ≤ 2) → + (∀ j, Z j ≤ Real.exp H) → + (∀ j q, q ∈ S j \ deleted j → Real.exp T ≤ (q : ℝ)) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternLogPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Qfreq y ψ X lo hi hlo hhi φ G L U logSlots cb x‖ ≤ + (W * A) * 4 ^ Fintype.card (TreeLeafIndex n × Fin m) * δ ^ m + + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, ∑ z, ‖a z‖ * err c + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * Real.exp (H - T) + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) := by + intro data freq spec A W M S Z a err hlocal hmass hZ hlow + have hA : 0 ≤ A := by dsimp only [A]; positivity + have hf (z) : ‖freq z‖ ≤ A := + frozenBulkFrequencyFactor_norm_le base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Qfreq y hy z + have hspec (i) (z) : ‖spec i z‖ ≤ Kspec i ^ (2 ^ (n + 1)) := + frozenBulkSpectatorHaar_norm_le base n m t _ _ (twist i) perm (g i) (Kspec i) + (hKspec i) (hgnorm i) z + have heq := movingPatternLogPrimeBulkHaar_mean e tierB tierC t small slot perm pattern hsmall hB htier + base primes hprimes hbase childBound pivotBound hfreq F E outside R r hR hr p hc g hg twist + P Qfreq y j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U logSlots cb + u v c₀ S deleted (fun _ => Finset.Subset.refl _) hdeletedBase hout hdeletedOut + dsimp only at heq + rw [heq] + have hb := P.movingPattern_log_separated_kernel_bound e tierB tierC t small slot perm pattern hB htier + hsmallLen base childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ + hφ hlip hφout L U logSlots cb Dlog hDlog hloglip rlog hslots r p hc freq spec A hA hf Q hQ hMQ hpage primes u v hu huv hshort + hmassCell c₀ hP hsep deleted hdeleted δ hδ H T (fun i => Kspec i ^ (2 ^ (n + 1))) + (fun i => pow_nonneg (hKspec i) _) + exact hb hlocal hspec hmass hZ hlow + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeBulk.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeBulk.lean new file mode 100644 index 0000000000000000000000000000000000000000..cc6efb9a001759a6611f1f9cf8096a43269fc6aa --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeBulk.lean @@ -0,0 +1,140 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogIntegrand + +namespace OAI + +/-! # Exact selected-prime mean of the original pattern kernel -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell I : Type*} [Fintype Cell] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + +/-- This is the original real kernel and its original Page and spectator +averages, evaluated after inserting the selected prime draws. -/ +noncomputable def movingPatternLogPrimeBulkHaar (x : (TreeLeafIndex n × Fin m) → primes) : ℂ := + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + let hp := primeBulkValues_prime base (movingPatternBulkEmbedding e slot) x hprimes hbase + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes value (fun i => (hp i).ne_zero) + childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + ((∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + (movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPageAverage value outside F E data nodes R r P Q y * + ∏ i, movingSpectatorHaarAverage value (p i) (g i) (twist i) data)) + +include hsmall hR hr hg in +/-- Removing the fixed nonbulk primes is sufficient for the supported +arithmetic identity. The averaging law and its normalizers remain unchanged. -/ +theorem movingPatternLogPrimeBulkHaar_mean + [NeZero (∏ i, bulkResidueModuli r p i)] + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (S deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hS : ∀ j, S j ⊆ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1)) + (hdeleted : ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) + (hout : ∀ q ∈ outside, q.Prime) + (hdeletedOut : ∀ j q, q ∈ outside → q ∈ deleted j) : + let M := ∏ i, bulkResidueModuli r p i + let label := fun (x : (TreeLeafIndex n × Fin m) → primes) j => primeCellLabel M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) c₀ (x j) + let K := movingPatternLogIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U logSlots cb + let a := fun z => frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F E (movingPatternFinBulkData e n m t small slot perm pattern) childBound R r P Q y + (bulkResidueEquiv r p hc z).1 * + ∏ i, frozenBulkSpectatorHaar base n m t (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (twist i) perm (g i) ((bulkResidueEquiv r p hc z).2 i) + (∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternLogPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Q y ψ X lo hi hlo hhi φ G L U logSlots cb x) = + ∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + (if Function.Injective x then a (fun j => (label x j).2) * + K (fun j => Real.log (x j : ℕ)) else 0) := by + intro M label K a + apply Finset.sum_congr rfl + intro x _ + by_cases hw : (∏ j, primeSubsetPrior primes (S j \ deleted j) (x j)) = 0 + · simp only [hw, Complex.ofReal_zero, zero_mul] + · have hx (j) : (x j : ℕ) ∈ S j \ deleted j := + primeSubsetPrior_support primes _ _ (Finset.prod_ne_zero_iff.mp hw j (Finset.mem_univ j)) + have hxcell (j) : (x j : ℕ) ∈ primeCellSupport M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) \ deleted j := + Finset.mem_sdiff.mpr ⟨hS j (Finset.mem_sdiff.mp (hx j)).1, (Finset.mem_sdiff.mp (hx j)).2⟩ + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + have hp := primeBulkValues_prime base (movingPatternBulkEmbedding e slot) x hprimes hbase + have hv (i) (hi : i ∉ Set.range (movingPatternBulkEmbedding e slot)) : value i = base i := + primeBulkValues_off base (movingPatternBulkEmbedding e slot) x i hi + have hz (j) : (value (movingPatternBulkEmbedding e slot j) : ZMod M) = + ((label x j).2 : ZMod M) := + primeBulkValues_cell_label base (movingPatternBulkEmbedding e slot) x M u v c₀ deleted hxcell j + have hid := movingPattern_bulk_supported_identity e tierB tierC t small slot perm pattern + hsmall hB htier base value hv hp childBound pivotBound hfreq F E outside + (primeBulkValues_cross_of_deleted base (movingPatternBulkEmbedding e slot) x S deleted hx hdeleted) + (primeBulkValues_outside_coprime base (movingPatternBulkEmbedding e slot) x S deleted + hprimes hx outside hout hdeletedOut) + R r hR hr p hc g hg twist (fun j => (label x j).2) hz P Q y + j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + dsimp only at hid + have hinj : Function.Injective (value ∘ movingPatternBulkEmbedding e slot) ↔ + Function.Injective x := primeBulkValues_injective_iff base (movingPatternBulkEmbedding e slot) x + simp only [hinj] at hid + apply congrArg (fun z : ℂ => ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * z) + have hK : K (fun j => Real.log (x j : ℕ)) = + ((∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U (fun j => Real.log (x j : ℕ)) := by + have hnat := movingPatternLogIntegrand_nat e tierB tierC t small slot perm pattern hB htier + childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + logSlots cb base value hv (fun i => (hp i).ne_zero) hfreq + have hbaseNat := movingPatternBulkIntegrand_nat e tierB tierC t small slot perm pattern hB htier + childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + base value hv (fun i => (hp i).ne_zero) hfreq + simp only [value, primeBulkValues_at] at hnat hbaseNat + simpa only [K, hbaseNat] using hnat + unfold movingPatternLogPrimeBulkHaar + dsimp only + rw [hid, hK] + split_ifs <;> simp only [primeBulkValues_at, a, value, mul_zero] + ring + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeMeasurable.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeMeasurable.lean new file mode 100644 index 0000000000000000000000000000000000000000..c554c9aad1a60cd3cadbeb0b465dad3e2d088199 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeMeasurable.lean @@ -0,0 +1,47 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePairHaarRegularity +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelTransport + +namespace OAI + +/-! # Measurability of the original two-prime pattern integrand -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (input : PublishedProgressionInput) (Q : ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + +theorem movingPatternLogPrimeObservable_measurable + (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) (x : Fin (N + 1) → primes) : + Measurable (fun z : ℝ × ℝ => + movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist input Q z.2 + ψ X lo hi hlo hhi φ G (Real.exp z.1) (Real.exp z.2) logSlots cb x) := by + have h := movingPatternPrimeObservable_measurable e t small slot perm pattern + primes hprimes childBound pivotBound hfreq F E outside R r p g twist input Q + ψ X lo hi hlo hhi φ G Bφ Dφ hBφ hDφ hφ hlip hout x + exact measurable_const.mul h + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b43eedb5f3dd4d4e86c64d5912044e9b90b644d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeNorm.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePointwiseNorm + +namespace OAI + +/-! # Pointwise bound for the literal original prime observable -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell I : Type*} [Fintype Cell] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + +include hB htier hV hBφ hDφ hφ hlip hφout j₀ in +/-- This uniform pointwise estimate allows the extra nonbulk-prime deletion +error to be returned to the initial external law. -/ +theorem movingPatternLogPrimeBulkHaar_norm + (hy : 0 ≤ y) (Kspec : I → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (x : (TreeLeafIndex n × Fin m) → primes) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let amp := 2 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + ‖movingPatternLogPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Q y ψ X lo hi hlo hhi φ G L U logSlots cb x‖ ≤ + (amp * ∏ i, Kspec i ^ (2 ^ (n + 1))) * W := by + intro data amp W + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + have hn : 0 ≤ ∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb (logSlots j) := + Finset.prod_nonneg (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).1) + have hle : (∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb (logSlots j)) ≤ 1 := + Finset.prod_le_one₀ (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).1) + (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).2) + change ‖((_ : ℝ) : ℂ) * movingPatternPrimeBulkHaar e t small slot perm pattern base + primes hprimes hbase childBound pivotBound hfreq F E outside R r p g twist P Q y + ψ X lo hi hlo hhi φ G L U x‖ ≤ _ + rw [norm_mul, Complex.norm_real, Real.norm_of_nonneg hn] + apply (mul_le_of_le_one_left (norm_nonneg _) hle).trans + exact movingPatternPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + base primes hprimes hbase childBound pivotBound hfreq F E outside R r p g twist P Q y + j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U hy Kspec hKspec hgnorm x + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeObservable.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeObservable.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bc71de99dea9252e3831547ab024b083135c72e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeObservable.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMean + +namespace OAI + +/-! # The literal prime observable in the original nonbulk Fubini formula -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (P : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + +/-- The coefficient before selecting or conditioning any of its bulk +coordinates. All original frequency and coprimality gates are retained. -/ +noncomputable def movingPatternLogPrimeObservable (x : Fin (N + 1) → primes) : ℂ := + let value := fun i => (x i : ℕ) + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + ((∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + (movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPageAverage value outside F E data nodes R r P Q y * + ∏ i, movingSpectatorHaarAverage value (p i) (g i) (twist i) data)) + +/-- The terminal log factors are real weights, depending only on the +regular prime assignment and not on either giant variable. -/ +theorem movingPatternLogPrimeObservable_eq (x : Fin (N + 1) → primes) : + movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q y + ψ X lo hi hlo hhi φ G L U logSlots cb x = + ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q y + ψ X lo hi hlo hhi φ G L U x := rfl + +theorem movingPatternLogPrimeObservable_join (base : Fin (N + 1) → primes) + (z : TreeLeafIndex n × Fin m → primes) : + movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q y ψ X lo hi hlo hhi φ G L U logSlots cb + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => base i)) = + movingPatternLogPrimeBulkHaar e t small slot perm pattern (fun i => (base i : ℕ)) primes + hprimes (fun i _ => hprimes _ (base i).property) childBound pivotBound hfreq F E outside + R r p g twist P Q y ψ X lo hi hlo hhi φ G L U logSlots cb z := by + have hv : (fun i => (joinBulkNonbulk (A := primes) (movingPatternBulkEmbedding e slot) z + (fun j => base j) i : ℕ)) = + primeBulkValues (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) z := by + funext i + by_cases hi : i ∈ Set.range (movingPatternBulkEmbedding e slot) + · obtain ⟨j, rfl⟩ := hi + rw [joinBulkNonbulk_bulk, primeBulkValues_at] + · rw [joinBulkNonbulk_nonbulk (movingPatternBulkEmbedding e slot) z + (fun j => base j) ⟨i, hi⟩, primeBulkValues_off _ _ _ i hi] + let eval : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} → ℂ := fun v => + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes v.val v.property childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + ((∏ j, bulkLogCutoffWeight (fun i => (v.val i : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + (movingRealKernelPair v.val data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPageAverage v.val outside F E data nodes R r P Q y * + ∏ i, movingSpectatorHaarAverage v.val (p i) (g i) (twist i) data)) + let left : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} := + ⟨fun i => (joinBulkNonbulk (A := primes) (movingPatternBulkEmbedding e slot) z + (fun j => base j) i : ℕ), + fun i => (hprimes _ ((joinBulkNonbulk (A := primes) + (movingPatternBulkEmbedding e slot) z (fun j => base j)) i).property).ne_zero⟩ + let right : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} := + ⟨primeBulkValues (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) z, + fun i => (primeBulkValues_prime (fun i => (base i : ℕ)) + (movingPatternBulkEmbedding e slot) z hprimes + (fun i _ => hprimes _ (base i).property) i).ne_zero⟩ + change eval left = eval right + exact congrArg eval (Subtype.ext hv) + +/-- This is exactly the selected-coordinate average used by the signed +pattern majorant, under the initial word law. -/ +theorem movingPatternBulkMean_logPrimeObservable (base : Fin (N + 1) → primes) + (ν : B → primes → ℝ) (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hν : ∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) : + movingPatternBulkMean e ν slot + (movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q y ψ X lo hi hlo hhi φ G L U logSlots cb) base = + ∑ z : TreeLeafIndex n × Fin m → primes, + ((∏ j, primeSubsetPrior primes (initial j) (z j) : ℝ) : ℂ) * + movingPatternLogPrimeBulkHaar e t small slot perm pattern (fun i => (base i : ℕ)) primes + hprimes (fun i _ => hprimes _ (base i).property) childBound pivotBound hfreq F E outside + R r p g twist P Q y ψ X lo hi hlo hhi φ G L U logSlots cb z := by + unfold movingPatternBulkMean + apply Finset.sum_congr rfl + intro z _ + rw [movingPatternLogPrimeObservable_join] + simp only [hν] + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeObservableCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeObservableCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c165eb53db69f252b8723fb44ac84bfd3292476 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogPrimeObservableCost.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelGain + +namespace OAI + +/-! # The actual observable and its uniform pointwise arithmetic cost -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + +include hB htier hV hBφ hDφ hφ hlip hφout j₀ in +theorem movingPatternLogPrimeObservable_norm + (hy : 0 ≤ y) (Kspec : I → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (x : Fin (N + 1) → primes) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let amp := 2 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + ‖movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q y + ψ X lo hi hlo hhi φ G L U logSlots cb x‖ ≤ (amp * ∏ i, Kspec i ^ (2 ^ (n + 1))) * W := by + dsimp only + let z := fun j => x (movingPatternBulkEmbedding e slot j) + have heq : joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i) = x := by + funext i + by_cases hi : i ∈ Set.range (movingPatternBulkEmbedding e slot) + · obtain ⟨j, rfl⟩ := hi + rw [joinBulkNonbulk_bulk] + · exact joinBulkNonbulk_nonbulk (movingPatternBulkEmbedding e slot) z + (fun i => x i) ⟨i, hi⟩ + have ho := movingPatternLogPrimeObservable_join e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q y + ψ X lo hi hlo hhi φ G L U logSlots cb x z + rw [heq] at ho + rw [ho] + exact movingPatternLogPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + (fun i => (x i : ℕ)) primes hprimes (fun i _ => hprimes _ (x i).property) + childBound pivotBound hfreq F E outside R r p g twist P Q y j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U logSlots cb hy Kspec hKspec hgnorm z + +end + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogSeparatedBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogSeparatedBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..125356bdcbd3d281e62085e7bda5e324c0961c35 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogSeparatedBound.lean @@ -0,0 +1,136 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogIntegrand +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkArithmetic +import OAI.NumberTheory.Ostmann.Construction.OriginalSeparatedBulkBound + +namespace OAI + +/-! # The sharp pattern kernel under its original bulk prime law -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The actual pattern kernel, frequency factor and spectator factors can be +averaged under the original deleted prime law. The comparison error here is +derived from the published progression input, with the concrete tree degrees; +the sharp kernel and the old prime normalizers are retained. -/ +theorem PublishedProgressionInput.movingPattern_log_separated_kernel_bound + (P : PublishedProgressionInput) {B C Cell : Type*} [Fintype Cell] + {N n m r₀ : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (hsmall : ∀ b, MovingLeafLengthLE n (small b) r₀) + (base : Fin (N + 1) → ℕ) (childBound pivotBound : ℕ → ℕ) + (j₀ : TreeLeafIndex n × Fin m) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb Dlog : ℝ) + (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (rlog : ℕ) (hslots : ∀ j, (logSlots j).length ≤ rlog) + (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, NeZero (p i)] + [NeZero (∏ i, bulkResidueModuli r p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (freq : ((TreeLeafIndex n × Fin m) → (ZMod r)ˣ) → ℂ) + (spec : ∀ i, ((TreeLeafIndex n × Fin m) → (ZMod (p i))ˣ) → ℂ) + (A : ℝ) (hA : 0 ≤ A) (hf : ∀ a, ‖freq a‖ ≤ A) + (Q : ℕ) (hQ : 2 ≤ Q) (hMQ : (∏ i, bulkResidueModuli r p i) ≤ Q) + (hpage : pageAtModulus (∏ i, bulkResidueModuli r p i) (selectedPageZero P Q) = + pageAtModulus r (selectedPageZero P Q)) + (primes : Finset ℕ) (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (hu : ∀ j c, 1 ≤ u j c) (huv : ∀ j c, u j c ≤ v j c) + (hshort : ∀ j c, v j c ≤ u j c + 1) + (hmassCell : ∀ j c (a : (ZMod (∏ i, bulkResidueModuli r p i))ˣ), + ∑ q ∈ primeLogCellSet (∏ i, bulkResidueModuli r p i) a.val.val (u j c) (v j c), + (q : ℝ)⁻¹ ≤ 2) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hP : ∀ j, primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ primes) + (hsep : ∀ j (c d : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ), c ≠ d → + ¬Nat.ModEq (∏ i, bulkResidueModuli r p i) c.2.val.val d.2.val.val ∨ + v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hdeleted : ∀ j, (∑ q ∈ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted j, (q : ℝ)⁻¹) ≠ 0) + (δ : ℝ) (hδ : 0 ≤ δ) (H T : ℝ) (Bspec : Fin m → ℝ) + (hBspec : ∀ i, 0 ≤ Bspec i) : + let K := movingPatternLogIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U logSlots cb + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let label := fun (x : (TreeLeafIndex n × Fin m) → primes) j => primeCellLabel M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) c₀ (x j) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + let err := fun c : (TreeLeafIndex n × Fin m) → Cell => + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkLogWeightedKernelPairBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 tlog rlog Bφ Dφ Dlog * + bulkPrimeErrorFactor P Q (u j (c j)) + (∀ i, ‖(Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, spec i z‖ ≤ δ) → + (∀ i z, ‖spec i z‖ ≤ Bspec i) → + (∀ j, Z j * ∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹ ≤ 2) → + (∀ j, Z j ≤ Real.exp H) → + (∀ j q, q ∈ S j \ deleted j → Real.exp T ≤ (q : ℝ)) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + (if Function.Injective x then a (fun j => (label x j).2) * + K (fun j => Real.log (x j : ℕ)) else 0)‖ ≤ + (W * A) * 4 ^ Fintype.card (TreeLeafIndex n × Fin m) * δ ^ m + + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, ∑ z, ‖a z‖ * err c + + (A * (∏ i, Bspec i) * W) * (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * + Real.exp (H - T) + + (A * (∏ i, Bspec i) * W) * ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) := by + intro K W M S Z label a err hlocal hspec hmass hZ hlow + have hW : 0 ≤ W := sq_nonneg _ + have hk : ∀ z, ‖K z‖ ≤ W := movingPatternLogIntegrand_norm e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U logSlots cb + have herr (c : (TreeLeafIndex n × Fin m) → Cell) + (z : (TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : + ‖(∫ y, K y ∂Measure.pi (fun j => primeLogCellMeasure M (z j).val.val (u j (c j)) (v j (c j)))) - + ∫ y, K y ∂Measure.pi (fun j => primeGiantMeasure P Q M (z j).val.val (u j (c j)) (v j (c j)))‖ ≤ + err c := + P.movingPatternLogIntegrand_comparison e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ + hBφ hDφ hφ hlip hout L U logSlots cb hsmall Dlog hDlog hloglip rlog hslots hQ (fun _ => ∏ i, bulkResidueModuli r p i) + (fun j => (z j).val.val) (fun j => u j (c j)) (fun j => v j (c j)) + (fun _ => Nat.pos_of_ne_zero (NeZero.ne _)) (fun _ => hMQ) + (fun j => ZMod.val_coe_unit_coprime (z j)) (fun j => hu j (c j)) + (fun j => huv j (c j)) (fun j => hshort j (c j)) (fun j => hmassCell j (c j) (z j)) + have hn (x : (TreeLeafIndex n × Fin m) → primes) : + ‖a (fun j => (label x j).2) * K (fun j => Real.log (x j : ℕ))‖ ≤ A * (∏ i, Bspec i) * W := by + rw [norm_mul] + apply mul_le_mul _ (hk _) (norm_nonneg _) (mul_nonneg hA (Finset.prod_nonneg fun i _ => hBspec i)) + change ‖freq _ * ∏ i, spec i _‖ ≤ _ + rw [norm_mul, norm_prod] + exact mul_le_mul (hf _) (Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + (fun i _ => hspec i _)) (Finset.prod_nonneg fun _ _ => norm_nonneg _) hA + have hb := @original_separated_bulk_bound (Fin m) (TreeLeafIndex n × Fin m) Cell + inferInstance inferInstance inferInstance r inferInstance p inferInstance inferInstance hc primes u v + (fun j c => lt_of_lt_of_le zero_lt_one (hu j c)) c₀ hP hsep deleted hdeleted + K freq spec W A δ hW hA hδ hk hf (fun i => by + simpa only [Fintype.card, finite_univ_canonical] using hlocal i) P Q hpage (fun c _ => err c) herr H T + (A * (∏ i, Bspec i) * W) + (mul_nonneg (mul_nonneg hA (Finset.prod_nonneg fun i _ => hBspec i)) hW) + dsimp only at hb + simpa only [a, label, S, Z, M, Fintype.card_fin, finite_univ_canonical] using hb hmass hZ hlow hn + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeBulk.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeBulk.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d156e6ac28f32d0dba32f202ea39dc3e8a9c739 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeBulk.lean @@ -0,0 +1,140 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogIntegrand + +namespace OAI + +/-! # Exact selected-prime mean of the original pattern kernel -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell I : Type*} [Fintype Cell] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + +/-- This is the original real kernel and its original Page and spectator +averages, evaluated after inserting the selected prime draws. -/ +noncomputable def movingPatternLogTwoPrimeBulkHaar (x : (TreeLeafIndex n × Fin m) → primes) : ℂ := + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + let hp := primeBulkValues_prime base (movingPatternBulkEmbedding e slot) x hprimes hbase + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes value (fun i => (hp i).ne_zero) + childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + ((∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + (movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPrimeAverage value outside F E data nodes R r P Q xg y * + ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) data)) + +include hsmall hR hr hg in +/-- Removing the fixed nonbulk primes is sufficient for the supported +arithmetic identity. The averaging law and its normalizers remain unchanged. -/ +theorem movingPatternLogTwoPrimeBulkHaar_mean + [NeZero (∏ i, bulkResidueModuli r p i)] + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (S deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hS : ∀ j, S j ⊆ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1)) + (hdeleted : ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) + (hout : ∀ q ∈ outside, q.Prime) + (hdeletedOut : ∀ j q, q ∈ outside → q ∈ deleted j) : + let M := ∏ i, bulkResidueModuli r p i + let label := fun (x : (TreeLeafIndex n × Fin m) → primes) j => primeCellLabel M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) c₀ (x j) + let K := movingPatternLogIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U logSlots cb + let a := fun z => frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + F E (movingPatternFinBulkData e n m t small slot perm pattern) childBound R r P Q xg y + (bulkResidueEquiv r p hc z).1 * + ∏ i, frozenBulkSpectatorPrime base n m t (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (twist i) perm (g i) ((bulkResidueEquiv r p hc z).2 i) + (∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U logSlots cb x) = + ∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + (if Function.Injective x then a (fun j => (label x j).2) * + K (fun j => Real.log (x j : ℕ)) else 0) := by + intro M label K a + apply Finset.sum_congr rfl + intro x _ + by_cases hw : (∏ j, primeSubsetPrior primes (S j \ deleted j) (x j)) = 0 + · simp only [hw, Complex.ofReal_zero, zero_mul] + · have hx (j) : (x j : ℕ) ∈ S j \ deleted j := + primeSubsetPrior_support primes _ _ (Finset.prod_ne_zero_iff.mp hw j (Finset.mem_univ j)) + have hxcell (j) : (x j : ℕ) ∈ primeCellSupport M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) \ deleted j := + Finset.mem_sdiff.mpr ⟨hS j (Finset.mem_sdiff.mp (hx j)).1, (Finset.mem_sdiff.mp (hx j)).2⟩ + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + have hp := primeBulkValues_prime base (movingPatternBulkEmbedding e slot) x hprimes hbase + have hv (i) (hi : i ∉ Set.range (movingPatternBulkEmbedding e slot)) : value i = base i := + primeBulkValues_off base (movingPatternBulkEmbedding e slot) x i hi + have hz (j) : (value (movingPatternBulkEmbedding e slot j) : ZMod M) = + ((label x j).2 : ZMod M) := + primeBulkValues_cell_label base (movingPatternBulkEmbedding e slot) x M u v c₀ deleted hxcell j + have hid := movingPattern_two_prime_bulk_supported_identity e tierB tierC t small slot perm pattern + hsmall hB htier base value hv hp childBound pivotBound hfreq F E outside + (primeBulkValues_cross_of_deleted base (movingPatternBulkEmbedding e slot) x S deleted hx hdeleted) + (primeBulkValues_outside_coprime base (movingPatternBulkEmbedding e slot) x S deleted + hprimes hx outside hout hdeletedOut) + R r hR hr p hc g hg twist (fun j => (label x j).2) hz P Q xg y + j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + dsimp only at hid + have hinj : Function.Injective (value ∘ movingPatternBulkEmbedding e slot) ↔ + Function.Injective x := primeBulkValues_injective_iff base (movingPatternBulkEmbedding e slot) x + simp only [hinj] at hid + apply congrArg (fun z : ℂ => ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * z) + have hK : K (fun j => Real.log (x j : ℕ)) = + ((∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U (fun j => Real.log (x j : ℕ)) := by + have hnat := movingPatternLogIntegrand_nat e tierB tierC t small slot perm pattern hB htier + childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + logSlots cb base value hv (fun i => (hp i).ne_zero) hfreq + have hbaseNat := movingPatternBulkIntegrand_nat e tierB tierC t small slot perm pattern hB htier + childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + base value hv (fun i => (hp i).ne_zero) hfreq + simp only [value, primeBulkValues_at] at hnat hbaseNat + simpa only [K, hbaseNat] using hnat + unfold movingPatternLogTwoPrimeBulkHaar + dsimp only + rw [hid, hK] + split_ifs <;> simp only [primeBulkValues_at, a, value, mul_zero] + ring + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeInitialNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeInitialNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..97ce06858b103f52d1861f72a17d2f0e9738edbf --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeInitialNormRate.lean @@ -0,0 +1,182 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeNormRate +import OAI.NumberTheory.Ostmann.Construction.NestedPrimePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeNorm + +namespace OAI + +/-! # Retaining the norm bound under the initial bulk law -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_log_initial_two_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex n × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (initial j) (x j) : ℝ) : ℂ) * + movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + have hconditional := P.movingPattern_log_original_two_prime_norm_rate ψ n r₀ k + A Wwin Bφ Dφ F Cmass hA hWwin hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + filter_upwards [hconditional, movingPattern_bad_event_rate_window ψ n r₀ k + A Wwin Bφ Dφ F (Cmass + 1) hA hWwin hF, + P.original_harmonic_box_rate Cmass hCmass, eventually_ge_atTop (2000 : ℝ)] + with L hconditional hbad hnormal hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted logSlots cb + hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hbd := hbad lo hi hhi hwindow p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hdeletedBound := hconditional lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq xg y X A₀ + j₀ φ G XL U u v deleted logSlots cb hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ + hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout + hA₀ hlocal c₀ + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * W + have hpoint (x : (TreeLeafIndex n × Fin m) → primes) : + ‖movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ cost := + movingPatternLogTwoPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb + hxg hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hcollision : 0 ≤ cost * (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * + Real.exp ((Cmass + 1) * L - Real.exp ((39 / 10000 : ℝ) * L)) := by + dsimp only [cost, W, amp] + positivity + have hreturnCost := (le_add_of_nonneg_left hcollision).trans hbd + have hcost0 : 0 ≤ cost := by dsimp only [cost, W, amp]; positivity + have hfinal := @nested_prime_prior_three_errors (TreeLeafIndex n × Fin m) + inferInstance primes S initial deleted hS hsub hretain (fun j => (hnorm j).1) + (fun x => movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb x) + cost (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L))) + (Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcost0 hpoint + (by simpa only [finite_univ_canonical, m, S, M] using hdeletedBound) + (by simpa only [finite_univ_canonical, cost, W, m, Z] using hreturnCost) + simpa only [finite_univ_canonical, m, S, M] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeIntegratedRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeIntegratedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3242dfaea89696df51d6e9d31cb0d9451b94fd9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeIntegratedRate.lean @@ -0,0 +1,212 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeSameNormArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHarmonicIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # The actual two-prime arithmetic bound integrated over its giant cells -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_same_assignment_two_prime_integral_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG : ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (Fw true) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := fun xg y => movingPatternLogTwoPrimeObservable e t small slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i b j, + j ∈ flattenMovingSlots n (small b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (fun x => ∫ xg in Set.Ioc uG vG, ∫ y in Set.Ioc rG sG, + obs xg y x / ((xg : ℂ) * (y : ℂ))) x * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + (((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))))) / (uG * rG) := by + filter_upwards [P.movingPattern_log_same_assignment_two_prime_arithmetic_rate ψ n r₀ k + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog, + eventually_ge_atTop (0 : ℝ)] with L hrate hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq Fw outside _ p _ hc _ twist sets + Qfreq X j₀ φ G u v deleted initial μ ν Eprior αall βint Vint Uall uG vG rG sG logSlots cb + hslots huG hrG huvG hrsG hvG hsG + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq n ft + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let obs := fun xg y => movingPatternLogTwoPrimeObservable e t small slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let amp := 4 * (‖movingDataWeight (Fw false) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (Fw true) (fun _ _ _ _ => 1) (data true)‖) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let bound := ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) + have hmean (xg : ℝ) (hxg : xg ∈ Set.Ioc uG vG) (y : ℝ) (hy : y ∈ Set.Ioc rG sG) : + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (obs xg y) x * movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) n t small + (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ bound := by + exact hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes childBound pivotBound hfreq Fw outside p hc twist sets Qfreq xg y X j₀ φ G + (Real.exp xg) (Real.exp y) u v deleted initial μ ν Eprior αall βint Vint Uall logSlots cb + hslots hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp (by linarith [hxg.1]) (by linarith [hy.1]) + hpupper hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hSS hdel hmass + hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint + hVint hUall hμbound hμall hνall hμmax hμmin hvalues + (hdisjoint xg hxg y hy) (hcross xg hxg y hy) (hfmod xg hxg y hy) + have hA₀ : 0 ≤ A₀ := by + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro z hz + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hz + exact pairFrequencySupportBound_nonneg D f + exact mul_nonneg (by positivity) (mul_nonneg hleaf0 hprod) + have hcost : 0 ≤ cost := by dsimp only [cost, amp]; positivity + have herr := movingInternalArithmeticError_nonneg n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + (Real.one_le_exp (mul_nonneg hA (Nat.cast_nonneg m))) hUall hαall hβint hVint.le + have hbound : 0 ≤ bound := by dsimp only [bound]; positivity + apply movingPattern_prime_harmonic_integral_bound e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) μ ν t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) + pattern (fun x xg y => obs xg y x) _ uG vG rG sG bound huG hrG huvG hrsG hvG hsG + hbound (fun _ => cost) (fun _ => hcost) _ hmean + · intro x + exact movingPatternLogTwoPrimeObservable_measurable e t small slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq ψ X lo hi hlo hhi φ G Bφ Dφ hBφ hDφ hφ hlip hφout logSlots cb x + · intro x xg hxg y hy + exact movingPatternLogTwoPrimeObservable_norm e tierB tierC t small slot (Equiv.refl _) pattern + hB htier primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G + Bφ Dφ hBφ hDφ hφ hlip hφout (Real.exp xg) (Real.exp y) logSlots cb + (by linarith [hxg.1]) (by linarith [hy.1]) (fun i => (p i : ℝ)) (fun _ => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeMeasurable.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeMeasurable.lean new file mode 100644 index 0000000000000000000000000000000000000000..6acd73784bc27cb3e2187a091f3a3104a21d0361 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeMeasurable.lean @@ -0,0 +1,47 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePairHaarRegularity +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelTransport + +namespace OAI + +/-! # Measurability of the original two-prime pattern integrand -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (input : PublishedProgressionInput) (Q : ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + +theorem movingPatternLogTwoPrimeObservable_measurable + (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) (x : Fin (N + 1) → primes) : + Measurable (fun z : ℝ × ℝ => + movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist input Q z.1 z.2 + ψ X lo hi hlo hhi φ G (Real.exp z.1) (Real.exp z.2) logSlots cb x) := by + have h := movingPatternTwoPrimeObservable_measurable e t small slot perm pattern + primes hprimes childBound pivotBound hfreq F E outside R r p g twist input Q + ψ X lo hi hlo hhi φ G Bφ Dφ hBφ hDφ hφ hlip hout x + exact measurable_const.mul h + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc4f38599219b904c1e3d379549ea055f52e4c8e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeNorm.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePointwiseNorm + +namespace OAI + +/-! # Pointwise bound for the literal original prime observable -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell I : Type*} [Fintype Cell] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + +include hB htier hV hBφ hDφ hφ hlip hφout j₀ in +/-- This uniform pointwise estimate allows the extra nonbulk-prime deletion +error to be returned to the initial external law. -/ +theorem movingPatternLogTwoPrimeBulkHaar_norm + (hxg : 0 ≤ xg) (hy : 0 ≤ y) (Kspec : I → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (x : (TreeLeafIndex n × Fin m) → primes) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let amp := 4 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + ‖movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U logSlots cb x‖ ≤ + (amp * ∏ i, Kspec i ^ (2 ^ (n + 1))) * W := by + intro data amp W + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + have hn : 0 ≤ ∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb (logSlots j) := + Finset.prod_nonneg (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).1) + have hle : (∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb (logSlots j)) ≤ 1 := + Finset.prod_le_one₀ (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).1) + (fun j _ => (bulkLogCutoffWeight_bounds _ _ _).2) + change ‖((_ : ℝ) : ℂ) * movingPatternTwoPrimeBulkHaar e t small slot perm pattern base + primes hprimes hbase childBound pivotBound hfreq F E outside R r p g twist P Q xg y + ψ X lo hi hlo hhi φ G L U x‖ ≤ _ + rw [norm_mul, Complex.norm_real, Real.norm_of_nonneg hn] + apply (mul_le_of_le_one_left (norm_nonneg _) hle).trans + exact movingPatternTwoPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + base primes hprimes hbase childBound pivotBound hfreq F E outside R r p g twist P Q xg y + j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U hxg hy Kspec hKspec hgnorm x + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeNormBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeNormBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..8df274e825d232459322d3988f73eee74ecd5c6b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeNormBound.lean @@ -0,0 +1,140 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePointwiseNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogKernelNormBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternNormKernel +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSpectatorNorm + +namespace OAI + +/-! # The norm estimate for the literal original prime mean -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell : Type*} [Fintype Cell] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q Qfreq : ℕ) (xg y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb Dlog : ℝ) + (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (rlog : ℕ) (hslots : ∀ j, (logSlots j).length ≤ rlog) + +include hsmall hB htier hR hr hg hV hBφ hDφ hφ hlip hφout j₀ hDlog hloglip hslots in +/-- Transfer a retained arithmetic absolute mean to the original prime law, +with the sharp window factor in the main term and the established variation +budget in the approximation errors. -/ +theorem PublishedProgressionInput.movingPattern_log_two_prime_norm_bound + [NeZero (∏ i, bulkResidueModuli r p i)] + (r₀ : ℕ) (hsmallLen : ∀ b, MovingLeafLengthLE n (small b) r₀) + (hxg : 0 ≤ xg) (hy : 0 ≤ y) (hQ : 2 ≤ Q) (hMQ : (∏ i, bulkResidueModuli r p i) ≤ Q) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (hu : ∀ j c, 1 ≤ u j c) (huv : ∀ j c, u j c ≤ v j c) + (hshort : ∀ j c, v j c ≤ u j c + 1) + (hmassCell : ∀ j c (a : (ZMod (∏ i, bulkResidueModuli r p i))ˣ), + ∑ q ∈ primeLogCellSet (∏ i, bulkResidueModuli r p i) a.val.val (u j c) (v j c), + (q : ℝ)⁻¹ ≤ 2) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hP : ∀ j, primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ primes) + (hsep : ∀ j (c d : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ), c ≠ d → + ¬Nat.ModEq (∏ i, bulkResidueModuli r p i) c.2.val.val d.2.val.val ∨ + v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hdeleted : ∀ j, (∑ q ∈ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted j, (q : ℝ)⁻¹) ≠ 0) + (hdeletedBase : ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) + (hout : ∀ q ∈ outside, q.Prime) (hdeletedOut : ∀ j q, q ∈ outside → q ∈ deleted j) + (Kspec : Fin m → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (A₀ : ℝ) (hA₀ : 0 ≤ A₀) (H T : ℝ) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (g i) + let A := 4 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let W₀ := ((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * Bφ ^ (2 ^ n - 1)) ^ 2 + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + let err := fun c : (TreeLeafIndex n × Fin m) → Cell => + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkLogWeightedKernelPairBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 tlog rlog Bφ Dφ Dlog * + bulkPrimeErrorFactor P Q (u j (c j)) + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P Q M (w j).val.val (z j)‖ ≤ A₀) → + (∀ j, Z j * ∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹ ≤ 2) → + (∀ j, Z j ≤ Real.exp H) → + (∀ j q, q ∈ S j \ deleted j → Real.exp T ≤ (q : ℝ)) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Qfreq xg y ψ X lo hi hlo hhi φ G L U logSlots cb x‖ ≤ + (W₀ * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, ∑ z, ‖a z‖ * err c + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * Real.exp (H - T) + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) := by + intro data freq spec A W W₀ M S Z a err hlocal hmass hZ hlow + have hA : 0 ≤ A := by dsimp only [A]; positivity + have hf (z) : ‖freq z‖ ≤ A := + frozenBulkFrequencyPrime_norm_le base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Qfreq xg y hxg hy z + have hspec (i) (z) : ‖spec i z‖ ≤ Kspec i ^ (2 ^ (n + 1)) := + frozenBulkSpectatorPrime_norm_le base n m t _ _ (twist i) perm (g i) (Kspec i) + (hKspec i) (hgnorm i) z + have heq := movingPatternLogTwoPrimeBulkHaar_mean e tierB tierC t small slot perm pattern hsmall hB htier + base primes hprimes hbase childBound pivotBound hfreq F E outside R r hR hr p hc g hg twist + P Qfreq xg y j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U logSlots cb + u v c₀ S deleted (fun _ => Finset.Subset.refl _) hdeletedBase hout hdeletedOut + dsimp only at heq + rw [heq] + have hb := P.movingPattern_log_norm_kernel_bound e tierB tierC t small slot perm pattern hB htier + hsmallLen base childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ + hφ hlip hφout L U logSlots cb Dlog hDlog hloglip rlog hslots r p hc freq spec A hA hf Q hQ hMQ primes u v hu huv hshort + hmassCell c₀ hP hsep deleted hdeleted A₀ hA₀ H T (fun i => Kspec i ^ (2 ^ (n + 1))) + (fun i => pow_nonneg (hKspec i) _) + exact hb hlocal hspec hmass hZ hlow + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..4521f06d6787b991ff3071ff38bb7df150046e3f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeNormRate.lean @@ -0,0 +1,189 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeNormBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogCellError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBadEventRate +import OAI.NumberTheory.Ostmann.Construction.OriginalHarmonicRate +import OAI.NumberTheory.Ostmann.ZeroDensity.BulkProgressionCutoff + +namespace OAI + +/-! # The original-prior norm estimate at the manuscript scales -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_log_original_two_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨Cerr, hCerr, hCnorm, hcellRate⟩ := + P.movingPattern_log_cell_error_rate_window ψ n r₀ k A Wwin Bφ Dφ F (Cmass + 1) Dlog + hA hWwin hF hDlog tlog htlog + obtain ⟨Tcell, _, hcellTwo⟩ := P.short_prime_cell_mass_two + have hlarge : ∀ᶠ L : ℝ in atTop, Tcell ≤ Real.exp ((39 / 10000 : ℝ) * L) := + (Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num))).eventually + (eventually_ge_atTop Tcell) + filter_upwards [hcellRate, movingPattern_bad_event_rate_window ψ n r₀ k + A Wwin Bφ Dφ F (Cmass + 1) hA hWwin hF, + P.original_harmonic_box_rate Cmass hCmass, hlarge, eventually_ge_atTop (2000 : ℝ)] + with L herror hbad hnormal hlarge hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted logSlots cb + hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime base n m t + (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (twist i) perm + (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hZ (j) : Z j ≤ Real.exp (Cerr * L) := (hnorm j).2.1.trans + (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hCnorm (by linarith))) + have hunit : (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) := + bulkResidueModulus_unit_card hMQ (Nat.floor_le (Real.exp_nonneg _)) + have ha (z) : ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) := by + exact moving_frozen_prime_residue_coefficient_norm base (movingPatternBulkEmbedding e slot) outside + Fw Ew n m data childBound R r P Qfreq xg y hxg hy p sets hsets hsetsp + t _ _ twist perm (bulkResidueEquiv r p hc z).1 (bulkResidueEquiv r p hc z).2 + have he := herror lo hi hhi hwindow Cell M (bulkProgressionCutoff L) hQ.1 hQ.2 p Z a amp + (Real.exp ((39 / 10000 : ℝ) * L)) (2 ^ n * (r₀ + m + 4 * n)) le_rfl + hpupper hZ0 hZ hcard hunit hamp0 hamp ha le_rfl u hulow + have hbd := hbad lo hi hhi hwindow p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hb := P.movingPattern_log_two_prime_norm_bound e tierB tierC t small slot perm pattern + hsmall hB htier base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r + hR hr p hc (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) twist (bulkProgressionCutoff L) Qfreq xg y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb Dlog hDlog hloglip (2 ^ n * (r₀ + m + 4 * n)) hslots + r₀ hsmallLen hxg hy hQ.1 hMQ u v hu huv hshort + (fun j c z => hcellTwo M z.val.val (u j c) (v j c) (hlarge.trans (hulow j c)) (hshort j c)) + c₀ hS (fun j => unitPrimeCells_separated M (u j) (v j) (hsep j)) deleted + (fun j => (hnorm j).1.ne') hdelbase hout hdelout (fun i => (p i : ℝ)) + (fun i => Nat.cast_nonneg _) (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) + A₀ hA₀ ((Cmass + 1) * L) (Real.exp ((39 / 10000 : ℝ) * L)) + hlocal (fun j => (hnorm j).2.2) (fun j => (hnorm j).2.1) + (fun j q hq => hlow j q (Finset.mem_sdiff.mp hq).1) + dsimp only at hb + have hh := add_le_add (le_refl + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m))) (add_le_add he hbd) + apply hb.trans + simpa only [add_assoc, W, amp, Z, a, spec, freq, data, M, S] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeObservable.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeObservable.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d1db3df02a896194ee2c0b4f1ffaeeb753d5c62 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeObservable.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMean + +namespace OAI + +/-! # The literal prime observable in the original nonbulk Fubini formula -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (P : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + +/-- The coefficient before selecting or conditioning any of its bulk +coordinates. All original frequency and coprimality gates are retained. -/ +noncomputable def movingPatternLogTwoPrimeObservable (x : Fin (N + 1) → primes) : ℂ := + let value := fun i => (x i : ℕ) + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + ((∏ j, bulkLogCutoffWeight (fun i => (value i : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + (movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPrimeAverage value outside F E data nodes R r P Q xg y * + ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) data)) + +/-- The terminal log factors are real weights, depending only on the +regular prime assignment and not on either giant variable. -/ +theorem movingPatternLogTwoPrimeObservable_eq (x : Fin (N + 1) → primes) : + movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q xg y + ψ X lo hi hlo hhi φ G L U logSlots cb x = + ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + movingPatternTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q xg y + ψ X lo hi hlo hhi φ G L U x := rfl + +theorem movingPatternLogTwoPrimeObservable_join (base : Fin (N + 1) → primes) + (z : TreeLeafIndex n × Fin m → primes) : + movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U logSlots cb + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => base i)) = + movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern (fun i => (base i : ℕ)) primes + hprimes (fun i _ => hprimes _ (base i).property) childBound pivotBound hfreq F E outside + R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U logSlots cb z := by + have hv : (fun i => (joinBulkNonbulk (A := primes) (movingPatternBulkEmbedding e slot) z + (fun j => base j) i : ℕ)) = + primeBulkValues (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) z := by + funext i + by_cases hi : i ∈ Set.range (movingPatternBulkEmbedding e slot) + · obtain ⟨j, rfl⟩ := hi + rw [joinBulkNonbulk_bulk, primeBulkValues_at] + · rw [joinBulkNonbulk_nonbulk (movingPatternBulkEmbedding e slot) z + (fun j => base j) ⟨i, hi⟩, primeBulkValues_off _ _ _ i hi] + let eval : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} → ℂ := fun v => + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes v.val v.property childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + ((∏ j, bulkLogCutoffWeight (fun i => (v.val i : ℝ)) cb (logSlots j) : ℝ) : ℂ) * + (movingRealKernelPair v.val data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPrimeAverage v.val outside F E data nodes R r P Q xg y * + ∏ i, movingSpectatorPrimeAverage v.val (p i) (g i) (twist i) data)) + let left : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} := + ⟨fun i => (joinBulkNonbulk (A := primes) (movingPatternBulkEmbedding e slot) z + (fun j => base j) i : ℕ), + fun i => (hprimes _ ((joinBulkNonbulk (A := primes) + (movingPatternBulkEmbedding e slot) z (fun j => base j)) i).property).ne_zero⟩ + let right : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} := + ⟨primeBulkValues (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) z, + fun i => (primeBulkValues_prime (fun i => (base i : ℕ)) + (movingPatternBulkEmbedding e slot) z hprimes + (fun i _ => hprimes _ (base i).property) i).ne_zero⟩ + change eval left = eval right + exact congrArg eval (Subtype.ext hv) + +/-- This is exactly the selected-coordinate average used by the signed +pattern majorant, under the initial word law. -/ +theorem movingPatternBulkMean_logTwoPrimeObservable (base : Fin (N + 1) → primes) + (ν : B → primes → ℝ) (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hν : ∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) : + movingPatternBulkMean e ν slot + (movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U logSlots cb) base = + ∑ z : TreeLeafIndex n × Fin m → primes, + ((∏ j, primeSubsetPrior primes (initial j) (z j) : ℝ) : ℂ) * + movingPatternLogTwoPrimeBulkHaar e t small slot perm pattern (fun i => (base i : ℕ)) primes + hprimes (fun i _ => hprimes _ (base i).property) childBound pivotBound hfreq F E outside + R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U logSlots cb z := by + unfold movingPatternBulkMean + apply Finset.sum_congr rfl + intro z _ + rw [movingPatternLogTwoPrimeObservable_join] + simp only [hν] + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeObservableCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeObservableCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..2af22ec6a28f4692bd72282bcd9409bac01ae601 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeObservableCost.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelGain + +namespace OAI + +/-! # The actual observable and its uniform pointwise arithmetic cost -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + {tlog : ℕ} (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + +include hB htier hV hBφ hDφ hφ hlip hφout j₀ in +theorem movingPatternLogTwoPrimeObservable_norm + (hxg : 0 ≤ xg) (hy : 0 ≤ y) (Kspec : I → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (x : Fin (N + 1) → primes) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let amp := 4 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + ‖movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q xg y + ψ X lo hi hlo hhi φ G L U logSlots cb x‖ ≤ (amp * ∏ i, Kspec i ^ (2 ^ (n + 1))) * W := by + dsimp only + let z := fun j => x (movingPatternBulkEmbedding e slot j) + have heq : joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i) = x := by + funext i + by_cases hi : i ∈ Set.range (movingPatternBulkEmbedding e slot) + · obtain ⟨j, rfl⟩ := hi + rw [joinBulkNonbulk_bulk] + · exact joinBulkNonbulk_nonbulk (movingPatternBulkEmbedding e slot) z + (fun i => x i) ⟨i, hi⟩ + have ho := movingPatternLogTwoPrimeObservable_join e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q xg y + ψ X lo hi hlo hhi φ G L U logSlots cb x z + rw [heq] at ho + rw [ho] + exact movingPatternLogTwoPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + (fun i => (x i : ℕ)) primes hprimes (fun i _ => hprimes _ (x i).property) + childBound pivotBound hfreq F E outside R r p g twist P Q xg y j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U logSlots cb hxg hy Kspec hKspec hgnorm z + +end + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeOriginalNormArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeOriginalNormArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..57e762952e6775438994a3032e232d9bc15730f7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeOriginalNormArithmetic.lean @@ -0,0 +1,193 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeSelectedNormRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate + +namespace OAI + +/-! # The norm estimate with the original internal and external priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_original_two_prime_norm_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + 0 ≤ A₀ → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + let freq := frozenBulkFrequencyPrime (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) + outside Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime (fun i => (x i : ℕ)) n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + ∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern obs x * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot perm) pattern x‖ ≤ + ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + filter_upwards [P.movingPattern_log_selected_two_prime_norm_rate ψ n r₀ k + A Wwin Bφ Dφ F Cmass hA hWwin hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted initial + μ ν Eprior αall βint Vint Uall logSlots cb hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper + hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout + hA₀ hlocal c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let obs := movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb + let cost := (4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hpoint (x) : ‖obs x‖ ≤ cost := + movingPatternLogTwoPrimeObservable_norm e tierB tierC t small slot perm pattern hB htier + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb + hxg hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hminor (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ‖movingPatternBulkMean e ν slot obs x‖ ≤ + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + exact hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern primes hprimes x + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq xg y X A₀ j₀ φ G XL U u v (deleted x) logSlots cb + hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS (hdel x hx) hmass (hdelbase x hx) hout (hdelout x hx) + hA₀ (hlocal x hx) c₀ initial hsub (hretain x hx) ν hν + have hfinal := movingPrimePattern_signed_arithmetic_on_support e (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) tierB tierC t small + (movingPatternBulkLeaves n m slot perm) pattern rep + (fun b j _ => hB j) (fun b j _ => hB j) htier + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hUall + (movingPatternFinBulkData_size e t small slot perm pattern hsmallLen) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hV) + (fun q => by + simpa only [Int.cast_natCast, abs_of_nonneg (show (0 : ℝ) ≤ (q : ℕ) from Nat.cast_nonneg _)] + using hvalues q) + μ ν hμ0 hν0 hμmass hνmass Eprior αall βint Vint hEprior hαall hβint hVint + hμbound hμall hνall hμmax hμmin obs cost (by dsimp only [cost]; positivity) + hpoint hdisjoint hcross hfmod m slot perm rfl + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hminor + (fun _ => Classical.arbitrary primes) + simpa only [movingInternalArithmeticError, obs, cost, data, m] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeSameNormArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeSameNormArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..830f9b7eb5213776b8f67bdec47eb019bbb419fd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeSameNormArithmetic.lean @@ -0,0 +1,202 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeOriginalNormArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNormalizedNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFrequencyModulus +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate + +namespace OAI + +/-! # The norm estimate with the original internal and external priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_same_assignment_two_prime_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (Fw true) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternLogTwoPrimeObservable e t small slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i b j, + j ∈ flattenMovingSlots n (small b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern obs x * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + filter_upwards [P.movingPattern_log_original_two_prime_norm_arithmetic_rate ψ n r₀ k + A Wwin Bφ Dφ 2 Cmass hA hWwin (by norm_num) hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq Fw outside _ p _ hc _ twist sets + Qfreq xg y X j₀ φ G XL U u v deleted initial μ ν Eprior αall βint Vint Uall logSlots cb + hslots hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq n ft + have hR (b : Bool) : (movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern b).frequencyProduct ∣ (R : ℤ) := by + simpa only [ht, R] using movingPattern_frequencyProduct_dvd e Sfreq ft small slot (Equiv.refl _) pattern b + have hroots (b : Bool) (j : Fin (2 ^ n - 1)) : + (singleTreeNodeFrequencies Sfreq n (frequencyPairProjection Sfreq n b ft) j.val).root.natAbs ∣ R := + frequencyModelBase_roots Sfreq n ft b j + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + have hone (b : Bool) : ‖movingDataWeight (Fw b) (fun _ _ _ _ => 1) (data b)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (Fw b) (fun s regular => + (hleaf b s regular).trans (by split_ifs <;> norm_num)) (data b) + have hamp : 4 * (‖movingDataWeight (Fw false) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (Fw true) (fun _ _ _ _ => 1) (data true)‖) ≤ Real.exp ((2 : ℝ) * m) := by + have hpair := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm + have he : (2 : ℝ) ≤ Real.exp (m : ℝ) := by linarith [Real.add_one_le_exp (m : ℝ)] + calc + _ ≤ 4 := by linarith + _ ≤ (Real.exp (m : ℝ)) ^ 2 := by nlinarith [Real.exp_pos (m : ℝ)] + _ = _ := by simpa only [Nat.cast_ofNat] using (Real.exp_nat_mul (m : ℝ) 2).symm + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + have hA₀ : 0 ≤ A₀ := by + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro x hx + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hx + exact pairFrequencySupportBound_nonneg D f + exact mul_nonneg (by positivity) (mul_nonneg hleaf0 hprod) + have hlocal (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) + (z : (TreeLeafIndex n × Fin m) → ℝ) (hz : ∀ j, 0 ≤ z j) := + movingPattern_normalized_same_assignment_prime_norm e tierB tierC Sfreq ft R Nfreq Vleaf + hS hN hroots small slot pattern hsmall hB htier (fun i => (x i : ℕ)) (hbase x hx) + Fw hleaf D hD hdiv hm p hc hp + (by simpa only [ht] using hfreqp) (hsmallp x hx) (hsamplesp x hx) + sets hsets hsetsp twist outside childBound P Qfreq (bulkProgressionCutoff L) xg y hxg hy z hz + have h := hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot (Equiv.refl _) pattern rep + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p hc twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted initial μ ν + Eprior αall βint Vint Uall logSlots cb hslots hsmall hB htier hsmallLen hR (frequencyModelModulus_precision R n) + hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell + hSS hdel hmass hdelbase hout hdelout hA₀ + (by + intro x hx + dsimp only + intro z hz + have hz' := hlocal x hx z hz + simpa only [A₀, m, ht, finite_univ_canonical, Fintype.card_eq_nat_card, Nat.card_fin] using hz') + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + exact h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeSelectedNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeSelectedNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..19fae2b1d80ff4f09c616c2953b148f26906c61e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogTwoPrimeSelectedNormRate.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeInitialNormRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogTwoPrimeObservable + +namespace OAI + +/-! # Norm estimate for the original selected-coordinate mean -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_log_selected_two_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ n) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (base : Fin (N + 1) → primes) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyPrime (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime (fun i => (base i : ℕ)) n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ j, (logSlots j).length ≤ 2 ^ n * (r₀ + m + 4 * n)) → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (base i : ℕ) ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex n × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ∀ ν : Bidx → primes → ℝ, + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + ‖movingPatternBulkMean e ν slot + (movingPatternLogTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U logSlots cb) base‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + filter_upwards [P.movingPattern_log_initial_two_prime_norm_rate ψ n r₀ k A Wwin Bφ Dφ F Cmass + hA hWwin hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern primes hprimes base + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted logSlots cb + hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain ν hν + rw [movingPatternBulkMean_logTwoPrimeObservable] + · exact hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern + (fun i => (base i : ℕ)) primes hprimes (fun i _ => hprimes _ (base i).property) + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted logSlots cb + hslots hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain + · exact hν + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..a69c2fbfdbd60f5254380e4196aac80d46b3a111 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowArithmetic.lean @@ -0,0 +1,211 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogWindowSelectedRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMultiplier + +namespace OAI + +/-! # The complete arithmetic bound under the original union-of-cells prior -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_weighted_arithmetic_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (W : (Fin (N + 1) → primes) → ℂ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb + let obs := fun x => W x * raw x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, ‖W x‖ ≤ 1) → + (∀ x z, W (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) = W x) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_log_selected_prime_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted initial + μ ν logSlots cb W Eprior αall βint Vint Uall hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hW hWbulk hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let raw := movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb + let obs := fun x => W x * raw x + let cost := (2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + have hraw (x) : ‖raw x‖ ≤ cost := + movingPatternLogPrimeObservable_norm e tierB tierC t small slot perm pattern hB htier + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hpoint (x) : ‖obs x‖ ≤ cost := by + change ‖W x * raw x‖ ≤ cost + rw [norm_mul] + exact (mul_le_mul_of_nonneg_right (hW x) (norm_nonneg _)).trans (by simpa using hraw x) + have hminor (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ‖movingPatternBulkMean e ν slot obs x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + rw [movingPatternBulkMean_weight e ν slot W raw hWbulk x, norm_mul] + apply (mul_le_mul_of_nonneg_right (hW x) (norm_nonneg _)).trans + simp only [one_mul] + exact hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern primes hprimes x + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X j₀ φ G XL U u v (deleted x) logSlots cb + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp (hsmallp x hx) (hsamplesp x hx) + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS (hdel x hx) hmass (hdelbase x hx) hout (hdelout x hx) + c₀ initial hsub (hretain x hx) ν hν + have hfinal := movingPattern_signed_arithmetic_on_support e (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) tierB tierC t small + (movingPatternBulkLeaves (n + 2) m slot perm) pattern rep + (fun b j _ => hB j) (fun b j _ => hB j) htier + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hUall + (movingPatternFinBulkData_size e t small slot perm pattern hsmallLen) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hV) + (fun q => by + simpa only [Int.cast_natCast, abs_of_nonneg (show (0 : ℝ) ≤ (q : ℕ) from Nat.cast_nonneg _)] + using hvalues q) + μ ν hμ0 hν0 hμmass hνmass Eprior αall βint Vint hEprior hαall hβint hVint + hμbound hμall hνall hμmax hμmin obs cost (by dsimp only [cost]; positivity) + hpoint hdisjoint hcross hfmod m slot perm rfl + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hminor + (fun _ => Classical.arbitrary primes) + simpa only [movingInternalArithmeticError, obs, raw, cost, data, m] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowInitialRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowInitialRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1b818380121438cbb29e3b6f85183de20573d77 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowInitialRate.lean @@ -0,0 +1,181 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogWindowPrimeRate +import OAI.NumberTheory.Ostmann.Construction.NestedPrimePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeNorm + +namespace OAI + +/-! # Signed cancellation under the initial, unconditioned bulk law -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_initial_prime_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) → + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ‖∑ x : (TreeLeafIndex (n + 2) × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (initial j) (x j) : ℝ) : ℂ) * + movingPatternLogPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hconditional⟩ := + P.movingPattern_log_original_prime_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hconditional, movingPattern_bad_event_rate_window ψ (n + 2) r₀ k + A H Bφ Dφ F (Cmass + 1) hA hH hF, + P.original_harmonic_box_rate Cmass hCmass, eventually_ge_atTop (2000 : ℝ)] + with L hconditional hbad hnormal hL + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted logSlots cb + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hbd := hbad lo hi hhi hwidth p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hdeletedBound := hconditional lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X + j₀ φ G XL U u v deleted logSlots cb hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * W + have hpoint (x : (TreeLeafIndex (n + 2) × Fin m) → primes) : + ‖movingPatternLogPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ cost := + movingPatternLogPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hcollision : 0 ≤ cost * (Fintype.card (TreeLeafIndex (n + 2) × Fin m) : ℝ) ^ 2 * + Real.exp ((Cmass + 1) * L - Real.exp ((39 / 10000 : ℝ) * L)) := by + dsimp only [cost, W, amp] + positivity + have hreturnCost := (le_add_of_nonneg_left hcollision).trans hbd + have hcost0 : 0 ≤ cost := by dsimp only [cost, W, amp]; positivity + have hfinal := @nested_prime_prior_three_errors (TreeLeafIndex (n + 2) × Fin m) + inferInstance primes S initial deleted hS hsub hretain (fun j => (hnorm j).1) + (fun x => movingPatternLogPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb x) + cost (Real.exp (-gain * m)) (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L))) + (Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcost0 hpoint + (by simpa only [finite_univ_canonical, m, S, M] using hdeletedBound) + (by simpa only [finite_univ_canonical, cost, W, m, Z] using hreturnCost) + simpa only [finite_univ_canonical, m, S, M] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..703c59102cd471ab79025dd127ef2c35b3cecb8a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowIntegral.lean @@ -0,0 +1,213 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogWindowArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedHarmonicIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # Signed quartet cancellation under both giant-cell integrals -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_weighted_mixed_integral_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ) + (W : ℝ → ℝ → (Fin (N + 1) → primes) → ℂ) + (Eprior αall βint Vint Uall uG vG rG sG center : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := fun xg y => movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let obs := fun xg y x => W xg y x * raw xg y x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, Measurable (fun z : ℝ × ℝ => W z.1 z.2 x)) → + (∀ xg y x, ‖W xg y x‖ ≤ 1) → + (∀ xg y x z, W xg y (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) = W xg y x) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ∫ xg in Set.Ioc uG vG, ∫ y in Set.Ioc rG sG, + obs xg y x * (Real.exp (xg - center) : ℂ) / (y : ℂ)) x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + (2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_log_weighted_arithmetic_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq X j₀ φ G u v deleted initial + μ ν logSlots cb W Eprior αall βint Vint Uall uG vG rG sG center + hslots huG hrG huvG hrsG hvG hsG hcenter hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hWmeas hW hWbulk hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let raw := fun xg y => movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) logSlots cb + let obs := fun xg y x => W xg y x * raw xg y x + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + let bound := ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) + have hmean (xg : ℝ) (hxg : xg ∈ Set.Ioc uG vG) (y : ℝ) (hy : y ∈ Set.Ioc rG sG) : + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (obs xg y) x * movingPatternHaarProduct e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) (n + 2) t small + (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ bound := by + exact hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern rep primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X j₀ φ G + (Real.exp xg) (Real.exp y) u v deleted initial μ ν logSlots cb (W xg y) Eprior αall βint Vint Uall + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp (by linarith [hy.1]) hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues (hW xg y) (hWbulk xg y) + (hdisjoint xg hxg y hy) (hcross xg hxg y hy) (hfmod xg hxg y hy) + have hcost : 0 ≤ cost := by dsimp only [cost, amp]; positivity + have herr := movingInternalArithmeticError_nonneg (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + (Real.one_le_exp (mul_nonneg hA (Nat.cast_nonneg m))) hUall hαall hβint hVint.le + have hbound : 0 ≤ bound := by dsimp only [bound]; positivity + apply movingPattern_mixed_harmonic_integral_bound e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) μ ν t small (movingPatternBulkLeaves (n + 2) m slot perm) + pattern (fun x xg y => obs xg y x) _ uG vG rG sG center bound huG hrG huvG hrsG hvG hsG hcenter + hbound (fun _ => cost) (fun _ => hcost) _ hmean + · intro x + exact (hWmeas x).mul (movingPatternLogPrimeObservable_measurable e t small slot perm pattern + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + ψ X lo hi hlo hhi φ G Bφ Dφ hBφ hDφ hφ hlip hφout logSlots cb x) + · intro x xg hxg y hy + have hh := movingPatternLogPrimeObservable_norm e tierB tierC t small slot perm pattern + hB htier primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout (Real.exp xg) (Real.exp y) logSlots cb + (by linarith [hy.1]) (fun i => (p i : ℝ)) (fun _ => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + change ‖W xg y x * raw xg y x‖ ≤ cost + rw [norm_mul] + exact (mul_le_mul (hW xg y x) hh (norm_nonneg _) (by norm_num)).trans_eq (one_mul _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowPrimeRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowPrimeRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..c3ca075c76d59e8b380f03b6edfd92234722b5bd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowPrimeRate.lean @@ -0,0 +1,198 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogMixedPrimeSignedBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowPrimeGain +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogCellError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBadEventRate +import OAI.NumberTheory.Ostmann.Construction.OriginalHarmonicRate +import OAI.NumberTheory.Ostmann.ZeroDensity.BulkProgressionCutoff + +namespace OAI + +/-! # One original-prior signed bulk estimate at the manuscript scales -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The three arithmetic costs are combined for the literal original prime +mean. The only analytic input is the published progression theorem; local +cancellation is proved from the balanced spectator sets and their mixed +Fourier bounds. All prime normalizers are those before idealization. -/ +theorem PublishedProgressionInput.movingPattern_log_original_prime_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) → + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ‖∑ x : (TreeLeafIndex (n + 2) × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternLogPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, δ, hε, hε1, hδ, cutoff, hcutoff, hgain⟩ := + exists_movingPatternPrimeGain_window ψ n r₀ A H Bφ Dφ F gain hA hH + obtain ⟨Cerr, hCerr, hCnorm, hcellRate⟩ := + P.movingPattern_log_cell_error_rate_window ψ (n + 2) r₀ k A H Bφ Dφ F (Cmass + 1) Dlog hA hH hF hDlog tlog htlog + obtain ⟨Tcell, _, hcellTwo⟩ := P.short_prime_cell_mass_two + have hlarge : ∀ᶠ L : ℝ in atTop, Tcell ≤ Real.exp ((39 / 10000 : ℝ) * L) := + (Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num))).eventually + (eventually_ge_atTop Tcell) + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hcellRate, movingPattern_bad_event_rate_window ψ (n + 2) r₀ k + A H Bφ Dφ F (Cmass + 1) hA hH hF, + P.original_harmonic_box_rate Cmass hCmass, hlarge, eventually_ge_atTop (2000 : ℝ)] + with L herror hbad hnormal hlarge hL + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted logSlots cb + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq y + let spec := fun i => frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) (twist i) perm + (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hg := hgain m hm lo hi hhi hwidth Bidx Cidx N e base t small pattern p hp + (fun i b s hs => ⟨hfreq b s hs, hfreqp i b s hs⟩) hsmallp hsamplesp + twist perm hgood sets hdlo hdhi hsets hsetsp β hβ hbias amp hamp0 hamp + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hZ (j) : Z j ≤ Real.exp (Cerr * L) := (hnorm j).2.1.trans + (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hCnorm (by linarith))) + have hunit : (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) := + bulkResidueModulus_unit_card hMQ (Nat.floor_le (Real.exp_nonneg _)) + have ha (z) : ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1)) := by + exact moving_frozen_residue_coefficient_norm base (movingPatternBulkEmbedding e slot) outside + Fw Ew (n + 2) m data childBound R r P Qfreq y hy p sets hsets hsetsp + t _ _ twist perm (bulkResidueEquiv r p hc z).1 (bulkResidueEquiv r p hc z).2 + have he := herror lo hi hhi hwidth Cell M (bulkProgressionCutoff L) hQ.1 hQ.2 p Z a amp + (Real.exp ((39 / 10000 : ℝ) * L)) (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) le_rfl hpupper hZ0 hZ hcard hunit hamp0 hamp ha le_rfl u hulow + have hbd := hbad lo hi hhi hwidth p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hb := P.movingPattern_log_mixed_prime_signed_bound e tierB tierC t small slot perm pattern + hsmall hB htier base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r + hR hr p hc (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) twist (bulkProgressionCutoff L) Qfreq y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U logSlots cb Dlog hDlog hloglip + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) hslots r₀ hsmallLen hy hQ.1 hMQ hpage u v hu huv hshort + (fun j c z => hcellTwo M z.val.val (u j c) (v j c) (hlarge.trans (hulow j c)) (hshort j c)) + c₀ hS (fun j => unitPrimeCells_separated M (u j) (v j) (hsep j)) deleted + (fun j => (hnorm j).1.ne') hdelbase hout hdelout (fun i => (p i : ℝ)) + (fun i => Nat.cast_nonneg _) (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) + δ hδ.le ((Cmass + 1) * L) (Real.exp ((39 / 10000 : ℝ) * L)) + hg.1 (fun j => (hnorm j).2.2) (fun j => (hnorm j).2.1) + (fun j q hq => hlow j q (Finset.mem_sdiff.mp hq).1) + dsimp only at hb + calc + _ ≤ _ := hb + _ ≤ Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + have hh := add_le_add (add_le_add hg.2 he) hbd + simpa only [add_assoc, W, amp, Z, a, spec, freq, data, M, S] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowSelectedRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowSelectedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..da7d3406f41a67f4c46e829634c70ae1837d9962 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternLogWindowSelectedRate.lean @@ -0,0 +1,123 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogWindowInitialRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogPrimeObservable + +namespace OAI + +/-! # The published prime estimate in the original selected-coordinate mean -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_log_selected_prime_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 2 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (base : Fin (N + 1) → primes) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (logSlots : Fin tlog → List (Fin (N + 1))) (cb : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + (∀ j, (logSlots j).length ≤ 2 ^ (n + 2) * (r₀ + m + 4 * (n + 2))) → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((base (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ i c, ((base (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (base i : ℕ) ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ∀ ν : Bidx → primes → ℝ, + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + ‖movingPatternBulkMean e ν slot + (movingPatternLogPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U logSlots cb) base‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_log_initial_prime_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern primes hprimes base + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted logSlots cb + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain ν hν + rw [movingPatternBulkMean_logPrimeObservable] + · exact hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern + (fun i => (base i : ℕ)) primes hprimes (fun i _ => hprimes _ (base i).property) + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X j₀ φ G XL U u v deleted logSlots cb + hslots hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain + · exact hν + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMainGain.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMainGain.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a226c69e2aeae2045b22374555354bef8502302 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMainGain.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelGain +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCost + +namespace OAI + +/-! # The actual quartet main term absorbs the full sharp kernel cost -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- A single mixed-character tolerance and prime threshold work for all +actual pattern trees and bulk lengths. No local cancellation bound is an +assumption here: it is derived from the quartet theorem. -/ +theorem exists_movingPatternMainGain (ψ : 𝓢(ℝ, ℂ)) (n r₀ : ℕ) + (A lo hi B D F gain : ℝ) (hA : 0 ≤ A) (hhi : lo ≤ hi) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ (m : ℕ), 1 ≤ m → ∀ (Bidx Cidx : Type) (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (base : Fin (N + 1) → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime], + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0 ∧ s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) → + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) → + ∀ (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)), + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + ∀ S : ∀ i, Finset (ZMod (p i)), + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (S i)) → + (∀ i, residueDensity (S i) ≤ 2 / 3) → + (∀ i, (S i).Nonempty) → (∀ i, (S i).card < p i) → + ∀ β : Fin m → ℝ, (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((S i).card : ℂ)⁻¹ * ∑ x ∈ S i, χ⁻¹ (-a - x)‖ ≤ β i) → + ∀ amp : ℝ, 0 ≤ amp → amp ≤ Real.exp (F * m) → + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + (W * amp) * 4 ^ Fintype.card (TreeLeafIndex (n + 2) × Fin m) * + ∏ i, ‖(Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) (twist i) perm + (normalizedResidueTransform (S i)) z‖ ≤ Real.exp (-gain * m) := by + obtain ⟨C, _, hkernel⟩ := exists_movingPatternKernelGain ψ (n + 2) r₀ + A lo hi B D F gain hA hhi + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hlocal⟩ := exists_frozenSpectatorGain n (C + F) gain + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + intro m hm Bidx Cidx N e base t small pattern p _ hp hfreq hsmall hsamples twist perm hgood + S hlo hhi hS hSp β hβ hbias amp hamp hampBound + dsimp only + let δ := signedBulkGainTarget (n + 2) (C + F) gain + have hi (i : Fin m) : + ‖(Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) (twist i) perm + (normalizedResidueTransform (S i)) z‖ ≤ δ := + hlocal (p i) (hp i) (Fin (N + 1)) base m (by omega) t _ _ + (fun b => movingGiantFrequencyUnits_of_bounds (t b) (hfreq i b)) + (fun b => movingPatternFiniteSmall_unit e base (small b) (hsmall i b)) + (movingPatternFiniteSamples_units e base pattern (hsamples i)) + (twist i) perm hgood (S i) (hlo i) (hhi i) (hS i) (hSp i) (β i) (hβ i) (hbias i) + have hpmean := Finset.prod_le_prod₀ (fun i (_ : i ∈ (Finset.univ : Finset (Fin m))) => + norm_nonneg ((Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) (twist i) perm + (normalizedResidueTransform (S i)) z)) (fun i _ => hi i) + simp only [Finset.prod_const, Finset.card_univ, Fintype.card_fin] at hpmean + apply (mul_le_mul_of_nonneg_left hpmean (by positivity)).trans + exact hkernel m hm amp δ hamp hampBound (signedBulkGainTarget_pos _ _ _).le le_rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedConditions.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedConditions.lean new file mode 100644 index 0000000000000000000000000000000000000000..be6182a8409e06450ff097f235afe09c8dee11f6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedConditions.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSeparatedConditions +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternRegularUnits +import OAI.NumberTheory.Ostmann.Characters.NormalizedResidueFamily + +namespace OAI + +/-! # The complete matched-history arithmetic data under the original prime priors -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +theorem movingPattern_matched_conditions (input : PublishedProgressionInput) + (n r₀ k : ℕ) (Cfreq : ℝ) (hCfreq : 0 ≤ Cfreq) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (A B C : Type) [Fintype A] [Fintype B] [Fintype C] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (tier : A → ℕ) (tierB : B → ℕ) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (S : Finset ℤ) (V : ℕ) (t : FrequencyTree (S × S) n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (p : Fin m → ℕ) (lo cutoff : ℕ) (E : ℝ) + (sreg : ℤ) (sets : ∀ q : ℕ, Finset (ZMod q)), + let R := frequencyModelBase S n t + let Pi := fun x => movingPatternInternalPrimes e prime x + let M := fun x => ∏ b, movingArithmeticModuli (R ^ (n - 1 + 2)) p (Pi x) Finset.univ b + let Reg := fun x => MovingSlotReversal.naturalProduct (fun i => prime (x i)) + (movingPatternRegularSlots e n m small slot) + Function.Injective prime → + (∀ j a, 0 ≤ μ j a) → (∀ j a, 0 ≤ ν j a) → + (∀ j a, (prime a : ℝ) * μ j a ≤ E) → + (∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → (∀ b, n ≤ tierB b) → + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) → (V : ℝ) ≤ Real.exp (Cfreq * m) → + V ≤ lo → V < cutoff → cutoff ≤ lo → + (∀ j a, μ j a ≠ 0 → lo < prime a) → + (∀ j a, ν j a ≠ 0 → lo < prime a) → + (∀ a, (prime a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, (p i).Prime ∧ cutoff ≤ p i ∧ p i ≤ lo ∧ + (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + MovingLeafLengthLE n small r₀ → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → prime a ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → prime a ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ V → + (∀ q, q.Prime → (sets q).Nonempty ∧ (sets q).card < q) → + ∀ x : Fin (N + 1) → A, + movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) x ≠ 0 → + let t₀ := fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t) + let slots := movingPatternRegularSlots e n m small slot + let T := movingPatternFinBulkData e n m t₀ (fun _ => small) slot perm pattern + ∀ (outside : List ℕ), + (∀ b, movingRegularOutsidePairwise (fun i => prime (x i)) outside (T b)) → + let : ∀ j : Fin slots.length, Fact (prime (x (slots.get j))).Prime := + fun _ => ⟨hprime _⟩ + (∀ i j, (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e i) ≠ + (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e j) → + prime (x i) ≠ prime (x j)) ∧ + (∀ i, V < prime (x i)) ∧ + (∀ i, IsCoprime (prime (x i) : ℤ) (R : ℤ)) ∧ + (∀ i, (R ^ (n - 1 + 2)).Coprime (prime (x i))) ∧ + (∀ i j, (prime (x j) : ZMod (p i)) ≠ 0) ∧ + (Reg x).Coprime (M x) ∧ Reg x * M x ≤ giantProgressionCutoff L ∧ + pageAtModulus (Reg x * M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) ∧ + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus (R ^ (n - 1 + 2)) (selectedPageZero input (giantProgressionCutoff L)) ∧ + Pairwise (fun i j : Fin slots.length => + (prime (x (slots.get i))).Coprime (prime (x (slots.get j)))) ∧ + (∀ i : Fin slots.length, (sreg : ZMod (prime (x (slots.get i)))) ≠ 0) ∧ + (∀ i : Fin slots.length, + (movingRegularOther (fun j => prime (x j)) outside slots i : + ZMod (prime (x (slots.get i)))) ≠ 0) ∧ + (∀ i : Fin slots.length, normalizedResidueFamily sets (prime (x (slots.get i))) 0 = 0) ∧ + (∀ i : Fin slots.length, + (∑ z : ZMod (prime (x (slots.get i))), + ‖normalizedResidueFamily sets (prime (x (slots.get i))) z‖ ^ 2) = + prime (x (slots.get i))) := by + filter_upwards [movingPattern_separated_giant_conditions input n r₀ k Cfreq hCfreq] + with L hbase + dsimp only + intro A B C _ _ _ N e prime hprime tier tierB μ ν pattern rep S V t small slot perm p lo cutoff E + sreg sets hinj hμ hν hbound hμtier hνtier hB hS hV hVlo hVcut hcutlo hμlo hνlo + hupper hp hsmall hdeleteμ hdeletep hdeleteν hsreg hsregV hsets x hx outside hgood + have hb := hbase A B C N e prime tier tierB μ ν pattern rep S V t small slot p lo cutoff E + hinj hprime hμ hν hbound hμtier hνtier hB hS hV hVlo hVcut hcutlo hμlo hνlo hupper + hp hsmall hdeleteμ hdeletep hdeleteν x hx + dsimp only at hb + rcases hb with ⟨hsep, hlarge, hcop, hrcop, hres, hfull, hregcop, hpageReg, hpage, _⟩ + let t₀ := fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t) + let slots := movingPatternRegularSlots e n (spectatorBulkCount k L) small slot + let : ∀ j : Fin slots.length, Fact (prime (x (slots.get j))).Prime := fun _ => ⟨hprime _⟩ + refine ⟨hsep, hlarge, hcop, hrcop, hres, hregcop, hfull, hpageReg, hpage, ?_, ?_, ?_, ?_, ?_⟩ + · exact movingPattern_regular_pairwise e t₀ small slot pattern (fun i => prime (x i)) + outside false (hgood false) + · exact movingPattern_regular_frequency_unit (fun i => prime (x i)) (fun _ => hprime _) + slots V hlarge sreg hsreg hsregV + · exact movingPattern_regular_other_unit e t₀ small slot pattern (fun i => prime (x i)) + (fun _ => hprime _) outside false (hgood false) + · intro i + exact normalizedResidueFamily_zero sets _ + · intro i + exact normalizedResidueFamily_energy sets _ (hsets _ (hprime _)).1 (hsets _ (hprime _)).2 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedHaarComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedHaarComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..55cbc0cb45f3fc1b7fe511933ea393dbf2e79fe0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedHaarComparison.lean @@ -0,0 +1,159 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedIntegralCRT +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPermutedProduct +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedSeparatedDiagonalRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingLeafAmplitude + +namespace OAI + +/-! # The literal mixed comparison for arbitrarily matched sample trees -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_pattern_matched_haar_rate + (input : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (Afreq Wwin Bφ Dφ : ℝ) (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B C J : Type) [Fintype C] [Fintype J] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) (x : Fin (N + 1) → primes) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (reg : J → ℕ) [∀ j, Fact (reg j).Prime] + (active : J → Bool) (sreg : ℤ) (other : ∀ j, ZMod (reg j)) + (greg : ∀ j, ZMod (reg j) → ℂ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (R : ℤ) (r : ℕ) [NeZero r] (P : Finset ℕ) [∀ q : P, Fact q.val.Prime] + [∀ b, NeZero (movingArithmeticModuli r p P Finset.univ b)] + [NeZero (∏ b, movingArithmeticModuli r p P Finset.univ b)] + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (V : ℕ) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) (diagonal : Bool), + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern + let M := ∏ b, movingArithmeticModuli r p P Finset.univ b + let Reg := MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) + (∀ b, n ≤ tierB b) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → value i ≠ value j) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ V) → (∀ i, V < value i) → + (∀ s, ‖f s‖ ≤ 1) → (∀ i, g i 0 = 0) → (∀ i z, ‖g i z‖ ≤ (p i : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + (∀ b, (T b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ i, IsCoprime (value i : ℤ) R) → + (∀ i j, (value j : ZMod (p i)) ≠ 0) → (∀ i, V < p i) → + P = Finset.univ.image (fun c : C => value (e.symm (.inr c))) → + Function.Injective (fun c : C => value (e.symm (.inr c))) → + Pairwise (fun a b => (movingArithmeticModuli r p P Finset.univ a).Coprime + (movingArithmeticModuli r p P Finset.univ b)) → + Reg = ∏ j, reg j → Reg.Coprime M → Reg * M ≤ giantProgressionCutoff L → + pageAtModulus (Reg * M) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus M (selectedPageZero input (giantProgressionCutoff L)) → + pageAtModulus M (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus r (selectedPageZero input (giantProgressionCutoff L)) → + (∀ b, movingRegularOutsidePairwise value outside (T b)) → + Pairwise (fun i j => (reg i).Coprime (reg j)) → + (∀ i, (∏ j, reg j).Coprime (p i)) → + (∀ i, (sreg : ZMod (reg i)) ≠ 0) → (∀ i, other i ≠ 0) → + (∀ i, greg i 0 = 0) → (∀ i, (∑ z : ZMod (reg i), ‖greg i z‖ ^ 2) = reg i) → + (V : ℝ) ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ z, |φ z| ≤ Bφ) → (∀ z w, |φ z - φ w| ≤ Dφ * |z - w|) → + (∀ z, 1 ≤ |z| → φ z = 0) → + ∀ u v a b center : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → u ≤ v → v ≤ u + 1 → v ≤ center + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ a → a ≤ b → b ≤ a + 1 → + ‖complexPrimeInterval 1 0 a b (fun y => complexIntegerInterval 1 0 u v center (fun z => + movingOriginalSupportedOuterPair p value outside childBound pivotBound + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g (fun _ => Dq) Finset.univ + ψ X lo hi φ G Jleft Jright diagonal T t ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (((∏ j, if active j then (1 : ℝ) else 1 - (reg j : ℝ)⁻¹) : ℝ) : ℂ)) * + movingPatternPrimeObservable e t (fun _ => small) slot perm pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x) * + (Real.exp (z - center) : ℂ) / (y : ℂ)) * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t (fun _ => small) (movingPatternBulkLeaves n m slot perm) pattern x‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [input.moving_original_supported_separated_diagonal_prime_rate ψ n r₀ k + Afreq Wwin Bφ Dφ hAfreq hWwin hBφ hDφ] with L hL + dsimp only + intro B C J _ _ N e tierB tierC t small slot perm pattern primes hprimes x p _ g Dq + reg _ active sreg other greg f outside childBound pivotBound R r _ P _ _ _ hfreq V + X lo hi hlo hhi φ G Jleft Jright diagonal + let m := spectatorBulkCount k L + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern + let hf := movingPatternFinBulkData_frequencies e t (fun _ => small) slot perm + pattern (· ≠ 0) hfreq + let nodes := fun b => (T b).formulaNodes value (fun i => (hprimes _ (x i).property).ne_zero) + childBound pivotBound (hf b) (.prime false) (.prime true) + let M := ∏ b, movingArithmeticModuli r p P Finset.univ b + intro hB htier hdisjoint hV hlarge hfnorm hg hgnorm hout hR hprecision hsmallR hres hspecLarge hP hinj hc + hRegEq hcop hfull hpageReg hpage houtside hreg hqs hsreg hother hgreg henergy + hVA hwindow hpupper hφ hlip hφout u v a b center hcenter huv hv hvcenter ha hab hb + have hprime (i) : (value i).Prime := hprimes _ (x i).property + have hVN (side) : (T side).Frequencies (fun s => s.natAbs ≤ V) := + movingPatternFinBulkData_frequencies e t (fun _ => small) slot perm pattern _ hV side + have hVR (side) : (T side).Frequencies (fun s => |(s : ℝ)| ≤ (V : ℝ)) := + (hVN side).mono (fun s hs => by + simpa only [Nat.cast_natAbs, Int.cast_abs] using (show (s.natAbs : ℝ) ≤ V by exact_mod_cast hs)) + have hsmall (side) := (T side).small_frequency_units value hprime V hlarge (hf side) (hVN side) + have hfmod (side) := (T side).small_frequency_residues value hprime V hlarge (hf side) (hVN side) + have hden (side i) : (T side).ModularDenominators value (p i) := by + apply (T side).modularDenominators_of_units value (p i) (hres i) + exact movingPatternFinBulkData_frequencies e t (fun _ => small) slot perm + pattern (fun s => (s : ZMod (p i)) ≠ 0) + (fun b s hs => intCast_ne_zero_of_natAbs_lt (p i) s (hfreq b s hs) + ((hV b s hs).trans_lt (hspecLarge i))) side + have hcover := movingPatternFinBulkData_internal_cover e tierB tierC t (fun _ => small) + slot perm pattern hB htier (fun q : primes => (q : ℕ)) x + have hcoverP (side o) (ho : o ∈ (T side).occurrences) (j) (hj : j ∈ o.current.compensationSlots) : + value j ∈ P := by + rw [hP] + exact hcover side o ho j hj + have hperiod := movingArithmeticModuli_periods r p P Finset.univ R (n + 1) hprecision + + have hweight (side) : ‖movingDataWeight (fun {_} _ => f) (fun {_} _ _ _ _ => 1) (T side)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (fun {_} _ => f) (fun s _ => hfnorm s) (T side) + have hregular (side) : MovingSlotReversal.naturalProduct value (T side).regularSlots = ∏ j, reg j := + (movingPatternFinBulkData_regular_product_permuted e t small slot perm pattern value side).trans hRegEq + have hqpos : 1 ≤ (∏ j, reg j) * M := by + apply Nat.one_le_iff_ne_zero.mpr + exact mul_ne_zero (Finset.prod_ne_zero_iff.mpr (fun j _ => (Fact.out : (reg j).Prime).ne_zero)) + (NeZero.ne M) + have hh := hL (Fin (N + 1)) J p ((Sum.elim tierB tierC) ∘ e) value hprime hdisjoint outside + childBound pivotBound T hf t + (movingPatternFinBulkData_follows e t (fun _ => small) slot perm pattern) + (movingPatternFinBulkData_levels e tierB tierC n m t (fun _ => small) slot perm pattern hB htier) + (movingPatternFinBulkData_regular_coherent e t (fun _ => small) slot perm pattern) + hsmall hfmod (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g hg (fun _ => Dq) + R hR hsmallR (fun side i => hden side i) hout reg hregular active sreg other greg + X lo hi hlo hhi φ G Jleft Jright hφ hlip hφout diagonal V hVR (Nat.cast_nonneg _) hVA hwindow hpupper + M inferInstance hperiod.1 (fun side o ho j hj => hperiod.2.1 _ (hcoverP side o ho j hj)) + (fun i => hperiod.2.2 i (Finset.mem_univ i)) + (by simpa only [hRegEq] using hcop) + ((∏ j, reg j) * M) hqpos (by simpa only [hRegEq] using hfull) rfl + houtside hreg hqs (by simpa only [hRegEq] using hpageReg) + hsreg hother hgreg henergy u v a b center hcenter huv hv hvcenter ha hab hb hweight hgnorm + rw [movingPatternPrimeObservable_outer_integral_crt e t (fun _ => small) slot perm + pattern primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input (giantProgressionCutoff L) + ψ X lo hi hlo hhi φ G x P hP hinj hR hprecision hcoverP hc hpage] + exact hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedObservable.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedObservable.lean new file mode 100644 index 0000000000000000000000000000000000000000..16cc8466dc5b29187cdfbd498ac7cae630f52775 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedObservable.lean @@ -0,0 +1,42 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkData +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedOuterFactor +import OAI.NumberTheory.Ostmann.Construction.RegularGiantMultiplier + +namespace OAI + +/-! # The original matched-history observable on the finite pattern sample space -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingOriginalPatternMatchedObservable {B C J : Type*} [Fintype J] + {N n m : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (reg : J → Fin (N + 1)) (active : J → Bool) (sreg : ℤ) + (other : (Fin (N + 1) → primes) → J → ℤ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (x : Fin (N + 1) → primes) : ℂ := by + let value := fun i => (x i : ℕ) + let : ∀ j, Fact (value (reg j)).Prime := fun j => ⟨hprimes _ (x (reg j)).property⟩ + exact complexPrimeInterval 1 0 a b (fun y => complexIntegerInterval 1 0 u v center (fun z => + movingOriginalSupportedOuterPair p value outside childBound pivotBound + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g (fun _ => Dq) Finset.univ + ψ X lo hi φ G Jleft Jright diagonal + (movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern) + t ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier (fun j => value (reg j)) active sreg + (fun j => (other x j : ZMod (value (reg j)))) (fun j => greg (value (reg j))) + ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ : ℂ))) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedPrimeRanges.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedPrimeRanges.lean new file mode 100644 index 0000000000000000000000000000000000000000..01939f9758bd3a3fec5f92b1dd175a9b759511a9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedPrimeRanges.lean @@ -0,0 +1,142 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternOriginalMatchedNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMatchedConditions + +namespace OAI + +/-! # The original signed matched-history bound from actual prime ranges and conductor deletion -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_matched_prime_ranges + (input : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (Afreq Wwin Bφ Dφ : ℝ) (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B C : Type) [Fintype B] [Fintype C] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (_rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] (_hinjp : Function.Injective p) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (active : Fin (movingPatternRegularSlots e n m small slot).length → Bool) + (sreg : ℤ) (sets : ∀ q : ℕ, Finset (ZMod q)) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (S : Finset ℤ) (ft : FrequencyTree (S × S) n) + [NeZero (frequencyModelBase S n ft ^ (n - 1 + 2))] (V : ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) (diagonal : Bool) + (E U u v a b center : ℝ), + let reg := (movingPatternRegularSlots e n m small slot).get + let other := fun (x : Fin (N + 1) → primes) => + movingRegularOther (fun i => (x i : ℕ)) outside (movingPatternRegularSlots e n m small slot) + let greg := normalizedResidueFamily sets + let R : ℤ := frequencyModelBase S n ft + let r := frequencyModelBase S n ft ^ (n - 1 + 2) + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ E → 0 ≤ U → (∀ j (q : primes), (q : ℝ) * μ j q ≤ E) → + (∀ q : primes, (q : ℝ) ≤ U) → + (∀ b, n ≤ tierB b) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ V) → + (∀ s, ‖f s‖ ≤ 1) → (∀ i, g i 0 = 0) → (∀ i z, ‖g i z‖ ≤ (p i : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + (V : ℝ) ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ z, |φ z| ≤ Bφ) → (∀ z w, |φ z - φ w| ≤ Dφ * |z - w|) → + (∀ z, 1 ≤ |z| → φ z = 0) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → u ≤ v → v ≤ u + 1 → v ≤ center + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ a → a ≤ b → b ≤ a + 1 → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b ft)) → + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) → + ∀ (tier : primes → ℕ) (lower cutoff : ℕ), + V ≤ lower → V < cutoff → cutoff ≤ lower → + (∀ j, j < n → ∀ q, μ j q ≠ 0 → tier q = j) → + (∀ j q, ν j q ≠ 0 → tier q = tierB j) → + (∀ j q, μ j q ≠ 0 → lower < (q : ℕ)) → + (∀ j q, ν j q ≠ 0 → lower < (q : ℕ)) → + (∀ q : primes, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ lower) → + MovingLeafLengthLE n small r₀ → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ V → + (∀ q, q.Prime → (sets q).Nonempty ∧ (sets q).card < q) → + let actual := movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p g Dq reg active sreg other greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center + let integral := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * + movingPatternPrimeObservable e t (fun _ => small) slot perm pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x) * + (Real.exp (z - center) : ℂ) / (y : ℂ) + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern actual x‖ ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern integral x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t (fun _ => small) (movingPatternBulkLeaves n m slot perm) pattern x‖ := by + filter_upwards [input.movingPattern_original_matched_norm ψ n r₀ k Afreq Wwin Bφ Dφ + hAfreq hWwin hBφ hDφ, movingPattern_matched_conditions input n r₀ k Afreq hAfreq] + with L hnorm hconditions + dsimp only + intro B C _ _ N e tierB tierC t small slot perm pattern rep primes hprimes μ ν p _ hinjp + g Dq active sreg sets f outside childBound pivotBound S ft _ V hfreq + X lo hi hlo hhi φ G Jleft Jright diagonal E U u v a b center + hμ hν hμmass hνmass hE hU hbound hsize hB htier hV hf hg hgnorm hout + hVA hwindow hpupper hφ hlip hφout hcenter huv hv hvcenter ha hab hb + ht hS tier lower cutoff hVlo hVcut hcutlo hμtier hνtier hμlo hνlo hupper + hp hsmall hdeleteμ hdeletep hdeleteν hsreg hsregV hsets + let m := spectatorBulkCount k L + let R := frequencyModelBase S n ft + let r := R ^ (n - 1 + 2) + let slots := movingPatternRegularSlots e n m small slot + let reg := slots.get + let other := fun (x : Fin (N + 1) → primes) => movingRegularOther (fun i => (x i : ℕ)) outside slots + have hR (b : Bool) : + (movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern b).frequencyProduct ∣ + (R : ℤ) := by + simpa only [ht, R] using + movingPattern_frequencyProduct_dvd e S ft (fun _ => small) slot perm pattern b + have hrp (i) : r.Coprime (p i) := by + exact ((prime_coprime_frequencyModelBase S V (p i) n Fact.out + (hVcut.trans_le (hp i).1) hS ft).pow_right _).symm + apply hnorm B C (Fin slots.length) N e tierB tierC t small slot perm pattern rep primes hprimes μ ν + p hinjp g Dq reg active sreg other (normalizedResidueFamily sets) f outside + childBound pivotBound (R : ℤ) r V hfreq X lo hi hlo hhi φ G Jleft Jright diagonal + E U u v a b center hμ hν hμmass hνmass hE hU hbound hsize hB htier hV hf hg hgnorm hout + hR (frequencyModelModulus_precision R n) hrp (fun i => hVcut.trans_le (hp i).1) + hVA hwindow hpupper hφ hlip hφout hcenter huv hv hvcenter ha hab hb + · intro x + exact naturalProduct_eq_finprod (fun i => (x i : ℕ)) slots + · intro x hx hgood + have hh := hconditions primes B C N e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) tier tierB μ ν pattern rep S V ft small slot perm p lower cutoff E + sreg sets Subtype.val_injective hμ hν hbound hμtier hνtier hB hS hVA hVlo hVcut hcutlo + hμlo hνlo hupper (fun i => ⟨Fact.out, (hp i).1, (hp i).2, hpupper i⟩) hsmall + hdeleteμ hdeletep hdeleteν hsreg hsregV hsets x hx outside + have hteq : tierC = fun c => movingSampleTier (rep c).val.2 := by + funext c + have hh := htier (rep c).val + simpa only [(rep c).property] using hh + simpa only [← ht, ← hteq] using hh (by simpa only [← ht] using hgood) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..613ab8548fbc49d9bc3fea0510899b53c3afd492 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMatchedProduct.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMatchedObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMatchedRegularProduct + +namespace OAI + +/-! # The original diagonal observable with its genuine common-product multiplier -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalPatternMatchedObservable_primeProduct {B C : Type*} + {N n m : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (x : Fin (N + 1) → primes) : + let slots := movingPatternRegularSlots e n m small slot + let value := fun i => (x i : ℕ) + movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes p g Dq + slots.get (fun _ => true) s + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside slots) greg f outside + childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center x = + complexPrimeInterval 1 0 a b (fun y => complexIntegerInterval 1 0 u v center (fun z => + movingOriginalSupportedOuterPair p value outside childBound pivotBound + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g (fun _ => Dq) Finset.univ + ψ X lo hi φ G Jleft Jright diagonal + (movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern) + t ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ * + (‖primeProductTransform greg (outside.prod * ⌊Real.exp z⌋₊ * ⌊Real.exp y⌋₊) + (MovingSlotReversal.naturalProduct value slots) s‖ ^ 2 : ℝ))) := by + dsimp only + unfold movingOriginalPatternMatchedObservable + dsimp only + apply congrArg (complexPrimeInterval 1 0 a b) + funext y + apply congrArg (complexIntegerInterval 1 0 u v center) + funext z + exact movingOriginalSupportedOuterPair_matched_regular_product e t small slot perm pattern + (fun i => (x i : ℕ)) (fun i => hprimes _ (x i).property) outside p g (fun _ => Dq) + greg s childBound pivotBound (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) + ψ X lo hi φ G Jleft Jright diagonal ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedCRT.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedCRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..47e5fadd23d880e24cc4af8a97cf1dd0d238b497 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedCRT.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedAverages +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternArithmeticComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeObservable + +namespace OAI + +/-! # Identifying the actual mixed-giant pattern with its corrected CRT mean -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- Each equality class contributes exactly one prime-square factor. -/ +theorem movingPatternHaarProduct_eq_image {A B C : Type*} [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (x : Fin (N + 1) → A) + (P : Finset ℕ) [∀ p : P, Fact p.val.Prime] + (hP : P = Finset.univ.image (fun c : C => prime (x (e.symm (.inr c))))) + (hinj : Function.Injective (fun c : C => prime (x (e.symm (.inr c))))) : + movingPatternHaarProduct e prime hprime n t small bulk pattern x = + ∏ p : P, movingInternalHaarAverage (fun i => prime (x i)) + (movingPatternFinData e n t small bulk pattern) p.val := by + let f : C → P := fun c => ⟨prime (x (e.symm (.inr c))), by + rw [hP] + exact Finset.mem_image.mpr ⟨c, Finset.mem_univ _, rfl⟩⟩ + have hf : Function.Bijective f := by + constructor + · intro a b hab + exact hinj (congrArg Subtype.val hab) + · intro p + have hp : p.val ∈ Finset.univ.image (fun c : C => prime (x (e.symm (.inr c)))) := by + simpa only [hP] using p.property + obtain ⟨c, _, hc⟩ := Finset.mem_image.mp hp + exact ⟨c, Subtype.ext hc⟩ + let T := movingPatternFinData e n t small bulk pattern + let : ∀ c : C, Fact (prime (x (e.symm (.inr c)))).Prime := fun _ => ⟨hprime _⟩ + change (∏ c : C, movingInternalHaarAverage (fun i => prime (x i)) T + (prime (x (e.symm (.inr c))))) = _ + exact Fintype.prod_equiv (Equiv.ofBijective f hf) _ _ (fun _ => rfl) + +section +variable {B C I : Type*} [Fintype C] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (input : PublishedProgressionInput) (Q : ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + +/-- The original mixed-prime observable, including its internal Haar factors, +is the corrected mean of the separated residue coefficient. -/ +theorem movingPatternPrimeObservable_crt (x : Fin (N + 1) → primes) + (P : Finset ℕ) [∀ q : P, Fact q.val.Prime] + [∀ b, NeZero (movingArithmeticModuli r p P Finset.univ b)] + [NeZero (∏ b, movingArithmeticModuli r p P Finset.univ b)] + (hP : P = Finset.univ.image (fun c : C => (x (e.symm (.inr c)) : ℕ))) + (hinj : Function.Injective (fun c : C => (x (e.symm (.inr c)) : ℕ))) + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hprecision : R ^ (n + 1) ∣ (r : ℤ)) + (hcover : ∀ b, ∀ o ∈ (movingPatternFinBulkData e n m t small slot perm pattern b).occurrences, + ∀ i ∈ o.current.compensationSlots, (x i : ℕ) ∈ P) + (hc : Pairwise (fun b c => (movingArithmeticModuli r p P Finset.univ b).Coprime + (movingArithmeticModuli r p P Finset.univ c))) + (hpage : pageAtModulus (∏ b, movingArithmeticModuli r p P Finset.univ b) + (selectedPageZero input Q) = pageAtModulus r (selectedPageZero input Q)) (u v : ℝ) : + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (T b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + movingPatternPrimeObservable e t small slot perm pattern primes hprimes childBound pivotBound + hfreq F E outside R r p g twist input Q v ψ X lo hi hlo hhi φ G (Real.exp u) (Real.exp v) x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot perm) pattern x = + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp u) (Real.exp v) * + correctedMixedPairAverage input Q (∏ b, movingArithmeticModuli r p P Finset.univ b) + (movingSeparatedPairResidueCoefficient p value outside F E g (fun b i => twist i b) + Finset.univ T nodes R) v := by + dsimp only + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t small slot perm pattern + let hf := movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq + let nodes := fun b => (T b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound (hf b) + (.prime false) (.prime true) + have h := movingSeparatedPairResidueCoefficient_page_factorization p value outside F E g + (fun b i => twist i b) T nodes R r P Finset.univ hf hR hprecision hcover hc input Q hpage v + have hspec : (∏ i : (Finset.univ : Finset I), + movingSpectatorHaarAverage value (p i.val) (g i.val) (fun b => twist i.val b) T) = + ∏ i : I, movingSpectatorHaarAverage value (p i) (g i) (twist i) T := by + exact Finset.prod_coe_sort Finset.univ + (fun i => movingSpectatorHaarAverage value (p i) (g i) (twist i) T) + rw [hspec] at h + rw [h, movingPatternHaarProduct_eq_image e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) t small (movingPatternBulkLeaves n m slot perm) pattern x P hP hinj] + unfold movingPatternPrimeObservable + let K := movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp u) (Real.exp v) + let A := movingFrequencyPageAverage value outside F E T nodes R r input Q v + let S := ∏ i, movingSpectatorHaarAverage value (p i) (g i) (twist i) T + let H := ∏ q : P, movingInternalHaarAverage value T q.val + change (K * (A * S)) * H = K * ((A * H) * S) + ring + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedHarmonicIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedHarmonicIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..e00cc095cde15a2a7fd35b227b91979e5d774441 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedHarmonicIntegral.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCoefficientMass +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternProducts +import OAI.NumberTheory.Ostmann.Characters.MixedPairIntegral + +namespace OAI + +/-! # Passing the signed original-pattern bound through both giant cells -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators + +theorem movingPattern_mixed_harmonic_integral_bound {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (G : (Fin (N + 1) → A) → ℝ → ℝ → ℂ) + (hG : ∀ x, Measurable (Function.uncurry (G x))) + (u v r s center D : ℝ) (hu : 1 ≤ u) (hr : 1 ≤ r) + (huv : u ≤ v) (hrs : r ≤ s) (hv : v ≤ u + 1) (hs : s ≤ r + 1) (hcenter : v ≤ center + 1) (hD : 0 ≤ D) + (K : (Fin (N + 1) → A) → ℝ) (hK : ∀ x, 0 ≤ K x) + (hbound : ∀ x a, a ∈ Set.Ioc u v → ∀ b, b ∈ Set.Ioc r s → ‖G x a b‖ ≤ K x) + (hmean : ∀ a ∈ Set.Ioc u v, ∀ b ∈ Set.Ioc r s, + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern (fun x => G x a b) x * + movingPatternHaarProduct e prime hprime n t small bulk pattern x‖ ≤ D) : + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern + (fun x => ∫ a in Set.Ioc u v, ∫ b in Set.Ioc r s, + G x a b * (Real.exp (a - center) : ℂ) / (b : ℂ)) x * + movingPatternHaarProduct e prime hprime n t small bulk pattern x‖ ≤ (2 * Real.exp 1 * D) / r := by + let w := movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) + let H := movingPatternHaarProduct e prime hprime n t small bulk pattern + have hpoint (a : ℝ) (ha : a ∈ Set.Ioc u v) (b : ℝ) (hb : b ∈ Set.Ioc r s) : + ‖∑ x, w x * (G x a b * H x)‖ ≤ D := by + have he (x) : movingOriginalPatternWeight e μ ν prime n pattern (fun x => G x a b) x * H x = + w x * (G x a b * H x) := by + rw [movingOriginalPatternWeight_eq_coefficient_mul] + exact mul_assoc _ _ _ + have hm := hmean a ha b hb + change ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern (fun x => G x a b) x * H x‖ ≤ D at hm + simpa only [he] using hm + have h := finite_mixed_pair_sum_norm u v r s center D hu hr huv hrs hv hs hcenter hD w + (fun x a b => G x a b * H x) (fun x => (hG x).mul_const (H x)) + (fun x => K x * ‖H x‖) (fun x => mul_nonneg (hK x) (norm_nonneg _)) + (by + intro x a ha b hb + rw [norm_mul] + exact mul_le_mul_of_nonneg_right (hbound x a ha b hb) (norm_nonneg _)) hpoint + have he (x) : movingOriginalPatternWeight e μ ν prime n pattern + (fun x => ∫ a in Set.Ioc u v, ∫ b in Set.Ioc r s, + G x a b * (Real.exp (a - center) : ℂ) / (b : ℂ)) x * H x = + w x * ∫ a in Set.Ioc u v, ∫ b in Set.Ioc r s, + (G x a b * H x) * (Real.exp (a - center) : ℂ) / (b : ℂ) := by + rw [movingOriginalPatternWeight_eq_coefficient_mul] + simp_rw [show ∀ a b : ℝ, (G x a b * H x) * (Real.exp (a - center) : ℂ) / (b : ℂ) = + (G x a b * (Real.exp (a - center) : ℂ) / (b : ℂ)) * H x by intros; ring, integral_mul_const] + exact mul_assoc _ _ _ + change ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern + (fun x => ∫ a in Set.Ioc u v, ∫ b in Set.Ioc r s, + G x a b * (Real.exp (a - center) : ℂ) / (b : ℂ)) x * H x‖ ≤ _ + simpa only [he] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedIntegralCRT.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedIntegralCRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..03c290b1a273571b83402d00f9a7b18b64130a6f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedIntegralCRT.lean @@ -0,0 +1,132 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedCRT +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterKernel + +namespace OAI + +/-! # Integrating the exact mixed CRT identity with its original outer factors -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype C] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (input : PublishedProgressionInput) (Q : ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + +/-- Any outer factor can be retained through the finite CRT identity and both +giant integrals. The physical integer measure is `exp(z-center) dz`. -/ +theorem movingPatternPrimeObservable_weighted_integral_crt (x : Fin (N + 1) → primes) + (P : Finset ℕ) [∀ q : P, Fact q.val.Prime] + [∀ b, NeZero (movingArithmeticModuli r p P Finset.univ b)] + [NeZero (∏ b, movingArithmeticModuli r p P Finset.univ b)] + (hP : P = Finset.univ.image (fun c : C => (x (e.symm (.inr c)) : ℕ))) + (hinj : Function.Injective (fun c : C => (x (e.symm (.inr c)) : ℕ))) + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hprecision : R ^ (n + 1) ∣ (r : ℤ)) + (hcover : ∀ b, ∀ o ∈ (movingPatternFinBulkData e n m t small slot perm pattern b).occurrences, + ∀ i ∈ o.current.compensationSlots, (x i : ℕ) ∈ P) + (hc : Pairwise (fun b c => (movingArithmeticModuli r p P Finset.univ b).Coprime + (movingArithmeticModuli r p P Finset.univ c))) + (hpage : pageAtModulus (∏ b, movingArithmeticModuli r p P Finset.univ b) + (selectedPageZero input Q) = pageAtModulus r (selectedPageZero input Q)) + (W : ℝ → ℝ → ℂ) (u v a b center : ℝ) : + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun side => (T side).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq side) + (.prime false) (.prime true) + (∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + (W z y * movingPatternPrimeObservable e t small slot perm pattern primes hprimes childBound pivotBound + hfreq F E outside R r p g twist input Q y ψ X lo hi hlo hhi φ G + (Real.exp z) (Real.exp y) x) * (Real.exp (z - center) : ℂ) / (y : ℂ)) * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot perm) pattern x = + ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + (W z y * movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) * + correctedMixedPairAverage input Q (∏ j, movingArithmeticModuli r p P Finset.univ j) + (movingSeparatedPairResidueCoefficient p value outside F E g (fun side i => twist i side) + Finset.univ T nodes R) y) * (Real.exp (z - center) : ℂ) / (y : ℂ) := by + dsimp only + rw [← integral_mul_const] + congr 1 + funext z + rw [← integral_mul_const] + congr 1 + funext y + have he := movingPatternPrimeObservable_crt e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist input Q ψ X lo hi hlo hhi φ G + x P hP hinj hR hprecision hcover hc hpage z y + dsimp only at he + calc + _ = (W z y * (movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist input Q y ψ X lo hi hlo hhi φ G + (Real.exp z) (Real.exp y) x * movingPatternHaarProduct e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) n t small (movingPatternBulkLeaves n m slot perm) pattern x)) * + (Real.exp (z - center) : ℂ) / (y : ℂ) := by ring + _ = _ := by rw [he]; ring + +/-- The ideal diagonal environment is exactly the same CRT integral, with +the two outer cutoffs and remaining inactive regular density retained. -/ +theorem movingPatternPrimeObservable_outer_integral_crt (x : Fin (N + 1) → primes) + (P : Finset ℕ) [∀ q : P, Fact q.val.Prime] + [∀ b, NeZero (movingArithmeticModuli r p P Finset.univ b)] + [NeZero (∏ b, movingArithmeticModuli r p P Finset.univ b)] + (hP : P = Finset.univ.image (fun c : C => (x (e.symm (.inr c)) : ℕ))) + (hinj : Function.Injective (fun c : C => (x (e.symm (.inr c)) : ℕ))) + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hprecision : R ^ (n + 1) ∣ (r : ℤ)) + (hcover : ∀ b, ∀ o ∈ (movingPatternFinBulkData e n m t small slot perm pattern b).occurrences, + ∀ i ∈ o.current.compensationSlots, (x i : ℕ) ∈ P) + (hc : Pairwise (fun b c => (movingArithmeticModuli r p P Finset.univ b).Coprime + (movingArithmeticModuli r p P Finset.univ c))) + (hpage : pageAtModulus (∏ b, movingArithmeticModuli r p P Finset.univ b) + (selectedPageZero input Q) = pageAtModulus r (selectedPageZero input Q)) + (density Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) : + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun side => (T side).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq side) + (.prime false) (.prime true) + (∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * (density : ℂ)) * + movingPatternPrimeObservable e t small slot perm pattern primes hprimes childBound pivotBound + hfreq F E outside R r p g twist input Q y ψ X lo hi hlo hhi φ G + (Real.exp z) (Real.exp y) x) * (Real.exp (z - center) : ℂ) / (y : ℂ)) * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot perm) pattern x = + ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal + (Real.exp z) (Real.exp y) * (Real.exp (z - center) : ℂ) * + ((density : ℂ) * correctedMixedPairAverage input Q + (∏ j, movingArithmeticModuli r p P Finset.univ j) + (movingSeparatedPairResidueCoefficient p value outside F E g (fun side i => twist i side) + Finset.univ T nodes R) y) / (y : ℂ) := by + dsimp only + rw [movingPatternPrimeObservable_weighted_integral_crt e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist input Q ψ X lo hi hlo hhi φ G + x P hP hinj hR hprecision hcover hc hpage] + congr 1 + funext z + congr 1 + funext y + unfold movingOuterKernel + ring + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedIntegratedRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedIntegratedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ae49bdc45878f91dbb991ee35fe38c9e5c964d0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedIntegratedRate.lean @@ -0,0 +1,216 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedSameNormArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedHarmonicIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # The actual two-prime arithmetic bound integrated over its giant cells -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_same_assignment_mixed_prime_integral_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (W : ℝ → ℝ → (Fin (N + 1) → primes) → ℂ) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG center : ℝ), + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (Fw true) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := fun xg y => movingPatternPrimeObservable e t small slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + let obs := fun xg y x => W xg y x * raw xg y x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i b j, + j ∈ flattenMovingSlots n (small b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, Measurable (fun z : ℝ × ℝ => W z.1 z.2 x)) → + (∀ xg y x, ‖W xg y x‖ ≤ 1) → + (∀ xg y x z, W xg y (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) = W xg y x) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (fun x => ∫ xg in Set.Ioc uG vG, ∫ y in Set.Ioc rG sG, + obs xg y x * (Real.exp (xg - center) : ℂ) / (y : ℂ)) x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + (2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG := by + filter_upwards [P.movingPattern_same_assignment_mixed_prime_arithmetic_rate ψ n r₀ k + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ, + eventually_ge_atTop (0 : ℝ)] with L hrate hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq Fw outside _ p _ hc _ twist sets + Qfreq X j₀ φ G u v deleted initial μ ν W Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hWmeas hW hWbulk hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq n ft + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let raw := fun xg y => movingPatternPrimeObservable e t small slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + let obs := fun xg y x => W xg y x * raw xg y x + let amp := 2 * (‖movingDataWeight (Fw false) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (Fw true) (fun _ _ _ _ => 1) (data true)‖) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let bound := ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) + have hmean (xg : ℝ) (hxg : xg ∈ Set.Ioc uG vG) (y : ℝ) (hy : y ∈ Set.Ioc rG sG) : + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (obs xg y) x * movingPatternHaarProduct e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) n t small + (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ bound := by + exact hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes childBound pivotBound hfreq Fw outside p hc twist sets Qfreq y X j₀ φ G + (Real.exp xg) (Real.exp y) u v deleted initial μ ν (W xg y) Eprior αall βint Vint Uall + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp (by linarith [hy.1]) + hpupper hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hSS hdel hmass + hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint + hVint hUall hμbound hμall hνall hμmax hμmin hvalues (hW xg y) (hWbulk xg y) + (hdisjoint xg hxg y hy) (hcross xg hxg y hy) (hfmod xg hxg y hy) + have hA₀ : 0 ≤ A₀ := by + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro z hz + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hz + exact pairFrequencySupportBound_nonneg D f + exact mul_nonneg (by positivity) (mul_nonneg hleaf0 hprod) + have hcost : 0 ≤ cost := by dsimp only [cost, amp]; positivity + have herr := movingInternalArithmeticError_nonneg n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + (Real.one_le_exp (mul_nonneg hA (Nat.cast_nonneg m))) hUall hαall hβint hVint.le + have hbound : 0 ≤ bound := by dsimp only [bound]; positivity + apply movingPattern_mixed_harmonic_integral_bound e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) μ ν t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) + pattern (fun x xg y => obs xg y x) _ uG vG rG sG center bound huG hrG huvG hrsG hvG hsG hcenter + hbound (fun _ => cost) (fun _ => hcost) _ hmean + · intro x + exact (hWmeas x).mul (movingPatternPrimeObservable_measurable e t small slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq ψ X lo hi hlo hhi φ G Bφ Dφ hBφ hDφ hφ hlip hφout x) + · intro x xg hxg y hy + have hh := movingPatternPrimeObservable_norm e tierB tierC t small slot (Equiv.refl _) pattern + hB htier primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G + Bφ Dφ hBφ hDφ hφ hlip hφout (Real.exp xg) (Real.exp y) + (by linarith [hy.1]) (fun i => (p i : ℝ)) (fun _ => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + change ‖W xg y x * raw xg y x‖ ≤ cost + rw [norm_mul] + exact (mul_le_mul (hW xg y x) hh (norm_nonneg _) (by norm_num)).trans_eq (one_mul _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedMeasurable.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedMeasurable.lean new file mode 100644 index 0000000000000000000000000000000000000000..e9aced1d3b4796137e90c16ac25dbad9d71a4205 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedMeasurable.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeObservable +import OAI.NumberTheory.Ostmann.Characters.MixedPairHaarRegularity +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePairHaarRegularity +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelTransport + +namespace OAI + +/-! # Measurability of the original two-prime pattern integrand -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (input : PublishedProgressionInput) (Q : ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + +theorem movingPatternPrimeObservable_measurable + (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (x : Fin (N + 1) → primes) : + Measurable (fun z : ℝ × ℝ => + movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist input Q z.2 + ψ X lo hi hlo hhi φ G (Real.exp z.1) (Real.exp z.2) x) := by + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t small slot perm pattern + let hf := movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq + let nodes := fun b => (T b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound (hf b) + (.prime false) (.prime true) + have hk := measurable_exp_pair_mul (movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G) + (measurable_movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + Bφ Dφ hBφ hDφ hφ hlip hout) (1 : ℂ) + simp only [one_mul] at hk + have ha := (continuous_correctedMixedPairAverage input Q r + (fun a b => movingFrequencyPairFactor value outside F E T nodes R a b)).measurable.comp (show Measurable (Prod.snd : ℝ × ℝ → ℝ) from measurable_snd) + change Measurable (fun z : ℝ × ℝ => + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp z.1) (Real.exp z.2) * + (movingFrequencyPageAverage value outside F E T nodes R r input Q z.2 * + ∏ i, movingSpectatorHaarAverage value (p i) (g i) (twist i) T)) + exact hk.mul (ha.mul measurable_const) + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedNormalizedNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedNormalizedNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..803bfeb8636f763ae3f860b5498bd14a4e1fc481 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedNormalizedNorm.lean @@ -0,0 +1,332 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenBulkFrequencyNorm +import OAI.NumberTheory.Ostmann.Arithmetic.BulkResidueAbsolute + +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenUnitArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSpectatorUnits +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkFrozen +import OAI.NumberTheory.Ostmann.Characters.NormalizedResidueIndicator + +namespace OAI + +/-! # Mixed arithmetic norm with distinct giant and bulk Page cutoffs -/ + +namespace Ostmann +open scoped Classical BigOperators + +section +variable {σ I : Type*} [Fintype I] (base : σ → ℕ) (tier : σ → ℕ) (S : Finset ℤ) (n m R : ℕ) + [NeZero (R ^ (n - 1 + 2))] (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0) (hR : ∀ b (j : Fin (2 ^ n - 1)), + (singleTreeNodeFrequencies S n (frequencyPairProjection S n b t) j.val).root.natAbs ∣ R) + (slot : (TreeLeafIndex n × Fin m) ↪ σ) + (small : Bool → TreeLeafTuple (List σ) n) (a : Bool → MovingSampleSlots σ n) + (hslot : ∀ j, n ≤ tier (slot j)) + (hsmall : ∀ b i, i ∈ flattenMovingSlots n (small b) → i ∉ Set.range slot) + (ha : ∀ b, (a b).Levels tier) + (hbase : ∀ i ∉ Set.range slot, IsCoprime (base i : ℤ) (R : ℤ)) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℤ → ℤ → ℝ) + (N : ℕ) (D : ℝ) (hD : 0 ≤ D) (hN : ∀ s ∈ S, s.natAbs ≤ N) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) + (hm : 0 < m) + +include hslot hsmall ha hbase hS hR hD hN hdiv hm in +/-- The nonnegative original arithmetic model retains the frequency saving, +the absolute spectator moments and the exact number of bulk Page factors. -/ +theorem frozenArithmetic_same_assignment_mixed_norm + (p : I → ℕ) [∀ i, Fact (p i).Prime] + [NeZero (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli (R ^ (n - 1 + 2)) p i).Coprime + (bulkResidueModuli (R ^ (n - 1 + 2)) p j))) + (hp : ∀ i, 3 ≤ p i) + (hfreq : ∀ i b, movingGiantFrequencyUnits (p i) n + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t))) + (hsmallp : ∀ i b, ((treeLeafProduct n (movingSlotValues base n (small b)) : ℕ) : ZMod (p i)) ≠ 0) + (hasamples : ∀ i b, ((a b).values base).UnitsAt (p i)) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (henergy : ∀ i, ∑ x : ZMod (p i), ‖g i x‖ ^ 2 ≤ (p i : ℝ)) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (outside : List ℕ) (childBound : ℕ → ℕ) (input : PublishedProgressionInput) (Qfreq Qbulk : ℕ) + (Y : ℝ) (hY : 0 ≤ Y) (Ybulk : TreeLeafIndex n × Fin m → ℝ) (hYbulk : ∀ j, 0 ≤ Ybulk j) : + let ts := fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t) + let T := fun b => buildMovingSlotData n (ts b) (small b) (bulkSlotLeaves n m slot) (a b) + let Freq := frozenBulkFrequencyFactor base slot outside F E T childBound R + (R ^ (n - 1 + 2)) input Qfreq Y + let Spec := fun i => frozenBulkSpectatorHaar base n m ts small a (twist i) (Equiv.refl _) (g i) + (Fintype.card (TreeLeafIndex n × Fin m → + (ZMod (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i))ˣ) : ℝ)⁻¹ * + (∑ x : TreeLeafIndex n × Fin m → + (ZMod (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i))ˣ, + ‖(Freq (bulkResidueEquiv (R ^ (n - 1 + 2)) p hc x).1 * + ∏ j, pageGiantWeight input Qbulk (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i) + (x j).val.val (Ybulk j)) * + ∏ i, Spec i ((bulkResidueEquiv (R ^ (n - 1 + 2)) p hc x).2 i)‖) ≤ + (2 : ℝ) ^ (2 ^ n * m) * + ((2 * ((‖movingDataWeight (F false) (E false) (T false)‖ * + ‖movingDataWeight (F true) (E true) (T true)‖) * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod)) * + (3 : ℝ) ^ (2 ^ n * Fintype.card I)) := by + intro ts T Freq Spec + let B := 2 * ((‖movingDataWeight (F false) (E false) (T false)‖ * + ‖movingDataWeight (F true) (E true) (T true)‖) * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod) + have hprob : 0 ≤ ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro c hc + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hc + exact pairFrequencySupportBound_nonneg D f + have hB : 0 ≤ B := by dsimp [B]; positivity + have hFreq : (Fintype.card (TreeLeafIndex n × Fin m → (ZMod (R ^ (n - 1 + 2)))ˣ) : ℝ)⁻¹ * + ∑ z, ‖Freq z‖ ≤ B := + frozenBulkFrequencyFactor_mean_le base tier S n m R t hS hR slot small a hslot hsmall ha + hbase F E N D hD hN hdiv hm outside childBound input Qfreq Y hY + have hSpec (i : I) : (Fintype.card (TreeLeafIndex n × Fin m → (ZMod (p i))ˣ) : ℝ)⁻¹ * + ∑ z, ‖Spec i z‖ ≤ (3 : ℝ) ^ (2 ^ n) := + frozenBulkSpectatorHaar_absolute_mean_le (hp i) base n m hm ts small a + (hfreq i) (hsmallp i) (hasamples i) (twist i) (Equiv.refl _) (g i) (hg i) (henergy i) + have h := bulk_residue_absolute_mean_le (I := I) (J := TreeLeafIndex n × Fin m) + (R ^ (n - 1 + 2)) p hc input Qbulk Ybulk hYbulk + Freq Spec B hB (fun _ => (3 : ℝ) ^ (2 ^ n)) + (by + simp only [finite_univ_canonical, Fintype.card_eq_nat_card] at hFreq ⊢ + exact hFreq) + (by + intro i + have hi := hSpec i + simp only [finite_univ_canonical, Fintype.card_eq_nat_card] at hi ⊢ + exact hi) + simp only [Fintype.card_prod, card_treeLeafIndex, Fintype.card_fin, Finset.prod_const, + Finset.card_univ, ← pow_mul, B] at h + simp only [finite_univ_canonical, Fintype.card_eq_nat_card] at h ⊢ + exact h + +end + +noncomputable def frozenMixedUnitArithmeticMean {σ I : Type*} [Fintype I] + (base : σ → ℕ) (n m R : ℕ) [NeZero (R ^ (n - 1 + 2))] + (ts : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List σ) n) + (a : Bool → MovingSampleSlots σ n) (slot : (TreeLeafIndex n × Fin m) ↪ σ) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (outside : List ℕ) (childBound : ℕ → ℕ) (input : PublishedProgressionInput) (Qfreq Qbulk : ℕ) + (Y : ℝ) (p : I → ℕ) [∀ i, Fact (p i).Prime] + [NeZero (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli (R ^ (n - 1 + 2)) p i).Coprime + (bulkResidueModuli (R ^ (n - 1 + 2)) p j))) + (g : ∀ i, ZMod (p i) → ℂ) (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (Ybulk : TreeLeafIndex n × Fin m → ℝ) : ℝ := + let T := fun b => buildMovingSlotData n (ts b) (small b) (bulkSlotLeaves n m slot) (a b) + let Freq := frozenBulkFrequencyFactor base slot outside F (fun _ _ _ _ _ => 1) T childBound R + (R ^ (n - 1 + 2)) input Qfreq Y + let Spec := fun i => frozenBulkSpectatorHaar base n m ts small a (twist i) (Equiv.refl _) (g i) + (Fintype.card (TreeLeafIndex n × Fin m → + (ZMod (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i))ˣ) : ℝ)⁻¹ * + ∑ x : TreeLeafIndex n × Fin m → (ZMod (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i))ˣ, + ‖(Freq (bulkResidueEquiv (R ^ (n - 1 + 2)) p hc x).1 * + ∏ j, pageGiantWeight input Qbulk (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i) + (x j).val.val (Ybulk j)) * + ∏ i, Spec i ((bulkResidueEquiv (R ^ (n - 1 + 2)) p hc x).2 i)‖ + +theorem frozenMixedUnitArithmeticMean_nonneg {σ I : Type*} [Fintype I] + (base : σ → ℕ) (n m R : ℕ) [NeZero (R ^ (n - 1 + 2))] + (ts : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List σ) n) + (a : Bool → MovingSampleSlots σ n) (slot : (TreeLeafIndex n × Fin m) ↪ σ) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (outside : List ℕ) (childBound : ℕ → ℕ) (input : PublishedProgressionInput) (Qfreq Qbulk : ℕ) + (Y : ℝ) (p : I → ℕ) [∀ i, Fact (p i).Prime] + [NeZero (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli (R ^ (n - 1 + 2)) p i).Coprime + (bulkResidueModuli (R ^ (n - 1 + 2)) p j))) + (g : ∀ i, ZMod (p i) → ℂ) (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (Ybulk : TreeLeafIndex n × Fin m → ℝ) : + 0 ≤ frozenMixedUnitArithmeticMean base n m R ts small a slot F outside childBound input Qfreq Qbulk Y + p hc g twist Ybulk := by unfold frozenMixedUnitArithmeticMean; positivity + +theorem frozenMixedUnitArithmeticMean_le {σ I : Type*} [Fintype I] + (base : σ → ℕ) (tier : σ → ℕ) (S : Finset ℤ) (n m R N V : ℕ) + [NeZero (R ^ (n - 1 + 2))] (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0) (hN : ∀ s ∈ S, s.natAbs ≤ N) + (hR : ∀ b (j : Fin (2 ^ n - 1)), + (singleTreeNodeFrequencies S n (frequencyPairProjection S n b t) j.val).root.natAbs ∣ R) + (slot : (TreeLeafIndex n × Fin m) ↪ σ) + (small : Bool → TreeLeafTuple (List σ) n) (a : Bool → MovingSampleSlots σ n) + (hslot : ∀ j, n ≤ tier (slot j)) + (hsmall : ∀ b i, i ∈ flattenMovingSlots n (small b) → i ∉ Set.range slot) + (ha : ∀ b, (a b).Levels tier) + (hbase : ∀ i ∉ Set.range slot, IsCoprime (base i : ℤ) (R : ℤ)) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (hF : ∀ b s regular, ‖F b (.leaf s regular) s‖ ≤ if s.natAbs ≤ V then 1 else 0) + (D : ℝ) (hD : 0 ≤ D) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) (hm : 0 < m) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + [NeZero (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli (R ^ (n - 1 + 2)) p i).Coprime + (bulkResidueModuli (R ^ (n - 1 + 2)) p j))) (hp : ∀ i, 3 ≤ p i) + (hfreq : ∀ i b, movingGiantFrequencyUnits (p i) n + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t))) + (hsmallp : ∀ i b, ((treeLeafProduct n (movingSlotValues base n (small b)) : ℕ) : ZMod (p i)) ≠ 0) + (hasamples : ∀ i b, ((a b).values base).UnitsAt (p i)) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (henergy : ∀ i, ∑ x : ZMod (p i), ‖g i x‖ ^ 2 ≤ (p i : ℝ)) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (outside : List ℕ) (childBound : ℕ → ℕ) + (input : PublishedProgressionInput) (Qfreq Qbulk : ℕ) (Y : ℝ) (hY : 0 ≤ Y) + (Ybulk : TreeLeafIndex n × Fin m → ℝ) (hYbulk : ∀ j, 0 ≤ Ybulk j) : + frozenMixedUnitArithmeticMean base n m R + (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t)) + small a slot F outside childBound input Qfreq Qbulk Y p hc g twist Ybulk ≤ + ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * Fintype.card I)) * + (frequencyLeafWeight (pairedFrequencyLeaf S V) n t * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod) := by + have h := frozenArithmetic_same_assignment_mixed_norm base tier S n m R t hS hR slot small a + hslot hsmall ha hbase F (fun _ _ _ _ _ => 1) N D hD hN hdiv hm p hc hp hfreq + hsmallp hasamples g hg henergy twist outside childBound input Qfreq Qbulk Y hY Ybulk hYbulk + have hamp := movingDataWeight_pair_unit_leaf_bound F V hF S n t small (bulkSlotLeaves n m slot) a + have hprob : 0 ≤ ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro c hc + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hc + exact pairFrequencySupportBound_nonneg D f + have hbound := mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left (mul_le_mul_of_nonneg_right hamp hprob) (by norm_num : (0 : ℝ) ≤ 2)) + (by positivity : (0 : ℝ) ≤ 3 ^ (2 ^ n * Fintype.card I))) + (by positivity : (0 : ℝ) ≤ 2 ^ (2 ^ n * m)) + have h' : frozenMixedUnitArithmeticMean base n m R + (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t)) + small a slot F outside childBound input Qfreq Qbulk Y p hc g twist Ybulk ≤ _ := h + exact h'.trans (hbound.trans_eq (by ring)) + +theorem movingPattern_same_assignment_mixed_norm {B C I : Type*} [Fintype I] {N₀ n m : ℕ} + (e : Fin (N₀ + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (S : Finset ℤ) (t : FrequencyTree (S × S) n) (R N V : ℕ) + [NeZero (R ^ (n - 1 + 2))] + (hS : ∀ s ∈ S, s ≠ 0) (hN : ∀ s ∈ S, s.natAbs ≤ N) + (hR : ∀ b (j : Fin (2 ^ n - 1)), + (singleTreeNodeFrequencies S n (frequencyPairProjection S n b t) j.val).root.natAbs ∣ R) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b i, i ∈ flattenMovingSlots n (small b) → i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N₀ + 1) → ℕ) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), IsCoprime (base i : ℤ) (R : ℤ)) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N₀ + 1)) k → ℤ → ℂ) + (hF : ∀ b s regular, ‖F b (.leaf s regular) s‖ ≤ if s.natAbs ≤ V then 1 else 0) + (D : ℝ) (hD : 0 ≤ D) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) (hm : 0 < m) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + [NeZero (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli (R ^ (n - 1 + 2)) p i).Coprime + (bulkResidueModuli (R ^ (n - 1 + 2)) p j))) (hp : ∀ i, 3 ≤ p i) + (hfreq : ∀ i b, movingGiantFrequencyUnits (p i) n + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t))) + (hsmallp : ∀ i b j, j ∈ flattenMovingSlots n (small b) → + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) + (hasamples : ∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (henergy : ∀ i, ∑ x : ZMod (p i), ‖g i x‖ ^ 2 ≤ (p i : ℝ)) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (outside : List ℕ) (childBound : ℕ → ℕ) + (input : PublishedProgressionInput) (Qfreq Qbulk : ℕ) (Y : ℝ) (hY : 0 ≤ Y) + (Ybulk : TreeLeafIndex n × Fin m → ℝ) (hYbulk : ∀ j, 0 ≤ Ybulk j) : + let ts := fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t) + let data := movingPatternFinBulkData e n m ts small slot (Equiv.refl _) pattern + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F (fun _ _ _ _ _ => 1) data childBound R (R ^ (n - 1 + 2)) input Qfreq Y + let spec := fun i => frozenBulkSpectatorHaar base n m ts + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) (Equiv.refl _) (g i) + let M := ∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i + let A := fun z => freq (bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).2 i) + (Fintype.card (TreeLeafIndex n × Fin m → (ZMod M)ˣ) : ℝ)⁻¹ * + (∑ z : TreeLeafIndex n × Fin m → (ZMod M)ˣ, + ‖A z * ∏ j, pageGiantWeight input Qbulk M (z j).val.val (Ybulk j)‖) ≤ + ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * Fintype.card I)) * + (frequencyLeafWeight (pairedFrequencyLeaf S V) n t * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod) := by + intro ts data freq spec M A + have hslot (j : TreeLeafIndex n × Fin m) : + n ≤ ((Sum.elim tierB tierC) ∘ e) (movingPatternBulkEmbedding e slot j) := by + change n ≤ Sum.elim tierB tierC (e (e.symm (.inl (slot j)))) + simpa only [Equiv.apply_symm_apply, Sum.elim_inl] using hB (slot j) + have hd : data = fun b => buildMovingSlotData n (ts b) (movingPatternFiniteSmall e n (small b)) + (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot)) (movingPatternFiniteSamples e n pattern b) := by + funext b + dsimp only [data] + rw [movingPatternFinBulkData_build] + cases b <;> rfl + have h := frozenMixedUnitArithmeticMean_le base ((Sum.elim tierB tierC) ∘ e) S n m R N V t + hS hN hR (movingPatternBulkEmbedding e slot) (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) hslot + (fun b => movingPatternFiniteSmall_absent e slot (small b) (hsmall b)) + (movingPatternFiniteSamples_levels e tierB tierC n pattern htier) hbase F hF D hD hdiv hm p hc hp hfreq + (fun i b => movingPatternFiniteSmall_unit e base (small b) (hsmallp i b)) + (fun i => movingPatternFiniteSamples_units e base pattern (hasamples i)) + g hg henergy twist outside childBound input Qfreq Qbulk Y hY Ybulk hYbulk + dsimp only [A, freq, spec, M] + rw [hd] + unfold frozenMixedUnitArithmeticMean at h + dsimp only at h + simp only [finite_univ_canonical, Fintype.card_eq_nat_card] at h ⊢ + apply le_trans (le_of_eq ?_) h + congr 1 + apply Finset.sum_congr rfl + intro z _ + congr 1 + exact mul_right_comm _ _ _ + +theorem movingPattern_normalized_same_assignment_mixed_norm {B C I : Type*} [Fintype I] {N₀ n m : ℕ} + (e : Fin (N₀ + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (S : Finset ℤ) (t : FrequencyTree (S × S) n) (R N V : ℕ) + [NeZero (R ^ (n - 1 + 2))] + (hS : ∀ s ∈ S, s ≠ 0) (hN : ∀ s ∈ S, s.natAbs ≤ N) + (hR : ∀ b (j : Fin (2 ^ n - 1)), + (singleTreeNodeFrequencies S n (frequencyPairProjection S n b t) j.val).root.natAbs ∣ R) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b i, i ∈ flattenMovingSlots n (small b) → i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N₀ + 1) → ℕ) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), IsCoprime (base i : ℤ) (R : ℤ)) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N₀ + 1)) k → ℤ → ℂ) + (hF : ∀ b s regular, ‖F b (.leaf s regular) s‖ ≤ if s.natAbs ≤ V then 1 else 0) + (D : ℝ) (hD : 0 ≤ D) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) (hm : 0 < m) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + [NeZero (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli (R ^ (n - 1 + 2)) p i).Coprime + (bulkResidueModuli (R ^ (n - 1 + 2)) p j))) (hp : ∀ i, 3 ≤ p i) + (hfreq : ∀ i b, movingGiantFrequencyUnits (p i) n + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t))) + (hsmallp : ∀ i b j, j ∈ flattenMovingSlots n (small b) → + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) + (hasamples : ∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) + (sets : ∀ i, Finset (ZMod (p i))) + (hsets : ∀ i, (sets i).Nonempty) (hsetsLt : ∀ i, (sets i).card < p i) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (outside : List ℕ) (childBound : ℕ → ℕ) + (input : PublishedProgressionInput) (Qfreq Qbulk : ℕ) (Y : ℝ) (hY : 0 ≤ Y) + (Ybulk : TreeLeafIndex n × Fin m → ℝ) (hYbulk : ∀ j, 0 ≤ Ybulk j) : + let ts := fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t) + let data := movingPatternFinBulkData e n m ts small slot (Equiv.refl _) pattern + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F (fun _ _ _ _ _ => 1) data childBound R (R ^ (n - 1 + 2)) input Qfreq Y + let spec := fun i => frozenBulkSpectatorHaar base n m ts + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) (Equiv.refl _) (normalizedResidueTransform (sets i)) + let M := ∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i + let A := fun z => freq (bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).2 i) + (Fintype.card (TreeLeafIndex n × Fin m → (ZMod M)ˣ) : ℝ)⁻¹ * + (∑ z : TreeLeafIndex n × Fin m → (ZMod M)ˣ, + ‖A z * ∏ j, pageGiantWeight input Qbulk M (z j).val.val (Ybulk j)‖) ≤ + ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * Fintype.card I)) * + (frequencyLeafWeight (pairedFrequencyLeaf S V) n t * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod) := by + exact movingPattern_same_assignment_mixed_norm e tierB tierC S t R N V hS hN hR small slot pattern + hsmall hB htier base hbase F hF D hD hdiv hm p hc hp hfreq hsmallp hasamples + (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) + (fun i => (normalizedResidueTransform_energy (sets i) (hsets i) (hsetsLt i)).le) + twist outside childBound input Qfreq Qbulk Y hY Ybulk hYbulk + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedOriginalNormArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedOriginalNormArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..5393748039bbfe1146b3fa3c078a38b91a21a7e4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedOriginalNormArithmetic.lean @@ -0,0 +1,199 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedPrimeSelectedNormRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMultiplier + +namespace OAI + +/-! # The norm estimate with the original internal and external priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_mixed_prime_norm_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (W : (Fin (N + 1) → primes) → ℂ) (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U + let obs := fun x => W x * raw x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + 0 ≤ A₀ → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + let freq := frozenBulkFrequencyFactor (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) + outside Fw Ew data childBound R r P Qfreq y + let spec := fun i => frozenBulkSpectatorHaar (fun i => (x i : ℕ)) n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + ∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, ‖W x‖ ≤ 1) → + (∀ x z, W (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) = W x) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot perm) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + filter_upwards [P.movingPattern_selected_mixed_prime_norm_rate ψ n r₀ k + A Wwin Bφ Dφ F Cmass hA hWwin hF hCmass hBφ hDφ] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq y X A₀ j₀ φ G XL U u v deleted initial + μ ν W Eprior αall βint Vint Uall hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper + hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout + hA₀ hlocal c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hW hWbulk hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let raw := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U + let obs := fun x => W x * raw x + let cost := (2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hpoint (x) : ‖obs x‖ ≤ cost := by + have hh := movingPatternPrimeObservable_norm e tierB tierC t small slot perm pattern hB htier + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + change ‖W x * raw x‖ ≤ cost + rw [norm_mul] + exact (mul_le_mul (hW x) hh (norm_nonneg _) (by norm_num)).trans_eq (one_mul _) + have hminor (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ‖movingPatternBulkMean e ν slot obs x‖ ≤ + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + have hh := hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern primes hprimes x + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq y X A₀ j₀ φ G XL U u v (deleted x) + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS (hdel x hx) hmass (hdelbase x hx) hout (hdelout x hx) + hA₀ (hlocal x hx) c₀ initial hsub (hretain x hx) ν hν + change ‖movingPatternBulkMean e ν slot (fun x => W x * raw x) x‖ ≤ _ + rw [movingPatternBulkMean_weight e ν slot W raw hWbulk x, norm_mul] + exact (mul_le_mul (hW x) hh (norm_nonneg _) (by norm_num)).trans_eq (one_mul _) + have hfinal := movingPattern_signed_arithmetic_on_support e (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) tierB tierC t small + (movingPatternBulkLeaves n m slot perm) pattern rep + (fun b j _ => hB j) (fun b j _ => hB j) htier + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hUall + (movingPatternFinBulkData_size e t small slot perm pattern hsmallLen) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hV) + (fun q => by + simpa only [Int.cast_natCast, abs_of_nonneg (show (0 : ℝ) ≤ (q : ℕ) from Nat.cast_nonneg _)] + using hvalues q) + μ ν hμ0 hν0 hμmass hνmass Eprior αall βint Vint hEprior hαall hβint hVint + hμbound hμall hνall hμmax hμmin obs cost (by dsimp only [cost]; positivity) + hpoint hdisjoint hcross hfmod m slot perm rfl + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hminor + (fun _ => Classical.arbitrary primes) + simpa only [movingInternalArithmeticError, obs, raw, cost, data, m] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeInitialNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeInitialNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..0cf5ddeb9a75addfb3ba0d904585667d3afada55 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeInitialNormRate.lean @@ -0,0 +1,177 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedPrimeNormRate +import OAI.NumberTheory.Ostmann.Construction.NestedPrimePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNorm + +namespace OAI + +/-! # Retaining the norm bound under the initial bulk law -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_initial_mixed_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq y + let spec := fun i => frozenBulkSpectatorHaar base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex n × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (initial j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U x‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + have hconditional := P.movingPattern_original_mixed_prime_norm_rate ψ n r₀ k + A Wwin Bφ Dφ F Cmass hA hWwin hF hCmass hBφ hDφ + filter_upwards [hconditional, movingPattern_bad_event_rate_window ψ n r₀ k + A Wwin Bφ Dφ F (Cmass + 1) hA hWwin hF, + P.original_harmonic_box_rate Cmass hCmass, eventually_ge_atTop (2000 : ℝ)] + with L hconditional hbad hnormal hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq y X A₀ j₀ φ G XL U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hbd := hbad lo hi hhi hwindow p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hdeletedBound := hconditional lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq y X A₀ + j₀ φ G XL U u v deleted hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ + hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout + hA₀ hlocal c₀ + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * W + have hpoint (x : (TreeLeafIndex n × Fin m) → primes) : + ‖movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U x‖ ≤ cost := + movingPatternPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hcollision : 0 ≤ cost * (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * + Real.exp ((Cmass + 1) * L - Real.exp ((39 / 10000 : ℝ) * L)) := by + dsimp only [cost, W, amp] + positivity + have hreturnCost := (le_add_of_nonneg_left hcollision).trans hbd + have hcost0 : 0 ≤ cost := by dsimp only [cost, W, amp]; positivity + have hfinal := @nested_prime_prior_three_errors (TreeLeafIndex n × Fin m) + inferInstance primes S initial deleted hS hsub hretain (fun j => (hnorm j).1) + (fun x => movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U x) + cost (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L))) + (Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcost0 hpoint + (by simpa only [finite_univ_canonical, m, S, M] using hdeletedBound) + (by simpa only [finite_univ_canonical, cost, W, m, Z] using hreturnCost) + simpa only [finite_univ_canonical, m, S, M] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeNormBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeNormBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..77bbd98fca1c505110b7f122492a1d2e5c6909c3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeNormBound.lean @@ -0,0 +1,135 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelNormBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternNormKernel +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSpectatorNorm + +namespace OAI + +/-! # The norm estimate for the literal mixed-giant prime mean -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell : Type*} [Fintype Cell] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q Qfreq : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +include hsmall hB htier hR hr hg hV hBφ hDφ hφ hlip hφout j₀ in +/-- Transfer a retained arithmetic absolute mean to the original prime law, +with the sharp window factor in the main term and the established variation +budget in the approximation errors. -/ +theorem PublishedProgressionInput.movingPattern_original_mixed_prime_norm_bound + [NeZero (∏ i, bulkResidueModuli r p i)] + (r₀ : ℕ) (hsmallLen : ∀ b, MovingLeafLengthLE n (small b) r₀) + (hy : 0 ≤ y) (hQ : 2 ≤ Q) (hMQ : (∏ i, bulkResidueModuli r p i) ≤ Q) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (hu : ∀ j c, 1 ≤ u j c) (huv : ∀ j c, u j c ≤ v j c) + (hshort : ∀ j c, v j c ≤ u j c + 1) + (hmassCell : ∀ j c (a : (ZMod (∏ i, bulkResidueModuli r p i))ˣ), + ∑ q ∈ primeLogCellSet (∏ i, bulkResidueModuli r p i) a.val.val (u j c) (v j c), + (q : ℝ)⁻¹ ≤ 2) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hP : ∀ j, primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ primes) + (hsep : ∀ j (c d : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ), c ≠ d → + ¬Nat.ModEq (∏ i, bulkResidueModuli r p i) c.2.val.val d.2.val.val ∨ + v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hdeleted : ∀ j, (∑ q ∈ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted j, (q : ℝ)⁻¹) ≠ 0) + (hdeletedBase : ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) + (hout : ∀ q ∈ outside, q.Prime) (hdeletedOut : ∀ j q, q ∈ outside → q ∈ deleted j) + (Kspec : Fin m → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (A₀ : ℝ) (hA₀ : 0 ≤ A₀) (H T : ℝ) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Qfreq y + let spec := fun i => frozenBulkSpectatorHaar base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (g i) + let A := 2 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let W₀ := ((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * Bφ ^ (2 ^ n - 1)) ^ 2 + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + let err := fun c : (TreeLeafIndex n × Fin m) → Cell => + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkKernelPairComparisonBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 Bφ Dφ * + bulkPrimeErrorFactor P Q (u j (c j)) + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P Q M (w j).val.val (z j)‖ ≤ A₀) → + (∀ j, Z j * ∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹ ≤ 2) → + (∀ j, Z j ≤ Real.exp H) → + (∀ j q, q ∈ S j \ deleted j → Real.exp T ≤ (q : ℝ)) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Qfreq y ψ X lo hi hlo hhi φ G L U x‖ ≤ + (W₀ * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, ∑ z, ‖a z‖ * err c + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * Real.exp (H - T) + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) := by + intro data freq spec A W W₀ M S Z a err hlocal hmass hZ hlow + have hA : 0 ≤ A := by dsimp only [A]; positivity + have hf (z) : ‖freq z‖ ≤ A := + frozenBulkFrequencyFactor_norm_le base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Qfreq y hy z + have hspec (i) (z) : ‖spec i z‖ ≤ Kspec i ^ (2 ^ (n + 1)) := + frozenBulkSpectatorHaar_norm_le base n m t _ _ (twist i) perm (g i) (Kspec i) + (hKspec i) (hgnorm i) z + have heq := movingPatternPrimeBulkHaar_mean e tierB tierC t small slot perm pattern hsmall hB htier + base primes hprimes hbase childBound pivotBound hfreq F E outside R r hR hr p hc g hg twist + P Qfreq y j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + u v c₀ S deleted (fun _ => Finset.Subset.refl _) hdeletedBase hout hdeletedOut + dsimp only at heq + rw [heq] + have hb := P.movingPattern_norm_kernel_bound e tierB tierC t small slot perm pattern hB htier + hsmallLen base childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ + hφ hlip hφout L U r p hc freq spec A hA hf Q hQ hMQ primes u v hu huv hshort + hmassCell c₀ hP hsep deleted hdeleted A₀ hA₀ H T (fun i => Kspec i ^ (2 ^ (n + 1))) + (fun i => pow_nonneg (hKspec i) _) + exact hb hlocal hspec hmass hZ hlow + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c7b91615307c2f0e368fb98f9c5bcfb538b311c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeNormRate.lean @@ -0,0 +1,182 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedPrimeNormBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCellError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBadEventRate +import OAI.NumberTheory.Ostmann.Construction.OriginalHarmonicRate +import OAI.NumberTheory.Ostmann.ZeroDensity.BulkProgressionCutoff + +namespace OAI + +/-! # The original-prior norm estimate at the manuscript scales -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_original_mixed_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq y + let spec := fun i => frozenBulkSpectatorHaar base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U x‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨Cerr, hCerr, hCnorm, hcellRate⟩ := + P.movingPattern_cell_error_rate_window ψ n r₀ k A Wwin Bφ Dφ F (Cmass + 1) hA hWwin hF + obtain ⟨Tcell, _, hcellTwo⟩ := P.short_prime_cell_mass_two + have hlarge : ∀ᶠ L : ℝ in atTop, Tcell ≤ Real.exp ((39 / 10000 : ℝ) * L) := + (Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num))).eventually + (eventually_ge_atTop Tcell) + filter_upwards [hcellRate, movingPattern_bad_event_rate_window ψ n r₀ k + A Wwin Bφ Dφ F (Cmass + 1) hA hWwin hF, + P.original_harmonic_box_rate Cmass hCmass, hlarge, eventually_ge_atTop (2000 : ℝ)] + with L herror hbad hnormal hlarge hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq y X A₀ j₀ φ G XL U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq y + let spec := fun i => frozenBulkSpectatorHaar base n m t + (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (twist i) perm + (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hZ (j) : Z j ≤ Real.exp (Cerr * L) := (hnorm j).2.1.trans + (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hCnorm (by linarith))) + have hunit : (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) := + bulkResidueModulus_unit_card hMQ (Nat.floor_le (Real.exp_nonneg _)) + have ha (z) : ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) := by + exact moving_frozen_residue_coefficient_norm base (movingPatternBulkEmbedding e slot) outside + Fw Ew n m data childBound R r P Qfreq y hy p sets hsets hsetsp + t _ _ twist perm (bulkResidueEquiv r p hc z).1 (bulkResidueEquiv r p hc z).2 + have he := herror lo hi hhi hwindow Cell M (bulkProgressionCutoff L) hQ.1 hQ.2 p Z a amp + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 hZ hcard hunit hamp0 hamp ha le_rfl u hulow + have hbd := hbad lo hi hhi hwindow p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hb := P.movingPattern_original_mixed_prime_norm_bound e tierB tierC t small slot perm pattern + hsmall hB htier base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r + hR hr p hc (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) twist (bulkProgressionCutoff L) Qfreq y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U + r₀ hsmallLen hy hQ.1 hMQ u v hu huv hshort + (fun j c z => hcellTwo M z.val.val (u j c) (v j c) (hlarge.trans (hulow j c)) (hshort j c)) + c₀ hS (fun j => unitPrimeCells_separated M (u j) (v j) (hsep j)) deleted + (fun j => (hnorm j).1.ne') hdelbase hout hdelout (fun i => (p i : ℝ)) + (fun i => Nat.cast_nonneg _) (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) + A₀ hA₀ ((Cmass + 1) * L) (Real.exp ((39 / 10000 : ℝ) * L)) + hlocal (fun j => (hnorm j).2.2) (fun j => (hnorm j).2.1) + (fun j q hq => hlow j q (Finset.mem_sdiff.mp hq).1) + dsimp only at hb + have hh := add_le_add (le_refl + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m))) (add_le_add he hbd) + apply hb.trans + simpa only [add_assoc, W, amp, Z, a, spec, freq, data, M, S] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeSelectedNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeSelectedNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..cf3fa32123c6e9eab0d50b2fe580a684639aa08d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeSelectedNormRate.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedPrimeInitialNormRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeObservable + +namespace OAI + +/-! # Norm estimate for the original selected-coordinate mean -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_selected_mixed_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (base : Fin (N + 1) → primes) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyFactor (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq y + let spec := fun i => frozenBulkSpectatorHaar (fun i => (base i : ℕ)) n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (base i : ℕ) ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex n × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ∀ ν : Bidx → primes → ℝ, + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + ‖movingPatternBulkMean e ν slot + (movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U) base‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + filter_upwards [P.movingPattern_initial_mixed_prime_norm_rate ψ n r₀ k A Wwin Bφ Dφ F Cmass + hA hWwin hF hCmass hBφ hDφ] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern primes hprimes base + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq y X A₀ j₀ φ G XL U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain ν hν + rw [movingPatternBulkMean_primeObservable] + · exact hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern + (fun i => (base i : ℕ)) primes hprimes (fun i _ => hprimes _ (base i).property) + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq y X A₀ j₀ φ G XL U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain + · exact hν + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeSignedBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeSignedBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..a3d6eb4e16af85c14e701c773ab51c60d13946f4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedPrimeSignedBound.lean @@ -0,0 +1,134 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSeparatedBound +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSpectatorNorm + +namespace OAI + +/-! # Separate giant and bulk Page cutoffs in the signed prime estimate -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell : Type*} [Fintype Cell] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q Qfreq : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +include hsmall hB htier hR hr hg hV hBφ hDφ hφ hlip hφout j₀ in +/-- The original Page/spectator kernel now has a signed bound under its +literal deleted prime prior. Its frequency and pointwise spectator bounds +are derived; the remaining local signed mean is exactly the quartet input. -/ +theorem PublishedProgressionInput.movingPattern_mixed_prime_signed_bound + [NeZero (∏ i, bulkResidueModuli r p i)] + (r₀ : ℕ) (hsmallLen : ∀ b, MovingLeafLengthLE n (small b) r₀) + (hy : 0 ≤ y) (hQ : 2 ≤ Q) (hMQ : (∏ i, bulkResidueModuli r p i) ≤ Q) + (hpage : pageAtModulus (∏ i, bulkResidueModuli r p i) (selectedPageZero P Q) = + pageAtModulus r (selectedPageZero P Q)) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (hu : ∀ j c, 1 ≤ u j c) (huv : ∀ j c, u j c ≤ v j c) + (hshort : ∀ j c, v j c ≤ u j c + 1) + (hmassCell : ∀ j c (a : (ZMod (∏ i, bulkResidueModuli r p i))ˣ), + ∑ q ∈ primeLogCellSet (∏ i, bulkResidueModuli r p i) a.val.val (u j c) (v j c), + (q : ℝ)⁻¹ ≤ 2) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hP : ∀ j, primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ primes) + (hsep : ∀ j (c d : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ), c ≠ d → + ¬Nat.ModEq (∏ i, bulkResidueModuli r p i) c.2.val.val d.2.val.val ∨ + v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hdeleted : ∀ j, (∑ q ∈ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted j, (q : ℝ)⁻¹) ≠ 0) + (hdeletedBase : ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) + (hout : ∀ q ∈ outside, q.Prime) (hdeletedOut : ∀ j q, q ∈ outside → q ∈ deleted j) + (Kspec : Fin m → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (δ : ℝ) (hδ : 0 ≤ δ) (H T : ℝ) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Qfreq y + let spec := fun i => frozenBulkSpectatorHaar base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (g i) + let A := 2 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + let err := fun c : (TreeLeafIndex n × Fin m) → Cell => + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkKernelPairComparisonBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 Bφ Dφ * + bulkPrimeErrorFactor P Q (u j (c j)) + (∀ i, ‖(Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, spec i z‖ ≤ δ) → + (∀ j, Z j * ∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹ ≤ 2) → + (∀ j, Z j ≤ Real.exp H) → + (∀ j q, q ∈ S j \ deleted j → Real.exp T ≤ (q : ℝ)) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Qfreq y ψ X lo hi hlo hhi φ G L U x‖ ≤ + (W * A) * 4 ^ Fintype.card (TreeLeafIndex n × Fin m) * δ ^ m + + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, ∑ z, ‖a z‖ * err c + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * Real.exp (H - T) + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) := by + intro data freq spec A W M S Z a err hlocal hmass hZ hlow + have hA : 0 ≤ A := by dsimp only [A]; positivity + have hf (z) : ‖freq z‖ ≤ A := + frozenBulkFrequencyFactor_norm_le base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Qfreq y hy z + have hspec (i) (z) : ‖spec i z‖ ≤ Kspec i ^ (2 ^ (n + 1)) := + frozenBulkSpectatorHaar_norm_le base n m t _ _ (twist i) perm (g i) (Kspec i) + (hKspec i) (hgnorm i) z + have heq := movingPatternPrimeBulkHaar_mean e tierB tierC t small slot perm pattern hsmall hB htier + base primes hprimes hbase childBound pivotBound hfreq F E outside R r hR hr p hc g hg twist + P Qfreq y j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + u v c₀ S deleted (fun _ => Finset.Subset.refl _) hdeletedBase hout hdeletedOut + dsimp only at heq + rw [heq] + have hb := P.movingPattern_separated_kernel_bound e tierB tierC t small slot perm pattern hB htier + hsmallLen base childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ + hφ hlip hφout L U r p hc freq spec A hA hf Q hQ hMQ hpage primes u v hu huv hshort + hmassCell c₀ hP hsep deleted hdeleted δ hδ H T (fun i => Kspec i ^ (2 ^ (n + 1))) + (fun i => pow_nonneg (hKspec i) _) + exact hb hlocal hspec hmass hZ hlow + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedSameNormArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedSameNormArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb2906fa6ea68a5158767df90c9667f83bb41692 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternMixedSameNormArithmetic.lean @@ -0,0 +1,201 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedOriginalNormArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedNormalizedNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFrequencyModulus +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMultiplier + +namespace OAI + +/-! # The norm estimate with the original internal and external priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_same_assignment_mixed_prime_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (W : (Fin (N + 1) → primes) → ℂ) (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (Fw true) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := movingPatternPrimeObservable e t small slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U + let obs := fun x => W x * raw x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i b j, + j ∈ flattenMovingSlots n (small b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, ‖W x‖ ≤ 1) → + (∀ x z, W (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) = W x) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + filter_upwards [P.movingPattern_original_mixed_prime_norm_arithmetic_rate ψ n r₀ k + A Wwin Bφ Dφ 2 Cmass hA hWwin (by norm_num) hCmass hBφ hDφ] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq Fw outside _ p _ hc _ twist sets + Qfreq y X j₀ φ G XL U u v deleted initial μ ν W Eprior αall βint Vint Uall + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hW hWbulk hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq n ft + have hR (b : Bool) : (movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern b).frequencyProduct ∣ (R : ℤ) := by + simpa only [ht, R] using movingPattern_frequencyProduct_dvd e Sfreq ft small slot (Equiv.refl _) pattern b + have hroots (b : Bool) (j : Fin (2 ^ n - 1)) : + (singleTreeNodeFrequencies Sfreq n (frequencyPairProjection Sfreq n b ft) j.val).root.natAbs ∣ R := + frequencyModelBase_roots Sfreq n ft b j + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + have hone (b : Bool) : ‖movingDataWeight (Fw b) (fun _ _ _ _ => 1) (data b)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (Fw b) (fun s regular => + (hleaf b s regular).trans (by split_ifs <;> norm_num)) (data b) + have hamp : 2 * (‖movingDataWeight (Fw false) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (Fw true) (fun _ _ _ _ => 1) (data true)‖) ≤ Real.exp ((2 : ℝ) * m) := by + have hpair := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm + have he : (2 : ℝ) ≤ Real.exp (m : ℝ) := by linarith [Real.add_one_le_exp (m : ℝ)] + calc + _ ≤ 4 := by linarith + _ ≤ (Real.exp (m : ℝ)) ^ 2 := by nlinarith [Real.exp_pos (m : ℝ)] + _ = _ := by simpa only [Nat.cast_ofNat] using (Real.exp_nat_mul (m : ℝ) 2).symm + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + have hA₀ : 0 ≤ A₀ := by + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro x hx + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hx + exact pairFrequencySupportBound_nonneg D f + exact mul_nonneg (by positivity) (mul_nonneg hleaf0 hprod) + have hlocal (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) + (z : (TreeLeafIndex n × Fin m) → ℝ) (hz : ∀ j, 0 ≤ z j) := + movingPattern_normalized_same_assignment_mixed_norm e tierB tierC Sfreq ft R Nfreq Vleaf + hS hN hroots small slot pattern hsmall hB htier (fun i => (x i : ℕ)) (hbase x hx) + Fw hleaf D hD hdiv hm p hc hp + (by simpa only [ht] using hfreqp) (hsmallp x hx) (hsamplesp x hx) + sets hsets hsetsp twist outside childBound P Qfreq (bulkProgressionCutoff L) y hy z hz + have h := hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot (Equiv.refl _) pattern rep + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p hc twist sets Qfreq y X A₀ j₀ φ G XL U u v deleted initial μ ν W + Eprior αall βint Vint Uall hsmall hB htier hsmallLen hR (frequencyModelModulus_precision R n) + hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell + hSS hdel hmass hdelbase hout hdelout hA₀ + (by + intro x hx + dsimp only + intro z hz + have hz' := hlocal x hx z hz + simpa only [A₀, m, ht, finite_univ_canonical, Fintype.card_eq_nat_card, Nat.card_fin] using hz') + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hW hWbulk hdisjoint hcross hfmod + exact h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternModulusRange.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternModulusRange.lean new file mode 100644 index 0000000000000000000000000000000000000000..b7b9168c9e001780fad5f849da26b446d37c7c1c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternModulusRange.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeSupport +import OAI.NumberTheory.Ostmann.ZeroDensity.BulkProgressionCutoff + +namespace OAI + +/-! # The full pattern modulus and the separate giant progression cutoff -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +/-- The giant comparison includes internal prime squares; the external bulk +comparison keeps `bulkProgressionCutoff L`. -/ +noncomputable def giantProgressionCutoff (L : ℝ) : ℕ := bulkProgressionCutoff (10 * L) + +theorem giantProgressionCutoff_bounds (L : ℝ) (hL : 200 ≤ L) : + 2 ≤ giantProgressionCutoff L ∧ + Real.log (4 * (giantProgressionCutoff L : ℝ)) ≤ + 2 * Real.exp ((12 / 1000 : ℝ) * L) := by + have h := bulkProgressionCutoff_bounds (10 * L) (by linarith) + norm_num [giantProgressionCutoff, ← mul_assoc] at h ⊢ + exact h + +theorem movingArithmeticModuli_exp_bound (m r : ℕ) (p : Fin m → ℕ) (P : Finset ℕ) + (F U V : ℝ) (hr : (r : ℝ) ≤ Real.exp (F * m)) + (hP : ∀ q ∈ P, (q : ℝ) ≤ Real.exp U) + (hp : ∀ i, (p i : ℝ) ≤ Real.exp V) : + ((∏ b, movingArithmeticModuli r p P Finset.univ b : ℕ) : ℝ) ≤ + Real.exp (F * m + 2 * P.card * U + (m : ℝ) * V) := by + have hprod : ((∏ q ∈ P, q : ℕ) : ℝ) ≤ Real.exp ((P.card : ℝ) * U) := by + rw [Nat.cast_prod] + calc + _ ≤ ∏ _q ∈ P, Real.exp U := + Finset.prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) hP + _ = _ := by simp only [Finset.prod_const, ← Real.exp_nat_mul] + have hspec : ((∏ i : Fin m, p i : ℕ) : ℝ) ≤ Real.exp ((m : ℝ) * V) := by + rw [Nat.cast_prod] + calc + _ ≤ ∏ _i : Fin m, Real.exp V := + Finset.prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) (fun i _ => hp i) + _ = _ := by simp only [Finset.prod_const, Finset.card_univ, Fintype.card_fin, ← Real.exp_nat_mul] + rw [movingArithmeticModuli_product] + simp only [Nat.cast_mul, Nat.cast_pow] + calc + _ ≤ Real.exp (F * m) * ((Real.exp ((P.card : ℝ) * U)) ^ 2 * + Real.exp ((m : ℝ) * V)) := + mul_le_mul hr (mul_le_mul (pow_le_pow_left₀ (Nat.cast_nonneg _) hprod 2) + hspec (Nat.cast_nonneg _) (by positivity)) (by positivity) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add]; congr 1; ring + +/-- The actual number of internal classes is fixed by the tree depth. Thus +internal squares fit the giant cutoff, uniformly in the pattern and its +sampled prime assignment. -/ +theorem movingArithmeticModuli_giant_range (n : ℕ) (F K : ℝ) + (hF : 0 ≤ F) (hK : 0 ≤ K) : + ∀ᶠ L : ℝ in atTop, ∀ (m r : ℕ) (p : Fin m → ℕ) (P : Finset ℕ), + (m : ℝ) ≤ K * L → P.card ≤ 4 * n * 2 ^ n → + (r : ℝ) ≤ Real.exp (F * m) → + (∀ q ∈ P, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∏ b, movingArithmeticModuli r p P Finset.univ b) ≤ giantProgressionCutoff L := by + let J : ℝ := 4 * n * 2 ^ n + let C := F * K + 2 * J + K + have hJ : 0 ≤ J := by dsimp only [J]; positivity + have hFK : 0 ≤ F * K := mul_nonneg hF hK + filter_upwards [arithmetic_exponent_absorption (11 / 1000) (12 / 1000) 0 C 1 1 + (by norm_num) (by norm_num) (by norm_num) (by norm_num), + eventually_ge_atTop (1 : ℝ)] with L hrate hL + intro m r p P hm hc hr hP hp + apply Nat.le_floor + have hbound := movingArithmeticModuli_exp_bound m r p P F + (Real.exp ((11 / 1000 : ℝ) * L)) (Real.exp ((1 / 1000 : ℝ) * L)) hr hP hp + apply hbound.trans + change Real.exp _ ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * (10 * L))) + rw [show (12 / 10000 : ℝ) * (10 * L) = (12 / 1000 : ℝ) * L by ring] + apply Real.exp_le_exp.mpr + have hc' : (P.card : ℝ) ≤ J := by + dsimp only [J] + exact_mod_cast hc + have he : Real.exp ((1 / 1000 : ℝ) * L) ≤ Real.exp ((11 / 1000 : ℝ) * L) := + Real.exp_le_exp.mpr (by linarith) + have hKL : 0 ≤ K * L := mul_nonneg hK (by linarith) + have hmain := mul_le_mul_of_nonneg_left hm hF + have hi := mul_le_mul_of_nonneg_right hc' (Real.exp_nonneg ((11 / 1000 : ℝ) * L)) + have hiL : 2 * J * Real.exp ((11 / 1000 : ℝ) * L) ≤ + (2 * J * L) * Real.exp ((11 / 1000 : ℝ) * L) := by + exact mul_le_mul_of_nonneg_right + (le_mul_of_one_le_right (mul_nonneg (by norm_num) hJ) hL) (Real.exp_nonneg _) + have hs := mul_le_mul hm he (Real.exp_nonneg _) hKL + have hC1 : F * K ≤ C := by dsimp only [C]; linarith + have hC2 : 2 * J + K ≤ C := by dsimp only [C]; linarith + have hC1L := mul_le_mul_of_nonneg_right hC1 (show 0 ≤ L by linarith) + have hC2L := mul_le_mul_of_nonneg_right hC2 (show 0 ≤ L by linarith) + have hC2e := mul_le_mul_of_nonneg_right hC2L (Real.exp_nonneg ((11 / 1000 : ℝ) * L)) + simp only [pow_one, zero_mul, Real.exp_zero, one_mul] at hrate + nlinarith only [hmain, hi, hiL, hs, hC1L, hC2e, hrate] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternNormKernel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternNormKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..ffb09856ec89456bb0347c51725a470ff624b3b3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternNormKernel.lean @@ -0,0 +1,40 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternIntegrand +import OAI.NumberTheory.Ostmann.Characters.FourierWindowDecay + +namespace OAI + +/-! # The window decay for the literal prime-cell integrand -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℝ) (childBound pivotBound : ℕ → ℕ) + (j₀ : TreeLeafIndex n × Fin m) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +theorem movingPatternBulkIntegrand_norm_window (z : (TreeLeafIndex n × Fin m) → ℝ) : + ‖movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier base + childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ hBφ hDφ hφ hlip hout L U z‖ ≤ + ((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * Bφ ^ (2 ^ n - 1)) ^ 2 := + realValueKernelPair_norm_window + (bulkLogValues base (selectedBulkSet (movingPatternBulkEmbedding e slot)) + (bulkCoordinateInsert base (movingPatternBulkEmbedding e slot) z)) + childBound pivotBound (movingPatternFinBulkData e n m t small slot perm pattern) + ψ X lo hi hlo hhi φ G Bφ hBφ hφ L U + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternNormalizedNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternNormalizedNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..7bbc8ab9a9f3afc6ef2a75a2daa11b7f9b0d38f3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternNormalizedNorm.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFrozenNorm +import OAI.NumberTheory.Ostmann.Characters.NormalizedResidueIndicator + +namespace OAI + +/-! # The arithmetic absolute norm for the actual normalized spectator transforms -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_normalized_same_assignment_norm {B C I : Type*} [Fintype I] {N₀ n m : ℕ} + (e : Fin (N₀ + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (S : Finset ℤ) (t : FrequencyTree (S × S) n) (R N V : ℕ) + [NeZero (R ^ (n - 1 + 2))] + (hS : ∀ s ∈ S, s ≠ 0) (hN : ∀ s ∈ S, s.natAbs ≤ N) + (hR : ∀ b (j : Fin (2 ^ n - 1)), + (singleTreeNodeFrequencies S n (frequencyPairProjection S n b t) j.val).root.natAbs ∣ R) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b i, i ∈ flattenMovingSlots n (small b) → i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N₀ + 1) → ℕ) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), IsCoprime (base i : ℤ) (R : ℤ)) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N₀ + 1)) k → ℤ → ℂ) + (hF : ∀ b s regular, ‖F b (.leaf s regular) s‖ ≤ if s.natAbs ≤ V then 1 else 0) + (D : ℝ) (hD : 0 ≤ D) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) (hm : 0 < m) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + [NeZero (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli (R ^ (n - 1 + 2)) p i).Coprime + (bulkResidueModuli (R ^ (n - 1 + 2)) p j))) (hp : ∀ i, 3 ≤ p i) + (hfreq : ∀ i b, movingGiantFrequencyUnits (p i) n + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t))) + (hsmallp : ∀ i b j, j ∈ flattenMovingSlots n (small b) → + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) + (hasamples : ∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) + (sets : ∀ i, Finset (ZMod (p i))) + (hsets : ∀ i, (sets i).Nonempty) (hsetsLt : ∀ i, (sets i).card < p i) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (outside : List ℕ) (childBound : ℕ → ℕ) + (input : PublishedProgressionInput) (Q : ℕ) (Y : ℝ) (hY : 0 ≤ Y) + (Ybulk : TreeLeafIndex n × Fin m → ℝ) (hYbulk : ∀ j, 0 ≤ Ybulk j) : + let ts := fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t) + let data := movingPatternFinBulkData e n m ts small slot (Equiv.refl _) pattern + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F (fun _ _ _ _ _ => 1) data childBound R (R ^ (n - 1 + 2)) input Q Y + let spec := fun i => frozenBulkSpectatorHaar base n m ts + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) (Equiv.refl _) (normalizedResidueTransform (sets i)) + let M := ∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i + let A := fun z => freq (bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).2 i) + (Fintype.card (TreeLeafIndex n × Fin m → (ZMod M)ˣ) : ℝ)⁻¹ * + (∑ z : TreeLeafIndex n × Fin m → (ZMod M)ˣ, + ‖A z * ∏ j, pageGiantWeight input Q M (z j).val.val (Ybulk j)‖) ≤ + ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * Fintype.card I)) * + (frequencyLeafWeight (pairedFrequencyLeaf S V) n t * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod) := by + exact movingPattern_same_assignment_norm e tierB tierC S t R N V hS hN hR small slot pattern + hsmall hB htier base hbase F hF D hD hdiv hm p hc hp hfreq hsmallp hasamples + (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) + (fun i => (normalizedResidueTransform_energy (sets i) (hsets i) (hsetsLt i)).le) + twist outside childBound input Q Y hY Ybulk hYbulk + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternObservableCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternObservableCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..a9bec50ee3b4239a50cb8bf43388378372e393d0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternObservableCost.lean @@ -0,0 +1,125 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelGain + +namespace OAI + +/-! # The actual observable and its uniform pointwise arithmetic cost -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +include hB htier hV hBφ hDφ hφ hlip hφout j₀ in +theorem movingPatternPrimeObservable_norm + (hy : 0 ≤ y) (Kspec : I → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (x : Fin (N + 1) → primes) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let amp := 2 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + ‖movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q y + ψ X lo hi hlo hhi φ G L U x‖ ≤ (amp * ∏ i, Kspec i ^ (2 ^ (n + 1))) * W := by + dsimp only + let z := fun j => x (movingPatternBulkEmbedding e slot j) + have heq : joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i) = x := by + funext i + by_cases hi : i ∈ Set.range (movingPatternBulkEmbedding e slot) + · obtain ⟨j, rfl⟩ := hi + rw [joinBulkNonbulk_bulk] + · exact joinBulkNonbulk_nonbulk (movingPatternBulkEmbedding e slot) z + (fun i => x i) ⟨i, hi⟩ + have ho := movingPatternPrimeObservable_join e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q y + ψ X lo hi hlo hhi φ G L U x z + rw [heq] at ho + rw [ho] + exact movingPatternPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + (fun i => (x i : ℕ)) primes hprimes (fun i _ => hprimes _ (x i).property) + childBound pivotBound hfreq F E outside R r p g twist P Q y j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U hy Kspec hKspec hgnorm z + +end + +/-- The full pointwise cost from the actual observable is uniform over +patterns and prime assignments at fixed depth. -/ +theorem movingPattern_pointwise_cost (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi B D F : ℝ) (hA : 0 ≤ A) (hhi : lo ≤ hi) (hF : 0 ≤ F) : + ∃ C : ℝ, 1 ≤ C ∧ ∀ L : ℝ, 1 ≤ L → let m := spectatorBulkCount k L + ∀ (p : Fin m → ℕ) (amp : ℝ), + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 0 ≤ amp → amp ≤ Real.exp (F * m) → + (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ 2 + C * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + obtain ⟨Cw, hCw, hkernel⟩ := movingPatternKernelBudget_spectatorScale ψ n r₀ k + A lo hi B D hA hhi + let K := (F + 1) * ((k : ℝ) ^ 4 + 1) + let C := max Cw ((((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K) + have hCwC : Cw ≤ C := le_max_left _ _ + have hCs : (((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K ≤ C := le_max_right _ _ + refine ⟨C, hCw.trans hCwC, ?_⟩ + intro L hL + dsimp only + intro p amp hp hamp0 hamp + let m := spectatorBulkCount k L + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hL0 : 0 ≤ L := by linarith + have hK : 0 ≤ K := by dsimp only [K]; positivity + have hFk : F * (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4] + have hkK : (k : ℝ) ^ 4 ≤ K := by + dsimp only [K] + nlinarith [mul_nonneg hF (pow_nonneg (Nat.cast_nonneg k : (0 : ℝ) ≤ k) 4)] + have hm := spectatorBulkCount_upper k L hL0 + have hmK : (m : ℝ) ≤ K * L := hm.trans (mul_le_mul_of_nonneg_right hkK hL0) + have hampK : amp ≤ Real.exp (K * L) := hamp.trans (Real.exp_le_exp.mpr (by + exact (mul_le_mul_of_nonneg_left hm hF).trans + (by nlinarith [mul_le_mul_of_nonneg_right hFk hL0]))) + have hspec := moving_spectator_linear_cost n m p K L amp hK hL0 hamp0 hmK hampK hp + have hspec' : amp * (∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) ≤ + Real.exp (C * L * Real.exp ((1 / 1000 : ℝ) * L)) := by + apply hspec.trans + apply Real.exp_le_exp.mpr + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right hCs hL0) (Real.exp_nonneg _) + have hW : W ≤ Real.exp (C * L ^ 2) := by + apply (bulkKernelPair_smooth_le_budget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D).trans + exact (hkernel L hL).trans (Real.exp_le_exp.mpr + (mul_le_mul_of_nonneg_right hCwC (sq_nonneg L))) + exact (mul_le_mul hspec' hW (sq_nonneg _) (Real.exp_nonneg _)).trans_eq (by + rw [← Real.exp_add, add_comm]) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..d81487edf13c8dd859a6b41abf7c8b5a23c99616 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalArithmetic.lean @@ -0,0 +1,192 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSelectedRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate + +namespace OAI + +/-! # The complete arithmetic bound under the original union-of-cells prior -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_selected_prime_rate ψ n r₀ k A lo hi Bφ Dφ F Cmass gain + hA hlo hhi hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β y X j₀ φ G U u v deleted initial + μ ν Eprior αall βint Vint Uall hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let obs := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U + let cost := (2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + have hpoint (x) : ‖obs x‖ ≤ cost := + movingPatternPrimeObservable_norm e tierB tierC t small slot perm pattern hB htier + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hminor (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ‖movingPatternBulkMean e ν slot obs x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + exact hrate Bidx Cidx Cell N e tierB tierC t small slot perm pattern primes hprimes x + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β y X j₀ φ G U u v (deleted x) + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp (hsmallp x hx) (hsamplesp x hx) + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS (hdel x hx) hmass (hdelbase x hx) hout (hdelout x hx) + c₀ initial hsub (hretain x hx) ν hν + have hfinal := movingPattern_signed_arithmetic_on_support e (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) tierB tierC t small + (movingPatternBulkLeaves (n + 2) m slot perm) pattern rep + (fun b j _ => hB j) (fun b j _ => hB j) htier + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hUall + (movingPatternFinBulkData_size e t small slot perm pattern hsmallLen) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hV) + (fun q => by + simpa only [Int.cast_natCast, abs_of_nonneg (show (0 : ℝ) ≤ (q : ℕ) from Nat.cast_nonneg _)] + using hvalues q) + μ ν hμ0 hν0 hμmass hνmass Eprior αall βint Vint hEprior hαall hβint hVint + hμbound hμall hνall hμmax hμmin obs cost (by dsimp only [cost]; positivity) + hpoint hdisjoint hcross hfmod m slot perm rfl + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hminor + (fun _ => Classical.arbitrary primes) + simpa only [movingInternalArithmeticError, obs, cost, data, m] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalDiagonalNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalDiagonalNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..bcf27607b7c94ef2686a30d38c1409748edb210b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalDiagonalNorm.lean @@ -0,0 +1,203 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalHaarComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCoefficientMass +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternRegularSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalOuterWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularCollisionSupport + +namespace OAI + +/-! # The original signed diagonal and its retained arithmetic integral -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_diagonal_norm + (input : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (Afreq Wwin Bφ Dφ : ℝ) (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B C J : Type) [Fintype B] [Fintype C] [Fintype J] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (pattern : Bool × MovingSampleIndex n → C) + (_rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] (_hinjp : Function.Injective p) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (reg : J → Fin (N + 1)) (active : J → Bool) (sreg : ℤ) + (other : (Fin (N + 1) → primes) → J → ℤ) (greg : ∀ q : ℕ, ZMod q → ℂ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (R : ℤ) (r : ℕ) [NeZero r] (V : ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) (diagonal : Bool) + (E U u v a b center : ℝ), + let : ∀ q : primes, Fact (q : ℕ).Prime := fun q => ⟨hprimes _ q.property⟩ + let T := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let coeff := movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun _ => 1) + let Pi := fun x => movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x + let M := fun x => ∏ z, movingArithmeticModuli r p (Pi x) Finset.univ z + let Reg := fun x => MovingSlotReversal.naturalProduct (fun i => (x i : ℕ)) + (movingPatternRegularSlots e n m small slot) + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ E → 0 ≤ U → (∀ j (q : primes), (q : ℝ) * μ j q ≤ E) → + (∀ q : primes, (q : ℝ) ≤ U) → + (∀ b, n ≤ tierB b) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ V) → + (∀ s, ‖f s‖ ≤ 1) → (∀ i, g i 0 = 0) → (∀ i z, ‖g i z‖ ≤ (p i : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + (∀ b, (T b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ i, r.Coprime (p i)) → (∀ i, V < p i) → + (V : ℝ) ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ z, |φ z| ≤ Bφ) → (∀ z w, |φ z - φ w| ≤ Dφ * |z - w|) → + (∀ z, 1 ≤ |z| → φ z = 0) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → u ≤ v → v ≤ u + 1 → v ≤ center + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ a → a ≤ b → b ≤ a + 1 → + (∀ x, Reg x = ∏ j, (x (reg j) : ℕ)) → + (∀ x, coeff x ≠ 0 → + (∀ b, movingRegularOutsidePairwise (fun i => (x i : ℕ)) outside (T b)) → + (∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) ∧ + (∀ i, V < (x i : ℕ)) ∧ + (∀ i, IsCoprime ((x i : ℕ) : ℤ) R) ∧ + (∀ i, r.Coprime (x i : ℕ)) ∧ + (∀ i j, ((x j : ℕ) : ZMod (p i)) ≠ 0) ∧ + (Reg x).Coprime (M x) ∧ Reg x * M x ≤ giantProgressionCutoff L ∧ + pageAtModulus (Reg x * M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) ∧ + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus r (selectedPageZero input (giantProgressionCutoff L)) ∧ + Pairwise (fun i j => (x (reg i) : ℕ).Coprime (x (reg j) : ℕ)) ∧ + (∀ i, (sreg : ZMod (x (reg i) : ℕ)) ≠ 0) ∧ + (∀ i, (other x i : ZMod (x (reg i) : ℕ)) ≠ 0) ∧ + (∀ i, greg (x (reg i) : ℕ) 0 = 0) ∧ + (∀ i, (∑ z : ZMod (x (reg i) : ℕ), ‖greg (x (reg i) : ℕ) z‖ ^ 2) = (x (reg i) : ℕ))) → + let actual := movingOriginalPatternDiagonalObservable e t small slot pattern primes hprimes + p g Dq reg active sreg other greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center + let integral := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * + movingPatternPrimeObservable e t (fun _ => small) slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x) * + (Real.exp (z - center) : ℂ) / (y : ℂ) + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern actual x‖ ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern integral x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t (fun _ => small) (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ := by + filter_upwards [input.moving_pattern_diagonal_haar_rate ψ n r₀ k Afreq Wwin Bφ Dφ + hAfreq hWwin hBφ hDφ] with L hL + dsimp only + intro B C J _ _ _ N e tierB tierC t small slot pattern rep primes hprimes μ ν + p _ hinjp g Dq reg active sreg other greg f outside childBound pivotBound R r _ V hfreq + X lo hi hlo hhi φ G Jleft Jright diagonal E U u v a b center + hμ hν hμmass hνmass hE hU hbound hsize hB htier hV hf hg hgnorm hout hR + hprecision hrp hspecLarge hVA hwindow hpupper hφ hlip hφout hcenter huv hv hvcenter + ha hab hb hRegEq hdata + let m := spectatorBulkCount k L + let T := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let Pi := fun x => movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x + let haar := movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t (fun _ => small) (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern + let actual := movingOriginalPatternDiagonalObservable e t small slot pattern primes hprimes + p g Dq reg active sreg other greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center + let integral := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * + movingPatternPrimeObservable e t (fun _ => small) slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x) * + (Real.exp (z - center) : ℂ) / (y : ℂ) + let ε := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) + have hcompare (x : Fin (N + 1) → primes) + (hx : movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun _ => 1) x ≠ 0) : + ‖actual x - integral x * haar x‖ ≤ ε := by + by_cases hgood : ∀ b, movingRegularOutsidePairwise (fun i => (x i : ℕ)) outside (T b) + · + obtain ⟨hdisjoint, hlarge, hsmallR, hrcop, hres, hcop, hfull, hpageReg, hpage, + hreg, hsreg, hother, hgreg, henergy⟩ := hdata x hx hgood + have hprime (i) : (x i : ℕ).Prime := hprimes _ (x i).property + let : ∀ j, Fact (x (reg j) : ℕ).Prime := fun j => ⟨hprime _⟩ + have hPi := movingPatternInternalPrimes_prime e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) x + let : ∀ q : Pi x, Fact q.val.Prime := fun q => ⟨hPi _ q.property⟩ + have hnz (z) : movingArithmeticModuli r p (Pi x) Finset.univ z ≠ 0 := + movingArithmeticModuli_ne_zero r p (Pi x) Finset.univ (NeZero.ne r) hPi + (fun i _ => (Fact.out : (p i).Prime)) z + let : ∀ z, NeZero (movingArithmeticModuli r p (Pi x) Finset.univ z) := fun z => ⟨hnz z⟩ + let : NeZero (∏ z, movingArithmeticModuli r p (Pi x) Finset.univ z) := + ⟨Finset.prod_ne_zero_iff.mpr (fun z _ => hnz z)⟩ + have hsep (i : Fin m) (j : Fin (N + 1)) : (x j : ℕ) ≠ p i := by + intro heq + apply hres i j + rw [heq] + exact ZMod.natCast_self (p i) + have hc := movingPattern_prime_moduli_coprime e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) x r p (fun i => (Fact.out : (p i).Prime)) + hinjp hrcop hrp hsep + have hinj := movingPattern_nonzero_internal_injective e μ ν (fun q : primes => (q : ℕ)) + Subtype.val_injective pattern (fun _ => 1) x hx + have hqs (i : Fin m) : (∏ j, (x (reg j) : ℕ)).Coprime (p i) := by + apply Nat.coprime_prod_left_iff.mpr + intro j _ + exact (Nat.coprime_primes (hprime _) (Fact.out : (p i).Prime)).mpr (hsep i _) + have hh := hL B C J N e tierB tierC t small slot pattern primes hprimes x p g Dq + (fun j => (x (reg j) : ℕ)) active sreg (fun j => (other x j : ZMod (x (reg j) : ℕ))) + (fun j => greg (x (reg j) : ℕ)) f outside childBound pivotBound R r (Pi x) hfreq V + X lo hi hlo hhi φ G Jleft Jright diagonal hB htier hdisjoint hV hlarge hf hg hgnorm + hout hR hprecision hsmallR hres hspecLarge rfl hinj hc (hRegEq x) hcop hfull hpageReg hpage + hgood hreg hqs hsreg hother hgreg henergy hVA hwindow hpupper hφ hlip hφout + u v a b center hcenter huv hv hvcenter ha hab hb + exact hh + · have ha0 (XL XR : ℕ) : movingOriginalSupportedOuterPair p (fun i => (x i : ℕ)) outside + childBound pivotBound (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g + (fun _ => Dq) Finset.univ ψ X lo hi φ G Jleft Jright diagonal T t XL XR = 0 := + movingOriginalSupportedOuterPair_zero_of_not_regular p _ outside childBound pivotBound + _ _ g _ Finset.univ ψ X lo hi φ G Jleft Jright diagonal T t hgood XL XR + have hraw (z y : ℝ) : movingPatternPrimeObservable e t (fun _ => small) slot (Equiv.refl _) + pattern primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x = 0 := by + change _ * (movingFrequencyPageAverage (fun i => (x i : ℕ)) outside + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) T _ R r input + (giantProgressionCutoff L) y * _) = 0 + rw [movingFrequencyPageAverage_zero_of_not_regular _ outside _ _ T _ R r input + (giantProgressionCutoff L) y hgood, zero_mul, mul_zero] + dsimp only [T, m] at ha0 + have hactual : actual x = 0 := by + simp only [actual, movingOriginalPatternDiagonalObservable, ha0, zero_mul, + complexIntegerInterval, complexPrimeInterval, ite_self, Finset.sum_const_zero] + have hideal : integral x = 0 := by + simp only [integral, hraw, mul_zero, zero_mul, zero_div, integral_zero] + rw [hactual, hideal, zero_mul, sub_self, norm_zero] + dsimp only [ε] + positivity + have hbnd := movingPattern_comparison_norm e μ ν (fun q : primes => (q : ℕ)) pattern rep + E U ε hE hU (by dsimp only [ε]; positivity) (fun q => hprimes _ q.property) + hμ hν hμmass hνmass hbound hsize actual (fun x => integral x * haar x) hcompare + have he : (∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (fun x => integral x * haar x) x) = + ∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern integral x * haar x := by + apply Finset.sum_congr rfl + intro x _ + conv_lhs => rw [movingOriginalPatternWeight_eq_coefficient_mul] + conv_rhs => rw [movingOriginalPatternWeight_eq_coefficient_mul] + ring + simpa only [he] using hbnd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalIntegralNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalIntegralNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..355ac022a8db7ffd6d3b7b61140aa52b824d0c8b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalIntegralNorm.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeHaarComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCoefficientMass + +namespace OAI + +/-! # Carrying the literal pattern integral to the signed arithmetic norm -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem movingPattern_original_integral_norm {B C I : Type} + [Fintype B] [Fintype C] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (f : ℤ → ℂ) (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (Dq : ∀ i, (ZMod (p i))ˣ) (input : PublishedProgressionInput) (Q : ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (u v a b : ℝ) + (E U ε : ℝ) (hE : 0 ≤ E) (hU : 0 ≤ U) (hε : 0 ≤ ε) + (hμ : ∀ j q, 0 ≤ μ j q) (hν : ∀ j q, 0 ≤ ν j q) + (hμmass : ∀ j, ∑ q, μ j q = 1) (hνmass : ∀ j, ∑ q, ν j q = 1) + (hbound : ∀ j (q : primes), (q : ℝ) * μ j q ≤ E) + (hsize : ∀ q : primes, (q : ℝ) ≤ U) : + let actual := movingOriginalPatternPrimeObservable e pattern p + (fun q : primes => (q : ℕ)) outside childBound pivotBound (fun {_} _ => f) g Dq Finset.univ + ψ X lo hi φ G t small (bulkSlotLeaves n m slot) u v a b + let integral := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + movingPatternTwoPrimeObservable e t (fun _ => small) slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) + outside R r p g (fun i _ => Dq i) input Q z y ψ X lo hi hlo hhi φ G + (Real.exp z) (Real.exp y) x / ((z : ℂ) * (y : ℂ)) + let haar := movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) n t (fun _ => small) + (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern + (∀ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (fun _ => 1) x ≠ 0 → ‖actual x - integral x * haar x‖ ≤ ε) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern actual x‖ ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * ε + + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern integral x * haar x‖ := by + intro actual integral haar hcompare + have h := movingPattern_comparison_norm e μ ν (fun q : primes => (q : ℕ)) pattern rep + E U ε hE hU hε (fun q => hprimes _ q.property) hμ hν hμmass hνmass hbound hsize + actual (fun x => integral x * haar x) hcompare + have he (x) : movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (fun x => integral x * haar x) x = + movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern integral x * haar x := by + simp only [movingOriginalPatternWeight, movingPatternInjectionGuard] + split_ifs <;> ring + simpa only [he] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalMatchedNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalMatchedNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a78cb6b4fc435e4ac4c7c18940899ada2348217 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalMatchedNorm.lean @@ -0,0 +1,204 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMatchedObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMatchedHaarComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCoefficientMass +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternRegularSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalOuterWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularCollisionSupport + +namespace OAI + +/-! # The original signed matched-history sum and its arithmetic integral -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_matched_norm + (input : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (Afreq Wwin Bφ Dφ : ℝ) (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B C J : Type) [Fintype B] [Fintype C] [Fintype J] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (_rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] (_hinjp : Function.Injective p) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (reg : J → Fin (N + 1)) (active : J → Bool) (sreg : ℤ) + (other : (Fin (N + 1) → primes) → J → ℤ) (greg : ∀ q : ℕ, ZMod q → ℂ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (R : ℤ) (r : ℕ) [NeZero r] (V : ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) (diagonal : Bool) + (E U u v a b center : ℝ), + let : ∀ q : primes, Fact (q : ℕ).Prime := fun q => ⟨hprimes _ q.property⟩ + let T := movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern + let coeff := movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun _ => 1) + let Pi := fun x => movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x + let M := fun x => ∏ z, movingArithmeticModuli r p (Pi x) Finset.univ z + let Reg := fun x => MovingSlotReversal.naturalProduct (fun i => (x i : ℕ)) + (movingPatternRegularSlots e n m small slot) + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ E → 0 ≤ U → (∀ j (q : primes), (q : ℝ) * μ j q ≤ E) → + (∀ q : primes, (q : ℝ) ≤ U) → + (∀ b, n ≤ tierB b) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ V) → + (∀ s, ‖f s‖ ≤ 1) → (∀ i, g i 0 = 0) → (∀ i z, ‖g i z‖ ≤ (p i : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + (∀ b, (T b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ i, r.Coprime (p i)) → (∀ i, V < p i) → + (V : ℝ) ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ z, |φ z| ≤ Bφ) → (∀ z w, |φ z - φ w| ≤ Dφ * |z - w|) → + (∀ z, 1 ≤ |z| → φ z = 0) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → u ≤ v → v ≤ u + 1 → v ≤ center + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ a → a ≤ b → b ≤ a + 1 → + (∀ x, Reg x = ∏ j, (x (reg j) : ℕ)) → + (∀ x, coeff x ≠ 0 → + (∀ b, movingRegularOutsidePairwise (fun i => (x i : ℕ)) outside (T b)) → + (∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) ∧ + (∀ i, V < (x i : ℕ)) ∧ + (∀ i, IsCoprime ((x i : ℕ) : ℤ) R) ∧ + (∀ i, r.Coprime (x i : ℕ)) ∧ + (∀ i j, ((x j : ℕ) : ZMod (p i)) ≠ 0) ∧ + (Reg x).Coprime (M x) ∧ Reg x * M x ≤ giantProgressionCutoff L ∧ + pageAtModulus (Reg x * M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) ∧ + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus r (selectedPageZero input (giantProgressionCutoff L)) ∧ + Pairwise (fun i j => (x (reg i) : ℕ).Coprime (x (reg j) : ℕ)) ∧ + (∀ i, (sreg : ZMod (x (reg i) : ℕ)) ≠ 0) ∧ + (∀ i, (other x i : ZMod (x (reg i) : ℕ)) ≠ 0) ∧ + (∀ i, greg (x (reg i) : ℕ) 0 = 0) ∧ + (∀ i, (∑ z : ZMod (x (reg i) : ℕ), ‖greg (x (reg i) : ℕ) z‖ ^ 2) = (x (reg i) : ℕ))) → + let actual := movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p g Dq reg active sreg other greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center + let integral := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * + movingPatternPrimeObservable e t (fun _ => small) slot perm pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x) * + (Real.exp (z - center) : ℂ) / (y : ℂ) + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern actual x‖ ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern integral x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t (fun _ => small) (movingPatternBulkLeaves n m slot perm) pattern x‖ := by + filter_upwards [input.moving_pattern_matched_haar_rate ψ n r₀ k Afreq Wwin Bφ Dφ + hAfreq hWwin hBφ hDφ] with L hL + dsimp only + intro B C J _ _ _ N e tierB tierC t small slot perm pattern rep primes hprimes μ ν + p _ hinjp g Dq reg active sreg other greg f outside childBound pivotBound R r _ V hfreq + X lo hi hlo hhi φ G Jleft Jright diagonal E U u v a b center + hμ hν hμmass hνmass hE hU hbound hsize hB htier hV hf hg hgnorm hout hR + hprecision hrp hspecLarge hVA hwindow hpupper hφ hlip hφout hcenter huv hv hvcenter + ha hab hb hRegEq hdata + let m := spectatorBulkCount k L + let T := movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern + let Pi := fun x => movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x + let haar := movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t (fun _ => small) (movingPatternBulkLeaves n m slot perm) pattern + let actual := movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p g Dq reg active sreg other greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center + let integral := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * + movingPatternPrimeObservable e t (fun _ => small) slot perm pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x) * + (Real.exp (z - center) : ℂ) / (y : ℂ) + let ε := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) + have hcompare (x : Fin (N + 1) → primes) + (hx : movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun _ => 1) x ≠ 0) : + ‖actual x - integral x * haar x‖ ≤ ε := by + by_cases hgood : ∀ b, movingRegularOutsidePairwise (fun i => (x i : ℕ)) outside (T b) + · + obtain ⟨hdisjoint, hlarge, hsmallR, hrcop, hres, hcop, hfull, hpageReg, hpage, + hreg, hsreg, hother, hgreg, henergy⟩ := hdata x hx hgood + have hprime (i) : (x i : ℕ).Prime := hprimes _ (x i).property + let : ∀ j, Fact (x (reg j) : ℕ).Prime := fun j => ⟨hprime _⟩ + have hPi := movingPatternInternalPrimes_prime e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) x + let : ∀ q : Pi x, Fact q.val.Prime := fun q => ⟨hPi _ q.property⟩ + have hnz (z) : movingArithmeticModuli r p (Pi x) Finset.univ z ≠ 0 := + movingArithmeticModuli_ne_zero r p (Pi x) Finset.univ (NeZero.ne r) hPi + (fun i _ => (Fact.out : (p i).Prime)) z + let : ∀ z, NeZero (movingArithmeticModuli r p (Pi x) Finset.univ z) := fun z => ⟨hnz z⟩ + let : NeZero (∏ z, movingArithmeticModuli r p (Pi x) Finset.univ z) := + ⟨Finset.prod_ne_zero_iff.mpr (fun z _ => hnz z)⟩ + have hsep (i : Fin m) (j : Fin (N + 1)) : (x j : ℕ) ≠ p i := by + intro heq + apply hres i j + rw [heq] + exact ZMod.natCast_self (p i) + have hc := movingPattern_prime_moduli_coprime e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) x r p (fun i => (Fact.out : (p i).Prime)) + hinjp hrcop hrp hsep + have hinj := movingPattern_nonzero_internal_injective e μ ν (fun q : primes => (q : ℕ)) + Subtype.val_injective pattern (fun _ => 1) x hx + have hqs (i : Fin m) : (∏ j, (x (reg j) : ℕ)).Coprime (p i) := by + apply Nat.coprime_prod_left_iff.mpr + intro j _ + exact (Nat.coprime_primes (hprime _) (Fact.out : (p i).Prime)).mpr (hsep i _) + have hh := hL B C J N e tierB tierC t small slot perm pattern primes hprimes x p g Dq + (fun j => (x (reg j) : ℕ)) active sreg (fun j => (other x j : ZMod (x (reg j) : ℕ))) + (fun j => greg (x (reg j) : ℕ)) f outside childBound pivotBound R r (Pi x) hfreq V + X lo hi hlo hhi φ G Jleft Jright diagonal hB htier hdisjoint hV hlarge hf hg hgnorm + hout hR hprecision hsmallR hres hspecLarge rfl hinj hc (hRegEq x) hcop hfull hpageReg hpage + hgood hreg hqs hsreg hother hgreg henergy hVA hwindow hpupper hφ hlip hφout + u v a b center hcenter huv hv hvcenter ha hab hb + exact hh + · have ha0 (XL XR : ℕ) : movingOriginalSupportedOuterPair p (fun i => (x i : ℕ)) outside + childBound pivotBound (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g + (fun _ => Dq) Finset.univ ψ X lo hi φ G Jleft Jright diagonal T t XL XR = 0 := + movingOriginalSupportedOuterPair_zero_of_not_regular p _ outside childBound pivotBound + _ _ g _ Finset.univ ψ X lo hi φ G Jleft Jright diagonal T t hgood XL XR + have hraw (z y : ℝ) : movingPatternPrimeObservable e t (fun _ => small) slot perm + pattern primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x = 0 := by + change _ * (movingFrequencyPageAverage (fun i => (x i : ℕ)) outside + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) T _ R r input + (giantProgressionCutoff L) y * _) = 0 + rw [movingFrequencyPageAverage_zero_of_not_regular _ outside _ _ T _ R r input + (giantProgressionCutoff L) y hgood, zero_mul, mul_zero] + dsimp only [T, m] at ha0 + have hactual : actual x = 0 := by + simp only [actual, movingOriginalPatternMatchedObservable, ha0, zero_mul, + complexIntegerInterval, complexPrimeInterval, ite_self, Finset.sum_const_zero] + have hideal : integral x = 0 := by + simp only [integral, hraw, mul_zero, zero_mul, zero_div, integral_zero] + rw [hactual, hideal, zero_mul, sub_self, norm_zero] + dsimp only [ε] + positivity + have hbnd := movingPattern_comparison_norm e μ ν (fun q : primes => (q : ℕ)) pattern rep + E U ε hE hU (by dsimp only [ε]; positivity) (fun q => hprimes _ q.property) + hμ hν hμmass hνmass hbound hsize actual (fun x => integral x * haar x) hcompare + have he : (∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (fun x => integral x * haar x) x) = + ∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern integral x * haar x := by + apply Finset.sum_congr rfl + intro x _ + conv_lhs => rw [movingOriginalPatternWeight_eq_coefficient_mul] + conv_rhs => rw [movingOriginalPatternWeight_eq_coefficient_mul] + ring + simpa only [he] using hbnd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalNormArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalNormArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..f441efd73e4786675bd07257b8828cb1dd045e30 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalNormArithmetic.lean @@ -0,0 +1,186 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSelectedNormRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate + +namespace OAI + +/-! # The norm estimate with the original internal and external priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_norm_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + 0 ≤ A₀ → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + let freq := frozenBulkFrequencyFactor (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) + outside Fw Ew data childBound R r P (bulkProgressionCutoff L) y + let spec := fun i => frozenBulkSpectatorHaar (fun i => (x i : ℕ)) n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + ∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot perm) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + filter_upwards [P.movingPattern_selected_prime_norm_rate ψ n r₀ k + A lo hi Bφ Dφ F Cmass hA hlo hhi hF hCmass hBφ hDφ] with L hrate + dsimp only + intro Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets y X A₀ j₀ φ G U u v deleted initial + μ ν Eprior αall βint Vint Uall hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper + hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout + hA₀ hlocal c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let obs := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U + let cost := (2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hpoint (x) : ‖obs x‖ ≤ cost := + movingPatternPrimeObservable_norm e tierB tierC t small slot perm pattern hB htier + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hminor (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ‖movingPatternBulkMean e ν slot obs x‖ ≤ + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + exact hrate Bidx Cidx Cell N e tierB tierC t small slot perm pattern primes hprimes x + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets y X A₀ j₀ φ G U u v (deleted x) + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS (hdel x hx) hmass (hdelbase x hx) hout (hdelout x hx) + hA₀ (hlocal x hx) c₀ initial hsub (hretain x hx) ν hν + have hfinal := movingPattern_signed_arithmetic_on_support e (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) tierB tierC t small + (movingPatternBulkLeaves n m slot perm) pattern rep + (fun b j _ => hB j) (fun b j _ => hB j) htier + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hUall + (movingPatternFinBulkData_size e t small slot perm pattern hsmallLen) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hV) + (fun q => by + simpa only [Int.cast_natCast, abs_of_nonneg (show (0 : ℝ) ≤ (q : ℕ) from Nat.cast_nonneg _)] + using hvalues q) + μ ν hμ0 hν0 hμmass hνmass Eprior αall βint Vint hEprior hαall hβint hVint + hμbound hμall hνall hμmax hμmin obs cost (by dsimp only [cost]; positivity) + hpoint hdisjoint hcross hfmod m slot perm rfl + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hminor + (fun _ => Classical.arbitrary primes) + simpa only [movingInternalArithmeticError, obs, cost, data, m] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..06459a2790b44b00d2066e9e34cdada205837118 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeArithmetic.lean @@ -0,0 +1,207 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeIntegratedRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternOriginalPrimeNorm + +namespace OAI + +/-! # The literal original prime integral with its sharp arithmetic main term -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_prime_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (Cbudget : ℝ) (d : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG : ℝ), + let Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ := fun _ {_} _ => f + let data := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let coeff := movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun _ => 1) + let Pi := fun x => movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x + let Mgiant := fun x => ∏ z, movingArithmeticModuli + ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p (Pi x) Finset.univ z + let Reg := fun x => MovingSlotReversal.naturalProduct (fun i => (x i : ℕ)) + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) + let Agiant := (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (Fw true) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := fun xg y => movingPatternTwoPrimeObservable e t (fun _ => small) slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) (fun i _ => Dq i) P Qfreq + xg y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots n ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b : Bool, MovingLeafLengthLE n ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i (b : Bool) j, + j ∈ flattenMovingSlots n ((fun _ => small) b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + (∀ i, ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)).Coprime (p i)) → + (∀ i, Nfreq < p i) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ Nfreq) → + 2 ≤ Qfreq → + Real.log (4 * (Qfreq : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ uG → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + 2 * Agiant * (movingFourierVariationBudget ψ Nfreq lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (Cbudget * L ^ d + Cbudget * L * Real.exp ((12 / 1000 : ℝ) * L)) → + (∀ x, coeff x ≠ 0 → + (∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) ∧ + (∀ i, Nfreq < (x i : ℕ)) ∧ + (∀ i, IsCoprime ((x i : ℕ) : ℤ) (frequencyModelBase Sfreq n ft : ℤ)) ∧ + (∀ i, ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)).Coprime (x i : ℕ)) ∧ + (∀ i j, ((x j : ℕ) : ZMod (p i)) ≠ 0) ∧ + Mgiant x ≤ Qfreq ∧ + pageAtModulus (Mgiant x) (selectedPageZero P Qfreq) = + pageAtModulus ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) (selectedPageZero P Qfreq) ∧ + Real.log (Mgiant x : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) ∧ + Real.log (Reg x : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (movingOriginalPatternPrimeObservable e pattern p (fun q : primes => (q : ℕ)) + outside childBound pivotBound (fun {_} _ => f) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X lo hi φ G t + small (bulkSlotLeaves n m slot) uG vG rG sG) x‖ ≤ + (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + Uall ^ Fintype.card Cidx) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + (((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))))) / (uG * rG) := by + filter_upwards [P.movingPattern_same_assignment_two_prime_integral_rate ψ n r₀ k + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ, + P.movingPattern_original_prime_norm n Cbudget d] with L hrate hgiant + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq f outside _ p _ hc _ Dq sets + Qfreq X j₀ φ G u v deleted initial μ ν Eprior αall βint Vint Uall uG vG rG sG + huG hrG huvG hrsG hvG hsG + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + houtcover hinjp hrp hspecN hfreqN hQ hQlog huBig hrBig hbudget hdata + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq n ft + have hI := hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq Vleaf D + (fun _ => small) slot pattern rep primes hprimes childBound pivotBound hfreq + (fun _ {_} _ => f) outside p hc (fun i _ => Dq i) sets Qfreq X j₀ φ G u v deleted + initial μ ν Eprior αall βint Vint Uall uG vG rG sG + huG hrG huvG hrsG hvG hsG hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp + hfreqp hbase hsmallp hsamplesp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + have hR (side : Bool) : + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern side).frequencyProduct ∣ + (R : ℤ) := by + simpa only [ht, R] using movingPattern_frequencyProduct_dvd e Sfreq ft + (fun _ => small) slot (Equiv.refl _) pattern side + have hf (s : ℤ) : ‖f s‖ ≤ 1 := (hleaf false s []).trans (by split_ifs <;> norm_num) + have hG := hgiant Bidx Cidx (Fin m) N m e tierB tierC t small slot pattern rep + primes hprimes μ ν p hinjp (fun i => normalizedResidueTransform (sets i)) Dq f + outside childBound pivotBound (R : ℤ) (R ^ (n - 1 + 2)) Qfreq Nfreq hfreq ψ X lo hi + hlo hhi φ G Bφ Dφ Eprior Uall uG vG rG sG + hμ0 hν0 hμmass hνmass hEprior (by linarith) hμbound hvalues hB htier hfreqN hf + (fun i => normalizedResidueTransform_zero (sets i)) + (fun i => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i)) + houtcover hR (frequencyModelModulus_precision R n) hrp hspecN hQ hBφ hDφ hφ hlip hφout + hQlog huBig huvG hvG hrBig hrsG hsG hbudget hdata + exact hG.trans (add_le_add (le_refl _) hI) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fbbde574ddc364d335cfa05946105860878f3c4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeNorm.lean @@ -0,0 +1,150 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternOriginalIntegralNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingLeafAmplitude + +namespace OAI + +/-! # The published giant comparison under the unchanged original prior -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Apply the published progression input before the signed arithmetic norm. +The internal modulus is the actual image of the sampled internal primes. +Its CRT coprimality and all compensation data are derived here. -/ +theorem PublishedProgressionInput.movingPattern_original_prime_norm + (input : PublishedProgressionInput) (n : ℕ) (Cbudget : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, + ∀ (B C I : Type) [Fintype B] [Fintype C] [Fintype I] (N m : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (pattern : Bool × MovingSampleIndex n → C) + (_rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (p : I → ℕ) [∀ i, Fact (p i).Prime] (_hinjp : Function.Injective p) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (R : ℤ) (r : ℕ) [NeZero r] (Q V : ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ E U u v a b : ℝ), + let T := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let coeff := movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun _ => 1) + let Pi := fun x => movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x + let M := fun x => ∏ z, movingArithmeticModuli r p (Pi x) Finset.univ z + let Reg := fun x => MovingSlotReversal.naturalProduct (fun i => (x i : ℕ)) + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) + let A := (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ E → 0 ≤ U → (∀ j (q : primes), (q : ℝ) * μ j q ≤ E) → + (∀ q : primes, (q : ℝ) ≤ U) → + (∀ b, n ≤ tierB b) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ V) → + (∀ s, ‖f s‖ ≤ 1) → (∀ i, g i 0 = 0) → (∀ i z, ‖g i z‖ ≤ (p i : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + (∀ b, (T b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ i, r.Coprime (p i)) → (∀ i, V < p i) → + 2 ≤ Q → 0 ≤ Bφ → 0 ≤ Dφ → (∀ z, |φ z| ≤ Bφ) → + (∀ z w, |φ z - φ w| ≤ Dφ * |z - w|) → (∀ z, 1 ≤ |z| → φ z = 0) → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ a → a ≤ b → b ≤ a + 1 → + 2 * A * (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (Cbudget * L ^ d + Cbudget * L * Real.exp ((12 / 1000 : ℝ) * L)) → + (∀ x, coeff x ≠ 0 → + (∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) ∧ + (∀ i, V < (x i : ℕ)) ∧ + (∀ i, IsCoprime ((x i : ℕ) : ℤ) R) ∧ + (∀ i, r.Coprime (x i : ℕ)) ∧ + (∀ i j, ((x j : ℕ) : ZMod (p i)) ≠ 0) ∧ + M x ≤ Q ∧ + pageAtModulus (M x) (selectedPageZero input Q) = + pageAtModulus r (selectedPageZero input Q) ∧ + Real.log (M x : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) ∧ + Real.log (Reg x : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L)) → + let actual := movingOriginalPatternPrimeObservable e pattern p + (fun q : primes => (q : ℕ)) outside childBound pivotBound (fun {_} _ => f) + g Dq Finset.univ ψ X lo hi φ G t small (bulkSlotLeaves n m slot) u v a b + let integral := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + movingPatternTwoPrimeObservable e t (fun _ => small) slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input Q z y + ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x / ((z : ℂ) * (y : ℂ)) + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern actual x‖ ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern integral x * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) n t (fun _ => small) + (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ := by + filter_upwards [input.moving_original_pattern_prime_haar_rate n Cbudget d] with L hL + intro B C I _ _ _ N m e tierB tierC t small slot pattern rep primes hprimes μ ν + p _ hinjp g Dq f outside childBound pivotBound R r _ Q V hfreq ψ X lo hi hlo hhi + φ G Bφ Dφ E U u v a b + dsimp only + let T := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let Pi := fun x => movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x + let A := (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 + intro hμ hν hμmass hνmass hE hU hbound hsize hB htier hV hf hg hgnorm hout hR + hprecision hrp hspecLarge hQ hBφ hDφ hφ hlip hφout hQlog hu huv hv ha hab hb + hbudget hdata + apply movingPattern_original_integral_norm e t small slot pattern rep primes hprimes μ ν + childBound pivotBound hfreq f outside R r p g Dq input Q ψ X lo hi hlo hhi φ G u v a b + E U _ hE hU (by positivity) hμ hν hμmass hνmass hbound hsize + intro x hx + obtain ⟨hdisjoint, hlarge, hsmallR, hrcop, hres, hMQ, hpage, hMlog, hReglog⟩ := hdata x hx + have hprime (i) : (x i : ℕ).Prime := hprimes _ (x i).property + have hPi := movingPatternInternalPrimes_prime e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) x + let : ∀ q : Pi x, Fact q.val.Prime := fun q => ⟨hPi _ q.property⟩ + have hnz (z) : movingArithmeticModuli r p (Pi x) Finset.univ z ≠ 0 := + movingArithmeticModuli_ne_zero r p (Pi x) Finset.univ (NeZero.ne r) hPi + (fun i _ => (inferInstance : Fact (p i).Prime).out) z + let : ∀ z, NeZero (movingArithmeticModuli r p (Pi x) Finset.univ z) := fun z => ⟨hnz z⟩ + let : NeZero (∏ z, movingArithmeticModuli r p (Pi x) Finset.univ z) := + ⟨Finset.prod_ne_zero_iff.mpr (fun z _ => hnz z)⟩ + have hsep (i : I) (j : Fin (N + 1)) : (x j : ℕ) ≠ p i := by + intro heq + apply hres i j + rw [heq] + exact ZMod.natCast_self (p i) + have hc := movingPattern_prime_moduli_coprime e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) x r p (fun i => (inferInstance : Fact (p i).Prime).out) + hinjp hrcop hrp hsep + have hinj := movingPattern_nonzero_internal_injective e μ ν (fun q : primes => (q : ℕ)) + Subtype.val_injective pattern (fun _ => 1) x hx + have hweight (side) : ‖movingDataWeight (fun {_} _ => f) (fun {_} _ _ _ _ => 1) (T side)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (fun {_} _ => f) (fun s _ => hf s) (T side) + have hnorm (z w : ℕ) : + ‖movingSeparatedPairResidueCoefficient p (fun i => (x i : ℕ)) outside + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g (fun _ => Dq) Finset.univ T + (fun side => (T side).formulaNodes (fun i => (x i : ℕ)) (fun i => (hprime i).ne_zero) + childBound pivotBound (movingPatternFinBulkData_frequencies e t (fun _ => small) + slot (Equiv.refl _) pattern (· ≠ 0) hfreq side) (.prime false) (.prime true)) R z w‖ ≤ A := by + apply (movingSeparatedPairResidueCoefficient_norm p (fun i => (x i : ℕ)) outside + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g (fun _ => Dq) Finset.univ + (fun i => (p i : ℝ)) (fun i _ => Nat.cast_nonneg _) (fun i _ => hgnorm i) T _ R z w).trans + change (‖movingDataWeight (fun {_} _ => f) (fun {_} _ _ _ _ => 1) (T false)‖ * _ ) * + (‖movingDataWeight (fun {_} _ => f) (fun {_} _ _ _ _ => 1) (T true)‖ * _) ≤ _ + have hprod : 0 ≤ ∏ i, (p i : ℝ) ^ (2 ^ n) := by positivity + have hh := mul_le_mul (mul_le_mul_of_nonneg_right (hweight false) hprod) + (mul_le_mul_of_nonneg_right (hweight true) hprod) (by positivity) (by positivity) + simpa only [one_mul, pow_two, A] using hh + exact hL B C I N m e tierB tierC t small slot pattern primes hprimes x p g Dq f + outside childBound pivotBound R r (Pi x) hfreq V ψ X lo hi hlo hhi φ G Bφ Dφ + hB htier hdisjoint hV hlarge hg hout hR hprecision hsmallR hres hspecLarge + rfl hinj hc Q hQ hMQ hpage hBφ hDφ hφ hlip hφout hQlog hMlog + hReglog u v a b hu huv hv ha hab hb A (by dsimp only [A]; positivity) + (fun z _ w _ => hnorm z w) hbudget + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeRanges.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeRanges.lean new file mode 100644 index 0000000000000000000000000000000000000000..06d5adbf06d6726fc8d465003d4a64bf14e3baff --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeRanges.lean @@ -0,0 +1,219 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternOriginalPrimeSharp +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantConditions +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPriorArithmetic + +namespace OAI + +/-! # The original prime bound from actual ranges and conductor deletion -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_prime_range_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG : ℝ), + let Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ := fun _ {_} _ => f + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots n ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b : Bool, MovingLeafLengthLE n ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 1 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ uG → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Eprior ≤ Real.exp (Cmass * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) → + (∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (∀ j a, μ j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ j a, ν j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (movingOriginalPatternPrimeObservable e pattern p (fun q : primes => (q : ℕ)) + outside childBound pivotBound (fun {_} _ => f) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X lo hi φ G t + small (bulkSlotLeaves n m slot) uG vG rG sG) x‖ ≤ + ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * + 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) := by + filter_upwards [P.movingPattern_original_prime_sharp_rate ψ n r₀ k + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ, + movingPattern_giant_conditions P n r₀ k A hA, eventually_ge_atTop (200 : ℝ)] + with L hsharp hgiant hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound f outside _ p _ hc _ Dq sets + primeLo cutoff tier X j₀ φ G u v deleted initial μ ν Eprior αall βint Vint Uall uG vG rG sG + huG hrG huvG hrsG hvG hsG + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues + houtcover hinjp huBig hrBig hNfreq hEup hαup hβup hVeq hUlog hUup hμtier hνtier hNlo hNcut hcutlo hμlo hνlo hupper hpband hdeleteμ hdeletep + have hmem (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList n (t b)) : s ∈ Sfreq := by + rw [ht] at hs + exact allFrequencyList_subtype_mem Sfreq n (frequencyPairProjection Sfreq n b ft) s hs + have hfreq (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList n (t b)) : s ≠ 0 := + hS s (hmem b s hs) + have hfreqN (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList n (t b)) : s.natAbs ≤ Nfreq := + hN s (hmem b s hs) + have hV (b : Bool) (s : ℤ) (hs : s ∈ allFrequencyList n (t b)) : + |(s : ℝ)| ≤ Real.exp (A * spectatorBulkCount k L) := by + have hn : (s.natAbs : ℝ) ≤ Nfreq := by exact_mod_cast hfreqN b s hs + have hr : |(s : ℝ)| ≤ Nfreq := by simpa only [Nat.cast_natAbs, Int.cast_abs] using hn + exact hr.trans hNfreq + have htierC : tierC = fun c => movingSampleTier (rep c).val.2 := by + funext c + have h := htier (rep c).val + simpa only [(rep c).property] using h + have hdata := hgiant primes Bidx Cidx N e (fun q : primes => (q : ℕ)) tier tierB μ ν + pattern rep Sfreq Nfreq ft small slot p primeLo cutoff Eprior + Subtype.val_injective (fun a => hprimes _ a.property) hμ0 hν0 hμbound hμtier hνtier hB + (fun s hs => ⟨hS s hs, hN s hs⟩) hNfreq hNlo hNcut hcutlo hμlo hνlo hupper + (fun i => ⟨Fact.out, (hpband i).1, (hpband i).2, hpupper i⟩) + (hsmallLen false) hdeleteμ hdeletep + have hdata' : ∀ x : Fin (N + 1) → primes, + movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun _ => 1) x ≠ 0 → + (∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) ∧ + (∀ i, Nfreq < (x i : ℕ)) ∧ + (∀ i, IsCoprime ((x i : ℕ) : ℤ) (frequencyModelBase Sfreq n ft : ℤ)) ∧ + (∀ i, ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)).Coprime (x i : ℕ)) ∧ + (∀ i j, ((x j : ℕ) : ZMod (p i)) ≠ 0) ∧ + (∏ z, movingArithmeticModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x) Finset.univ z) ≤ giantProgressionCutoff L ∧ + pageAtModulus (∏ z, movingArithmeticModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x) Finset.univ z) + (selectedPageZero P (giantProgressionCutoff L)) = + pageAtModulus ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) + (selectedPageZero P (giantProgressionCutoff L)) ∧ + Real.log ((∏ z, movingArithmeticModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x) Finset.univ z : ℕ) : ℝ) ≤ + Real.exp ((12 / 1000 : ℝ) * L) ∧ + Real.log (MovingSlotReversal.naturalProduct (fun i => (x i : ℕ)) + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n _ (movingPatternBulkEmbedding e slot))) : ℝ) ≤ + Real.exp ((12 / 1000 : ℝ) * L) := by + simpa only [htierC] using hdata + have hsupport (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) := + movingPattern_prior_arithmetic_support e μ ν (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) pattern rep tier tierB tierC + hμtier hνtier hB htier Sfreq Nfreq primeLo ft (fun s hs => ⟨hS s hs, hN s hs⟩) + hNlo hμlo hνlo p (fun i => Fact.out) (fun i => (hpband i).2) t (fun _ => small) + slot (Equiv.refl _) hfreq hfreqN x hx + have hspecN (i) : Nfreq < p i := hNcut.trans_le (hpband i).1 + have hfreqp (i) (b : Bool) : movingGiantFrequencyUnits (p i) n (t b) := + movingGiantFrequencyUnits_of_bounds (t b) + (fun s hs => ⟨hfreq b s hs, (hfreqN b s hs).trans_lt (hspecN i)⟩) + have hrp (i) : ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)).Coprime (p i) := + ((prime_coprime_frequencyModelBase Sfreq Nfreq (p i) n Fact.out (hspecN i) + (fun s hs => ⟨hS s hs, hN s hs⟩) ft).pow_right _).symm + have hQ := giantProgressionCutoff_bounds L hL + exact hsharp lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq + Vleaf D small slot pattern rep primes hprimes childBound pivotBound hfreq f outside p hc + Dq sets (giantProgressionCutoff L) X j₀ φ G u v deleted initial μ ν Eprior αall βint Vint Uall uG vG rG sG + huG hrG huvG hrsG hvG hsG hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp + hfreqp (fun x hx i _ => (hsupport x hx).1 i) + (fun x hx i _ j _ => (hsupport x hx).2.1 i (e.symm (.inl j))) + (fun x hx i c => (hsupport x hx).2.1 i (e.symm (.inr c))) hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.1) + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.2.1) + (fun _ _ _ _ x hx _ => (hsupport x hx).2.2.2.2) + houtcover hinjp hrp hspecN hfreqN hQ.1 hQ.2 huBig hrBig hNfreq hEup hαup hβup hVeq + hUlog hUup hdata' + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeSharp.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeSharp.lean new file mode 100644 index 0000000000000000000000000000000000000000..7135ec53123fd938ac4622d8f174063792131317 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternOriginalPrimeSharp.lean @@ -0,0 +1,234 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternOriginalPrimeArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternInternalError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNormBudget + +namespace OAI + +/-! # The original prime pattern bound with all numerical errors discharged -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_prime_sharp_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG : ℝ), + let Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ := fun _ {_} _ => f + let data := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let coeff := movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun _ => 1) + let Pi := fun x => movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x + let Mgiant := fun x => ∏ z, movingArithmeticModuli + ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p (Pi x) Finset.univ z + let Reg := fun x => MovingSlotReversal.naturalProduct (fun i => (x i : ℕ)) + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := fun xg y => movingPatternTwoPrimeObservable e t (fun _ => small) slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) (fun i _ => Dq i) P Qfreq + xg y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots n ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b : Bool, MovingLeafLengthLE n ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i (b : Bool) j, + j ∈ flattenMovingSlots n ((fun _ => small) b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 1 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + (∀ i, ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)).Coprime (p i)) → + (∀ i, Nfreq < p i) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ Nfreq) → + 2 ≤ Qfreq → + Real.log (4 * (Qfreq : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ uG → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Eprior ≤ Real.exp (Cmass * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) → + (∀ x, coeff x ≠ 0 → + (∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) ∧ + (∀ i, Nfreq < (x i : ℕ)) ∧ + (∀ i, IsCoprime ((x i : ℕ) : ℤ) (frequencyModelBase Sfreq n ft : ℤ)) ∧ + (∀ i, ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)).Coprime (x i : ℕ)) ∧ + (∀ i j, ((x j : ℕ) : ZMod (p i)) ≠ 0) ∧ + Mgiant x ≤ Qfreq ∧ + pageAtModulus (Mgiant x) (selectedPageZero P Qfreq) = + pageAtModulus ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) (selectedPageZero P Qfreq) ∧ + Real.log (Mgiant x : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) ∧ + Real.log (Reg x : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (movingOriginalPatternPrimeObservable e pattern p (fun q : primes => (q : ℕ)) + outside childBound pivotBound (fun {_} _ => f) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X lo hi φ G t + small (bulkSlotLeaves n m slot) uG vG rG sG) x‖ ≤ + ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * + 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) := by + obtain ⟨Cbudget, _, hbudget⟩ := movingPattern_giant_variation_budget ψ n r₀ k + A Wwin Bφ Dφ hA hWwin + filter_upwards [P.movingPattern_original_prime_arithmetic_rate ψ n r₀ k Cbudget 2 + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ, + movingPattern_internal_arithmetic_error_rate ψ n r₀ k A Wwin Bφ Dφ Cmass + hA hWwin (by linarith), movingPattern_original_prime_norm_budget n Cmass hCmass, + eventually_ge_atTop (1 : ℝ)] with L hraw herr hnorm hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq f outside _ p _ hc _ Dq sets + Qfreq X j₀ φ G u v deleted initial μ ν Eprior αall βint Vint Uall uG vG rG sG + huG hrG huvG hrsG hvG hsG + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + houtcover hinjp hrp hspecN hfreqN hQ hQlog huBig hrBig hNfreq hEup hαup hβup hVeq hUlog hUup hdata + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let amp := 4 * (‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (fun {_} _ => f) (fun _ _ _ _ => 1) (data true)‖) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let main := ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + have hg := hbudget L hL p Nfreq lo hi (Nat.cast_nonneg _) hNfreq hhi hwindow hpupper + have hb := hraw lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq + Vleaf D small slot pattern rep primes hprimes childBound pivotBound hfreq f outside p hc + Dq sets Qfreq X j₀ φ G u v deleted initial μ ν Eprior αall βint Vint Uall uG vG rG sG + huG hrG huvG hrsG hvG hsG hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp + hfreqp hbase hsmallp hsamplesp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass (by linarith) hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + houtcover hinjp hrp hspecN hfreqN hQ hQlog huBig hrBig hg hdata + have hf (s : ℤ) : ‖f s‖ ≤ 1 := (hleaf false s []).trans (by split_ifs <;> norm_num) + have hone (b : Bool) : ‖movingDataWeight (fun {_} _ => f) + (fun _ _ _ _ => 1) (data b)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (fun {_} _ => f) (fun s _ => hf s) (data b) + have hamp : amp ≤ 4 := by + have hp := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + dsimp only [amp] + nlinarith + have hcost0 : 0 ≤ cost := by dsimp only [cost, amp]; positivity + have herror0 := movingInternalArithmeticError_nonneg n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + (Real.one_le_exp (mul_nonneg hA (Nat.cast_nonneg m))) hUall hαall hβint hVint.le + have hcnum := movingPattern_class_card_le n pattern rep + have he := herr p (Fintype.card Cidx) Uall αall βint amp lo hi hcnum hUall hUlog + hαall hαup hβint hβup (by dsimp only [amp]; positivity) hamp hhi hwindow hpupper + rw [← hVeq] at he + have hA₀ : 0 ≤ A₀ := by + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro z hz + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hz + exact pairFrequencySupportBound_nonneg D f + exact mul_nonneg (by positivity) (mul_nonneg hleaf0 hprod) + have hmain : 0 ≤ main := by dsimp only [main]; positivity + exact hnorm (Fintype.card Cidx) Eprior Uall uG rG + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint) + main (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) _ hcnum hEprior hEup + (by linarith) hUup huG hrG (mul_nonneg hcost0 herror0) hmain (by positivity) + he le_rfl (by simpa only [cost, amp, data, main, A₀, add_assoc] using hb) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPermutedProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPermutedProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b95d69c8e461a7cc88b805d3486d0639757d7a0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPermutedProduct.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternArithmeticData + +namespace OAI + +/-! # The common regular product under an arbitrary bulk matching -/ + +namespace Ostmann +open scoped Classical + +theorem bulkSlotLeaves_perm_matching {σ : Type*} (n m : ℕ) + (slot : (TreeLeafIndex n × Fin m) ↪ σ) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) : + (flattenMovingSlots n (bulkSlotLeaves n m (slot ∘ perm.symm))).Perm + (flattenMovingSlots n (bulkSlotLeaves n m slot)) := by + apply (List.perm_ext_iff_of_nodup + (bulkSlotLeaves_nodup n m _ (slot.injective.comp perm.symm.injective)) + (bulkSlotLeaves_nodup n m slot slot.injective)).mpr + intro i + rw [mem_flatten_bulkSlotLeaves, mem_flatten_bulkSlotLeaves] + constructor + · rintro ⟨j, hj⟩ + exact ⟨perm.symm j, hj⟩ + · rintro ⟨j, hj⟩ + refine ⟨perm j, ?_⟩ + simpa only [Function.comp_apply, Equiv.symm_apply_apply] using hj + +/-- A matching changes only the distribution of the bulk labels among leaves. +The regular product of the complete tree is preserved, even when the sampled +prime values have collisions. -/ +theorem movingPatternFinBulkData_regular_product_permuted {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) (value : Fin (N + 1) → ℕ) (b : Bool) : + MovingSlotReversal.naturalProduct value + (movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern b).regularSlots = + MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) := by + rw [movingPatternFinBulkData_build] + let bulk := if b then bulkSlotLeaves n m (movingPatternBulkEmbedding e slot ∘ perm.symm) + else bulkSlotLeaves n m (movingPatternBulkEmbedding e slot) + have hp := buildMovingSlotData_regular_perm n (t b) + (movingPatternFiniteSmall e n small) bulk (movingPatternFiniteSamples e n pattern b) + have hb : (flattenMovingSlots n bulk).Perm + (flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) := by + cases b + · exact List.Perm.refl _ + · exact bulkSlotLeaves_perm_matching n m (movingPatternBulkEmbedding e slot) perm + exact ((hp.trans ((List.Perm.refl _).append hb)).map value).prod_eq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc8398b5c95ec4e5115ed5fed1a087ef50b351a1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeBound.lean @@ -0,0 +1,134 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSeparatedBound +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSpectatorNorm + +namespace OAI + +/-! # The separated estimate for the literal original prime mean -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell : Type*} [Fintype Cell] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +include hsmall hB htier hR hr hg hV hBφ hDφ hφ hlip hφout j₀ in +/-- The original Page/spectator kernel now has a signed bound under its +literal deleted prime prior. Its frequency and pointwise spectator bounds +are derived; the remaining local signed mean is exactly the quartet input. -/ +theorem PublishedProgressionInput.movingPattern_original_prime_bound + [NeZero (∏ i, bulkResidueModuli r p i)] + (r₀ : ℕ) (hsmallLen : ∀ b, MovingLeafLengthLE n (small b) r₀) + (hy : 0 ≤ y) (hQ : 2 ≤ Q) (hMQ : (∏ i, bulkResidueModuli r p i) ≤ Q) + (hpage : pageAtModulus (∏ i, bulkResidueModuli r p i) (selectedPageZero P Q) = + pageAtModulus r (selectedPageZero P Q)) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (hu : ∀ j c, 1 ≤ u j c) (huv : ∀ j c, u j c ≤ v j c) + (hshort : ∀ j c, v j c ≤ u j c + 1) + (hmassCell : ∀ j c (a : (ZMod (∏ i, bulkResidueModuli r p i))ˣ), + ∑ q ∈ primeLogCellSet (∏ i, bulkResidueModuli r p i) a.val.val (u j c) (v j c), + (q : ℝ)⁻¹ ≤ 2) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hP : ∀ j, primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ primes) + (hsep : ∀ j (c d : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ), c ≠ d → + ¬Nat.ModEq (∏ i, bulkResidueModuli r p i) c.2.val.val d.2.val.val ∨ + v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hdeleted : ∀ j, (∑ q ∈ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted j, (q : ℝ)⁻¹) ≠ 0) + (hdeletedBase : ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) + (hout : ∀ q ∈ outside, q.Prime) (hdeletedOut : ∀ j q, q ∈ outside → q ∈ deleted j) + (Kspec : Fin m → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (δ : ℝ) (hδ : 0 ≤ δ) (H T : ℝ) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Q y + let spec := fun i => frozenBulkSpectatorHaar base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (g i) + let A := 2 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + let err := fun c : (TreeLeafIndex n × Fin m) → Cell => + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkKernelPairComparisonBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 Bφ Dφ * + bulkPrimeErrorFactor P Q (u j (c j)) + (∀ i, ‖(Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, spec i z‖ ≤ δ) → + (∀ j, Z j * ∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹ ≤ 2) → + (∀ j, Z j ≤ Real.exp H) → + (∀ j q, q ∈ S j \ deleted j → Real.exp T ≤ (q : ℝ)) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Q y ψ X lo hi hlo hhi φ G L U x‖ ≤ + (W * A) * 4 ^ Fintype.card (TreeLeafIndex n × Fin m) * δ ^ m + + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, ∑ z, ‖a z‖ * err c + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * Real.exp (H - T) + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) := by + intro data freq spec A W M S Z a err hlocal hmass hZ hlow + have hA : 0 ≤ A := by dsimp only [A]; positivity + have hf (z) : ‖freq z‖ ≤ A := + frozenBulkFrequencyFactor_norm_le base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Q y hy z + have hspec (i) (z) : ‖spec i z‖ ≤ Kspec i ^ (2 ^ (n + 1)) := + frozenBulkSpectatorHaar_norm_le base n m t _ _ (twist i) perm (g i) (Kspec i) + (hKspec i) (hgnorm i) z + have heq := movingPatternPrimeBulkHaar_mean e tierB tierC t small slot perm pattern hsmall hB htier + base primes hprimes hbase childBound pivotBound hfreq F E outside R r hR hr p hc g hg twist + P Q y j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + u v c₀ S deleted (fun _ => Finset.Subset.refl _) hdeletedBase hout hdeletedOut + dsimp only at heq + rw [heq] + have hb := P.movingPattern_separated_kernel_bound e tierB tierC t small slot perm pattern hB htier + hsmallLen base childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ + hφ hlip hφout L U r p hc freq spec A hA hf Q hQ hMQ hpage primes u v hu huv hshort + hmassCell c₀ hP hsep deleted hdeleted δ hδ H T (fun i => Kspec i ^ (2 ^ (n + 1))) + (fun i => pow_nonneg (hKspec i) _) + exact hb hlocal hspec hmass hZ hlow + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeBulk.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeBulk.lean new file mode 100644 index 0000000000000000000000000000000000000000..1350a0f36d5ddad1902a246237672b4842c386a4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeBulk.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.Ostmann.Construction.PrimeBulkInsertion + +namespace OAI + +/-! # Exact selected-prime mean of the original pattern kernel -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell I : Type*} [Fintype Cell] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +/-- This is the original real kernel and its original Page and spectator +averages, evaluated after inserting the selected prime draws. -/ +noncomputable def movingPatternPrimeBulkHaar (x : (TreeLeafIndex n × Fin m) → primes) : ℂ := + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + let hp := primeBulkValues_prime base (movingPatternBulkEmbedding e slot) x hprimes hbase + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes value (fun i => (hp i).ne_zero) + childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPageAverage value outside F E data nodes R r P Q y * + ∏ i, movingSpectatorHaarAverage value (p i) (g i) (twist i) data) + +include hsmall hR hr hg in +/-- Removing the fixed nonbulk primes is sufficient for the supported +arithmetic identity. The averaging law and its normalizers remain unchanged. -/ +theorem movingPatternPrimeBulkHaar_mean + [NeZero (∏ i, bulkResidueModuli r p i)] + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (S deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hS : ∀ j, S j ⊆ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1)) + (hdeleted : ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) + (hout : ∀ q ∈ outside, q.Prime) + (hdeletedOut : ∀ j q, q ∈ outside → q ∈ deleted j) : + let M := ∏ i, bulkResidueModuli r p i + let label := fun (x : (TreeLeafIndex n × Fin m) → primes) j => primeCellLabel M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) c₀ (x j) + let K := movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + let a := fun z => frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F E (movingPatternFinBulkData e n m t small slot perm pattern) childBound R r P Q y + (bulkResidueEquiv r p hc z).1 * + ∏ i, frozenBulkSpectatorHaar base n m t (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (twist i) perm (g i) ((bulkResidueEquiv r p hc z).2 i) + (∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Q y ψ X lo hi hlo hhi φ G L U x) = + ∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + (if Function.Injective x then a (fun j => (label x j).2) * + K (fun j => Real.log (x j : ℕ)) else 0) := by + intro M label K a + apply Finset.sum_congr rfl + intro x _ + by_cases hw : (∏ j, primeSubsetPrior primes (S j \ deleted j) (x j)) = 0 + · simp only [hw, Complex.ofReal_zero, zero_mul] + · have hx (j) : (x j : ℕ) ∈ S j \ deleted j := + primeSubsetPrior_support primes _ _ (Finset.prod_ne_zero_iff.mp hw j (Finset.mem_univ j)) + have hxcell (j) : (x j : ℕ) ∈ primeCellSupport M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) \ deleted j := + Finset.mem_sdiff.mpr ⟨hS j (Finset.mem_sdiff.mp (hx j)).1, (Finset.mem_sdiff.mp (hx j)).2⟩ + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + have hp := primeBulkValues_prime base (movingPatternBulkEmbedding e slot) x hprimes hbase + have hv (i) (hi : i ∉ Set.range (movingPatternBulkEmbedding e slot)) : value i = base i := + primeBulkValues_off base (movingPatternBulkEmbedding e slot) x i hi + have hz (j) : (value (movingPatternBulkEmbedding e slot j) : ZMod M) = + ((label x j).2 : ZMod M) := + primeBulkValues_cell_label base (movingPatternBulkEmbedding e slot) x M u v c₀ deleted hxcell j + have hid := movingPattern_bulk_supported_identity e tierB tierC t small slot perm pattern + hsmall hB htier base value hv hp childBound pivotBound hfreq F E outside + (primeBulkValues_cross_of_deleted base (movingPatternBulkEmbedding e slot) x S deleted hx hdeleted) + (primeBulkValues_outside_coprime base (movingPatternBulkEmbedding e slot) x S deleted + hprimes hx outside hout hdeletedOut) + R r hR hr p hc g hg twist (fun j => (label x j).2) hz P Q y + j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + dsimp only at hid + have hinj : Function.Injective (value ∘ movingPatternBulkEmbedding e slot) ↔ + Function.Injective x := primeBulkValues_injective_iff base (movingPatternBulkEmbedding e slot) x + simp only [hinj] at hid + apply congrArg (fun z : ℂ => ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * z) + unfold movingPatternPrimeBulkHaar + rw [hid] + split_ifs <;> simp only [primeBulkValues_at, K, a, value, mul_comm] + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeBulkArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeBulkArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..e5a744232d6bcaee293dc6c748754a07c95b3639 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeBulkArithmetic.lean @@ -0,0 +1,96 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkFrozen +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeBulkSupport + +namespace OAI + +/-! # Supported arithmetic of the original equality-pattern histories -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original pattern's Page and spectator factors separate on precisely +its selected bulk residues. The unchanged small and sampled data, denominator +independence and regular-list distinctness are derived from the constructor. -/ +theorem movingPattern_supported_prime_arithmetic {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base value : Fin (N + 1) → ℕ) + (hv : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), value i = base i) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (hprime : ∀ i, (value i).Prime) + (hf : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).Frequencies (· ≠ 0)) + (hinj : Function.Injective (value ∘ movingPatternBulkEmbedding e slot)) + (hcross : ∀ i j, bulkIndexPredicate (movingPatternBulkEmbedding e slot) i ≠ + bulkIndexPredicate (movingPatternBulkEmbedding e slot) j → value i ≠ value j) + (hout : ∀ j p, p ∈ outside → (value (movingPatternBulkEmbedding e slot j)).Coprime p) + (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (D : ∀ i, Bool → (ZMod (p i))ˣ) + (z : TreeLeafIndex n × Fin m → (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hz : ∀ j, (value (movingPatternBulkEmbedding e slot j) : ZMod (∏ i, bulkResidueModuli r p i)) = + (z j : ZMod _)) + (input : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) : + let T := movingPatternFinBulkData e n m t small slot perm pattern + let hvalue := fun i => (hprime i).ne_zero + movingFrequencyPrimeAverage value outside F E T + (fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) + (.prime false) (.prime true)) R r input Q xg y * + ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (D i) T = + frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + F E T childBound R r input Q xg y (bulkResidueEquiv r p hc z).1 * + ∏ i, frozenBulkSpectatorPrime base n m t (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (D i) perm (g i) + ((bulkResidueEquiv r p hc z).2 i) := by + have hfixed := fun b => movingPattern_nonbulk_values e tierB tierC slot base value hv + (small b) pattern (hsmall b) hB htier b + exact movingSupportedPrimeArithmetic_bulk_residues base value n m (movingPatternBulkEmbedding e slot) + hv t (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (fun b => (hfixed b).1) (fun b => (hfixed b).2) perm + (movingPatternFinBulkData e n m t small slot perm pattern) + (movingPatternFinBulkData_build e n m t small slot perm pattern) F E outside childBound pivotBound + (fun i => (hprime i).ne_zero) hf (fun _ _ _ i _ => hprime i) + (movingPatternFinBulkData_bulk_nodup e tierB tierC t small slot perm pattern hsmall hB htier) + hinj (fun _ _ _ i _ j _ h => hcross i j h) + (fun _ _ _ i _ hi p hp => by + obtain ⟨j, rfl⟩ := hi + exact hout j p hp) + R r (movingPatternFinBulkData_compensationAbsent e tierB tierC n m t small slot perm pattern hB htier) + hR hr p hc g hg D z hz input Q xg y + +/-- Bulk collisions are already zero under the original pattern coefficient, +so inserting the distinctness indicator precedes all changes of measure. -/ +theorem movingPattern_prime_arithmetic_collision_gate {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (value : Fin (N + 1) → ℕ) (hprime : ∀ i, (value i).Prime) + (outside : List ℕ) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (nodes : Bool → List MovingFormulaNode) (R : ℤ) (r : ℕ) [NeZero r] + (input : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) (A : ℂ) : + let T := movingPatternFinBulkData e n m t small slot perm pattern + movingFrequencyPrimeAverage value outside F E T nodes R r input Q xg y * A = + if Function.Injective (value ∘ movingPatternBulkEmbedding e slot) then + movingFrequencyPrimeAverage value outside F E T nodes R r input Q xg y * A else 0 := by + exact movingFrequencyPrimeAverage_collision_gate value n m (movingPatternBulkEmbedding e slot) + (t false) (movingPatternFiniteSmall e n (small false)) (movingPatternFiniteSamples e n pattern false) + outside hprime F E (movingPatternFinBulkData e n m t small slot perm pattern) + (movingPatternFinBulkData_build e n m t small slot perm pattern false) nodes R r input Q xg y A + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeCRT.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeCRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8fd14147ecce072fa904375a8685484b189da27 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeCRT.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeAverages +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternProducts +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeObservable + +namespace OAI + +/-! # Identifying the actual two-prime pattern with its corrected CRT mean -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- Each equality class contributes exactly one prime-square factor. -/ +theorem movingPatternPrimeHaarProduct_eq_image {A B C : Type*} [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (x : Fin (N + 1) → A) + (P : Finset ℕ) [∀ p : P, Fact p.val.Prime] + (hP : P = Finset.univ.image (fun c : C => prime (x (e.symm (.inr c))))) + (hinj : Function.Injective (fun c : C => prime (x (e.symm (.inr c))))) : + movingPatternPrimeHaarProduct e prime hprime n t small bulk pattern x = + ∏ p : P, movingInternalPrimeAverage (fun i => prime (x i)) + (movingPatternFinData e n t small bulk pattern) p.val := by + let f : C → P := fun c => ⟨prime (x (e.symm (.inr c))), by + rw [hP] + exact Finset.mem_image.mpr ⟨c, Finset.mem_univ _, rfl⟩⟩ + have hf : Function.Bijective f := by + constructor + · intro a b hab + exact hinj (congrArg Subtype.val hab) + · intro p + have hp : p.val ∈ Finset.univ.image (fun c : C => prime (x (e.symm (.inr c)))) := by + simpa only [hP] using p.property + obtain ⟨c, _, hc⟩ := Finset.mem_image.mp hp + exact ⟨c, Subtype.ext hc⟩ + let T := movingPatternFinData e n t small bulk pattern + let : ∀ c : C, Fact (prime (x (e.symm (.inr c)))).Prime := fun _ => ⟨hprime _⟩ + change (∏ c : C, movingInternalPrimeAverage (fun i => prime (x i)) T + (prime (x (e.symm (.inr c))))) = _ + exact Fintype.prod_equiv (Equiv.ofBijective f hf) _ _ (fun _ => rfl) + +section +variable {B C I : Type*} [Fintype C] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (input : PublishedProgressionInput) (Q : ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + +/-- The original two-prime observable, including its internal Haar factors, +is the corrected mean of the separated residue coefficient. -/ +theorem movingPatternTwoPrimeObservable_crt (x : Fin (N + 1) → primes) + (P : Finset ℕ) [∀ q : P, Fact q.val.Prime] + [∀ b, NeZero (movingArithmeticModuli r p P Finset.univ b)] + [NeZero (∏ b, movingArithmeticModuli r p P Finset.univ b)] + (hP : P = Finset.univ.image (fun c : C => (x (e.symm (.inr c)) : ℕ))) + (hinj : Function.Injective (fun c : C => (x (e.symm (.inr c)) : ℕ))) + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hprecision : R ^ (n + 1) ∣ (r : ℤ)) + (hcover : ∀ b, ∀ o ∈ (movingPatternFinBulkData e n m t small slot perm pattern b).occurrences, + ∀ i ∈ o.current.compensationSlots, (x i : ℕ) ∈ P) + (hc : Pairwise (fun b c => (movingArithmeticModuli r p P Finset.univ b).Coprime + (movingArithmeticModuli r p P Finset.univ c))) + (hpage : pageAtModulus (∏ b, movingArithmeticModuli r p P Finset.univ b) + (selectedPageZero input Q) = pageAtModulus r (selectedPageZero input Q)) (u v : ℝ) : + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (T b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + movingPatternTwoPrimeObservable e t small slot perm pattern primes hprimes childBound pivotBound + hfreq F E outside R r p g twist input Q u v ψ X lo hi hlo hhi φ G (Real.exp u) (Real.exp v) x * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot perm) pattern x = + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp u) (Real.exp v) * + correctedPrimePairAverage input Q (∏ b, movingArithmeticModuli r p P Finset.univ b) + (movingSeparatedPairResidueCoefficient p value outside F E g (fun b i => twist i b) + Finset.univ T nodes R) u v := by + dsimp only + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t small slot perm pattern + let hf := movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq + let nodes := fun b => (T b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound (hf b) + (.prime false) (.prime true) + have h := movingSeparatedPairResidueCoefficient_prime_page_factorization p value outside F E g + (fun b i => twist i b) T nodes R r P Finset.univ hf hR hprecision hcover hc input Q hpage u v + have hspec : (∏ i : (Finset.univ : Finset I), + movingSpectatorPrimeAverage value (p i.val) (g i.val) (fun b => twist i.val b) T) = + ∏ i : I, movingSpectatorPrimeAverage value (p i) (g i) (twist i) T := by + exact Finset.prod_coe_sort Finset.univ + (fun i => movingSpectatorPrimeAverage value (p i) (g i) (twist i) T) + rw [hspec] at h + rw [h, movingPatternPrimeHaarProduct_eq_image e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) t small (movingPatternBulkLeaves n m slot perm) pattern x P hP hinj] + unfold movingPatternTwoPrimeObservable + let K := movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp u) (Real.exp v) + let A := movingFrequencyPrimeAverage value outside F E T nodes R r input Q u v + let S := ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) T + let H := ∏ q : P, movingInternalPrimeAverage value T q.val + change (K * (A * S)) * H = K * ((A * H) * S) + ring + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeFrozenNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeFrozenNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..26ec0926e916e784b6f74262815f9c4d581f1bcd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeFrozenNorm.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenPrimeUnitArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSpectatorUnits +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkFrozen + +namespace OAI + +/-! # The two-prime arithmetic norm for the original same-assignment pattern -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_same_assignment_prime_norm {B C I : Type*} [Fintype I] {N₀ n m : ℕ} + (e : Fin (N₀ + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (S : Finset ℤ) (t : FrequencyTree (S × S) n) (R N V : ℕ) + [NeZero (R ^ (n - 1 + 2))] + (hS : ∀ s ∈ S, s ≠ 0) (hN : ∀ s ∈ S, s.natAbs ≤ N) + (hR : ∀ b (j : Fin (2 ^ n - 1)), + (singleTreeNodeFrequencies S n (frequencyPairProjection S n b t) j.val).root.natAbs ∣ R) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b i, i ∈ flattenMovingSlots n (small b) → i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N₀ + 1) → ℕ) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), IsCoprime (base i : ℤ) (R : ℤ)) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N₀ + 1)) k → ℤ → ℂ) + (hF : ∀ b s regular, ‖F b (.leaf s regular) s‖ ≤ if s.natAbs ≤ V then 1 else 0) + (D : ℝ) (hD : 0 ≤ D) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) (hm : 0 < m) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + [NeZero (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli (R ^ (n - 1 + 2)) p i).Coprime + (bulkResidueModuli (R ^ (n - 1 + 2)) p j))) (hp : ∀ i, 3 ≤ p i) + (hfreq : ∀ i b, movingGiantFrequencyUnits (p i) n + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t))) + (hsmallp : ∀ i b j, j ∈ flattenMovingSlots n (small b) → + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) + (hasamples : ∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (henergy : ∀ i, ∑ x : ZMod (p i), ‖g i x‖ ^ 2 ≤ (p i : ℝ)) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (outside : List ℕ) (childBound : ℕ → ℕ) + (input : PublishedProgressionInput) (Qfreq Qbulk : ℕ) (X Y : ℝ) (hX : 0 ≤ X) (hY : 0 ≤ Y) + (Ybulk : TreeLeafIndex n × Fin m → ℝ) (hYbulk : ∀ j, 0 ≤ Ybulk j) : + let ts := fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t) + let data := movingPatternFinBulkData e n m ts small slot (Equiv.refl _) pattern + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + F (fun _ _ _ _ _ => 1) data childBound R (R ^ (n - 1 + 2)) input Qfreq X Y + let spec := fun i => frozenBulkSpectatorPrime base n m ts + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) (Equiv.refl _) (g i) + let M := ∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i + let A := fun z => freq (bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).2 i) + (Fintype.card (TreeLeafIndex n × Fin m → (ZMod M)ˣ) : ℝ)⁻¹ * + (∑ z : TreeLeafIndex n × Fin m → (ZMod M)ˣ, + ‖A z * ∏ j, pageGiantWeight input Qbulk M (z j).val.val (Ybulk j)‖) ≤ + ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * Fintype.card I)) * + (frequencyLeafWeight (pairedFrequencyLeaf S V) n t * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod) := by + intro ts data freq spec M A + have hslot (j : TreeLeafIndex n × Fin m) : + n ≤ ((Sum.elim tierB tierC) ∘ e) (movingPatternBulkEmbedding e slot j) := by + change n ≤ Sum.elim tierB tierC (e (e.symm (.inl (slot j)))) + simpa only [Equiv.apply_symm_apply, Sum.elim_inl] using hB (slot j) + have hd : data = fun b => buildMovingSlotData n (ts b) (movingPatternFiniteSmall e n (small b)) + (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot)) (movingPatternFiniteSamples e n pattern b) := by + funext b + dsimp only [data] + rw [movingPatternFinBulkData_build] + cases b <;> rfl + have h := frozenPrimeUnitArithmeticMean_le base ((Sum.elim tierB tierC) ∘ e) S n m R N V t + hS hN hR (movingPatternBulkEmbedding e slot) (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) hslot + (fun b => movingPatternFiniteSmall_absent e slot (small b) (hsmall b)) + (movingPatternFiniteSamples_levels e tierB tierC n pattern htier) hbase F hF D hD hdiv hm p hc hp hfreq + (fun i b => movingPatternFiniteSmall_unit e base (small b) (hsmallp i b)) + (fun i => movingPatternFiniteSamples_units e base pattern (hasamples i)) + g hg henergy twist outside childBound input Qfreq Qbulk X Y hX hY Ybulk hYbulk + dsimp only [A, freq, spec, M] + rw [hd] + unfold frozenPrimeUnitArithmeticMean at h + dsimp only at h + simp only [finite_univ_canonical, Fintype.card_eq_nat_card] at h ⊢ + apply le_trans (le_of_eq ?_) h + congr 1 + apply Finset.sum_congr rfl + intro z _ + congr 1 + exact mul_right_comm _ _ _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeGain.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeGain.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d0b0d40625b213d62c7e40c9d33ab1266636254 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeGain.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelGain +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCost + +namespace OAI + +/-! # A common local tolerance for the literal prime comparison -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- A single mixed-character tolerance and prime threshold work for all +actual pattern trees and bulk lengths. No local cancellation bound is an +assumption here: it is derived from the quartet theorem. -/ +theorem exists_movingPatternPrimeGain (ψ : 𝓢(ℝ, ℂ)) (n r₀ : ℕ) + (A lo hi B D F gain : ℝ) (hA : 0 ≤ A) (hhi : lo ≤ hi) : + ∃ ε δ : ℝ, 0 < ε ∧ ε ≤ 1 ∧ 0 < δ ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ (m : ℕ), 1 ≤ m → ∀ (Bidx Cidx : Type) (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (base : Fin (N + 1) → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime], + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0 ∧ s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) → + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) → + ∀ (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)), + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + ∀ S : ∀ i, Finset (ZMod (p i)), + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (S i)) → + (∀ i, residueDensity (S i) ≤ 2 / 3) → + (∀ i, (S i).Nonempty) → (∀ i, (S i).card < p i) → + ∀ β : Fin m → ℝ, (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((S i).card : ℂ)⁻¹ * ∑ x ∈ S i, χ⁻¹ (-a - x)‖ ≤ β i) → + ∀ amp : ℝ, 0 ≤ amp → amp ≤ Real.exp (F * m) → + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + (∀ i, ‖(Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) (twist i) perm + (normalizedResidueTransform (S i)) z‖ ≤ δ) ∧ + (W * amp) * 4 ^ Fintype.card (TreeLeafIndex (n + 2) × Fin m) * + δ ^ m ≤ Real.exp (-gain * m) := by + obtain ⟨C, _, hkernel⟩ := exists_movingPatternKernelGain ψ (n + 2) r₀ + A lo hi B D F gain hA hhi + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hlocal⟩ := exists_frozenSpectatorGain n (C + F) gain + let δ := signedBulkGainTarget (n + 2) (C + F) gain + refine ⟨ε, δ, hε, hε1, signedBulkGainTarget_pos _ _ _, cutoff, hcutoff, ?_⟩ + intro m hm Bidx Cidx N e base t small pattern p _ hp hfreq hsmall hsamples twist perm hgood + S hlo hhi hS hSp β hβ hbias amp hamp hampBound + dsimp only + have hi (i : Fin m) : + ‖(Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) (twist i) perm + (normalizedResidueTransform (S i)) z‖ ≤ δ := + hlocal (p i) (hp i) (Fin (N + 1)) base m (by omega) t _ _ + (fun b => movingGiantFrequencyUnits_of_bounds (t b) (hfreq i b)) + (fun b => movingPatternFiniteSmall_unit e base (small b) (hsmall i b)) + (movingPatternFiniteSamples_units e base pattern (hsamples i)) + (twist i) perm hgood (S i) (hlo i) (hhi i) (hS i) (hSp i) (β i) (hβ i) (hbias i) + exact ⟨hi, hkernel m hm amp δ hamp hampBound (signedBulkGainTarget_pos _ _ _).le le_rfl⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeHaarComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeHaarComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..3302f9b1932bdf3b540f07ea17a3a806a2d8586d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeHaarComparison.lean @@ -0,0 +1,154 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeIntegralBridge +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternArithmeticData +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicSupport + +namespace OAI + +/-! # The original finite-pattern prime integral, with its actual CRT law -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- A direct application of the published progression input to the literal +pattern integral. Structural tree and compensation assumptions are derived +from the sampler and its prime ranges. The cutoff is uniform in all finite +pattern spaces, the sampled assignment, and the spectator list. -/ +theorem PublishedProgressionInput.moving_original_pattern_prime_haar_rate + (input : PublishedProgressionInput) (n : ℕ) (Cbudget : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, + ∀ (B C I : Type) [Fintype C] [Fintype I] (N m : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (x : Fin (N + 1) → primes) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (R : ℤ) (r : ℕ) [NeZero r] (P : Finset ℕ) [∀ q : P, Fact q.val.Prime] + [∀ b, NeZero (movingArithmeticModuli r p P Finset.univ b)] + [NeZero (∏ b, movingArithmeticModuli r p P Finset.univ b)] + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (V : ℕ) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ), + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let nodes := fun b => (T b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound + (movingPatternFinBulkData_frequencies e t (fun _ => small) slot (Equiv.refl _) + pattern (· ≠ 0) hfreq b) (.prime false) (.prime true) + let M := ∏ b, movingArithmeticModuli r p P Finset.univ b + let Reg := MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) + (∀ b, n ≤ tierB b) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → value i ≠ value j) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ V) → (∀ i, V < value i) → + (∀ i, g i 0 = 0) → (∀ q ∈ outside, ∃ i, p i = q) → + (∀ b, (T b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ i, IsCoprime (value i : ℤ) R) → + (∀ i j, (value j : ZMod (p i)) ≠ 0) → + (∀ i, V < p i) → + P = Finset.univ.image (fun c : C => value (e.symm (.inr c))) → + Function.Injective (fun c : C => value (e.symm (.inr c))) → + Pairwise (fun a b => (movingArithmeticModuli r p P Finset.univ a).Coprime + (movingArithmeticModuli r p P Finset.univ b)) → + ∀ Q : ℕ, 2 ≤ Q → M ≤ Q → + pageAtModulus M (selectedPageZero input Q) = pageAtModulus r (selectedPageZero input Q) → + 0 ≤ Bφ → 0 ≤ Dφ → (∀ z, |φ z| ≤ Bφ) → + (∀ z w, |φ z - φ w| ≤ Dφ * |z - w|) → (∀ z, 1 ≤ |z| → φ z = 0) → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + Real.log (M : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + Real.log (Reg : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v a b : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ a → a ≤ b → b ≤ a + 1 → + ∀ A : ℝ, 0 ≤ A → + (∀ z < M, ∀ w < M, + ‖movingSeparatedPairResidueCoefficient p value outside (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) g (fun _ => Dq) Finset.univ T nodes R z w‖ ≤ A) → + 2 * A * (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (Cbudget * L ^ d + Cbudget * L * Real.exp ((12 / 1000 : ℝ) * L)) → + ‖movingOriginalPatternPrimeObservable e pattern p (fun q : primes => (q : ℕ)) + outside childBound pivotBound (fun {_} _ => f) g Dq Finset.univ ψ X lo hi φ G + t small (bulkSlotLeaves n m slot) u v a b x - + (∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + movingPatternTwoPrimeObservable e t (fun _ => small) slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input Q z y + ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x / ((z : ℂ) * (y : ℂ))) * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) n t (fun _ => small) + (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [input.moving_original_supported_pair_haar_rate_uniform n Cbudget d] with L hL + intro B C I _ _ N m e tierB tierC t small slot pattern primes hprimes x p _ g Dq f outside + childBound pivotBound R r _ P _ _ _ hfreq V ψ X lo hi hlo hhi φ G Bφ Dφ + dsimp only + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let hf := movingPatternFinBulkData_frequencies e t (fun _ => small) slot (Equiv.refl _) + pattern (· ≠ 0) hfreq + let nodes := fun b => (T b).formulaNodes value (fun i => (hprimes _ (x i).property).ne_zero) + childBound pivotBound (hf b) (.prime false) (.prime true) + let M := ∏ b, movingArithmeticModuli r p P Finset.univ b + let Reg := MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) + intro hB htier hdisjoint hV hlarge hg hout hR hprecision hsmallR hres hspecLarge hP hinj hc + Q hQ hMQ hpage hBφ hDφ hφ hlip hφout hQlog hMlog hReglog + u v a b hu huv hv ha hab hb A hA hAbound hbudget + have hprime (i) : (value i).Prime := hprimes _ (x i).property + have hVN (side) : (T side).Frequencies (fun s => s.natAbs ≤ V) := + movingPatternFinBulkData_frequencies e t (fun _ => small) slot (Equiv.refl _) pattern _ hV side + have hVR (side) : (T side).Frequencies (fun s => |(s : ℝ)| ≤ (V : ℝ)) := + (hVN side).mono (fun s hs => by + simpa only [Nat.cast_natAbs, Int.cast_abs] using (show (s.natAbs : ℝ) ≤ V by exact_mod_cast hs)) + have hsmall (side) := (T side).small_frequency_units value hprime V hlarge (hf side) (hVN side) + have hfmod (side) := (T side).small_frequency_residues value hprime V hlarge (hf side) (hVN side) + have hden (side i) : (T side).ModularDenominators value (p i) := by + apply (T side).modularDenominators_of_units value (p i) (hres i) + exact movingPatternFinBulkData_frequencies e t (fun _ => small) slot (Equiv.refl _) + pattern (fun s => (s : ZMod (p i)) ≠ 0) + (fun b s hs => intCast_ne_zero_of_natAbs_lt (p i) s (hfreq b s hs) + ((hV b s hs).trans_lt (hspecLarge i))) side + have hcover := movingPatternFinBulkData_internal_cover e tierB tierC t (fun _ => small) + slot (Equiv.refl _) pattern hB htier (fun q : primes => (q : ℕ)) x + have hcoverP (side o) (ho : o ∈ (T side).occurrences) (j) (hj : j ∈ o.current.compensationSlots) : + value j ∈ P := by + rw [hP] + exact hcover side o ho j hj + have hperiod := movingArithmeticModuli_periods r p P Finset.univ R (n + 1) hprecision + have hReg : 0 < Reg := by + apply Nat.pos_of_ne_zero + change (List.map value _).prod ≠ 0 + apply List.prod_ne_zero + intro hz + obtain ⟨i, _, hi⟩ := List.mem_map.mp hz + exact (hprime i).ne_zero hi + have h := hL (Fin (N + 1)) I p ((Sum.elim tierB tierC) ∘ e) value hprime hdisjoint + outside childBound pivotBound T hf t + (movingPatternFinBulkData_follows e t (fun _ => small) slot (Equiv.refl _) pattern) + (movingPatternFinBulkData_levels e tierB tierC n m t (fun _ => small) slot (Equiv.refl _) pattern hB htier) + (movingPatternFinBulkData_regular_coherent e t (fun _ => small) slot (Equiv.refl _) pattern) + hsmall hfmod (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g hg (fun _ => Dq) Finset.univ + (fun q hq => by obtain ⟨i, hi⟩ := hout q hq; exact ⟨i, Finset.mem_univ _, hi⟩) + R hR hsmallR (fun side i _ => hden side i) Reg + (movingPatternFinBulkData_regular_product e t small slot pattern value) + ψ X lo hi hlo hhi φ G Bφ Dφ hBφ hDφ hφ hlip hφout V hVR Q M hQ + (Nat.one_le_iff_ne_zero.mpr (NeZero.ne M)) hMQ hperiod.1 + (fun side o ho j hj => hperiod.2.1 _ (hcoverP side o ho j hj)) + hperiod.2.2 hQlog u v a b hu huv hv ha hab hb hMlog hReg hReglog A hA hAbound hbudget + rw [movingOriginalPatternPrimeObservable_pair_frequency] + rw [movingPatternTwoPrimeObservable_integral_crt e t (fun _ => small) slot (Equiv.refl _) + pattern primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input Q ψ X lo hi hlo hhi φ G + x P hP hinj hR hprecision hcoverP hc hpage] + exact h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeIntegralBridge.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeIntegralBridge.lean new file mode 100644 index 0000000000000000000000000000000000000000..a48a60e895ea271ec701b69ad97aeccf4ee3c713 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeIntegralBridge.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeRelabel +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeCRT +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedPairHaarComparison + +namespace OAI + +/-! # The original prime integrand and the integrated pattern CRT identity -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The leaf frequency mask has no dependence on the names of sampled slots. -/ +theorem movingOriginalPatternPrimeObservable_pair_frequency {σ I B C : Type} + {N n m : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (pattern : Bool × MovingSampleIndex n → C) + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (x : Fin (N + 1) → σ) (u v r s : ℝ) : + movingOriginalPatternPrimeObservable e pattern q value outside childBound pivotBound + (fun {_} _ => f) g Dq S ψ X lo hi φ G t small (bulkSlotLeaves n m slot) u v r s x = + complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun z => + movingOriginalSupportedPair q (value ∘ x) outside childBound pivotBound + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g (fun _ => Dq) S ψ X lo hi φ G + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern) t + ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊)) := by + rw [movingOriginalPatternPrimeObservable_fin] + congr 1 + +section +variable {B C I : Type} [Fintype C] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (input : PublishedProgressionInput) (Q : ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + +theorem movingPatternTwoPrimeObservable_integral_crt (x : Fin (N + 1) → primes) + (P : Finset ℕ) [∀ q : P, Fact q.val.Prime] + [∀ b, NeZero (movingArithmeticModuli r p P Finset.univ b)] + [NeZero (∏ b, movingArithmeticModuli r p P Finset.univ b)] + (hP : P = Finset.univ.image (fun c : C => (x (e.symm (.inr c)) : ℕ))) + (hinj : Function.Injective (fun c : C => (x (e.symm (.inr c)) : ℕ))) + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hprecision : R ^ (n + 1) ∣ (r : ℤ)) + (hcover : ∀ b, ∀ o ∈ (movingPatternFinBulkData e n m t small slot perm pattern b).occurrences, + ∀ i ∈ o.current.compensationSlots, (x i : ℕ) ∈ P) + (hc : Pairwise (fun b c => (movingArithmeticModuli r p P Finset.univ b).Coprime + (movingArithmeticModuli r p P Finset.univ c))) + (hpage : pageAtModulus (∏ b, movingArithmeticModuli r p P Finset.univ b) + (selectedPageZero input Q) = pageAtModulus r (selectedPageZero input Q)) + (u v a b : ℝ) : + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun side => (T side).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq side) + (.prime false) (.prime true) + (∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + movingPatternTwoPrimeObservable e t small slot perm pattern primes hprimes childBound pivotBound + hfreq F E outside R r p g twist input Q z y ψ X lo hi hlo hhi φ G + (Real.exp z) (Real.exp y) x / ((z : ℂ) * (y : ℂ))) * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot perm) pattern x = + ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) * + correctedPrimePairAverage input Q (∏ j, movingArithmeticModuli r p P Finset.univ j) + (movingSeparatedPairResidueCoefficient p value outside F E g (fun side i => twist i side) + Finset.univ T nodes R) z y / ((z : ℂ) * (y : ℂ)) := by + dsimp only + rw [← integral_mul_const] + congr 1 + funext z + rw [← integral_mul_const] + congr 1 + funext y + rw [← mul_div_right_comm] + rw [movingPatternTwoPrimeObservable_crt e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist input Q ψ X lo hi hlo hhi φ G + x P hP hinj hR hprecision hcover hc hpage z y] + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2a18477ffcab7bac4019f59969efe3eadd33173 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNorm.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCost + +namespace OAI + +/-! # Pointwise bound for the literal original prime observable -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell I : Type*} [Fintype Cell] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +include hB htier hV hBφ hDφ hφ hlip hφout j₀ in +/-- This uniform pointwise estimate allows the extra nonbulk-prime deletion +error to be returned to the initial external law. -/ +theorem movingPatternPrimeBulkHaar_norm + (hy : 0 ≤ y) (Kspec : I → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (x : (TreeLeafIndex n × Fin m) → primes) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let amp := 2 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + ‖movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Q y ψ X lo hi hlo hhi φ G L U x‖ ≤ + (amp * ∏ i, Kspec i ^ (2 ^ (n + 1))) * W := by + intro data amp W + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + have hp := primeBulkValues_prime base (movingPatternBulkEmbedding e slot) x hprimes hbase + have hv : ∀ i, value i ≠ 0 := fun i => (hp i).ne_zero + have hf := movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq + let nodes := fun b => (data b).formulaNodes value hv childBound pivotBound (hf b) + (.prime false) (.prime true) + have hk : ‖movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U‖ ≤ W := by + rw [← realValueKernelPair_nat value hv childBound pivotBound data hf] + exact movingPattern_kernel_norm_le e tierB tierC t small slot perm pattern hB htier + (fun i => (value i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + have hfr : ‖movingFrequencyPageAverage value outside F E data nodes R r P Q y‖ ≤ amp := + movingFrequencyPageAverage_norm_le value outside F E data nodes R r P Q y hy + have hs : ‖∏ i, movingSpectatorHaarAverage value (p i) (g i) (twist i) data‖ ≤ + ∏ i, Kspec i ^ (2 ^ (n + 1)) := by + rw [norm_prod] + exact Finset.prod_le_prod₀ (fun i _ => norm_nonneg _) (fun i _ => + movingSpectatorHaarAverage_norm_le value (p i) (g i) (twist i) data + (Kspec i) (hKspec i) (hgnorm i)) + change ‖movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPageAverage value outside F E data nodes R r P Q y * + ∏ i, movingSpectatorHaarAverage value (p i) (g i) (twist i) data)‖ ≤ _ + simp only [norm_mul] + calc + _ ≤ W * (amp * ∏ i, Kspec i ^ (2 ^ (n + 1))) := + mul_le_mul hk (mul_le_mul hfr hs (norm_nonneg _) (by dsimp only [amp]; positivity)) + (by positivity) (sq_nonneg _) + _ = _ := mul_comm _ _ + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..feb2944c75e97a37b76e4ee322ee0c916054abc6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormBound.lean @@ -0,0 +1,135 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelNormBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternNormKernel +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSpectatorNorm + +namespace OAI + +/-! # The norm estimate for the literal original prime mean -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell : Type*} [Fintype Cell] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +include hsmall hB htier hR hr hg hV hBφ hDφ hφ hlip hφout j₀ in +/-- Transfer a retained arithmetic absolute mean to the original prime law, +with the sharp window factor in the main term and the established variation +budget in the approximation errors. -/ +theorem PublishedProgressionInput.movingPattern_original_prime_norm_bound + [NeZero (∏ i, bulkResidueModuli r p i)] + (r₀ : ℕ) (hsmallLen : ∀ b, MovingLeafLengthLE n (small b) r₀) + (hy : 0 ≤ y) (hQ : 2 ≤ Q) (hMQ : (∏ i, bulkResidueModuli r p i) ≤ Q) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (hu : ∀ j c, 1 ≤ u j c) (huv : ∀ j c, u j c ≤ v j c) + (hshort : ∀ j c, v j c ≤ u j c + 1) + (hmassCell : ∀ j c (a : (ZMod (∏ i, bulkResidueModuli r p i))ˣ), + ∑ q ∈ primeLogCellSet (∏ i, bulkResidueModuli r p i) a.val.val (u j c) (v j c), + (q : ℝ)⁻¹ ≤ 2) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hP : ∀ j, primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ primes) + (hsep : ∀ j (c d : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ), c ≠ d → + ¬Nat.ModEq (∏ i, bulkResidueModuli r p i) c.2.val.val d.2.val.val ∨ + v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hdeleted : ∀ j, (∑ q ∈ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted j, (q : ℝ)⁻¹) ≠ 0) + (hdeletedBase : ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) + (hout : ∀ q ∈ outside, q.Prime) (hdeletedOut : ∀ j q, q ∈ outside → q ∈ deleted j) + (Kspec : Fin m → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (A₀ : ℝ) (hA₀ : 0 ≤ A₀) (H T : ℝ) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Q y + let spec := fun i => frozenBulkSpectatorHaar base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (g i) + let A := 2 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let W₀ := ((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * Bφ ^ (2 ^ n - 1)) ^ 2 + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + let err := fun c : (TreeLeafIndex n × Fin m) → Cell => + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkKernelPairComparisonBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 Bφ Dφ * + bulkPrimeErrorFactor P Q (u j (c j)) + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P Q M (w j).val.val (z j)‖ ≤ A₀) → + (∀ j, Z j * ∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹ ≤ 2) → + (∀ j, Z j ≤ Real.exp H) → + (∀ j q, q ∈ S j \ deleted j → Real.exp T ≤ (q : ℝ)) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Q y ψ X lo hi hlo hhi φ G L U x‖ ≤ + (W₀ * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, ∑ z, ‖a z‖ * err c + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * Real.exp (H - T) + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) := by + intro data freq spec A W W₀ M S Z a err hlocal hmass hZ hlow + have hA : 0 ≤ A := by dsimp only [A]; positivity + have hf (z) : ‖freq z‖ ≤ A := + frozenBulkFrequencyFactor_norm_le base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Q y hy z + have hspec (i) (z) : ‖spec i z‖ ≤ Kspec i ^ (2 ^ (n + 1)) := + frozenBulkSpectatorHaar_norm_le base n m t _ _ (twist i) perm (g i) (Kspec i) + (hKspec i) (hgnorm i) z + have heq := movingPatternPrimeBulkHaar_mean e tierB tierC t small slot perm pattern hsmall hB htier + base primes hprimes hbase childBound pivotBound hfreq F E outside R r hR hr p hc g hg twist + P Q y j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + u v c₀ S deleted (fun _ => Finset.Subset.refl _) hdeletedBase hout hdeletedOut + dsimp only at heq + rw [heq] + have hb := P.movingPattern_norm_kernel_bound e tierB tierC t small slot perm pattern hB htier + hsmallLen base childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ + hφ hlip hφout L U r p hc freq spec A hA hf Q hQ hMQ primes u v hu huv hshort + hmassCell c₀ hP hsep deleted hdeleted A₀ hA₀ H T (fun i => Kspec i ^ (2 ^ (n + 1))) + (fun i => pow_nonneg (hKspec i) _) + exact hb hlocal hspec hmass hZ hlow + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..44759c0795296784a0dcd157fed149e8abca1094 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormBudget.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantErrorRate + +namespace OAI + +/-! # Joining the giant error to the sharp original arithmetic budget -/ + +namespace Ostmann +open Filter + +/-- The exact harmonic denominator can be discarded only after positivity. +The giant comparison adds one error and leaves the sharp Fourier main term +and its internal-class weight intact. -/ +theorem movingPattern_original_prime_norm_budget (n : ℕ) (C : ℝ) (hC : 1 ≤ C) : + ∀ᶠ L : ℝ in atTop, ∀ (c : ℕ) (E U u r cost main bulk a : ℝ), + c ≤ 4 * n * 2 ^ n → 1 ≤ E → E ≤ Real.exp (C * L) → + 0 ≤ U → U ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) → + 1 ≤ u → 1 ≤ r → 0 ≤ cost → 0 ≤ main → 0 ≤ bulk → + cost ≤ Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) → + bulk ≤ Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) → + a ≤ ((2 : ℝ) ^ c * E ^ (4 * n * 2 ^ n - c) * U ^ c) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + ((4 : ℝ) ^ c * E ^ (4 * n * 2 ^ n - c)) * (cost + main + bulk) / (u * r) → + a ≤ ((4 : ℝ) ^ c * E ^ (4 * n * 2 ^ n - c)) * + (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + main) := by + filter_upwards [movingPattern_giant_error_rate n C hC] with L hgiant + intro c E U u r cost main bulk a hc hE hEup hU hUup hu hr hcost hmain hbulk + hcostup hbulkup ha + let κ := (4 : ℝ) ^ c * E ^ (4 * n * 2 ^ n - c) + have hκ : 1 ≤ κ := one_le_mul_of_one_le_of_one_le + (one_le_pow₀ (by norm_num)) (one_le_pow₀ hE) + have hκ0 : 0 ≤ κ := by linarith + have hden : 1 ≤ u * r := one_le_mul_of_one_le_of_one_le hu hr + have hn : 0 ≤ κ * (cost + main + bulk) := by positivity + have hdiv := div_le_self hn hden + have hsmall := hgiant c hc E U (by linarith) hEup hU hUup + have hmove : Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) ≤ + κ * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := + le_mul_of_one_le_left (Real.exp_nonneg _) hκ + have hcost' := mul_le_mul_of_nonneg_left hcostup hκ0 + have hbulk' := mul_le_mul_of_nonneg_left hbulkup hκ0 + change a ≤ κ * _ + change a ≤ _ + κ * (cost + main + bulk) / (u * r) at ha + nlinarith only [ha, hdiv, hsmall, hmove, hcost', hbulk'] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..1eee204e8cfa964f0b15b14d995ba336dbdf2fd8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormRate.lean @@ -0,0 +1,180 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNormBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCellError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBadEventRate +import OAI.NumberTheory.Ostmann.Construction.OriginalHarmonicRate +import OAI.NumberTheory.Ostmann.ZeroDensity.BulkProgressionCutoff + +namespace OAI + +/-! # The original-prior norm estimate at the manuscript scales -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_original_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P (bulkProgressionCutoff L) y + let spec := fun i => frozenBulkSpectatorHaar base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U x‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨Cerr, hCerr, hCnorm, hcellRate⟩ := + P.movingPattern_cell_error_rate ψ n r₀ k A lo hi Bφ Dφ F (Cmass + 1) hA hhi hF + obtain ⟨Tcell, _, hcellTwo⟩ := P.short_prime_cell_mass_two + have hlarge : ∀ᶠ L : ℝ in atTop, Tcell ≤ Real.exp ((39 / 10000 : ℝ) * L) := + (Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num))).eventually + (eventually_ge_atTop Tcell) + filter_upwards [hcellRate, movingPattern_bad_event_rate ψ n r₀ k + A lo hi Bφ Dφ F (Cmass + 1) hA hhi hF, + P.original_harmonic_box_rate Cmass hCmass, hlarge, eventually_ge_atTop (2000 : ℝ)] + with L herror hbad hnormal hlarge hL + dsimp only + intro Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets y X A₀ j₀ φ G U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P (bulkProgressionCutoff L) y + let spec := fun i => frozenBulkSpectatorHaar base n m t + (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (twist i) perm + (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hZ (j) : Z j ≤ Real.exp (Cerr * L) := (hnorm j).2.1.trans + (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hCnorm (by linarith))) + have hunit : (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) := + bulkResidueModulus_unit_card hMQ (Nat.floor_le (Real.exp_nonneg _)) + have ha (z) : ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) := by + exact moving_frozen_residue_coefficient_norm base (movingPatternBulkEmbedding e slot) outside + Fw Ew n m data childBound R r P (bulkProgressionCutoff L) y hy p sets hsets hsetsp + t _ _ twist perm (bulkResidueEquiv r p hc z).1 (bulkResidueEquiv r p hc z).2 + have he := herror Cell M (bulkProgressionCutoff L) hQ.1 hQ.2 p Z a amp + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 hZ hcard hunit hamp0 hamp ha le_rfl u hulow + have hbd := hbad p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hb := P.movingPattern_original_prime_norm_bound e tierB tierC t small slot perm pattern + hsmall hB htier base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r + hR hr p hc (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) twist (bulkProgressionCutoff L) y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + r₀ hsmallLen hy hQ.1 hMQ u v hu huv hshort + (fun j c z => hcellTwo M z.val.val (u j c) (v j c) (hlarge.trans (hulow j c)) (hshort j c)) + c₀ hS (fun j => unitPrimeCells_separated M (u j) (v j) (hsep j)) deleted + (fun j => (hnorm j).1.ne') hdelbase hout hdelout (fun i => (p i : ℝ)) + (fun i => Nat.cast_nonneg _) (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) + A₀ hA₀ ((Cmass + 1) * L) (Real.exp ((39 / 10000 : ℝ) * L)) + hlocal (fun j => (hnorm j).2.2) (fun j => (hnorm j).2.1) + (fun j q hq => hlow j q (Finset.mem_sdiff.mp hq).1) + dsimp only at hb + have hh := add_le_add (le_refl + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m))) (add_le_add he hbd) + apply hb.trans + simpa only [add_assoc, W, amp, Z, a, spec, freq, data, M, S] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormalizedNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormalizedNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..62e93f4774927acb79329c2cf96cc7bda3d67951 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeNormalizedNorm.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeFrozenNorm +import OAI.NumberTheory.Ostmann.Characters.NormalizedResidueIndicator + +namespace OAI + +/-! # The two-prime absolute norm for the normalized spectator transforms -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_normalized_same_assignment_prime_norm {B C I : Type*} [Fintype I] {N₀ n m : ℕ} + (e : Fin (N₀ + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (S : Finset ℤ) (t : FrequencyTree (S × S) n) (R N V : ℕ) + [NeZero (R ^ (n - 1 + 2))] + (hS : ∀ s ∈ S, s ≠ 0) (hN : ∀ s ∈ S, s.natAbs ≤ N) + (hR : ∀ b (j : Fin (2 ^ n - 1)), + (singleTreeNodeFrequencies S n (frequencyPairProjection S n b t) j.val).root.natAbs ∣ R) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b i, i ∈ flattenMovingSlots n (small b) → i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N₀ + 1) → ℕ) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), IsCoprime (base i : ℤ) (R : ℤ)) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N₀ + 1)) k → ℤ → ℂ) + (hF : ∀ b s regular, ‖F b (.leaf s regular) s‖ ≤ if s.natAbs ≤ V then 1 else 0) + (D : ℝ) (hD : 0 ≤ D) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) (hm : 0 < m) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + [NeZero (∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli (R ^ (n - 1 + 2)) p i).Coprime + (bulkResidueModuli (R ^ (n - 1 + 2)) p j))) (hp : ∀ i, 3 ≤ p i) + (hfreq : ∀ i b, movingGiantFrequencyUnits (p i) n + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t))) + (hsmallp : ∀ i b j, j ∈ flattenMovingSlots n (small b) → + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) + (hasamples : ∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) + (sets : ∀ i, Finset (ZMod (p i))) + (hsets : ∀ i, (sets i).Nonempty) (hsetsLt : ∀ i, (sets i).card < p i) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (outside : List ℕ) (childBound : ℕ → ℕ) + (input : PublishedProgressionInput) (Qfreq Qbulk : ℕ) (X Y : ℝ) (hX : 0 ≤ X) (hY : 0 ≤ Y) + (Ybulk : TreeLeafIndex n × Fin m → ℝ) (hYbulk : ∀ j, 0 ≤ Ybulk j) : + let ts := fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t) + let data := movingPatternFinBulkData e n m ts small slot (Equiv.refl _) pattern + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + F (fun _ _ _ _ _ => 1) data childBound R (R ^ (n - 1 + 2)) input Qfreq X Y + let spec := fun i => frozenBulkSpectatorPrime base n m ts + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) (Equiv.refl _) (normalizedResidueTransform (sets i)) + let M := ∏ i, bulkResidueModuli (R ^ (n - 1 + 2)) p i + let A := fun z => freq (bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv (R ^ (n - 1 + 2)) p hc z).2 i) + (Fintype.card (TreeLeafIndex n × Fin m → (ZMod M)ˣ) : ℝ)⁻¹ * + (∑ z : TreeLeafIndex n × Fin m → (ZMod M)ˣ, + ‖A z * ∏ j, pageGiantWeight input Qbulk M (z j).val.val (Ybulk j)‖) ≤ + ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * Fintype.card I)) * + (frequencyLeafWeight (pairedFrequencyLeaf S V) n t * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod) := by + exact movingPattern_same_assignment_prime_norm e tierB tierC S t R N V hS hN hR small slot pattern + hsmall hB htier base hbase F hF D hD hdiv hm p hc hp hfreq hsmallp hasamples + (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) + (fun i => (normalizedResidueTransform_energy (sets i) (hsets i) (hsetsLt i)).le) + twist outside childBound input Qfreq Qbulk X Y hX hY Ybulk hYbulk + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeObservable.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeObservable.lean new file mode 100644 index 0000000000000000000000000000000000000000..f5aee0a584cf62a3f8f05159255525f1d9304bc3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeObservable.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMean + +namespace OAI + +/-! # The literal prime observable in the original nonbulk Fubini formula -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (P : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (L U : ℝ) + +/-- The coefficient before selecting or conditioning any of its bulk +coordinates. All original frequency and coprimality gates are retained. -/ +noncomputable def movingPatternPrimeObservable (x : Fin (N + 1) → primes) : ℂ := + let value := fun i => (x i : ℕ) + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPageAverage value outside F E data nodes R r P Q y * + ∏ i, movingSpectatorHaarAverage value (p i) (g i) (twist i) data) + +theorem movingPatternPrimeObservable_join (base : Fin (N + 1) → primes) + (z : TreeLeafIndex n × Fin m → primes) : + movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q y ψ X lo hi hlo hhi φ G L U + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => base i)) = + movingPatternPrimeBulkHaar e t small slot perm pattern (fun i => (base i : ℕ)) primes + hprimes (fun i _ => hprimes _ (base i).property) childBound pivotBound hfreq F E outside + R r p g twist P Q y ψ X lo hi hlo hhi φ G L U z := by + have hv : (fun i => (joinBulkNonbulk (A := primes) (movingPatternBulkEmbedding e slot) z + (fun j => base j) i : ℕ)) = + primeBulkValues (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) z := by + funext i + by_cases hi : i ∈ Set.range (movingPatternBulkEmbedding e slot) + · obtain ⟨j, rfl⟩ := hi + rw [joinBulkNonbulk_bulk, primeBulkValues_at] + · rw [joinBulkNonbulk_nonbulk (movingPatternBulkEmbedding e slot) z + (fun j => base j) ⟨i, hi⟩, primeBulkValues_off _ _ _ i hi] + let eval : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} → ℂ := fun v => + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes v.val v.property childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + movingRealKernelPair v.val data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPageAverage v.val outside F E data nodes R r P Q y * + ∏ i, movingSpectatorHaarAverage v.val (p i) (g i) (twist i) data) + let left : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} := + ⟨fun i => (joinBulkNonbulk (A := primes) (movingPatternBulkEmbedding e slot) z + (fun j => base j) i : ℕ), + fun i => (hprimes _ ((joinBulkNonbulk (A := primes) + (movingPatternBulkEmbedding e slot) z (fun j => base j)) i).property).ne_zero⟩ + let right : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} := + ⟨primeBulkValues (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) z, + fun i => (primeBulkValues_prime (fun i => (base i : ℕ)) + (movingPatternBulkEmbedding e slot) z hprimes + (fun i _ => hprimes _ (base i).property) i).ne_zero⟩ + change eval left = eval right + exact congrArg eval (Subtype.ext hv) + +/-- This is exactly the selected-coordinate average used by the signed +pattern majorant, under the initial word law. -/ +theorem movingPatternBulkMean_primeObservable (base : Fin (N + 1) → primes) + (ν : B → primes → ℝ) (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hν : ∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) : + movingPatternBulkMean e ν slot + (movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q y ψ X lo hi hlo hhi φ G L U) base = + ∑ z : TreeLeafIndex n × Fin m → primes, + ((∏ j, primeSubsetPrior primes (initial j) (z j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern (fun i => (base i : ℕ)) primes + hprimes (fun i _ => hprimes _ (base i).property) childBound pivotBound hfreq F E outside + R r p g twist P Q y ψ X lo hi hlo hhi φ G L U z := by + unfold movingPatternBulkMean + apply Finset.sum_congr rfl + intro z _ + rw [movingPatternPrimeObservable_join] + simp only [hν] + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..46e3963c4c68676a6915a2cee69af3129ee408f3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeRate.lean @@ -0,0 +1,192 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeGain +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCellError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBadEventRate +import OAI.NumberTheory.Ostmann.Construction.OriginalHarmonicRate +import OAI.NumberTheory.Ostmann.ZeroDensity.BulkProgressionCutoff + +namespace OAI + +/-! # One original-prior signed bulk estimate at the manuscript scales -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The three arithmetic costs are combined for the literal original prime +mean. The only analytic input is the published progression theorem; local +cancellation is proved from the balanced spectator sets and their mixed +Fourier bounds. All prime normalizers are those before idealization. -/ +theorem PublishedProgressionInput.movingPattern_original_prime_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) → + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ‖∑ x : (TreeLeafIndex (n + 2) × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, δ, hε, hε1, hδ, cutoff, hcutoff, hgain⟩ := + exists_movingPatternPrimeGain ψ n r₀ A lo hi Bφ Dφ F gain hA hhi + obtain ⟨Cerr, hCerr, hCnorm, hcellRate⟩ := + P.movingPattern_cell_error_rate ψ (n + 2) r₀ k A lo hi Bφ Dφ F (Cmass + 1) hA hhi hF + obtain ⟨Tcell, _, hcellTwo⟩ := P.short_prime_cell_mass_two + have hlarge : ∀ᶠ L : ℝ in atTop, Tcell ≤ Real.exp ((39 / 10000 : ℝ) * L) := + (Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num))).eventually + (eventually_ge_atTop Tcell) + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hcellRate, movingPattern_bad_event_rate ψ (n + 2) r₀ k + A lo hi Bφ Dφ F (Cmass + 1) hA hhi hF, + P.original_harmonic_box_rate Cmass hCmass, hlarge, eventually_ge_atTop (2000 : ℝ)] + with L herror hbad hnormal hlarge hL + dsimp only + intro Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β y X j₀ φ G U u v deleted + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P (bulkProgressionCutoff L) y + let spec := fun i => frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) (twist i) perm + (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hg := hgain m hm Bidx Cidx N e base t small pattern p hp + (fun i b s hs => ⟨hfreq b s hs, hfreqp i b s hs⟩) hsmallp hsamplesp + twist perm hgood sets hdlo hdhi hsets hsetsp β hβ hbias amp hamp0 hamp + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hZ (j) : Z j ≤ Real.exp (Cerr * L) := (hnorm j).2.1.trans + (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hCnorm (by linarith))) + have hunit : (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) := + bulkResidueModulus_unit_card hMQ (Nat.floor_le (Real.exp_nonneg _)) + have ha (z) : ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1)) := by + exact moving_frozen_residue_coefficient_norm base (movingPatternBulkEmbedding e slot) outside + Fw Ew (n + 2) m data childBound R r P (bulkProgressionCutoff L) y hy p sets hsets hsetsp + t _ _ twist perm (bulkResidueEquiv r p hc z).1 (bulkResidueEquiv r p hc z).2 + have he := herror Cell M (bulkProgressionCutoff L) hQ.1 hQ.2 p Z a amp + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 hZ hcard hunit hamp0 hamp ha le_rfl u hulow + have hbd := hbad p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hb := P.movingPattern_original_prime_bound e tierB tierC t small slot perm pattern + hsmall hB htier base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r + hR hr p hc (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) twist (bulkProgressionCutoff L) y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + r₀ hsmallLen hy hQ.1 hMQ hpage u v hu huv hshort + (fun j c z => hcellTwo M z.val.val (u j c) (v j c) (hlarge.trans (hulow j c)) (hshort j c)) + c₀ hS (fun j => unitPrimeCells_separated M (u j) (v j) (hsep j)) deleted + (fun j => (hnorm j).1.ne') hdelbase hout hdelout (fun i => (p i : ℝ)) + (fun i => Nat.cast_nonneg _) (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) + δ hδ.le ((Cmass + 1) * L) (Real.exp ((39 / 10000 : ℝ) * L)) + hg.1 (fun j => (hnorm j).2.2) (fun j => (hnorm j).2.1) + (fun j q hq => hlow j q (Finset.mem_sdiff.mp hq).1) + dsimp only at hb + calc + _ ≤ _ := hb + _ ≤ Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + have hh := add_le_add (add_le_add hg.2 he) hbd + simpa only [add_assoc, W, amp, Z, a, spec, freq, data, M, S] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeRelabel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..21449094634afd2dfc0b20c956ba22356f3b0db1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeRelabel.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPatternMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalWeightRelabel +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkData + +namespace OAI + +/-! # The original pattern prime integral in the arithmetic coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingPatternFinData_evaluate {σ B C : Type*} {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (x : Fin (N + 1) → σ) (b : Bool) : + (movingPatternFinData e n t small bulk pattern b).map x = + buildMovingSlotData n (t b) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n (small b)) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n (bulk b)) + (movingPatternSamples σ n (fun i => x (e.symm (.inr (pattern i)))) b) := by + rw [movingPatternFinData_build, buildMovingSlotData_map] + simp only [movingPatternFiniteSmall, treeLeafMap_list_comp, movingPatternFiniteSamples, + movingPatternSamples_map] + rfl + +/-- The supported prime term of the original pattern, with its values pulled +back along the finite assignment. -/ +noncomputable def movingPatternSupportedPrimeTerm {σ I B C : Type} + {N n : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (pattern : Bool × MovingSampleIndex n → C) + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) + (F : {d : ℕ} → MovingSlotData σ d → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (x : Fin (N + 1) → σ) (b : Bool) (XL XR : ℕ) : ℂ := + let T := movingPatternFinData e n t (fun _ => small) (fun _ => bulk) pattern b + movingSupportedWeight (value ∘ x) outside T XL XR + (movingOriginalGiantWeight q (value ∘ x) childBound pivotBound + (fun T => F (T.map x)) (fun _ _ _ _ => 1) g Dq S ψ X lo hi φ G T (t b) XL XR) + +theorem movingOriginalPatternPrimeObservable_fin {σ I B C : Type} + {N n : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (pattern : Bool × MovingSampleIndex n → C) + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) + (F : {d : ℕ} → MovingSlotData σ d → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (u v r w : ℝ) (x : Fin (N + 1) → σ) : + movingOriginalPatternPrimeObservable e pattern q value outside childBound pivotBound F g Dq S + ψ X lo hi φ G t small bulk u v r w x = + complexPrimeInterval 1 0 r w (fun y => complexPrimeInterval 1 0 u v (fun z => + movingPatternSupportedPrimeTerm e pattern q value outside childBound pivotBound F g Dq S + ψ X lo hi φ G t small bulk x false ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ * + star (movingPatternSupportedPrimeTerm e pattern q value outside childBound pivotBound F g Dq S + ψ X lo hi φ G t small bulk x true ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊))) := by + have hterm (b : Bool) (XL XR : ℕ) : + let T := buildMovingSlotData n (t b) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n small) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n bulk) + (movingPatternSamples σ n (fun i => x (e.symm (.inr (pattern i)))) b) + movingSupportedWeight value outside T XL XR + (movingOriginalGiantWeight q value childBound pivotBound F (fun _ _ _ _ => 1) + g Dq S ψ X lo hi φ G T (t b) XL XR) = + movingPatternSupportedPrimeTerm e pattern q value outside childBound pivotBound F g Dq S + ψ X lo hi φ G t small bulk x b XL XR := by + dsimp only + rw [← movingPatternFinData_evaluate e t (fun _ => small) (fun _ => bulk) pattern x b, + movingOriginalGiantWeight_map, movingSupportedWeight_map] + rfl + unfold movingOriginalPatternPrimeObservable movingOriginalPairPrimeKernel + change complexPrimeInterval 1 0 r w (fun y => complexPrimeInterval 1 0 u v (fun z => + _ * star _)) = _ + simp_rw [← hterm] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeSelectedPriors.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeSelectedPriors.lean new file mode 100644 index 0000000000000000000000000000000000000000..6fa84522f1c9a1c8e835d486e3f94c7da8803a98 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeSelectedPriors.lean @@ -0,0 +1,174 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeWholeShell +import OAI.NumberTheory.Ostmann.Construction.HarmonicFamilyBounds +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyModelRange + +namespace OAI + +/-! # The original-prime bound for actual selected harmonic laws -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_prime_selected_priors_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ c K : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hc : 0 < c) (hK : 0 ≤ K) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cmass := K + 1 + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (_rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (Qμ : ℕ → Finset ℕ) (Qν : Bidx → Finset ℕ) (uG vG rG sG : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let Eprior := Real.exp (Cmass * L) + let Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ := fun _ {_} _ => f + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots n ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → + (∀ b : Bool, MovingLeafLengthLE n ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ uG → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + (∀ j, j < n → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (movingOriginalPatternPrimeObservable e pattern p (fun q : primes => (q : ℕ)) + outside childBound pivotBound (fun {_} _ => f) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X lo hi φ G t + small (bulkSlotLeaves n m slot) uG vG rG sG) x‖ ≤ + ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * + 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) := by + have hfamily := selected_harmonic_family_bounds c K hc hK + let Cmass := K + 1 + have hCmass : 1 ≤ Cmass := hfamily.1 + filter_upwards [P.movingPattern_prime_whole_shell_rate C hM ψ n r₀ k + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ, + movingFrequencyModel_bulk_range n k A hA, + eventually_ge_atTop (max 1 (-Real.log c))] with L hrate hmod hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound f outside p _ Dq sets + primeLo cutoff tier X j₀ φ G global Qμ Qν uG vG rG sG + huG hrG huvG hrsG hvG hsG hsmall hB hsmallLen ht hS hN hleaf hD hdiv hm hp + hsets hsetsp hpupper hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp huBig hrBig + hNfreq hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let α := Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) + let β := Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) + let Vint := Real.exp ((1 / 100 : ℝ) * L) + let Uall := Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) + obtain ⟨hμ0, hν0, hμsum, hνsum, hμbound, hμα, hνα, hμβ, hμmin⟩ := + hfamily.2 L hL primes Bidx Qμ Qν hμP hνP hμmass hνmass hμrange hνrange + have htiers := selected_harmonic_family_tiers primes Bidx n Qμ Qν tier tierB hμtier hνtier + have hL0 : 0 ≤ L := le_trans (by norm_num) ((le_max_left _ _).trans hL) + have hμlo (j) (q : primes) (hq : μ j q ≠ 0) : primeLo < (q : ℕ) := by + have hr := hμmin j q hq + have hh : Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ + Real.exp (Real.exp ((1 / 100 : ℝ) * L)) := + Real.exp_le_exp.mpr (Real.exp_le_exp.mpr (by linarith only [hL0])) + exact_mod_cast (hloReal.trans_le (hh.trans hr)) + have hνlo (j) (q : primes) (hq : ν j q ≠ 0) : primeLo < (q : ℕ) := by + exact_mod_cast (hloReal.trans_le (hνrange j q (primeSubsetPrior_support primes (Qν j) q hq))) + have hUlog : Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) := by + dsimp only [Uall] + rw [Real.log_exp] + exact Real.exp_le_exp.mpr (by linarith only [hL0]) + have hUup : Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + exact Real.exp_le_exp.mpr (by simpa only [Uall, Real.log_exp] using hUlog) + obtain ⟨hrpos, hMpos, hcop, hMQ⟩ := hmod Sfreq Nfreq ft p hS hN hNfreq + (fun i => Fact.out) hinjp (fun i => hNcut.trans_le (hpband i).1) hpupper + let : NeZero (frequencyModelBase Sfreq n ft ^ (n - 1 + 2)) := ⟨Nat.ne_of_gt hrpos⟩ + let : NeZero (∏ i, bulkResidueModuli (frequencyModelBase Sfreq n ft ^ (n - 1 + 2)) p i) := + ⟨Nat.ne_of_gt hMpos⟩ + by_cases htier : ∀ i, movingSampleTier (rep (pattern i)).val.2 = movingSampleTier i.2 + · + exact hrate lo hi hlo hhi hwindow Bidx Cidx N e tierB (fun c => movingSampleTier (rep c).val.2) t Sfreq ft Nfreq Vleaf D + small slot pattern rep primes hprimes childBound pivotBound f outside p hcop Dq sets + primeLo cutoff tier X j₀ φ G global μ ν (Real.exp (Cmass * L)) α β Vint Uall uG vG rG sG + huG hrG huvG hrsG hvG hsG hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp + hsets hsetsp hpupper hMQ hφ hlip hφout hShell hdel hout + (fun j => congrArg (primeSubsetPrior primes) (hν j)) + hμ0 hν0 hμsum hνsum (Real.one_le_exp_iff.mpr (mul_nonneg (by linarith only [hCmass]) hL0)) + (Real.exp_pos _).le (Real.exp_pos _).le (Real.exp_pos _) (Real.one_le_exp_iff.mpr (Real.exp_pos _).le) + hμbound hμα hνα (fun c => hμβ _) (fun c => hμmin _) hupper houtcover hinjp huBig hrBig + hNfreq le_rfl le_rfl le_rfl rfl hUlog hUup htiers.1 htiers.2 hNlo hNcut hcutlo hμlo hνlo + hupper hpband + (fun z hz q hq j a ha heq => hdeleteμ z hz q hq j + (heq ▸ primeSubsetPrior_support primes (Qμ j) a ha)) hdeletep + · have hz (H : (Fin (N + 1) → primes) → ℂ) (x) : + movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern H x = 0 := + movingPattern_zero_of_inconsistent_tiers e μ ν (fun q : primes => (q : ℕ)) + pattern rep tier htiers.1 htier H x + dsimp only [μ, ν] at hz + simp only [hz, Finset.sum_const_zero, norm_zero] + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro z hz + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hz + exact pairFrequencySupportBound_nonneg D f + positivity + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..112d4f0c726961930bb1b49f342727e876d1cd4c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeSupport.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPriorRanges +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFrequencyModulus +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticModulus + +namespace OAI + +/-! # The concrete prime support of a nonzero original pattern coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original coefficient can only be nonzero on its representative +product prior. This implication does not replace repeated samples by +independent ones. -/ +theorem movingPattern_nonzero_prior {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (x : Fin (N + 1) → A) + (hx : movingOriginalPatternWeight e μ ν prime n pattern G x ≠ 0) : + productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 := by + intro hz + have h := movingPattern_coefficient_zero_of_prior e μ ν prime pattern rep E + hprime hμ hν hbound x hz + apply hx + change _ * movingPatternInjectionGuard e G x = 0 + rw [h, zero_mul] + +theorem movingPattern_nonzero_internal_injective {A B C : Type*} [Fintype B] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (hinj : Function.Injective prime) + (pattern : Bool × MovingSampleIndex n → C) + (G : (Fin (N + 1) → A) → ℂ) (x : Fin (N + 1) → A) + (hx : movingOriginalPatternWeight e μ ν prime n pattern G x ≠ 0) : + Function.Injective (fun c => prime (x (e.symm (.inr c)))) := by + have hg : movingPatternInjectionGuard e G x ≠ 0 := (mul_ne_zero_iff.mp hx).2 + exact hinj.comp (movingPatternInjectionGuard_nonzero e G x hg).1 + +/-- All prime coprimality conditions against the actual history modulus +follow from the lower endpoint of the original product prior. -/ +theorem movingPattern_prior_frequency_coprime {A B C : Type*} + {N n : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (hprime : ∀ a, (prime a).Prime) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (S : Finset ℤ) (V : ℕ) (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) + (hμ : ∀ j a, μ j a ≠ 0 → V < prime a) + (hν : ∀ j a, ν j a ≠ 0 → V < prime a) + (x : Fin (N + 1) → A) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ∀ i, (prime (x i)).Coprime (frequencyModelBase S n t) := by + intro i + have hi := Finset.prod_ne_zero_iff.mp hx i (Finset.mem_univ _) + apply prime_coprime_frequencyModelBase S V (prime (x i)) n (hprime _) + · cases he : e i with + | inl b => exact hν b (x i) (by simpa only [he, Sum.elim_inl] using hi) + | inr c => exact hμ _ (x i) (by simpa only [he, Sum.elim_inr] using hi) + · exact hS + +noncomputable def movingPatternInternalPrimes {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (x : Fin (N + 1) → A) : Finset ℕ := + Finset.univ.image (fun c : C => prime (x (e.symm (.inr c)))) + +theorem movingPatternInternalPrimes_prime {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (x : Fin (N + 1) → A) : + ∀ p ∈ movingPatternInternalPrimes e prime x, p.Prime := by + intro p hp + obtain ⟨c, _, rfl⟩ := Finset.mem_image.mp hp + exact hprime _ + +/-- Distinct spectators and the prior's elementary prime coprimality give +pairwise coprimality of every actual giant CRT block. -/ +theorem movingPattern_prime_moduli_coprime {A B C I : Type*} [Fintype C] [Fintype I] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (x : Fin (N + 1) → A) (r : ℕ) (p : I → ℕ) + (hp : ∀ i, (p i).Prime) (hinj : Function.Injective p) + (hr : ∀ i, r.Coprime (prime (x i))) (hrp : ∀ i, r.Coprime (p i)) + (hsep : ∀ i j, prime (x j) ≠ p i) : + Pairwise (fun a b => + (movingArithmeticModuli r p (movingPatternInternalPrimes e prime x) Finset.univ a).Coprime + (movingArithmeticModuli r p (movingPatternInternalPrimes e prime x) Finset.univ b)) := by + apply movingArithmeticModuli_coprime r p (movingPatternInternalPrimes e prime x) Finset.univ + (movingPatternInternalPrimes_prime e prime hprime x) (fun i _ => hp i) + (fun _ _ _ _ h => hinj h) + · intro q hq + obtain ⟨c, _, rfl⟩ := Finset.mem_image.mp hq + exact hr _ + · exact fun i _ => hrp i + · intro q hq i _ + obtain ⟨c, _, rfl⟩ := Finset.mem_image.mp hq + exact hsep i _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeWholeShell.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeWholeShell.lean new file mode 100644 index 0000000000000000000000000000000000000000..914dcc579a1c378776551567c3e3544e9373d5a5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPrimeWholeShell.lean @@ -0,0 +1,172 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternOriginalPrimeRanges +import OAI.NumberTheory.Ostmann.Arithmetic.WholeShellArithmeticCells +import OAI.NumberTheory.Ostmann.Construction.FrozenPrimeDeletions + +namespace OAI + +/-! # The sharp original prime bound on the entire bulk shell -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_prime_whole_shell_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (_hlo : 1 ≤ lo) (_hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (f : ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG : ℝ), + let Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ := fun _ {_} _ => f + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → + (∀ b : Bool, ∀ i ∈ flattenMovingSlots n ((fun _ => small) b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b : Bool, MovingLeafLengthLE n ((fun _ => small) b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, ν (slot j) = primeSubsetPrior primes (S \ global)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 1 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ q ∈ outside, ∃ i, p i = q) → + Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ uG → + Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (Nfreq : ℝ) ≤ Real.exp (A * m) → + Eprior ≤ Real.exp (Cmass * L) → + αall ≤ Real.exp (Cmass * L - Real.exp ((39 / 10000 : ℝ) * L)) → + βint ≤ Real.exp (Cmass * L - Real.exp ((1 / 100 : ℝ) * L)) → + Vint = Real.exp ((1 / 100 : ℝ) * L) → + Real.log Uall ≤ Real.exp ((12 / 1000 : ℝ) * L) → + Uall ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) → + (∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → + Nfreq ≤ primeLo → Nfreq < cutoff → cutoff ≤ primeLo → + (∀ j a, μ j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ j a, ν j a ≠ 0 → primeLo < (a : ℕ)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (movingOriginalPatternPrimeObservable e pattern p (fun q : primes => (q : ℕ)) + outside childBound pivotBound (fun {_} _ => f) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X lo hi φ G t + small (bulkSlotLeaves n m slot) uG vG rG sG) x‖ ≤ + ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * + 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) := by + filter_upwards [P.movingPattern_original_prime_range_rate ψ n r₀ k + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ, + whole_shell_arithmetic_cells C Cmass hM hCmass] with L hrate hcells + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound f outside _ p _ hc _ Dq sets + primeLo cutoff tier X j₀ φ G global μ ν Eprior αall βint Vint Uall uG vG rG sG + huG hrG huvG hrsG hvG hsG hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp + hsets hsetsp hpupper hMQ hφ hlip hφout hShell hdel hout hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues houtcover hinjp huBig hrBig + hNfreq hEup hαup hβup hVeq hUlog hUup hμtier hνtier hNlo hNcut hcutlo hμlo hνlo + hupper hpband hdeleteμ hdeletep + let m := spectatorBulkCount k L + let a : ℝ := (4 / 1000) * L + let b : ℝ := (6 / 1000) * L + let u := fun (_ : TreeLeafIndex n × Fin m) => wholeShellLower a b + let v := fun (_ : TreeLeafIndex n × Fin m) => wholeShellUpper a b + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := primeLogCellSet 1 0 (Real.exp a) (Real.exp b) + let deleted := fun x : Fin (N + 1) → primes => global ∪ + frozenPrimeDeletions (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside + obtain ⟨hcard, hunit, hlow, huv, hshort, hsep, hMcell, hsupport, hmass⟩ := + hcells M hMQ + have hDcard (x) : ((deleted x).card : ℝ) ≤ Real.exp (Cmass * L) := by + have hh : (deleted x).card ≤ global.card + (N + 1) + outside.length := by + have ht := (Finset.card_union_le global _).trans + (Nat.add_le_add_left (frozenPrimeDeletions_card_le + (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside) global.card) + simpa only [Fintype.card_fin, Nat.add_assoc] using ht + exact (Nat.cast_le.mpr hh).trans hdel + have hsub (j) : S \ global ⊆ primeCellSupport M + (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) := by + rw [hsupport]; exact Finset.sdiff_subset + have hretain (x) (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted x ⊆ S \ global := by + rw [hsupport] + intro q hq + exact Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hq).1, + fun hg => (Finset.mem_sdiff.mp hq).2 (Finset.mem_union_left _ hg)⟩ + exact hrate lo hi hlo hhi hwindow Bidx Cidx (Fin (wholePrimeGridCount b)) N e tierB tierC + t Sfreq ft Nfreq Vleaf D small slot pattern rep primes hprimes childBound pivotBound f + outside p hc Dq sets primeLo cutoff tier X j₀ φ G u v (fun x _ => deleted x) (fun _ => S \ global) + μ ν Eprior αall βint Vint Uall uG vG rG sG + huG hrG huvG hrsG hvG hsG hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp + hsets hsetsp hpupper hMQ hφ hlip hφout hcard (fun _ => hunit) (fun _ => hlow) + (fun _ => huv) (fun _ => hshort) (fun _ => hsep) (fun _ => hMcell) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hShell) (fun x _ _ => hDcard x) + (fun j => by dsimp only [u, v]; rw [hsupport]; exact hmass) + (fun x _ _ i hi => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_base (fun i => (x i : ℕ)) _ outside i hi)) hout + (fun x _ _ q hq => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_outside (fun i => (x i : ℕ)) _ outside q hq)) + (⟨0, wholePrimeGridCount_pos b⟩, 1) hsub (fun x _ => hretain x) hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues houtcover hinjp huBig hrBig + hNfreq hEup hαup hβup hVeq hUlog hUup hμtier hνtier hNlo hNcut hcutlo hμlo hνlo + hupper hpband hdeleteμ hdeletep + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPriorArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPriorArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..db175063d6d8d4c10ad65c0535620a55a59d98d5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPriorArithmetic.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkBudgets + +namespace OAI + +/-! # Arithmetic support under the unchanged representative prior -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The literal list of frequencies still lies in the finite source set. -/ +theorem allFrequencyList_subtype_mem (S : Finset ℤ) (n : ℕ) + (t : FrequencyTree S n) (s : ℤ) + (hs : s ∈ allFrequencyList n (frequencyTreeMap Subtype.val n t)) : s ∈ S := by + induction n with + | zero => + have heq : s = Subtype.val t := by simpa only [frequencyTreeMap, allFrequencyList, List.mem_singleton] using hs + simpa only [heq] using (Subtype.property t) + | succ n ih => + simp only [frequencyTreeMap, allFrequencyList, List.mem_cons, List.mem_append] at hs + rcases hs with heq | hs | hs + · simpa only [heq] using (Subtype.property t.1) + · exact ih t.2.1 hs + · exact ih t.2.2 hs + +/-- Range separation supplies the arithmetic support used when averaging +internal primes. The conclusion holds on the actual product prior, before +restricting to a nonzero observable. -/ +theorem movingPattern_prior_arithmetic_support {A B C I : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (hinj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (tier : A → ℕ) (tierB : B → ℕ) (tierC : C → ℕ) + (hμtier : ∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) + (hνtier : ∀ j a, ν j a ≠ 0 → tier a = tierB j) (hB : ∀ b, n ≤ tierB b) + (htierC : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (S : Finset ℤ) (V lo : ℕ) (ft : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) (hVlo : V ≤ lo) + (hμlo : ∀ j a, μ j a ≠ 0 → lo < prime a) + (hνlo : ∀ j a, ν j a ≠ 0 → lo < prime a) + (p : I → ℕ) (hp : ∀ i, (p i).Prime) (hplo : ∀ i, p i ≤ lo) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (hf : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ V) + (x : Fin (N + 1) → A) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + (∀ i, IsCoprime (prime (x i) : ℤ) (frequencyModelBase S n ft : ℤ)) ∧ + (∀ i j, (prime (x j) : ZMod (p i)) ≠ 0) ∧ + (∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + prime (x i) ≠ prime (x j)) ∧ + (∀ b c, prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) ∧ + (∀ c b, (movingPatternFinBulkData e n m t small slot perm pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) := by + have hlarge := movingPattern_prior_lower e μ ν prime pattern rep lo hμlo hνlo x hx + have hlargeV (i) : V < prime (x i) := hVlo.trans_lt (hlarge i) + have hcop := movingPattern_prior_frequency_coprime e μ ν prime hprime pattern rep S V ft hS + (fun j a ha => hVlo.trans_lt (hμlo j a ha)) + (fun j a ha => hVlo.trans_lt (hνlo j a ha)) x hx + have hsep := movingPattern_prior_prime_separation e μ ν pattern rep tier tierB prime hinj + hμtier hνtier hB x hx + have htierEq : tierC = fun c => movingSampleTier (rep c).val.2 := by + funext c + have h := htierC (rep c).val + simpa only [(rep c).property] using h + refine ⟨?_, ?_, ?_, hsep.2, ?_⟩ + · intro i + rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast, Int.natAbs_natCast] + exact hcop i + · intro i j hz + have hd := (ZMod.natCast_eq_zero_iff (prime (x j)) (p i)).mp hz + have heq := (Nat.prime_dvd_prime_iff_eq (hp i) (hprime _)).mp hd + have hlt := (hplo i).trans_lt (hlarge j) + omega + · simpa only [htierEq] using hsep.1 + · intro c b + let T := movingPatternFinBulkData e n m t small slot perm pattern b + exact T.small_frequency_residues (fun i => prime (x i)) (fun i => hprime _) + V hlargeV (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hf b) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hfreq b) (e.symm (.inr c)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPriorRanges.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPriorRanges.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff97bb6c1b44f262c475c89984da0d660a3c2f67 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPriorRanges.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPriorSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSmallFrequencyUnits + +namespace OAI + +/-! # Actual prior support supplies the level and prime-separation hypotheses -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_internal_prior_nonzero {A B C : Type*} [Fintype B] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (pattern : Bool × MovingSampleIndex n → C) + (G : (Fin (N + 1) → A) → ℂ) (x : Fin (N + 1) → A) + (hx : movingOriginalPatternWeight e μ ν prime n pattern G x ≠ 0) : + ∀ i, μ (movingSampleTier i.2) (x (e.symm (.inr (pattern i)))) ≠ 0 := by + have hm : movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) ≠ 0 := by + intro hz + apply hx + simp only [movingOriginalPatternWeight, hz, Complex.ofReal_zero, mul_zero, zero_mul] + have hp := movingPairCompensatedMass_pattern μ prime n pattern + (fun c => x (e.symm (.inr c))) + change movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) = _ at hp + rw [hp] at hm + intro i + exact (mul_ne_zero_iff.mp + (Finset.prod_ne_zero_iff.mp hm i (Finset.mem_univ _))).2 + +/-- Incompatible level identifications have zero original weight. This +permits retaining all setoids in the exact expansion. -/ +theorem movingPattern_tier_consistent_of_nonzero {A B C : Type*} [Fintype B] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (tier : A → ℕ) (hμ : ∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) + (G : (Fin (N + 1) → A) → ℂ) (x : Fin (N + 1) → A) + (hx : movingOriginalPatternWeight e μ ν prime n pattern G x ≠ 0) : + ∀ i, movingSampleTier (rep (pattern i)).val.2 = movingSampleTier i.2 := by + have hp := movingPattern_internal_prior_nonzero e μ ν prime pattern G x hx + intro i + have hi := hμ _ (movingSampleTier_lt i.2) _ (hp i) + have hr := hμ _ (movingSampleTier_lt (rep (pattern i)).val.2) _ (hp (rep (pattern i)).val) + rw [(rep (pattern i)).property] at hr + exact hr.symm.trans hi + +theorem movingPattern_zero_of_inconsistent_tiers {A B C : Type*} [Fintype B] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (tier : A → ℕ) (hμ : ∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) + (hbad : ¬ ∀ i, movingSampleTier (rep (pattern i)).val.2 = movingSampleTier i.2) + (G : (Fin (N + 1) → A) → ℂ) (x : Fin (N + 1) → A) : + movingOriginalPatternWeight e μ ν prime n pattern G x = 0 := by + by_contra hx + exact hbad (movingPattern_tier_consistent_of_nonzero e μ ν prime pattern rep tier hμ G x hx) + +theorem movingPattern_prior_tiers {A B C : Type*} {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (tier : A → ℕ) (tierB : B → ℕ) + (hμ : ∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) + (hν : ∀ j a, ν j a ≠ 0 → tier a = tierB j) + (x : Fin (N + 1) → A) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ∀ i, tier (x i) = (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e i) := by + intro i + have hi := Finset.prod_ne_zero_iff.mp hx i (Finset.mem_univ _) + cases he : e i with + | inl b => exact hν b (x i) (by simpa only [he, Sum.elim_inl] using hi) + | inr c => exact hμ _ (movingSampleTier_lt (rep c).val.2) (x i) (by simpa only [he, Sum.elim_inr] using hi) + +theorem movingPattern_prior_prime_separation {A B C : Type*} {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (tier : A → ℕ) (tierB : B → ℕ) (prime : A → ℕ) (hinj : Function.Injective prime) + (hμ : ∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) + (hν : ∀ j a, ν j a ≠ 0 → tier a = tierB j) + (hB : ∀ b, n ≤ tierB b) (x : Fin (N + 1) → A) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + (∀ i j, (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e i) ≠ + (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e j) → + prime (x i) ≠ prime (x j)) ∧ + (∀ b c, prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) := by + have ht := movingPattern_prior_tiers e μ ν pattern rep tier tierB hμ hν x hx + have hd (i j) (hij : (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e i) ≠ + (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e j)) : + prime (x i) ≠ prime (x j) := by + intro hp + apply hij + rw [← ht i, ← ht j, hinj hp] + refine ⟨hd, ?_⟩ + intro b c + apply hd + simp only [Equiv.apply_symm_apply, Sum.elim_inl, Sum.elim_inr] + have hc := movingSampleTier_lt (rep c).val.2 + have hb := hB b + omega + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPriorSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPriorSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d72136c72472ccf50b3481b2de5333041abab2a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternPriorSupport.lean @@ -0,0 +1,132 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternArithmeticComparison + +namespace OAI + +/-! # Arithmetic comparison restricted to the original product support -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Vanishing representative prior forces the original compensated coefficient +it dominates to vanish as well. -/ +theorem movingPattern_coefficient_zero_of_prior {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (x : Fin (N + 1) → A) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x = 0) : + ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) = 0 := by + have hd := movingPattern_fin_prior_bound e μ ν prime n pattern rep E hprime hμ hν hbound + (fun _ => 1) 1 (by norm_num) (fun _ => by norm_num) x + rw [hx, mul_zero] at hd + simp only [mul_one] at hd + have hscalar : 0 < ∏ c, internalLineScalar true (prime (x (e.symm (.inr c)))) := by + apply Finset.prod_pos + intro c _ + simp only [internalLineScalar, ite_true] + exact inv_pos.mpr (Nat.cast_pos.mpr (hprime _).pos) + apply norm_eq_zero.mp + nlinarith [norm_nonneg (((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ))] + +/-- Restricting the observable to the representative product support preserves +its exact original, compensated pattern weight. -/ +theorem movingOriginalPatternWeight_support_restrict {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (prime : A → ℕ) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (x : Fin (N + 1) → A) : + movingOriginalPatternWeight e μ ν prime n pattern + (fun x => if productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x = 0 then 0 else G x) x = + movingOriginalPatternWeight e μ ν prime n pattern G x := by + by_cases hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x = 0 + · have hz := movingPattern_coefficient_zero_of_prior e μ ν prime pattern rep E + hprime hμ hν hbound x hx + simp only [movingOriginalPatternWeight, hz, zero_mul] + · unfold movingOriginalPatternWeight movingPatternInjectionGuard + split_ifs <;> simp only [hx, ite_false] + +theorem movingPattern_arithmetic_comparison_on_support {A B C : Type*} + [Fintype A] [Nonempty A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ b, (movingPatternFinData e n t small bulk pattern b).SizeLE d) + (hfreq : ∀ b, (movingPatternFinData e n t small bulk pattern b).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E α β V : ℝ) (hE : 0 ≤ E) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hmax : ∀ j a, μ j a ≤ α) (hnmax : ∀ j a, ν j a ≤ α) + (hpmax : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≤ β) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + Real.exp V ≤ prime a) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hcross : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ b c, + prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (hfmod : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) : + let κ := D * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternHaarProduct e prime hprime n t small bulk pattern x - + movingPatternFlagProduct e prime n t small bulk pattern rep x)‖ ≤ + κ * (((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) + + 2 * ((Fintype.card C * (2 + 2 * (2 ^ n - 1)) : ℕ) : ℝ) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β)) := by + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let H := fun x => if productPrior law x = 0 then 0 else G x + have hsupp (x) (hx : H x ≠ 0) : productPrior law x ≠ 0 ∧ G x ≠ 0 := by + dsimp only [H] at hx + split_ifs at hx with hz + · exact False.elim (hx rfl) + · exact ⟨hz, hx⟩ + have hH (x) : ‖H x‖ ≤ D := by + dsimp only [H] + split_ifs + · simpa only [norm_zero] using hD + · exact hG x + have hh := movingPattern_arithmetic_comparison e prime hpInj hprime tierB tierC t small bulk + pattern rep hsmall hbulk htier d F U hF hU hsize hfreq hvalues μ ν hμ hν hmass hnmass + E α β V hE hα hβ hV hbound hmax hnmax hpmax hprimeSize H D hD hH + (fun x hx => hdisjoint x (hsupp x hx).1 (hsupp x hx).2) + (fun x hx => hcross x (hsupp x hx).1 (hsupp x hx).2) + (fun x hx => hfmod x (hsupp x hx).1 (hsupp x hx).2) + have heq (x) : movingOriginalPatternWeight e μ ν prime n pattern H x = + movingOriginalPatternWeight e μ ν prime n pattern G x := + movingOriginalPatternWeight_support_restrict e μ ν prime pattern rep E hprime hμ hν hbound G x + simp_rw [heq] at hh + exact hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternRegularSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternRegularSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..102417bae7823db6b0dff602122419fc633ca410 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternRegularSupport.lean @@ -0,0 +1,133 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedPageDeletion +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternArithmeticData + +namespace OAI + +/-! # Support and arithmetic of the original regular-prime list -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The common top list, before its primes are drawn. -/ +noncomputable def movingPatternRegularSlots {B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (n m : ℕ) (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) : + List (Fin (N + 1)) := + flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot)) + +theorem movingPatternRegularSlots_external {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (i : Fin (N + 1)) + (hi : i ∈ movingPatternRegularSlots e n m small slot) : + ∃ b, e.symm (.inl b) = i := by + rcases List.mem_append.mp hi with hi | hi + · rw [movingPatternFiniteSmall, flattenMovingSlots_map] at hi + obtain ⟨b, _, hb⟩ := List.mem_map.mp hi + exact ⟨b, hb⟩ + · obtain ⟨j, hj⟩ := (mem_flatten_bulkSlotLeaves n m (movingPatternBulkEmbedding e slot) i).mp hi + exact ⟨slot j, hj⟩ + +theorem naturalProduct_eq_finprod {σ : Type*} (value : σ → ℕ) (slots : List σ) : + MovingSlotReversal.naturalProduct value slots = ∏ i : Fin slots.length, value (slots.get i) := by + have h : List.ofFn (value ∘ slots.get) = slots.map value := by + rw [← List.map_ofFn, List.ofFn_get] + rw [MovingSlotReversal.naturalProduct, ← h, List.prod_ofFn] + rfl + +/-- The two history roots contain precisely the fixed regular slots. -/ +theorem movingPatternFinBulkData_regular_perm {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) (b : Bool) : + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern b).regularSlots.Perm + (movingPatternRegularSlots e n m small slot) := by + rw [movingPatternFinBulkData_build] + have h := buildMovingSlotData_regular_perm n (t b) + (movingPatternFiniteSmall e n small) + (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot)) + (movingPatternFiniteSamples e n pattern b) + cases b <;> exact h + +/-- Distinctness of the canonical regular enumeration comes from the original +support guard, so repeated independent draws need no extra assumption. -/ +theorem movingPattern_regular_pairwise {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) (value : Fin (N + 1) → ℕ) + (outside : List ℕ) (b : Bool) + (h : movingRegularOutsidePairwise value outside + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern b)) : + Pairwise (fun i j : Fin (movingPatternRegularSlots e n m small slot).length => + (value ((movingPatternRegularSlots e n m small slot).get i)).Coprime + (value ((movingPatternRegularSlots e n m small slot).get j))) := by + let slots := movingPatternRegularSlots e n m small slot + have hp := movingRegularOutsidePairwise_root value outside _ h + have hperm := (movingPatternFinBulkData_regular_perm e t small slot pattern b).map value + have hs : (slots.map value).Pairwise Nat.Coprime := + (hperm.pairwise_iff (R := Nat.Coprime) (fun h => h.symm)).mp hp + have hlist : List.ofFn (value ∘ slots.get) = slots.map value := by + rw [← List.map_ofFn, List.ofFn_get] + rw [← hlist, List.pairwise_ofFn] at hs + intro i j hij + rcases lt_or_gt_of_ne hij with hlt | hgt + · exact hs hlt + · exact (hs hgt).symm + +/-- External regular primes are coprime to the separated internal/frequency +block on the original prior support. -/ +theorem movingPattern_regular_arithmetic_coprime {A B C I : Type*} + [Fintype C] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (x : Fin (N + 1) → A) (r : ℕ) (p : I → ℕ) (hp : ∀ i, (p i).Prime) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (hr : ∀ i, r.Coprime (prime (x i))) + (hcross : ∀ b c, prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (hspect : ∀ i j, prime (x j) ≠ p i) : + (MovingSlotReversal.naturalProduct (fun i => prime (x i)) + (movingPatternRegularSlots e n m small slot)).Coprime + (∏ b, movingArithmeticModuli r p (movingPatternInternalPrimes e prime x) Finset.univ b) := by + let slots := movingPatternRegularSlots e n m small slot + rw [naturalProduct_eq_finprod] + apply movingArithmeticModuli_coprime_product r p (movingPatternInternalPrimes e prime x) + (fun j : Fin slots.length => prime (x (slots.get j))) hp + (movingPatternInternalPrimes_prime e prime hprime x) (fun _ => hprime _) + (fun j => (hr _).symm) + · intro j q hq + obtain ⟨c, _, rfl⟩ := Finset.mem_image.mp hq + obtain ⟨b, hb⟩ := movingPatternRegularSlots_external e small slot _ (List.get_mem slots j) + exact hb ▸ hcross b c + · exact fun j i => hspect i _ + +/-- The same one-prime conductor deletion used in the priors removes any +Page contribution from the original regular list. -/ +theorem movingPattern_regular_page_projection {A B C I : Type*} + [Fintype C] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (x : Fin (N + 1) → A) (p : I → ℕ) (hp : ∀ i, (p i).Prime) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (S : Finset ℤ) (V cutoff : ℕ) (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) (hcut : V < cutoff) + (hlarge : ∀ i, cutoff ≤ prime (x i)) (z : Option PrimitiveRealZero) + (hdelete : ∀ a, z = some a → ∀ q, + deletedConductorPrime a.modulus cutoff = some q → ∀ i, prime (x i) ≠ q) + (hdeletep : ∀ a, z = some a → ∀ q, + deletedConductorPrime a.modulus cutoff = some q → ∀ i, p i ≠ q) : + let M := ∏ b, movingArithmeticModuli (frequencyModelBase S n t ^ (n - 1 + 2)) + p (movingPatternInternalPrimes e prime x) Finset.univ b + pageAtModulus (MovingSlotReversal.naturalProduct (fun i => prime (x i)) + (movingPatternRegularSlots e n m small slot) * M) z = pageAtModulus M z := by + dsimp only + let slots := movingPatternRegularSlots e n m small slot + rw [naturalProduct_eq_finprod] + apply frequencyModel_regular_page_projection S n V cutoff t hS hcut + (movingPatternInternalPrimes e prime x) p (fun j : Fin slots.length => prime (x (slots.get j))) z + (movingPatternInternalPrimes_prime e prime hprime x) hp (fun j => ⟨hprime _, hlarge _⟩) + · intro a ha q hq hmem + obtain ⟨c, _, heq⟩ := Finset.mem_image.mp hmem + exact hdelete a ha q hq _ heq + · exact fun a ha q hq i => (hdeletep a ha q hq i).symm + · exact fun a ha q hq j => (hdelete a ha q hq _).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternRegularUnits.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternRegularUnits.lean new file mode 100644 index 0000000000000000000000000000000000000000..79315bcc9cecd3dbd755ecc65ec1ec36191d0f98 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternRegularUnits.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternRegularSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSmallFrequencyUnits + +namespace OAI + +/-! # The actual regular Fourier denominators are units on the original support -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The denominator left after removing one regular prime and both giants. -/ +noncomputable def movingRegularOther {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (slots : List σ) (j : Fin slots.length) : ℤ := + (outside.prod * ∏ i ∈ Finset.univ.erase j, value (slots.get i) : ℕ) + +theorem movingPattern_regular_other_unit {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) (value : Fin (N + 1) → ℕ) + (hprime : ∀ i, (value i).Prime) (outside : List ℕ) (b : Bool) + (h : movingRegularOutsidePairwise value outside + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern b)) + (j : Fin (movingPatternRegularSlots e n m small slot).length) : + (movingRegularOther value outside (movingPatternRegularSlots e n m small slot) j : + ZMod (value ((movingPatternRegularSlots e n m small slot).get j))) ≠ 0 := by + let slots := movingPatternRegularSlots e n m small slot + let : Fact (value (slots.get j)).Prime := ⟨hprime _⟩ + have hp : (((movingPatternFinBulkData e n m t (fun _ => small) slot + (Equiv.refl _) pattern b).regularSlots.map value) ++ outside).Pairwise Nat.Coprime := by + cases ht : movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern b with + | leaf => exact ht ▸ h + | node => exact (ht ▸ h).1 + have hperm := ((movingPatternFinBulkData_regular_perm e t small slot pattern b).map value).append_right outside + have hc : (slots.map value ++ outside).Pairwise Nat.Coprime := + (hperm.pairwise_iff (R := Nat.Coprime) (fun h => h.symm)).mp hp + have ho : (value (slots.get j)).Coprime outside.prod := by + apply Nat.coprime_list_prod_right_iff.mpr + intro q hq + exact (List.pairwise_append.mp hc).2.2 _ + (List.mem_map.mpr ⟨slots.get j, List.get_mem slots j, rfl⟩) q hq + have hr := movingPattern_regular_pairwise e t small slot pattern value outside b h + have hrest : (value (slots.get j)).Coprime + (∏ i ∈ Finset.univ.erase j, value (slots.get i)) := by + apply Nat.coprime_prod_right_iff.mpr + intro i hi + exact hr (Finset.ne_of_mem_erase hi).symm + have hu := (ZMod.isUnit_iff_coprime _ (value (slots.get j))).mpr (ho.mul_right hrest).symm + simpa only [movingRegularOther, Int.cast_natCast] using hu.ne_zero + +/-- Every retained frequency is a unit at a regular prime above the common cutoff. -/ +theorem movingPattern_regular_frequency_unit {σ : Type*} + (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) (slots : List σ) + (V : ℕ) (hlarge : ∀ i, V < value i) (s : ℤ) (hs : s ≠ 0) (hV : s.natAbs ≤ V) + (j : Fin slots.length) : (s : ZMod (value (slots.get j))) ≠ 0 := by + let : Fact (value (slots.get j)).Prime := ⟨hprime _⟩ + have hc := small_prime_frequency_unit (value (slots.get j)) (hprime (slots.get j)) s hs + (hV.trans_lt (hlarge (slots.get j))) + have hu : IsUnit (s : ZMod (value (slots.get j))) := by + apply isCoprime_zero_right.mp + simpa only [Int.cast_natCast, ZMod.natCast_self] using + hc.intCast (R := ZMod (value (slots.get j))) + exact hu.ne_zero + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSameNormArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSameNormArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2759b80f86ead4ad7f09b2da730977391bfcdd2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSameNormArithmetic.lean @@ -0,0 +1,192 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternOriginalNormArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternNormalizedNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFrequencyModulus +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate + +namespace OAI + +/-! # The norm estimate with the original internal and external priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_same_assignment_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (y X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (Fw true) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternPrimeObservable e t small slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i b j, + j ∈ flattenMovingSlots n (small b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + filter_upwards [P.movingPattern_original_norm_arithmetic_rate ψ n r₀ k + A lo hi Bφ Dφ 1 Cmass hA hlo hhi (by norm_num) hCmass hBφ hDφ] with L hrate + dsimp only + intro Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq Fw outside _ p _ hc _ twist sets + y X j₀ φ G U u v deleted initial μ ν Eprior αall βint Vint Uall + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq n ft + have hR (b : Bool) : (movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern b).frequencyProduct ∣ (R : ℤ) := by + simpa only [ht, R] using movingPattern_frequencyProduct_dvd e Sfreq ft small slot (Equiv.refl _) pattern b + have hroots (b : Bool) (j : Fin (2 ^ n - 1)) : + (singleTreeNodeFrequencies Sfreq n (frequencyPairProjection Sfreq n b ft) j.val).root.natAbs ∣ R := + frequencyModelBase_roots Sfreq n ft b j + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + have hone (b : Bool) : ‖movingDataWeight (Fw b) (fun _ _ _ _ => 1) (data b)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (Fw b) (fun s regular => + (hleaf b s regular).trans (by split_ifs <;> norm_num)) (data b) + have hamp : 2 * (‖movingDataWeight (Fw false) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (Fw true) (fun _ _ _ _ => 1) (data true)‖) ≤ Real.exp ((1 : ℝ) * m) := by + have hpair := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm + have hexp := Real.add_one_le_exp ((1 : ℝ) * m) + nlinarith + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 2 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + have hA₀ : 0 ≤ A₀ := by + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro x hx + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hx + exact pairFrequencySupportBound_nonneg D f + exact mul_nonneg (by positivity) (mul_nonneg hleaf0 hprod) + have hlocal (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) + (z : (TreeLeafIndex n × Fin m) → ℝ) (hz : ∀ j, 0 ≤ z j) := + movingPattern_normalized_same_assignment_norm e tierB tierC Sfreq ft R Nfreq Vleaf + hS hN hroots small slot pattern hsmall hB htier (fun i => (x i : ℕ)) (hbase x hx) + Fw hleaf D hD hdiv hm p hc hp + (by simpa only [ht] using hfreqp) (hsmallp x hx) (hsamplesp x hx) + sets hsets hsetsp twist outside childBound P (bulkProgressionCutoff L) y hy z hz + have h := hrate Bidx Cidx Cell N e tierB tierC t small slot (Equiv.refl _) pattern rep + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p hc twist sets y X A₀ j₀ φ G U u v deleted initial μ ν + Eprior αall βint Vint Uall hsmall hB htier hsmallLen hR (frequencyModelModulus_precision R n) + hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell + hSS hdel hmass hdelbase hout hdelout hA₀ + (by + intro x hx + dsimp only + intro z hz + have hz' := hlocal x hx z hz + simpa only [A₀, m, ht, finite_univ_canonical, Fintype.card_eq_nat_card, Nat.card_fin] using hz') + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + exact h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSelectedNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSelectedNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..dd32d56b9bd7de45a4dd3ce52b0f4baba549ab80 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSelectedNormRate.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternInitialNormRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeObservable + +namespace OAI + +/-! # Norm estimate for the original selected-coordinate mean -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_selected_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (base : Fin (N + 1) → primes) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyFactor (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P (bulkProgressionCutoff L) y + let spec := fun i => frozenBulkSpectatorHaar (fun i => (base i : ℕ)) n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (base i : ℕ) ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex n × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ∀ ν : Bidx → primes → ℝ, + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + ‖movingPatternBulkMean e ν slot + (movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U) base‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + filter_upwards [P.movingPattern_initial_prime_norm_rate ψ n r₀ k A lo hi Bφ Dφ F Cmass + hA hlo hhi hF hCmass hBφ hDφ] with L hrate + dsimp only + intro Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern primes hprimes base + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets y X A₀ j₀ φ G U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain ν hν + rw [movingPatternBulkMean_primeObservable] + · exact hrate Bidx Cidx Cell N e tierB tierC t small slot perm pattern + (fun i => (base i : ℕ)) primes hprimes (fun i _ => hprimes _ (base i).property) + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets y X A₀ j₀ φ G U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain + · exact hν + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSelectedRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSelectedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b5011511c60d9a0be2cdff9dbc2d6de432a73c3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSelectedRate.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternInitialRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeObservable + +namespace OAI + +/-! # The published prime estimate in the original selected-coordinate mean -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_selected_prime_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (base : Fin (N + 1) → primes) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((base (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ i c, ((base (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (base i : ℕ) ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ∀ ν : Bidx → primes → ℝ, + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + ‖movingPatternBulkMean e ν slot + (movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U) base‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_initial_prime_rate ψ n r₀ k A lo hi Bφ Dφ F Cmass gain + hA hlo hhi hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern primes hprimes base + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β y X j₀ φ G U u v deleted + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain ν hν + rw [movingPatternBulkMean_primeObservable] + · exact hrate Bidx Cidx Cell N e tierB tierC t small slot perm pattern + (fun i => (base i : ℕ)) primes hprimes (fun i _ => hprimes _ (base i).property) + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β y X j₀ φ G U u v deleted + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain + · exact hν + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSeparatedBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSeparatedBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..34e060422db7c7266066f54388956aa3c2efef86 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSeparatedBound.lean @@ -0,0 +1,132 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternIntegrand +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkArithmetic +import OAI.NumberTheory.Ostmann.Construction.OriginalSeparatedBulkBound + +namespace OAI + +/-! # The sharp pattern kernel under its original bulk prime law -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The actual pattern kernel, frequency factor and spectator factors can be +averaged under the original deleted prime law. The comparison error here is +derived from the published progression input, with the concrete tree degrees; +the sharp kernel and the old prime normalizers are retained. -/ +theorem PublishedProgressionInput.movingPattern_separated_kernel_bound + (P : PublishedProgressionInput) {B C Cell : Type*} [Fintype Cell] + {N n m r₀ : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (hsmall : ∀ b, MovingLeafLengthLE n (small b) r₀) + (base : Fin (N + 1) → ℕ) (childBound pivotBound : ℕ → ℕ) + (j₀ : TreeLeafIndex n × Fin m) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, NeZero (p i)] + [NeZero (∏ i, bulkResidueModuli r p i)] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (freq : ((TreeLeafIndex n × Fin m) → (ZMod r)ˣ) → ℂ) + (spec : ∀ i, ((TreeLeafIndex n × Fin m) → (ZMod (p i))ˣ) → ℂ) + (A : ℝ) (hA : 0 ≤ A) (hf : ∀ a, ‖freq a‖ ≤ A) + (Q : ℕ) (hQ : 2 ≤ Q) (hMQ : (∏ i, bulkResidueModuli r p i) ≤ Q) + (hpage : pageAtModulus (∏ i, bulkResidueModuli r p i) (selectedPageZero P Q) = + pageAtModulus r (selectedPageZero P Q)) + (primes : Finset ℕ) (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (hu : ∀ j c, 1 ≤ u j c) (huv : ∀ j c, u j c ≤ v j c) + (hshort : ∀ j c, v j c ≤ u j c + 1) + (hmassCell : ∀ j c (a : (ZMod (∏ i, bulkResidueModuli r p i))ˣ), + ∑ q ∈ primeLogCellSet (∏ i, bulkResidueModuli r p i) a.val.val (u j c) (v j c), + (q : ℝ)⁻¹ ≤ 2) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hP : ∀ j, primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ primes) + (hsep : ∀ j (c d : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ), c ≠ d → + ¬Nat.ModEq (∏ i, bulkResidueModuli r p i) c.2.val.val d.2.val.val ∨ + v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hdeleted : ∀ j, (∑ q ∈ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted j, (q : ℝ)⁻¹) ≠ 0) + (δ : ℝ) (hδ : 0 ≤ δ) (H T : ℝ) (Bspec : Fin m → ℝ) + (hBspec : ∀ i, 0 ≤ Bspec i) : + let K := movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let label := fun (x : (TreeLeafIndex n × Fin m) → primes) j => primeCellLabel M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) c₀ (x j) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + let err := fun c : (TreeLeafIndex n × Fin m) → Cell => + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkKernelPairComparisonBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 Bφ Dφ * + bulkPrimeErrorFactor P Q (u j (c j)) + (∀ i, ‖(Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, spec i z‖ ≤ δ) → + (∀ i z, ‖spec i z‖ ≤ Bspec i) → + (∀ j, Z j * ∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹ ≤ 2) → + (∀ j, Z j ≤ Real.exp H) → + (∀ j q, q ∈ S j \ deleted j → Real.exp T ≤ (q : ℝ)) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + (if Function.Injective x then a (fun j => (label x j).2) * + K (fun j => Real.log (x j : ℕ)) else 0)‖ ≤ + (W * A) * 4 ^ Fintype.card (TreeLeafIndex n × Fin m) * δ ^ m + + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, ∑ z, ‖a z‖ * err c + + (A * (∏ i, Bspec i) * W) * (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * + Real.exp (H - T) + + (A * (∏ i, Bspec i) * W) * ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) := by + intro K W M S Z label a err hlocal hspec hmass hZ hlow + have hW : 0 ≤ W := sq_nonneg _ + have hk : ∀ z, ‖K z‖ ≤ W := movingPatternBulkIntegrand_norm e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq + φ G Bφ Dφ hBφ hDφ hφ hlip hout L U + have herr (c : (TreeLeafIndex n × Fin m) → Cell) + (z : (TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : + ‖(∫ y, K y ∂Measure.pi (fun j => primeLogCellMeasure M (z j).val.val (u j (c j)) (v j (c j)))) - + ∫ y, K y ∂Measure.pi (fun j => primeGiantMeasure P Q M (z j).val.val (u j (c j)) (v j (c j)))‖ ≤ + err c := + P.movingPatternBulkIntegrand_comparison e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hfreq φ G Bφ Dφ + hBφ hDφ hφ hlip hout L U hsmall hQ (fun _ => ∏ i, bulkResidueModuli r p i) + (fun j => (z j).val.val) (fun j => u j (c j)) (fun j => v j (c j)) + (fun _ => Nat.pos_of_ne_zero (NeZero.ne _)) (fun _ => hMQ) + (fun j => ZMod.val_coe_unit_coprime (z j)) (fun j => hu j (c j)) + (fun j => huv j (c j)) (fun j => hshort j (c j)) (fun j => hmassCell j (c j) (z j)) + have hn (x : (TreeLeafIndex n × Fin m) → primes) : + ‖a (fun j => (label x j).2) * K (fun j => Real.log (x j : ℕ))‖ ≤ A * (∏ i, Bspec i) * W := by + rw [norm_mul] + apply mul_le_mul _ (hk _) (norm_nonneg _) (mul_nonneg hA (Finset.prod_nonneg fun i _ => hBspec i)) + change ‖freq _ * ∏ i, spec i _‖ ≤ _ + rw [norm_mul, norm_prod] + exact mul_le_mul (hf _) (Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + (fun i _ => hspec i _)) (Finset.prod_nonneg fun _ _ => norm_nonneg _) hA + have hb := @original_separated_bulk_bound (Fin m) (TreeLeafIndex n × Fin m) Cell + inferInstance inferInstance inferInstance r inferInstance p inferInstance inferInstance hc primes u v + (fun j c => lt_of_lt_of_le zero_lt_one (hu j c)) c₀ hP hsep deleted hdeleted + K freq spec W A δ hW hA hδ hk hf (fun i => by + simpa only [Fintype.card, finite_univ_canonical] using hlocal i) P Q hpage (fun c _ => err c) herr H T + (A * (∏ i, Bspec i) * W) + (mul_nonneg (mul_nonneg hA (Finset.prod_nonneg fun i _ => hBspec i)) hW) + dsimp only at hb + simpa only [a, label, S, Z, M, Fintype.card_fin, finite_univ_canonical] using hb hmass hZ hlow hn + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSeparatedConditions.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSeparatedConditions.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b2a8be8e017ad54121d3c874120aceed5cac5b9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSeparatedConditions.lean @@ -0,0 +1,130 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantConditions +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternUniformBudget +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternRegularSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedModulusRange + +namespace OAI + +/-! # Supplying the giant arithmetic conditions from the original prime priors -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +/-- All assignment-dependent conditions of the giant comparison follow from +actual prime ranges, original-prior support, and the prescribed conductor +prime deletion. No arithmetic comparison is assumed in this statement. -/ +theorem movingPattern_separated_giant_conditions (input : PublishedProgressionInput) + (n r₀ k : ℕ) (Cfreq : ℝ) (hCfreq : 0 ≤ Cfreq) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (A B C : Type) [Fintype A] [Fintype B] [Fintype C] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (tier : A → ℕ) (tierB : B → ℕ) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (S : Finset ℤ) (V : ℕ) (t : FrequencyTree (S × S) n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (p : Fin m → ℕ) (lo cutoff : ℕ) (E : ℝ), + let R := frequencyModelBase S n t + let Pi := fun x => movingPatternInternalPrimes e prime x + let M := fun x => ∏ b, movingArithmeticModuli (R ^ (n - 1 + 2)) p (Pi x) Finset.univ b + let Reg := fun x => MovingSlotReversal.naturalProduct (fun i => prime (x i)) + (movingPatternRegularSlots e n m small slot) + Function.Injective prime → (∀ a, (prime a).Prime) → + (∀ j a, 0 ≤ μ j a) → (∀ j a, 0 ≤ ν j a) → + (∀ j a, (prime a : ℝ) * μ j a ≤ E) → + (∀ j, j < n → ∀ a, μ j a ≠ 0 → tier a = j) → + (∀ j a, ν j a ≠ 0 → tier a = tierB j) → (∀ b, n ≤ tierB b) → + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) → (V : ℝ) ≤ Real.exp (Cfreq * m) → + V ≤ lo → V < cutoff → cutoff ≤ lo → + (∀ j a, μ j a ≠ 0 → lo < prime a) → + (∀ j a, ν j a ≠ 0 → lo < prime a) → + (∀ a, (prime a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, (p i).Prime ∧ cutoff ≤ p i ∧ p i ≤ lo ∧ + (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + MovingLeafLengthLE n small r₀ → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → prime a ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → prime a ≠ q) → + ∀ x : Fin (N + 1) → A, + movingOriginalPatternWeight e μ ν prime n pattern (fun _ => 1) x ≠ 0 → + (∀ i j, (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e i) ≠ + (Sum.elim tierB (fun c => movingSampleTier (rep c).val.2)) (e j) → + prime (x i) ≠ prime (x j)) ∧ + (∀ i, V < prime (x i)) ∧ + (∀ i, IsCoprime (prime (x i) : ℤ) (R : ℤ)) ∧ + (∀ i, (R ^ (n - 1 + 2)).Coprime (prime (x i))) ∧ + (∀ i j, (prime (x j) : ZMod (p i)) ≠ 0) ∧ + Reg x * M x ≤ giantProgressionCutoff L ∧ + (Reg x).Coprime (M x) ∧ + pageAtModulus (Reg x * M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) ∧ + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus (R ^ (n - 1 + 2)) (selectedPageZero input (giantProgressionCutoff L)) ∧ + Real.log (M x : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) := by + filter_upwards [movingPattern_giant_conditions input n r₀ k Cfreq hCfreq, + movingPattern_actual_separated_modulus_range n r₀ k Cfreq hCfreq] + with L hbase hmod + dsimp only + intro A B C _ _ _ N e prime tier tierB μ ν pattern rep S V t small slot p lo cutoff E + hinj hprime hμ hν hbound hμtier hνtier hB hS hV hVlo hVcut hcutlo hμlo hνlo hupper + hp hsmall hdeleteμ hdeletep hdeleteν x hx + have hb := hbase A B C N e prime tier tierB μ ν pattern rep S V t small slot p lo cutoff E + hinj hprime hμ hν hbound hμtier hνtier hB hS hV hVlo hVcut hcutlo hμlo hνlo hupper + hp hsmall hdeleteμ hdeletep x hx + dsimp only at hb + rcases hb with ⟨hsep, hsize, hcop, hrcop, hres, _, hpage, hlog, _⟩ + let Pi := movingPatternInternalPrimes e prime x + have hprior := movingPattern_nonzero_prior e μ ν prime pattern rep E hprime hμ hν hbound + (fun _ => 1) x hx + have hlarge := movingPattern_prior_lower e μ ν prime pattern rep lo hμlo hνlo x hprior + have hcross := (movingPattern_prior_prime_separation e μ ν pattern rep tier tierB prime hinj + hμtier hνtier hB x hprior).2 + have hspec (i j) : prime (x j) ≠ p i := by + intro he + have hh := (hp i).2.2.1.trans_lt (hlarge j) + omega + have hregcop := movingPattern_regular_arithmetic_coprime e prime hprime x + (frequencyModelBase S n t ^ (n - 1 + 2)) p (fun i => (hp i).1) + small slot hrcop hcross hspec + have hdelete (z : PrimitiveRealZero) + (hz : selectedPageZero input (giantProgressionCutoff L) = some z) + (q : ℕ) (hq : deletedConductorPrime z.modulus cutoff = some q) : + ∀ i, prime (x i) ≠ q := by + intro i + have hi := Finset.prod_ne_zero_iff.mp hprior i (Finset.mem_univ i) + cases he : e i with + | inl b => + have hνi : ν b (x i) ≠ 0 := by simpa only [he, Sum.elim_inl] using hi + exact hdeleteν z hz q hq b (x i) hνi + | inr c => + have hμi : μ (movingSampleTier (rep c).val.2) (x i) ≠ 0 := by + simpa only [he, Sum.elim_inr] using hi + exact hdeleteμ z hz q hq _ _ hμi + have hregpage := movingPattern_regular_page_projection e prime hprime x p + (fun i => (hp i).1) small slot S V cutoff t hS hVcut + (fun i => hcutlo.trans (hlarge i).le) (selectedPageZero input (giantProgressionCutoff L)) + hdelete hdeletep + have hPi : ∀ q ∈ Pi, q.Prime ∧ (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) := by + intro q hq + obtain ⟨c, _, rfl⟩ := Finset.mem_image.mp hq + exact ⟨hprime _, hupper _⟩ + have hcard : Pi.card ≤ 4 * n * 2 ^ n := by + calc + Pi.card ≤ (Finset.univ : Finset C).card := Finset.card_image_le + _ = Fintype.card C := Finset.card_univ + _ ≤ 4 * n * 2 ^ n := movingPattern_class_card_le n pattern rep + have hfull := hmod B C N e small slot (fun i => prime (x i)) S V t p Pi hsmall + (fun i => hupper _) hS hV hcard hPi (fun i => ⟨(hp i).1, (hp i).2.2.2⟩) + exact ⟨hsep, hsize, hcop, hrcop, hres, hfull, hregcop, hregpage, hpage, hlog⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSignedArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSignedArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..155d82c9c7f7dbf075da962e86c446ff454a96db --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSignedArithmetic.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMean + +namespace OAI + +/-! # The signed original arithmetic bound for each equality pattern + +This combines the actual internal Haar comparison with cancellation in the +original selected-bulk mean. Only the proved comparison errors and the +representative-prior loss remain. +-/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_signed_arithmetic_bound {A B C : Type*} + [Fintype A] [Nonempty A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ b, (movingPatternFinData e n t small bulk pattern b).SizeLE d) + (hfreq : ∀ b, (movingPatternFinData e n t small bulk pattern b).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E α β V : ℝ) (hE : 0 ≤ E) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hmax : ∀ j a, μ j a ≤ α) (hnmax : ∀ j a, ν j a ≤ α) + (hpmax : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≤ β) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + Real.exp V ≤ prime a) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hcross : ∀ x, G x ≠ 0 → ∀ b c, + prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (hfmod : ∀ x, G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) + (m : ℕ) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (hbulkEq : bulk = movingPatternBulkLeaves n m slot perm) + (Dminor : ℝ) (hDminor : 0 ≤ Dminor) + (hminor : ∀ x, ‖movingPatternBulkMean e ν slot G x‖ ≤ Dminor) + (seed : TreeLeafIndex n × Fin m → A) : + let κ := (2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C) + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternHaarProduct e prime hprime n t small bulk pattern x‖ ≤ + κ * (D * (((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) + + 2 * ((Fintype.card C * (2 + 2 * (2 ^ n - 1)) : ℕ) : ℝ) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β)) + Dminor) := by + have ha := movingPattern_arithmetic_comparison e prime hpInj hprime tierB tierC t small bulk pattern rep + hsmall hbulk htier d F U hF hU hsize hfreq hvalues μ ν hμ hν hmass hnmass + E α β V hE hα hβ hV hbound hmax hnmax hpmax hprimeSize G D hD hG hdisjoint hcross hfmod + have hb : ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small bulk pattern rep x‖ ≤ + Dminor * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) := by + rw [hbulkEq] + exact movingPattern_signed_bulk_mean_bound e μ ν prime t small slot perm pattern rep E hprime hμ hν + hmass hnmass hbound G Dminor hDminor hminor seed + dsimp only at ha ⊢ + let X := ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternHaarProduct e prime hprime n t small bulk pattern x + let Y := ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small bulk pattern rep x + have heq : X - Y = ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternHaarProduct e prime hprime n t small bulk pattern x - + movingPatternFlagProduct e prime n t small bulk pattern rep x) := by + dsimp only [X, Y] + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro x _ + ring + have htriangle : ‖X‖ ≤ ‖X - Y‖ + ‖Y‖ := by + simpa only [sub_add_cancel] using norm_add_le (X - Y) Y + rw [heq] at htriangle + exact htriangle.trans ((add_le_add ha hb).trans_eq (by ring)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSignedMajorant.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSignedMajorant.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa660cd7b2663bc4b20513c4dfc196415a8b1d73 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSignedMajorant.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMajorant + +namespace OAI + +/-! # Signed arithmetic comparison with an averaged nonbulk error -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_signed_arithmetic_majorant {A B C : Type*} + [Fintype A] [Nonempty A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ b, (movingPatternFinData e n t small bulk pattern b).SizeLE d) + (hfreq : ∀ b, (movingPatternFinData e n t small bulk pattern b).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E α β V : ℝ) (hE : 0 ≤ E) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hmax : ∀ j a, μ j a ≤ α) (hnmax : ∀ j a, ν j a ≤ α) + (hpmax : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≤ β) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + Real.exp V ≤ prime a) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hcross : ∀ x, G x ≠ 0 → ∀ b c, + prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (hfmod : ∀ x, G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) + (m : ℕ) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (hbulkEq : bulk = movingPatternBulkLeaves n m slot perm) + (minor : (Fin (N + 1) → A) → ℝ) + (hminor : ∀ x, ‖movingPatternBulkMean e ν slot G x‖ ≤ minor x) + (seed : TreeLeafIndex n × Fin m → A) : + let κ := (2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternHaarProduct e prime hprime n t small bulk pattern x‖ ≤ + κ * (D * (((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) + + 2 * ((Fintype.card C * (2 + 2 * (2 ^ n - 1)) : ℕ) : ℝ) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β)) + ∑ x, productPrior law x * minor x) := by + have ha := movingPattern_arithmetic_comparison e prime hpInj hprime tierB tierC t small bulk pattern rep + hsmall hbulk htier d F U hF hU hsize hfreq hvalues μ ν hμ hν hmass hnmass + E α β V hE hα hβ hV hbound hmax hnmax hpmax hprimeSize G D hD hG hdisjoint hcross hfmod + have hb : ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small bulk pattern rep x‖ ≤ + ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * + ∑ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x * minor x := by + rw [hbulkEq] + exact movingPattern_signed_bulk_majorant e μ ν prime t small slot perm pattern rep E hE + hprime hμ hν hnmass hbound G minor hminor seed + dsimp only at ha ⊢ + let X := ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternHaarProduct e prime hprime n t small bulk pattern x + let Y := ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small bulk pattern rep x + have heq : X - Y = ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternHaarProduct e prime hprime n t small bulk pattern x - + movingPatternFlagProduct e prime n t small bulk pattern rep x) := by + dsimp only [X, Y] + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro x _ + ring + have htriangle : ‖X‖ ≤ ‖X - Y‖ + ‖Y‖ := by + simpa only [sub_add_cancel] using norm_add_le (X - Y) Y + rw [heq] at htriangle + exact htriangle.trans ((add_le_add ha hb).trans_eq (by ring)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSignedSum.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSignedSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d95962f82b6858963e5a590917bf9f5e50c31cf --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSignedSum.lean @@ -0,0 +1,35 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternUniformBudget + +namespace OAI + +/-! # Summing the signed pattern bounds without a bulk-length loss -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The per-class comparison error and signed bulk remainder can be summed +across every equality pattern with a cost depending only on the fixed depth. -/ +theorem movingPattern_signed_sum_bound (n : ℕ) (E D τ K : ℝ) + (hE : 0 ≤ E) (hD : 0 ≤ D) (hτ : 0 ≤ τ) (hK : 0 ≤ K) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + ∀ R : Setoid (Bool × MovingSampleIndex n) → ℂ, + (∀ s, ‖R s‖ ≤ + ((2 : ℝ) ^ Fintype.card (Quotient s) * + E ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) * + (D * Fintype.card (Quotient s) * τ + K)) → + ‖∑ s, R s‖ ≤ (2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) * + ((D * (4 * n * 2 ^ n : ℕ) * τ + K) * (max 2 E) ^ (4 * n * 2 ^ n)) := by + dsimp only + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + intro R hR + apply movingPattern_error_sum_le n E (D * (4 * n * 2 ^ n : ℕ) * τ + K) hE (by positivity) R + intro s + have hc : (Fintype.card (Quotient s) : ℝ) ≤ (4 * n * 2 ^ n : ℕ) := by + exact_mod_cast movingPattern_quotient_card_le n s + have hcost : D * Fintype.card (Quotient s) * τ + K ≤ D * (4 * n * 2 ^ n : ℕ) * τ + K := + add_le_add (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hc hD) hτ) le_rfl + exact (hR s).trans ((mul_le_mul_of_nonneg_left hcost (by positivity)).trans_eq (mul_comm _ _)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSpectatorGain.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSpectatorGain.lean new file mode 100644 index 0000000000000000000000000000000000000000..995c5a311ba4567c95316c55c6416f7ffb738900 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSpectatorGain.lean @@ -0,0 +1,44 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSpectatorUnits +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSpectatorNorm + +namespace OAI + +/-! # The quartet estimate for the actual equality-pattern spectator -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPatternSpectatorHaar_mean_le {B C : Type*} {N q n m : ℕ} [Fact q.Prime] + (e : Fin (N + 1) ≃ B ⊕ C) (base : Fin (N + 1) → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List B) (n + 2)) + (pattern : Bool × MovingSampleIndex (n + 2) → C) + (hq : 3 ≤ q) (hm : 0 < m) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0 ∧ s.natAbs < q) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl i)) : ZMod q) ≠ 0) + (hsamples : ∀ c, (base (e.symm (.inr c)) : ZMod q) ≠ 0) + (twist : Bool → (ZMod q)ˣ) (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (hgood : 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2))) + (S : Finset (ZMod q)) (hlo : (1 / 3 : ℝ) ≤ residueDensity S) + (hhi : residueDensity S ≤ 2 / 3) (hS : S.Nonempty) (hSq : S.card < q) + (β ε : ℝ) (hε : 0 ≤ ε) (hε1 : ε ≤ 1) + (hprincipal : 3 / Real.sqrt (q : ℝ) ≤ ε) (hβ : 2 * β ≤ ε) + (hbias : ∀ (χ : MulChar (ZMod q) ℂ), χ ≠ 1 → ∀ a : ZMod q, + ‖(S.card : ℂ)⁻¹ * ∑ x ∈ S, χ⁻¹ (-a - x)‖ ≤ β) + (δ : ℝ) (hδ : 0 ≤ δ) + (hnum : quartetTreeConstant n * (ε ^ 2 + Real.sqrt (3 / (q : ℝ))) ≤ δ ^ 2) : + ‖(Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod q)ˣ) : ℂ)⁻¹ * + ∑ z, frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) twist perm (normalizedResidueTransform S) z‖ ≤ δ := by + exact frozenBulkSpectatorHaar_mean_le hq base n m hm t _ _ + (fun b => movingGiantFrequencyUnits_of_bounds (t b) (hfreq b)) + (fun b => movingPatternFiniteSmall_unit e base (small b) (hsmall b)) + (movingPatternFiniteSamples_units e base pattern hsamples) + twist perm hgood S hlo hhi hS hSq β ε hε hε1 hprincipal hβ hbias δ hδ hnum + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSpectatorUnits.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSpectatorUnits.lean new file mode 100644 index 0000000000000000000000000000000000000000..abb34035b06ba5aed6162a86c0c1364d65a13d2f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSpectatorUnits.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkData +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSpectatorGain + +namespace OAI + +/-! # The spectator unit conditions from the actual pattern coordinates -/ + +namespace Ostmann +open scoped Classical + +theorem movingSlotValues_unit {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (n : ℕ) (small : TreeLeafTuple (List σ) n) + (h : ∀ i ∈ flattenMovingSlots n small, (value i : ZMod q) ≠ 0) : + ((treeLeafProduct n (movingSlotValues value n small) : ℕ) : ZMod q) ≠ 0 := by + rw [← movingSlotValues_flatten, MovingSlotReversal.naturalProduct, Nat.cast_list_prod, List.map_map] + apply List.prod_ne_zero + intro hz + obtain ⟨i, hi, he⟩ := List.mem_map.mp hz + exact h i hi he + +theorem MovingSampleSlots.values_units_of_coordinates {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) {n : ℕ} (samples : MovingSampleSlots σ n) + (h : ∀ i, (value (movingSampleCoordinates σ n samples i) : ZMod q) ≠ 0) : + (samples.values value).UnitsAt q := by + induction samples with + | leaf => trivial + | @node n u l r ihL ihR => + refine ⟨?_, ihL (fun i => h (.inr (true, i))), ihR (fun i => h (.inr (false, i)))⟩ + rw [← movingCompensationValues_product] + apply movingSlotValues_unit + apply movingCompensationSlots_forall + intro a j + exact h (.inl (a, j)) + +theorem movingPatternFiniteSamples_units {B C : Type*} {N n q : ℕ} [Fact q.Prime] + (e : Fin (N + 1) ≃ B ⊕ C) (value : Fin (N + 1) → ℕ) + (pattern : Bool × MovingSampleIndex n → C) + (h : ∀ c, (value (e.symm (.inr c)) : ZMod q) ≠ 0) (b : Bool) : + ((movingPatternFiniteSamples e n pattern b).values value).UnitsAt q := by + apply MovingSampleSlots.values_units_of_coordinates + intro i + simpa only [movingPatternFiniteSamples, movingPatternSamples, Equiv.apply_symm_apply, + Function.comp_apply] using h (pattern (b, i)) + +theorem movingPatternFiniteSmall_unit {B C : Type*} {N n q : ℕ} [Fact q.Prime] + (e : Fin (N + 1) ≃ B ⊕ C) (value : Fin (N + 1) → ℕ) + (small : TreeLeafTuple (List B) n) + (h : ∀ b ∈ flattenMovingSlots n small, (value (e.symm (.inl b)) : ZMod q) ≠ 0) : + ((treeLeafProduct n (movingSlotValues value n (movingPatternFiniteSmall e n small)) : ℕ) : ZMod q) ≠ 0 := by + apply movingSlotValues_unit + intro i hi + rw [movingPatternFiniteSmall, flattenMovingSlots_map] at hi + obtain ⟨b, hb, rfl⟩ := List.mem_map.mp hi + exact h b hb + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSquareError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSquareError.lean new file mode 100644 index 0000000000000000000000000000000000000000..7951b20b1fcdc09945e9fa7551f977fb8b3652a8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSquareError.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFinite +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalProductError + +namespace OAI + +/-! # Prime-square exclusions under the original pattern priors -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The relative square error for the actual class-indexed collection of +internal primes. Every class has a proved occurrence in the history pair. -/ +theorem movingRepresentativeProduct_error {σ C : Type*} [Fintype C] + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hlevels : ∀ b, (T b).Levels tier) + (rep : C → σ) (base : ∀ c, MovingPairRepresentativeOccurrences T (rep c)) + (hf : ∀ c b, (T b).Frequencies (fun s => (s : ZMod (value (rep c))) ≠ 0)) + (V : ℝ) (hsize : ∀ c, Real.exp V ≤ value (rep c)) : + letI : ∀ c, Fact (value (rep c)).Prime := fun _ => ⟨hprime _⟩ + ‖(∏ c, movingInternalHaarAverage value T (value (rep c))) - + ∏ c, (movingInternalLineProbability value T (value (rep c)) : ℂ)‖ ≤ + ((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) * + ∏ c, (value (rep c) : ℝ)⁻¹ := by + let _ : ∀ c, Fact (value (rep c)).Prime := fun _ => ⟨hprime _⟩ + have hprob (c) : 0 ≤ movingInternalLineProbability value T (value (rep c)) := + movingInternalLineProbability_nonneg value T _ + have hline (c) : movingInternalLineProbability value T (value (rep c)) ≤ + (value (rep c) : ℝ)⁻¹ := by + let j : MovingPrimeOccurrences value T (value (rep c)) := + ⟨(base c).1, ⟨(base c).2.val, ⟨rep c, (base c).2.property, rfl⟩⟩⟩ + exact movingInternalLineProbability_le_inv tier value hprime hdisjoint T hlevels _ (hf c) j + have hs : (∑ c, (value (rep c) : ℝ)⁻¹) ≤ (Fintype.card C : ℝ) * Real.exp (-V) := by + calc + _ ≤ ∑ _c : C, Real.exp (-V) := by + apply Finset.sum_le_sum + intro c _ + simpa only [Real.exp_neg] using inv_anti₀ (Real.exp_pos V) (hsize c) + _ = _ := by rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + have h := finite_relative_product_error (Finset.univ : Finset C) + (fun c => movingInternalHaarAverage value T (value (rep c))) + (fun c => (movingInternalLineProbability value T (value (rep c)) : ℂ)) + (fun c => movingInternalLineProbability value T (value (rep c))) + (fun c => 2 * (2 ^ n - 1 : ℕ) / (value (rep c) : ℝ)) + (fun c _ => hprob c) (fun c _ => by positivity) + (fun c _ => movingInternalPairFactor_probability_norm_le value T _) + (fun c _ => by rw [Complex.norm_real, Real.norm_of_nonneg (hprob c)]) + (fun c _ => movingInternalPairFactor_probability_error tier value hprime hdisjoint T hlevels _ (hf c)) + have hp : (∏ c, movingInternalLineProbability value T (value (rep c))) ≤ + ∏ c, (value (rep c) : ℝ)⁻¹ := + Finset.prod_le_prod₀ (fun c _ => hprob c) (fun c _ => hline c) + have hk : (∑ c, 2 * (2 ^ n - 1 : ℕ) / (value (rep c) : ℝ)) ≤ + (2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V) := by + simp only [div_eq_mul_inv, ← Finset.mul_sum] + exact (mul_le_mul_of_nonneg_left hs (by positivity)).trans_eq (by ring) + exact h.trans (mul_le_mul hk hp (Finset.prod_nonneg (fun c _ => hprob c)) (by positivity)) + +/-- Integrating a relative local error uses the original normalized prior, +not a conditioned law. The retained scale may include every internal class. -/ +theorem productPrior_relative_error {A : Type*} [Fintype A] {N : ℕ} + (μ : Fin N → A → ℝ) (hmass : ∀ i, ∑ a, μ i a = 1) + (weight err : (Fin N → A) → ℂ) (scale : (Fin N → A) → ℝ) + (B K : ℝ) (hK : 0 ≤ K) + (hweight : ∀ x, ‖weight x‖ * scale x ≤ B * productPrior μ x) + (herr : ∀ x, weight x ≠ 0 → ‖err x‖ ≤ K * scale x) : + ‖∑ x, weight x * err x‖ ≤ B * K := by + calc + _ ≤ ∑ x, ‖weight x * err x‖ := norm_sum_le _ _ + _ ≤ ∑ x, K * (B * productPrior μ x) := by + apply Finset.sum_le_sum + intro x _ + by_cases hz : weight x = 0 + · have hb := hweight x + rw [hz, norm_zero, zero_mul] at hb + simpa only [hz, zero_mul, norm_zero] using mul_nonneg hK hb + · rw [norm_mul] + calc + _ ≤ ‖weight x‖ * (K * scale x) := + mul_le_mul_of_nonneg_left (herr x hz) (norm_nonneg _) + _ = K * (‖weight x‖ * scale x) := by ring + _ ≤ K * (B * productPrior μ x) := mul_le_mul_of_nonneg_left (hweight x) hK + _ = B * K := by + rw [← Finset.mul_sum, ← Finset.mul_sum, productPrior_mass μ hmass] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSumCoordinates.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSumCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cc14a1d6179c92c9b87a7d2936ef924bfe71f17 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSumCoordinates.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFinite + +namespace OAI + +/-! # Exact passage from injective class assignments to the comparison sum -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem sum_injective_assignments {A C M : Type*} [Fintype A] [Fintype C] + [AddCommMonoid M] (F : (C → A) → M) : + (∑ z : {z : C → A // Function.Injective z}, F z.val) = + ∑ z : C → A, if Function.Injective z then F z else 0 := by + rw [← Finset.sum_subtype (Finset.univ.filter (fun z : C → A => Function.Injective z)) + (by simp) F, Finset.sum_filter] + +theorem sum_external_injective_pattern {A B C M : Type*} + [Fintype A] [Fintype B] [Fintype C] [AddCommMonoid M] + (F : (B → A) → (C → A) → M) : + (∑ y : B → A, ∑ z : {z : C → A // Function.Injective z}, F y z.val) = + ∑ x : B ⊕ C → A, + if Function.Injective (fun c => x (.inr c)) then + F (fun b => x (.inl b)) (fun c => x (.inr c)) else 0 := by + simp_rw [sum_injective_assignments] + have hp := Fintype.sum_prod_type (fun yz : (B → A) × (C → A) => + if Function.Injective yz.2 then F yz.1 yz.2 else 0) + have he := (Equiv.sumArrowEquivProdArrow B C A).sum_comp + (fun yz : (B → A) × (C → A) => if Function.Injective yz.2 then F yz.1 yz.2 else 0) + simp only [finite_univ_canonical] at hp he ⊢ + exact hp.symm.trans he.symm + +/-- This is an exact zero extension of the original injective class sum; +it is the form to which the independent-prior comparison applies. -/ +theorem sum_external_injective_pattern_fin {A B C M : Type*} + [Fintype A] [Fintype B] [Fintype C] [AddCommMonoid M] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (F : (B → A) → (C → A) → M) : + (∑ y : B → A, ∑ z : {z : C → A // Function.Injective z}, F y z.val) = + ∑ x : Fin (N + 1) → A, + if Function.Injective (fun c => x (e.symm (.inr c))) then + F (fun b => x (e.symm (.inl b))) (fun c => x (e.symm (.inr c))) else 0 := by + rw [sum_external_injective_pattern] + have he := (Equiv.arrowCongr e (Equiv.refl A)).sum_comp + (fun x : B ⊕ C → A => if Function.Injective (fun c => x (.inr c)) then + F (fun b => x (.inl b)) (fun c => x (.inr c)) else 0) + simp only [finite_univ_canonical] at he ⊢ + exact he.symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSupportedArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSupportedArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d50fabc67ab02e128bd769523205091f59730a5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSupportedArithmetic.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPriorSupport + +namespace OAI + +/-! # Combining arithmetic and bulk cancellation on the original support -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_signed_arithmetic_on_support {A B C : Type*} + [Fintype A] [Nonempty A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ b, (movingPatternFinData e n t small bulk pattern b).SizeLE d) + (hfreq : ∀ b, (movingPatternFinData e n t small bulk pattern b).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E α β V : ℝ) (hE : 0 ≤ E) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hmax : ∀ j a, μ j a ≤ α) (hnmax : ∀ j a, ν j a ≤ α) + (hpmax : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≤ β) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + Real.exp V ≤ prime a) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hcross : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ b c, + prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (hfmod : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) + (m : ℕ) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (hbulkEq : bulk = movingPatternBulkLeaves n m slot perm) + (Dminor : ℝ) + (hminor : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + ‖movingPatternBulkMean e ν slot G x‖ ≤ Dminor) + (seed : TreeLeafIndex n × Fin m → A) : + let κ := (2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C) + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternHaarProduct e prime hprime n t small bulk pattern x‖ ≤ + κ * (D * (((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) + + 2 * ((Fintype.card C * (2 + 2 * (2 ^ n - 1)) : ℕ) : ℝ) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β)) + Dminor) := by + have ha := movingPattern_arithmetic_comparison_on_support e prime hpInj hprime tierB tierC t small bulk pattern rep + hsmall hbulk htier d F U hF hU hsize hfreq hvalues μ ν hμ hν hmass hnmass + E α β V hE hα hβ hV hbound hmax hnmax hpmax hprimeSize G D hD hG hdisjoint hcross hfmod + have hb : ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small bulk pattern rep x‖ ≤ + Dminor * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) := by + rw [hbulkEq] + simpa only [mul_comm] using + movingPattern_signed_bulk_mean_on_support e μ ν prime t small slot perm pattern rep E hE + hprime hμ hν hmass hnmass hbound G Dminor hminor seed + dsimp only at ha ⊢ + let X := ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternHaarProduct e prime hprime n t small bulk pattern x + let Y := ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small bulk pattern rep x + have heq : X - Y = ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternHaarProduct e prime hprime n t small bulk pattern x - + movingPatternFlagProduct e prime n t small bulk pattern rep x) := by + dsimp only [X, Y] + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro x _ + ring + have htriangle : ‖X‖ ≤ ‖X - Y‖ + ‖Y‖ := by + simpa only [sub_add_cancel] using norm_add_le (X - Y) Y + rw [heq] at htriangle + exact htriangle.trans ((add_le_add ha hb).trans_eq (by ring)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSupportedMean.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSupportedMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d9528eef769b2a259b36b8da943b614a234bc48 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternSupportedMean.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMajorant + +namespace OAI + +/-! # Signed bulk estimates needed only on the original pattern prior -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Invalid role assignments outside the original product law require no +analytic estimate. This retains the original harmonic priors when applying +an estimate proved with their precise prime ranges. -/ +theorem movingPattern_signed_bulk_mean_on_support {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) (hE : 0 ≤ E) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) + (hG : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + ‖movingPatternBulkMean e ν slot G x‖ ≤ D) + (seed : TreeLeafIndex n × Fin m → A) : + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep x‖ ≤ + ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * D := by + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let minor := fun x => if productPrior law x = 0 then ‖movingPatternBulkMean e ν slot G x‖ else D + have hminor (x) : ‖movingPatternBulkMean e ν slot G x‖ ≤ minor x := by + dsimp only [minor] + split_ifs with h + · exact le_rfl + · exact hG x h + have hlaw (i) : ∑ a, law i a = 1 := by + dsimp only [law] + cases e i with + | inl b => exact hnmass b + | inr c => exact hmass _ + have hmean : (∑ x, productPrior law x * minor x) = D := by + calc + _ = ∑ x, productPrior law x * D := by + apply Finset.sum_congr rfl + intro x _ + dsimp only [minor] + split_ifs with h + · simp only [h, zero_mul] + · rfl + _ = D := by rw [← Finset.sum_mul, productPrior_mass law hlaw, one_mul] + have hh := movingPattern_signed_bulk_majorant e μ ν prime t small slot perm pattern rep E hE + hprime hμ hν hnmass hbound G minor hminor seed + dsimp only at hh + dsimp only [law] at hmean + rw [hmean] at hh + exact hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTemplateEnumeration.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTemplateEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..b80637a1676ec775900387ac2b0834a209203998 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTemplateEnumeration.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateEnumeration +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalDiagonalPatterns + +namespace OAI + +/-! # Identifying arithmetic pattern slots with the full regular template -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPatternTemplateSlots_eq {C : Type*} {N : ℕ} (n r m : ℕ) + (e : Fin (N + 1) ≃ MovingRegularSlot n r m ⊕ C) : + movingPatternRegularSlots e n m (movingTemplateSmall n r m) (movingTemplateBulk n r m) = + (movingTemplateSlotList n r m).map (fun b => e.symm (.inl b)) := by + exact movingPatternRegularSlots_eq_map e _ _ + +noncomputable def movingPatternTemplateEquiv {C : Type*} {N : ℕ} (n r m : ℕ) + (e : Fin (N + 1) ≃ MovingRegularSlot n r m ⊕ C) : + Fin (movingPatternRegularSlots e n m (movingTemplateSmall n r m) + (movingTemplateBulk n r m)).length ≃ MovingRegularSlot n r m := + (finCongr (by rw [movingPatternTemplateSlots_eq, List.length_map])).trans + (movingTemplateListEquiv n r m) + +theorem movingPatternTemplateEquiv_label {C : Type*} {N : ℕ} (n r m : ℕ) + (e : Fin (N + 1) ≃ MovingRegularSlot n r m ⊕ C) + (i : Fin (movingPatternRegularSlots e n m (movingTemplateSmall n r m) + (movingTemplateBulk n r m)).length) : + (movingPatternRegularSlots e n m (movingTemplateSmall n r m) + (movingTemplateBulk n r m)).get i = e.symm (.inl (movingPatternTemplateEquiv n r m e i)) := by + simp only [movingPatternTemplateEquiv, Equiv.trans_apply, movingTemplateListEquiv_apply, + List.get_eq_getElem, movingPatternTemplateSlots_eq, List.getElem_map, finCongr_apply, + Fin.val_cast] + +/-- The inactive-slot condition used by the arithmetic theorem follows from +activity of the actual bulk slots. -/ +theorem movingPatternTemplate_inactive_not_bulk {C : Type*} {N : ℕ} (n r m : ℕ) + (e : Fin (N + 1) ≃ MovingRegularSlot n r m ⊕ C) + (active : MovingRegularSlot n r m → Bool) + (hactive : ∀ j, active (movingTemplateBulk n r m j) = true) + (i : Fin (movingPatternRegularSlots e n m (movingTemplateSmall n r m) + (movingTemplateBulk n r m)).length) + (hi : active (movingPatternTemplateEquiv n r m e i) = false) : + (movingPatternRegularSlots e n m (movingTemplateSmall n r m) + (movingTemplateBulk n r m)).get i ∉ + Set.range (movingPatternBulkEmbedding e (movingTemplateBulk n r m)) := by + rintro ⟨j, hj⟩ + rw [movingPatternTemplateEquiv_label] at hj + have he : movingTemplateBulk n r m j = movingPatternTemplateEquiv n r m e i := by + apply Sum.inl.inj + apply e.symm.injective + exact hj + rw [← he, hactive j] at hi + cases hi + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTree.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..21d5197fd2c66f2654bb7d2bb88496a307c098a3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTree.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleMap +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePairPatterns + +namespace OAI + +/-! # The actual pair of sampled trees after fixing an internal pattern -/ + +namespace Ostmann +open scoped Classical + +/-- Fixed external labels and internal equality classes are kept separate. +The latter number depends only on depth, not on the bulk length. -/ +def movingPatternSamples (C : Type*) (n : ℕ) + (pattern : Bool × MovingSampleIndex n → C) (side : Bool) : MovingSampleSlots C n := + (movingSampleCoordinates C n).symm (fun i => pattern (side, i)) + +theorem movingPatternSamples_map {C A : Type*} (f : C → A) (n : ℕ) + (pattern : Bool × MovingSampleIndex n → C) (side : Bool) : + (movingPatternSamples C n pattern side).map f = + movingPatternSamples A n (f ∘ pattern) side := by + apply (movingSampleCoordinates A n).injective + funext i + rw [movingSampleCoordinates_map] + simp only [movingPatternSamples, Equiv.apply_symm_apply, Function.comp_apply] + +theorem movingPatternSamples_pair {C : Type*} (n : ℕ) + (pattern : Bool × MovingSampleIndex n → C) : + (movingPatternSamples C n pattern false, movingPatternSamples C n pattern true) = + (movingSamplePairCoordinates C n).symm pattern := rfl + +theorem treeLeafMap_list_comp {A B C : Type*} (f : A → B) (g : B → C) + (n : ℕ) (x : TreeLeafTuple (List A) n) : + treeLeafMap (List.map g) n (treeLeafMap (List.map f) n x) = + treeLeafMap (List.map (g ∘ f)) n x := by + induction n with + | zero => exact List.map_map + | succ n ih => exact Prod.ext (ih x.1) (ih x.2) + +def movingPatternSlotData {B C : Type*} (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (side : Bool) : MovingSlotData (B ⊕ C) n := + buildMovingSlotData n t (treeLeafMap (List.map Sum.inl) n small) + (treeLeafMap (List.map Sum.inl) n bulk) + (movingPatternSamples (B ⊕ C) n (Sum.inr ∘ pattern) side) + +/-- Evaluating the fixed pattern tree gives precisely the original sampled +constructor with those class values. No new sampler is introduced. -/ +theorem movingPatternSlotData_evaluate {A B C : Type*} (external : B → A) (internal : C → A) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (side : Bool) : + (movingPatternSlotData n t small bulk pattern side).map (Sum.elim external internal) = + buildMovingSlotData n t (treeLeafMap (List.map external) n small) + (treeLeafMap (List.map external) n bulk) + (movingPatternSamples A n (internal ∘ pattern) side) := by + unfold movingPatternSlotData + rw [buildMovingSlotData_map, treeLeafMap_list_comp, treeLeafMap_list_comp, + movingPatternSamples_map] + rfl + +theorem movingPatternSlotData_levels {B C : Type*} (tierB : B → ℕ) (tierC : C → ℕ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ i ∈ flattenMovingSlots n small, n ≤ tierB i) + (hbulk : ∀ i ∈ flattenMovingSlots n bulk, n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) (side : Bool) : + (movingPatternSlotData n t small bulk pattern side).Levels (Sum.elim tierB tierC) := by + apply buildMovingSlotData_levels + · intro i hi + rw [flattenMovingSlots_map] at hi + obtain ⟨j, hj, rfl⟩ := List.mem_map.mp hi + exact hsmall j hj + · intro i hi + rw [flattenMovingSlots_map] at hi + obtain ⟨j, hj, rfl⟩ := List.mem_map.mp hi + exact hbulk j hj + · apply movingSampleCoordinates_levels + intro i + exact htier (side, i) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeBulk.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeBulk.lean new file mode 100644 index 0000000000000000000000000000000000000000..bc2895733a53ad52404b0521884765bf4537c91a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeBulk.lean @@ -0,0 +1,123 @@ +import OAI.NumberTheory.Ostmann.Construction.PrimeBulkInsertion +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeBulkIdentity + +namespace OAI + +/-! # Exact selected-prime mean of the original pattern kernel -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell I : Type*} [Fintype Cell] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +/-- This is the original real kernel and its original Page and spectator +averages, evaluated after inserting the selected prime draws. -/ +noncomputable def movingPatternTwoPrimeBulkHaar (x : (TreeLeafIndex n × Fin m) → primes) : ℂ := + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + let hp := primeBulkValues_prime base (movingPatternBulkEmbedding e slot) x hprimes hbase + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes value (fun i => (hp i).ne_zero) + childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPrimeAverage value outside F E data nodes R r P Q xg y * + ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) data) + +include hsmall hR hr hg in +/-- Removing the fixed nonbulk primes is sufficient for the supported +arithmetic identity. The averaging law and its normalizers remain unchanged. -/ +theorem movingPatternTwoPrimeBulkHaar_mean + [NeZero (∏ i, bulkResidueModuli r p i)] + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (S deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hS : ∀ j, S j ⊆ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1)) + (hdeleted : ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) + (hout : ∀ q ∈ outside, q.Prime) + (hdeletedOut : ∀ j q, q ∈ outside → q ∈ deleted j) : + let M := ∏ i, bulkResidueModuli r p i + let label := fun (x : (TreeLeafIndex n × Fin m) → primes) j => primeCellLabel M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) c₀ (x j) + let K := movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + let a := fun z => frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + F E (movingPatternFinBulkData e n m t small slot perm pattern) childBound R r P Q xg y + (bulkResidueEquiv r p hc z).1 * + ∏ i, frozenBulkSpectatorPrime base n m t (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (twist i) perm (g i) ((bulkResidueEquiv r p hc z).2 i) + (∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U x) = + ∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + (if Function.Injective x then a (fun j => (label x j).2) * + K (fun j => Real.log (x j : ℕ)) else 0) := by + intro M label K a + apply Finset.sum_congr rfl + intro x _ + by_cases hw : (∏ j, primeSubsetPrior primes (S j \ deleted j) (x j)) = 0 + · simp only [hw, Complex.ofReal_zero, zero_mul] + · have hx (j) : (x j : ℕ) ∈ S j \ deleted j := + primeSubsetPrior_support primes _ _ (Finset.prod_ne_zero_iff.mp hw j (Finset.mem_univ j)) + have hxcell (j) : (x j : ℕ) ∈ primeCellSupport M + (fun c : Cell × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) \ deleted j := + Finset.mem_sdiff.mpr ⟨hS j (Finset.mem_sdiff.mp (hx j)).1, (Finset.mem_sdiff.mp (hx j)).2⟩ + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + have hp := primeBulkValues_prime base (movingPatternBulkEmbedding e slot) x hprimes hbase + have hv (i) (hi : i ∉ Set.range (movingPatternBulkEmbedding e slot)) : value i = base i := + primeBulkValues_off base (movingPatternBulkEmbedding e slot) x i hi + have hz (j) : (value (movingPatternBulkEmbedding e slot j) : ZMod M) = + ((label x j).2 : ZMod M) := + primeBulkValues_cell_label base (movingPatternBulkEmbedding e slot) x M u v c₀ deleted hxcell j + have hid := movingPattern_two_prime_bulk_supported_identity e tierB tierC t small slot perm pattern + hsmall hB htier base value hv hp childBound pivotBound hfreq F E outside + (primeBulkValues_cross_of_deleted base (movingPatternBulkEmbedding e slot) x S deleted hx hdeleted) + (primeBulkValues_outside_coprime base (movingPatternBulkEmbedding e slot) x S deleted + hprimes hx outside hout hdeletedOut) + R r hR hr p hc g hg twist (fun j => (label x j).2) hz P Q xg y + j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + dsimp only at hid + have hinj : Function.Injective (value ∘ movingPatternBulkEmbedding e slot) ↔ + Function.Injective x := primeBulkValues_injective_iff base (movingPatternBulkEmbedding e slot) x + simp only [hinj] at hid + apply congrArg (fun z : ℂ => ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * z) + unfold movingPatternTwoPrimeBulkHaar + rw [hid] + split_ifs <;> simp only [primeBulkValues_at, K, a, value, mul_comm] + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeBulkIdentity.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeBulkIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8ee1f5240c720cac8c57f33dc3d96362410c6eb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeBulkIdentity.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternIntegrand +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeBulkArithmetic + +namespace OAI + +/-! # Return the separated bulk kernel to the original supported histories -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- An exact identity for every original prime tuple. Its bulk collision +indicator is derived from the original regular-product support, before any +prime replacement or change of normalization. -/ +theorem movingPattern_two_prime_bulk_supported_identity {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base value : Fin (N + 1) → ℕ) + (hv : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), value i = base i) + (hprime : ∀ i, (value i).Prime) (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) + (hcross : ∀ i j, bulkIndexPredicate (movingPatternBulkEmbedding e slot) i ≠ + bulkIndexPredicate (movingPatternBulkEmbedding e slot) j → value i ≠ value j) + (hout : ∀ j p, p ∈ outside → (value (movingPatternBulkEmbedding e slot j)).Coprime p) + (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (z : TreeLeafIndex n × Fin m → (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hz : ∀ j, (value (movingPatternBulkEmbedding e slot j) : ZMod (∏ i, bulkResidueModuli r p i)) = + (z j : ZMod _)) + (P : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes value (fun i => (hprime i).ne_zero) + childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPrimeAverage value outside F E data nodes R r P Q xg y * + ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) data) = + if Function.Injective (value ∘ movingPatternBulkEmbedding e slot) then + movingPatternBulkIntegrand e tierB tierC t small slot perm pattern hB htier + (fun i => (base i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + (fun j => Real.log (value (movingPatternBulkEmbedding e slot j) : ℝ)) * + (frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Q xg y (bulkResidueEquiv r p hc z).1 * + ∏ i, frozenBulkSpectatorPrime base n m t (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (twist i) perm (g i) + ((bulkResidueEquiv r p hc z).2 i)) + else 0 := by + intro data nodes + by_cases hinj : Function.Injective (value ∘ movingPatternBulkEmbedding e slot) + · rw [ite_eq_left hinj] + rw [movingPatternBulkIntegrand_nat e tierB tierC t small slot perm pattern hB htier + childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + base value hv (fun i => (hprime i).ne_zero) hfreq] + congr 1 + exact movingPattern_supported_prime_arithmetic e tierB tierC t small slot perm pattern hsmall hB htier + base value hv F E outside childBound pivotBound hprime + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq) + hinj hcross hout R r hR hr p hc g hg twist z hz P Q xg y + · rw [ite_eq_right hinj] + have hzero := movingPattern_prime_arithmetic_collision_gate e t small slot perm pattern value hprime + outside F E nodes R r P Q xg y (∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) data) + dsimp only at hzero + rw [ite_eq_right hinj] at hzero + rw [hzero, mul_zero] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeInitialNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeInitialNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..b32981f372ff629557c27659738457da04bcfebd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeInitialNormRate.lean @@ -0,0 +1,177 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeNormRate +import OAI.NumberTheory.Ostmann.Construction.NestedPrimePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeNorm + +namespace OAI + +/-! # Retaining the norm bound under the initial bulk law -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_initial_two_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex n × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (initial j) (x j) : ℝ) : ℂ) * + movingPatternTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U x‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + have hconditional := P.movingPattern_original_two_prime_norm_rate ψ n r₀ k + A Wwin Bφ Dφ F Cmass hA hWwin hF hCmass hBφ hDφ + filter_upwards [hconditional, movingPattern_bad_event_rate_window ψ n r₀ k + A Wwin Bφ Dφ F (Cmass + 1) hA hWwin hF, + P.original_harmonic_box_rate Cmass hCmass, eventually_ge_atTop (2000 : ℝ)] + with L hconditional hbad hnormal hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hbd := hbad lo hi hhi hwindow p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hdeletedBound := hconditional lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq xg y X A₀ + j₀ φ G XL U u v deleted hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ + hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout + hA₀ hlocal c₀ + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * W + have hpoint (x : (TreeLeafIndex n × Fin m) → primes) : + ‖movingPatternTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U x‖ ≤ cost := + movingPatternTwoPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U + hxg hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hcollision : 0 ≤ cost * (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * + Real.exp ((Cmass + 1) * L - Real.exp ((39 / 10000 : ℝ) * L)) := by + dsimp only [cost, W, amp] + positivity + have hreturnCost := (le_add_of_nonneg_left hcollision).trans hbd + have hcost0 : 0 ≤ cost := by dsimp only [cost, W, amp]; positivity + have hfinal := @nested_prime_prior_three_errors (TreeLeafIndex n × Fin m) + inferInstance primes S initial deleted hS hsub hretain (fun j => (hnorm j).1) + (fun x => movingPatternTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U x) + cost (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L))) + (Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcost0 hpoint + (by simpa only [finite_univ_canonical, m, S, M] using hdeletedBound) + (by simpa only [finite_univ_canonical, cost, W, m, Z] using hreturnCost) + simpa only [finite_univ_canonical, m, S, M] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeIntegratedRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeIntegratedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9db804cc96c92549a3452c307395c1cffb237f9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeIntegratedRate.lean @@ -0,0 +1,207 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeSameNormArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHarmonicIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # The actual two-prime arithmetic bound integrated over its giant cells -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_same_assignment_two_prime_integral_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ) (uG vG rG sG : ℝ), + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (Fw true) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := fun xg y => movingPatternTwoPrimeObservable e t small slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i b j, + j ∈ flattenMovingSlots n (small b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (fun x => ∫ xg in Set.Ioc uG vG, ∫ y in Set.Ioc rG sG, + obs xg y x / ((xg : ℂ) * (y : ℂ))) x * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + (((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))))) / (uG * rG) := by + filter_upwards [P.movingPattern_same_assignment_two_prime_arithmetic_rate ψ n r₀ k + A Wwin Bφ Dφ Cmass hA hWwin hCmass hBφ hDφ, + eventually_ge_atTop (0 : ℝ)] with L hrate hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq Fw outside _ p _ hc _ twist sets + Qfreq X j₀ φ G u v deleted initial μ ν Eprior αall βint Vint Uall uG vG rG sG + huG hrG huvG hrsG hvG hsG + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq n ft + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let obs := fun xg y => movingPatternTwoPrimeObservable e t small slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + let amp := 4 * (‖movingDataWeight (Fw false) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (Fw true) (fun _ _ _ _ => 1) (data true)‖) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let bound := ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) + have hmean (xg : ℝ) (hxg : xg ∈ Set.Ioc uG vG) (y : ℝ) (hy : y ∈ Set.Ioc rG sG) : + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (obs xg y) x * movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) n t small + (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ bound := by + exact hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes childBound pivotBound hfreq Fw outside p hc twist sets Qfreq xg y X j₀ φ G + (Real.exp xg) (Real.exp y) u v deleted initial μ ν Eprior αall βint Vint Uall + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp (by linarith [hxg.1]) (by linarith [hy.1]) + hpupper hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hSS hdel hmass + hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint + hVint hUall hμbound hμall hνall hμmax hμmin hvalues + (hdisjoint xg hxg y hy) (hcross xg hxg y hy) (hfmod xg hxg y hy) + have hA₀ : 0 ≤ A₀ := by + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro z hz + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hz + exact pairFrequencySupportBound_nonneg D f + exact mul_nonneg (by positivity) (mul_nonneg hleaf0 hprod) + have hcost : 0 ≤ cost := by dsimp only [cost, amp]; positivity + have herr := movingInternalArithmeticError_nonneg n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + (Real.one_le_exp (mul_nonneg hA (Nat.cast_nonneg m))) hUall hαall hβint hVint.le + have hbound : 0 ≤ bound := by dsimp only [bound]; positivity + apply movingPattern_prime_harmonic_integral_bound e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) μ ν t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) + pattern (fun x xg y => obs xg y x) _ uG vG rG sG bound huG hrG huvG hrsG hvG hsG + hbound (fun _ => cost) (fun _ => hcost) _ hmean + · intro x + exact movingPatternTwoPrimeObservable_measurable e t small slot (Equiv.refl _) pattern + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq ψ X lo hi hlo hhi φ G Bφ Dφ hBφ hDφ hφ hlip hφout x + · intro x xg hxg y hy + exact movingPatternTwoPrimeObservable_norm e tierB tierC t small slot (Equiv.refl _) pattern + hB htier primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G + Bφ Dφ hBφ hDφ hφ hlip hφout (Real.exp xg) (Real.exp y) + (by linarith [hxg.1]) (by linarith [hy.1]) (fun i => (p i : ℝ)) (fun _ => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeMeasurable.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeMeasurable.lean new file mode 100644 index 0000000000000000000000000000000000000000..59c42af39830a0e9421931f3f5f1b8d86a161562 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeMeasurable.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeObservable +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePairHaarRegularity +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelTransport + +namespace OAI + +/-! # Measurability of the original two-prime pattern integrand -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (input : PublishedProgressionInput) (Q : ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + +theorem movingPatternTwoPrimeObservable_measurable + (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (x : Fin (N + 1) → primes) : + Measurable (fun z : ℝ × ℝ => + movingPatternTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist input Q z.1 z.2 + ψ X lo hi hlo hhi φ G (Real.exp z.1) (Real.exp z.2) x) := by + let value := fun i => (x i : ℕ) + let T := movingPatternFinBulkData e n m t small slot perm pattern + let hf := movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq + let nodes := fun b => (T b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound (hf b) + (.prime false) (.prime true) + have hk := measurable_exp_pair_mul (movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G) + (measurable_movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G + Bφ Dφ hBφ hDφ hφ hlip hout) (1 : ℂ) + simp only [one_mul] at hk + have ha := (continuous_correctedPrimePairAverage input Q r + (fun a b => movingFrequencyPairFactor value outside F E T nodes R a b)).measurable + change Measurable (fun z : ℝ × ℝ => + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp z.1) (Real.exp z.2) * + (movingFrequencyPrimeAverage value outside F E T nodes R r input Q z.1 z.2 * + ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) T)) + exact hk.mul (ha.mul measurable_const) + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..51345ab86856588f142f8c42da83726192e07915 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeNorm.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePointwiseNorm + +namespace OAI + +/-! # Pointwise bound for the literal original prime observable -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell I : Type*} [Fintype Cell] [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +include hB htier hV hBφ hDφ hφ hlip hφout j₀ in +/-- This uniform pointwise estimate allows the extra nonbulk-prime deletion +error to be returned to the initial external law. -/ +theorem movingPatternTwoPrimeBulkHaar_norm + (hxg : 0 ≤ xg) (hy : 0 ≤ y) (Kspec : I → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (x : (TreeLeafIndex n × Fin m) → primes) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let amp := 4 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + ‖movingPatternTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U x‖ ≤ + (amp * ∏ i, Kspec i ^ (2 ^ (n + 1))) * W := by + intro data amp W + let value := primeBulkValues base (movingPatternBulkEmbedding e slot) x + have hp := primeBulkValues_prime base (movingPatternBulkEmbedding e slot) x hprimes hbase + have hv : ∀ i, value i ≠ 0 := fun i => (hp i).ne_zero + have hf := movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq + let nodes := fun b => (data b).formulaNodes value hv childBound pivotBound (hf b) + (.prime false) (.prime true) + have hk : ‖movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U‖ ≤ W := by + rw [← realValueKernelPair_nat value hv childBound pivotBound data hf] + exact movingPattern_kernel_norm_le e tierB tierC t small slot perm pattern hB htier + (fun i => (value i : ℝ)) childBound pivotBound j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + have hfr : ‖movingFrequencyPrimeAverage value outside F E data nodes R r P Q xg y‖ ≤ amp := + movingFrequencyPrimeAverage_norm_le value outside F E data nodes R r P Q xg y hxg hy + have hs : ‖∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) data‖ ≤ + ∏ i, Kspec i ^ (2 ^ (n + 1)) := by + rw [norm_prod] + exact Finset.prod_le_prod₀ (fun i _ => norm_nonneg _) (fun i _ => + movingSpectatorPrimeAverage_norm_le value (p i) (g i) (twist i) data + (Kspec i) (hKspec i) (hgnorm i)) + change ‖movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPrimeAverage value outside F E data nodes R r P Q xg y * + ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) data)‖ ≤ _ + simp only [norm_mul] + calc + _ ≤ W * (amp * ∏ i, Kspec i ^ (2 ^ (n + 1))) := + mul_le_mul hk (mul_le_mul hfr hs (norm_nonneg _) (by dsimp only [amp]; positivity)) + (by positivity) (sq_nonneg _) + _ = _ := mul_comm _ _ + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeNormBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeNormBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c0334ee95a4555d102ccd205c85b16ba144612d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeNormBound.lean @@ -0,0 +1,136 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePointwiseNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelNormBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternNormKernel +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSpectatorNorm + +namespace OAI + +/-! # The norm estimate for the literal original prime mean -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap + +section +variable {B C Cell : Type*} [Fintype Cell] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (hR : ∀ b, (movingPatternFinBulkData e n m t small slot perm pattern b).frequencyProduct ∣ R) + (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q Qfreq : ℕ) (xg y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +include hsmall hB htier hR hr hg hV hBφ hDφ hφ hlip hφout j₀ in +/-- Transfer a retained arithmetic absolute mean to the original prime law, +with the sharp window factor in the main term and the established variation +budget in the approximation errors. -/ +theorem PublishedProgressionInput.movingPattern_original_two_prime_norm_bound + [NeZero (∏ i, bulkResidueModuli r p i)] + (r₀ : ℕ) (hsmallLen : ∀ b, MovingLeafLengthLE n (small b) r₀) + (hxg : 0 ≤ xg) (hy : 0 ≤ y) (hQ : 2 ≤ Q) (hMQ : (∏ i, bulkResidueModuli r p i) ≤ Q) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (hu : ∀ j c, 1 ≤ u j c) (huv : ∀ j c, u j c ≤ v j c) + (hshort : ∀ j c, v j c ≤ u j c + 1) + (hmassCell : ∀ j c (a : (ZMod (∏ i, bulkResidueModuli r p i))ˣ), + ∑ q ∈ primeLogCellSet (∏ i, bulkResidueModuli r p i) a.val.val (u j c) (v j c), + (q : ℝ)⁻¹ ≤ 2) + (c₀ : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hP : ∀ j, primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ primes) + (hsep : ∀ j (c d : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ), c ≠ d → + ¬Nat.ModEq (∏ i, bulkResidueModuli r p i) c.2.val.val d.2.val.val ∨ + v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hdeleted : ∀ j, (∑ q ∈ primeCellSupport (∏ i, bulkResidueModuli r p i) + (fun c : Cell × (ZMod (∏ i, bulkResidueModuli r p i))ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ deleted j, (q : ℝ)⁻¹) ≠ 0) + (hdeletedBase : ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) + (hout : ∀ q ∈ outside, q.Prime) (hdeletedOut : ∀ j q, q ∈ outside → q ∈ deleted j) + (Kspec : Fin m → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (A₀ : ℝ) (hA₀ : 0 ≤ A₀) (H T : ℝ) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (g i) + let A := 4 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let W₀ := ((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * Bφ ^ (2 ^ n - 1)) ^ 2 + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + let err := fun c : (TreeLeafIndex n × Fin m) → Cell => + 2 ^ Fintype.card (TreeLeafIndex n × Fin m) * ∑ j, + bulkKernelPairComparisonBudget ψ V lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 Bφ Dφ * + bulkPrimeErrorFactor P Q (u j (c j)) + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P Q M (w j).val.val (z j)‖ ≤ A₀) → + (∀ j, Z j * ∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹ ≤ 2) → + (∀ j, Z j ≤ Real.exp H) → + (∀ j q, q ∈ S j \ deleted j → Real.exp T ≤ (q : ℝ)) → + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq F E outside R r p g twist P Qfreq xg y ψ X lo hi hlo hhi φ G L U x‖ ≤ + (W₀ * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + (∏ j, Z j) * ∑ c : (TreeLeafIndex n × Fin m) → Cell, ∑ z, ‖a z‖ * err c + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + (Fintype.card (TreeLeafIndex n × Fin m) : ℝ) ^ 2 * Real.exp (H - T) + + (A * (∏ i, Kspec i ^ (2 ^ (n + 1))) * W) * + ((∏ j, (1 + Z j * ∑ q ∈ S j ∩ deleted j, (q : ℝ)⁻¹)) - 1) := by + intro data freq spec A W W₀ M S Z a err hlocal hmass hZ hlow + have hA : 0 ≤ A := by dsimp only [A]; positivity + have hf (z) : ‖freq z‖ ≤ A := + frozenBulkFrequencyPrime_norm_le base (movingPatternBulkEmbedding e slot) outside + F E data childBound R r P Qfreq xg y hxg hy z + have hspec (i) (z) : ‖spec i z‖ ≤ Kspec i ^ (2 ^ (n + 1)) := + frozenBulkSpectatorPrime_norm_le base n m t _ _ (twist i) perm (g i) (Kspec i) + (hKspec i) (hgnorm i) z + have heq := movingPatternTwoPrimeBulkHaar_mean e tierB tierC t small slot perm pattern hsmall hB htier + base primes hprimes hbase childBound pivotBound hfreq F E outside R r hR hr p hc g hg twist + P Qfreq xg y j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + u v c₀ S deleted (fun _ => Finset.Subset.refl _) hdeletedBase hout hdeletedOut + dsimp only at heq + rw [heq] + have hb := P.movingPattern_norm_kernel_bound e tierB tierC t small slot perm pattern hB htier + hsmallLen base childBound pivotBound j₀ ψ X lo hi V hlo hhi hV φ G Bφ Dφ hBφ hDφ + hφ hlip hφout L U r p hc freq spec A hA hf Q hQ hMQ primes u v hu huv hshort + hmassCell c₀ hP hsep deleted hdeleted A₀ hA₀ H T (fun i => Kspec i ^ (2 ^ (n + 1))) + (fun i => pow_nonneg (hKspec i) _) + exact hb hlocal hspec hmass hZ hlow + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..eaaa677c95170c4cb4730547817494977693c113 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeNormRate.lean @@ -0,0 +1,182 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeNormBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCellError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBadEventRate +import OAI.NumberTheory.Ostmann.Construction.OriginalHarmonicRate +import OAI.NumberTheory.Ostmann.ZeroDensity.BulkProgressionCutoff + +namespace OAI + +/-! # The original-prior norm estimate at the manuscript scales -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_original_two_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime base n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ‖∑ x : (TreeLeafIndex n × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternTwoPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U x‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨Cerr, hCerr, hCnorm, hcellRate⟩ := + P.movingPattern_cell_error_rate_window ψ n r₀ k A Wwin Bφ Dφ F (Cmass + 1) hA hWwin hF + obtain ⟨Tcell, _, hcellTwo⟩ := P.short_prime_cell_mass_two + have hlarge : ∀ᶠ L : ℝ in atTop, Tcell ≤ Real.exp ((39 / 10000 : ℝ) * L) := + (Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num))).eventually + (eventually_ge_atTop Tcell) + filter_upwards [hcellRate, movingPattern_bad_event_rate_window ψ n r₀ k + A Wwin Bφ Dφ F (Cmass + 1) hA hWwin hF, + P.original_harmonic_box_rate Cmass hCmass, hlarge, eventually_ge_atTop (2000 : ℝ)] + with L herror hbad hnormal hlarge hL + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + let freq := frozenBulkFrequencyPrime base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime base n m t + (fun b => movingPatternFiniteSmall e n (small b)) + (movingPatternFiniteSamples e n pattern) (twist i) perm + (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hZ (j) : Z j ≤ Real.exp (Cerr * L) := (hnorm j).2.1.trans + (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hCnorm (by linarith))) + have hunit : (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) := + bulkResidueModulus_unit_card hMQ (Nat.floor_le (Real.exp_nonneg _)) + have ha (z) : ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) := by + exact moving_frozen_prime_residue_coefficient_norm base (movingPatternBulkEmbedding e slot) outside + Fw Ew n m data childBound R r P Qfreq xg y hxg hy p sets hsets hsetsp + t _ _ twist perm (bulkResidueEquiv r p hc z).1 (bulkResidueEquiv r p hc z).2 + have he := herror lo hi hhi hwindow Cell M (bulkProgressionCutoff L) hQ.1 hQ.2 p Z a amp + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 hZ hcard hunit hamp0 hamp ha le_rfl u hulow + have hbd := hbad lo hi hhi hwindow p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hb := P.movingPattern_original_two_prime_norm_bound e tierB tierC t small slot perm pattern + hsmall hB htier base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r + hR hr p hc (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) twist (bulkProgressionCutoff L) Qfreq xg y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U + r₀ hsmallLen hxg hy hQ.1 hMQ u v hu huv hshort + (fun j c z => hcellTwo M z.val.val (u j c) (v j c) (hlarge.trans (hulow j c)) (hshort j c)) + c₀ hS (fun j => unitPrimeCells_separated M (u j) (v j) (hsep j)) deleted + (fun j => (hnorm j).1.ne') hdelbase hout hdelout (fun i => (p i : ℝ)) + (fun i => Nat.cast_nonneg _) (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) + A₀ hA₀ ((Cmass + 1) * L) (Real.exp ((39 / 10000 : ℝ) * L)) + hlocal (fun j => (hnorm j).2.2) (fun j => (hnorm j).2.1) + (fun j q hq => hlow j q (Finset.mem_sdiff.mp hq).1) + dsimp only at hb + have hh := add_le_add (le_refl + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m))) (add_le_add he hbd) + apply hb.trans + simpa only [add_assoc, W, amp, Z, a, spec, freq, data, M, S] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeObservable.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeObservable.lean new file mode 100644 index 0000000000000000000000000000000000000000..17c6b7e5d10ca21c030422142f4cab23542d4f84 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeObservable.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeBulk +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMean + +namespace OAI + +/-! # The literal prime observable in the original nonbulk Fubini formula -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (P : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (L U : ℝ) + +/-- The coefficient before selecting or conditioning any of its bulk +coordinates. All original frequency and coprimality gates are retained. -/ +noncomputable def movingPatternTwoPrimeObservable (x : Fin (N + 1) → primes) : ℂ := + let value := fun i => (x i : ℕ) + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes value + (fun i => (hprimes _ (x i).property).ne_zero) childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + movingRealKernelPair value data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPrimeAverage value outside F E data nodes R r P Q xg y * + ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (twist i) data) + +theorem movingPatternTwoPrimeObservable_join (base : Fin (N + 1) → primes) + (z : TreeLeafIndex n × Fin m → primes) : + movingPatternTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => base i)) = + movingPatternTwoPrimeBulkHaar e t small slot perm pattern (fun i => (base i : ℕ)) primes + hprimes (fun i _ => hprimes _ (base i).property) childBound pivotBound hfreq F E outside + R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U z := by + have hv : (fun i => (joinBulkNonbulk (A := primes) (movingPatternBulkEmbedding e slot) z + (fun j => base j) i : ℕ)) = + primeBulkValues (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) z := by + funext i + by_cases hi : i ∈ Set.range (movingPatternBulkEmbedding e slot) + · obtain ⟨j, rfl⟩ := hi + rw [joinBulkNonbulk_bulk, primeBulkValues_at] + · rw [joinBulkNonbulk_nonbulk (movingPatternBulkEmbedding e slot) z + (fun j => base j) ⟨i, hi⟩, primeBulkValues_off _ _ _ i hi] + let eval : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} → ℂ := fun v => + let data := movingPatternFinBulkData e n m t small slot perm pattern + let nodes := fun b => (data b).formulaNodes v.val v.property childBound pivotBound + (movingPatternFinBulkData_frequencies e t small slot perm pattern (· ≠ 0) hfreq b) + (.prime false) (.prime true) + movingRealKernelPair v.val data nodes ψ X lo hi hlo hhi φ G L U * + (movingFrequencyPrimeAverage v.val outside F E data nodes R r P Q xg y * + ∏ i, movingSpectatorPrimeAverage v.val (p i) (g i) (twist i) data) + let left : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} := + ⟨fun i => (joinBulkNonbulk (A := primes) (movingPatternBulkEmbedding e slot) z + (fun j => base j) i : ℕ), + fun i => (hprimes _ ((joinBulkNonbulk (A := primes) + (movingPatternBulkEmbedding e slot) z (fun j => base j)) i).property).ne_zero⟩ + let right : {v : Fin (N + 1) → ℕ // ∀ i, v i ≠ 0} := + ⟨primeBulkValues (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) z, + fun i => (primeBulkValues_prime (fun i => (base i : ℕ)) + (movingPatternBulkEmbedding e slot) z hprimes + (fun i _ => hprimes _ (base i).property) i).ne_zero⟩ + change eval left = eval right + exact congrArg eval (Subtype.ext hv) + +/-- This is exactly the selected-coordinate average used by the signed +pattern majorant, under the initial word law. -/ +theorem movingPatternBulkMean_twoPrimeObservable (base : Fin (N + 1) → primes) + (ν : B → primes → ℝ) (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (hν : ∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) : + movingPatternBulkMean e ν slot + (movingPatternTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U) base = + ∑ z : TreeLeafIndex n × Fin m → primes, + ((∏ j, primeSubsetPrior primes (initial j) (z j) : ℝ) : ℂ) * + movingPatternTwoPrimeBulkHaar e t small slot perm pattern (fun i => (base i : ℕ)) primes + hprimes (fun i _ => hprimes _ (base i).property) childBound pivotBound hfreq F E outside + R r p g twist P Q xg y ψ X lo hi hlo hhi φ G L U z := by + unfold movingPatternBulkMean + apply Finset.sum_congr rfl + intro z _ + rw [movingPatternTwoPrimeObservable_join] + simp only [hν] + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeObservableCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeObservableCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..fdcdf57eb18df0ef8c4d7d426ea88fcf438c5d16 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeObservableCost.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelGain + +namespace OAI + +/-! # The actual observable and its uniform pointwise arithmetic cost -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +section +variable {B C I : Type*} [Fintype I] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (hB : ∀ i, n ≤ tierB i) (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (F : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData (Fin (N + 1)) k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (P : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) + (j₀ : TreeLeafIndex n × Fin m) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ V) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφ : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hφout : ∀ x, 1 ≤ |x| → φ x = 0) (L U : ℝ) + +include hB htier hV hBφ hDφ hφ hlip hφout j₀ in +theorem movingPatternTwoPrimeObservable_norm + (hxg : 0 ≤ xg) (hy : 0 ≤ y) (Kspec : I → ℝ) (hKspec : ∀ i, 0 ≤ Kspec i) + (hgnorm : ∀ i z, ‖g i z‖ ≤ Kspec i) + (x : Fin (N + 1) → primes) : + let data := movingPatternFinBulkData e n m t small slot perm pattern + let amp := 4 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖) + let W := (movingFourierVariationBudget ψ V lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + ‖movingPatternTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q xg y + ψ X lo hi hlo hhi φ G L U x‖ ≤ (amp * ∏ i, Kspec i ^ (2 ^ (n + 1))) * W := by + dsimp only + let z := fun j => x (movingPatternBulkEmbedding e slot j) + have heq : joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i) = x := by + funext i + by_cases hi : i ∈ Set.range (movingPatternBulkEmbedding e slot) + · obtain ⟨j, rfl⟩ := hi + rw [joinBulkNonbulk_bulk] + · exact joinBulkNonbulk_nonbulk (movingPatternBulkEmbedding e slot) z + (fun i => x i) ⟨i, hi⟩ + have ho := movingPatternTwoPrimeObservable_join e t small slot perm pattern primes hprimes + childBound pivotBound hfreq F E outside R r p g twist P Q xg y + ψ X lo hi hlo hhi φ G L U x z + rw [heq] at ho + rw [ho] + exact movingPatternTwoPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + (fun i => (x i : ℕ)) primes hprimes (fun i _ => hprimes _ (x i).property) + childBound pivotBound hfreq F E outside R r p g twist P Q xg y j₀ ψ X lo hi V hlo hhi hV + φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U hxg hy Kspec hKspec hgnorm z + +end + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeOriginalNormArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeOriginalNormArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b75bd501d7b799333f8fa3e634bd8d560e7b421 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeOriginalNormArithmetic.lean @@ -0,0 +1,188 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeSelectedNormRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate + +namespace OAI + +/-! # The norm estimate with the original internal and external priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_two_prime_norm_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + 0 ≤ A₀ → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + let freq := frozenBulkFrequencyPrime (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) + outside Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime (fun i => (x i : ℕ)) n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + ∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern obs x * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot perm) pattern x‖ ≤ + ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + filter_upwards [P.movingPattern_selected_two_prime_norm_rate ψ n r₀ k + A Wwin Bφ Dφ F Cmass hA hWwin hF hCmass hBφ hDφ] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted initial + μ ν Eprior αall βint Vint Uall hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper + hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout + hA₀ hlocal c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e n m t small slot perm pattern + let obs := movingPatternTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U + let cost := (4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hpoint (x) : ‖obs x‖ ≤ cost := + movingPatternTwoPrimeObservable_norm e tierB tierC t small slot perm pattern hB htier + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq xg y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U + hxg hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hminor (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ‖movingPatternBulkMean e ν slot obs x‖ ≤ + (((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + exact hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern primes hprimes x + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq xg y X A₀ j₀ φ G XL U u v (deleted x) + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS (hdel x hx) hmass (hdelbase x hx) hout (hdelout x hx) + hA₀ (hlocal x hx) c₀ initial hsub (hretain x hx) ν hν + have hfinal := movingPrimePattern_signed_arithmetic_on_support e (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) tierB tierC t small + (movingPatternBulkLeaves n m slot perm) pattern rep + (fun b j _ => hB j) (fun b j _ => hB j) htier + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hUall + (movingPatternFinBulkData_size e t small slot perm pattern hsmallLen) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hV) + (fun q => by + simpa only [Int.cast_natCast, abs_of_nonneg (show (0 : ℝ) ≤ (q : ℕ) from Nat.cast_nonneg _)] + using hvalues q) + μ ν hμ0 hν0 hμmass hνmass Eprior αall βint Vint hEprior hαall hβint hVint + hμbound hμall hνall hμmax hμmin obs cost (by dsimp only [cost]; positivity) + hpoint hdisjoint hcross hfmod m slot perm rfl + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hminor + (fun _ => Classical.arbitrary primes) + simpa only [movingInternalArithmeticError, obs, cost, data, m] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeSameNormArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeSameNormArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..469f284152fab7ab27de2a764494723511384652 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeSameNormArithmetic.lean @@ -0,0 +1,197 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeOriginalNormArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNormalizedNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFrequencyModulus +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate + +namespace OAI + +/-! # The norm estimate with the original internal and external priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_same_assignment_two_prime_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (Sfreq : Finset ℤ) (ft : FrequencyTree (Sfreq × Sfreq) n) (Nfreq Vleaf : ℕ) (D : ℝ) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (pattern : Bool × MovingSampleIndex n → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (outside : List ℕ) [NeZero ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2))] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i).Coprime (bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p j))) + [NeZero (∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex n × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex n × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + let M := ∏ i, bulkResidueModuli ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) ((fun _ _ _ _ _ => 1) false) (data false)‖ * + ‖movingDataWeight (Fw true) ((fun _ _ _ _ _ => 1) true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternTwoPrimeObservable e t small slot (Equiv.refl _) pattern primes hprimes + childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside ((frequencyModelBase Sfreq n ft) : ℤ) ((frequencyModelBase Sfreq n ft) ^ (n - 1 + 2)) p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b ft)) → + (∀ s ∈ Sfreq, s ≠ 0) → (∀ s ∈ Sfreq, s.natAbs ≤ Nfreq) → + (∀ b s regular, ‖Fw b (.leaf s regular) s‖ ≤ if s.natAbs ≤ Vleaf then 1 else 0) → + 0 ≤ D → (∀ q : ℕ, q ≠ 0 → q ≤ Nfreq ^ 2 → (q.divisors.card : ℝ) ≤ D) → + 0 < m → (∀ i, 3 ≤ p i) → (∀ i b, movingGiantFrequencyUnits (p i) n (t b)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → IsCoprime ((x i : ℕ) : ℤ) ((frequencyModelBase Sfreq n ft) : ℤ)) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i b j, + j ∈ flattenMovingSlots n (small b) → ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → ∀ i c, + ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern obs x * + movingPatternPrimeHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t small (movingPatternBulkLeaves n m slot (Equiv.refl _)) pattern x‖ ≤ + ((4 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * n * 2 ^ n - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError n (Fintype.card Cidx) + (2 ^ n * (r₀ + m + 4 * n + 4)) (Real.exp (A * m)) Uall αall βint Vint + + ((((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m)) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + filter_upwards [P.movingPattern_original_two_prime_norm_arithmetic_rate ψ n r₀ k + A Wwin Bφ Dφ 2 Cmass hA hWwin (by norm_num) hCmass hBφ hDφ] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx _ _ Cell _ N e tierB tierC t Sfreq ft Nfreq Vleaf D small slot pattern rep + primes hprimes _ childBound pivotBound hfreq Fw outside _ p _ hc _ twist sets + Qfreq xg y X j₀ φ G XL U u v deleted initial μ ν Eprior αall βint Vint Uall + hsmall hB htier hsmallLen ht hS hN hleaf hD hdiv hm hp hfreqp hbase + hsmallp hsamplesp hV hsets hsetsp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hSS hdel hmass hdelbase hout hdelout + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let R := frequencyModelBase Sfreq n ft + have hR (b : Bool) : (movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern b).frequencyProduct ∣ (R : ℤ) := by + simpa only [ht, R] using movingPattern_frequencyProduct_dvd e Sfreq ft small slot (Equiv.refl _) pattern b + have hroots (b : Bool) (j : Fin (2 ^ n - 1)) : + (singleTreeNodeFrequencies Sfreq n (frequencyPairProjection Sfreq n b ft) j.val).root.natAbs ∣ R := + frequencyModelBase_roots Sfreq n ft b j + let data := movingPatternFinBulkData e n m t small slot (Equiv.refl _) pattern + have hone (b : Bool) : ‖movingDataWeight (Fw b) (fun _ _ _ _ => 1) (data b)‖ ≤ 1 := + movingDataWeight_unit_norm_le_one (Fw b) (fun s regular => + (hleaf b s regular).trans (by split_ifs <;> norm_num)) (data b) + have hamp : 4 * (‖movingDataWeight (Fw false) (fun _ _ _ _ => 1) (data false)‖ * + ‖movingDataWeight (Fw true) (fun _ _ _ _ => 1) (data true)‖) ≤ Real.exp ((2 : ℝ) * m) := by + have hpair := mul_le_mul (hone false) (hone true) (norm_nonneg _) (by norm_num : (0 : ℝ) ≤ 1) + have hmR : (1 : ℝ) ≤ m := by exact_mod_cast hm + have he : (2 : ℝ) ≤ Real.exp (m : ℝ) := by linarith [Real.add_one_le_exp (m : ℝ)] + calc + _ ≤ 4 := by linarith + _ ≤ (Real.exp (m : ℝ)) ^ 2 := by nlinarith [Real.exp_pos (m : ℝ)] + _ = _ := by simpa only [Nat.cast_ofNat] using (Real.exp_nat_mul (m : ℝ) 2).symm + let A₀ := ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq Vleaf) n ft * + ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod) + have hA₀ : 0 ≤ A₀ := by + have hleaf0 := frequencyLeafWeight_nonneg (pairedFrequencyLeaf Sfreq Vleaf) + (fun _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num) n ft + have hprod : 0 ≤ ((frequencySplitList Sfreq n ft).map (pairFrequencySupportBound D)).prod := by + apply List.prod_nonneg + intro x hx + obtain ⟨f, _, rfl⟩ := List.mem_map.mp hx + exact pairFrequencySupportBound_nonneg D f + exact mul_nonneg (by positivity) (mul_nonneg hleaf0 hprod) + have hlocal (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) + (z : (TreeLeafIndex n × Fin m) → ℝ) (hz : ∀ j, 0 ≤ z j) := + movingPattern_normalized_same_assignment_prime_norm e tierB tierC Sfreq ft R Nfreq Vleaf + hS hN hroots small slot pattern hsmall hB htier (fun i => (x i : ℕ)) (hbase x hx) + Fw hleaf D hD hdiv hm p hc hp + (by simpa only [ht] using hfreqp) (hsmallp x hx) (hsamplesp x hx) + sets hsets hsetsp twist outside childBound P Qfreq (bulkProgressionCutoff L) xg y hxg hy z hz + have h := hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot (Equiv.refl _) pattern rep + primes hprimes childBound pivotBound hfreq Fw (fun _ _ _ _ _ => 1) outside (R : ℤ) + (R ^ (n - 1 + 2)) p hc twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted initial μ ν + Eprior αall βint Vint Uall hsmall hB htier hsmallLen hR (frequencyModelModulus_precision R n) + hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout hcard hu hulow huv hshort hsep hMcell + hSS hdel hmass hdelbase hout hdelout hA₀ + (by + intro x hx + dsimp only + intro z hz + have hz' := hlocal x hx z hz + simpa only [A₀, m, ht, finite_univ_canonical, Fintype.card_eq_nat_card, Nat.card_fin] using hz') + c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + exact h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeSelectedNormRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeSelectedNormRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ee91c2e51684366b010f2392c4042e5fe79ed65 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternTwoPrimeSelectedNormRate.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeInitialNormRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTwoPrimeObservable + +namespace OAI + +/-! # Norm estimate for the original selected-coordinate mean -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- Uniform prime-cell comparison for the actual arithmetic absolute mean. +The sharp Fourier window factor is retained in the main term. The published +progression input controls the cell, collision and deletion errors. -/ +theorem PublishedProgressionInput.movingPattern_selected_two_prime_norm_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A Wwin Bφ Dφ F Cmass : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), + hi - lo ≤ Real.exp (Wwin * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List Bidx) n) + (slot : (TreeLeafIndex n × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → Cidx) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (base : Fin (N + 1) → primes) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (Qfreq : ℕ) (xg y X A₀ : ℝ) (_j₀ : TreeLeafIndex n × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex n × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex n × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e n m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 4 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let freq := frozenBulkFrequencyPrime (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq xg y + let spec := fun i => frozenBulkSpectatorPrime (fun i => (base i : ℕ)) n m t + (fun b => movingPatternFiniteSmall e n (small b)) (movingPatternFiniteSamples e n pattern) + (twist i) perm (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p _hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p _hc z).2 i) + (∀ b, ∀ i ∈ flattenMovingSlots n (small b), i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + amp ≤ Real.exp (F * m) → 0 ≤ xg → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (base i : ℕ) ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + 0 ≤ A₀ → + (∀ z : (TreeLeafIndex n × Fin m) → ℝ, (∀ j, 0 ≤ z j) → + (Fintype.card ((TreeLeafIndex n × Fin m) → (ZMod M)ˣ) : ℝ)⁻¹ * + ∑ w, ‖a w * ∏ j, pageGiantWeight P (bulkProgressionCutoff L) M + (w j).val.val (z j)‖ ≤ A₀) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex n × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ∀ ν : Bidx → primes → ℝ, + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + ‖movingPatternBulkMean e ν slot + (movingPatternTwoPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + xg y ψ X lo hi hlo hhi φ G XL U) base‖ ≤ + ((((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt lo) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * A₀) * 2 ^ Fintype.card (TreeLeafIndex n × Fin m) + + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + filter_upwards [P.movingPattern_initial_two_prime_norm_rate ψ n r₀ k A Wwin Bφ Dφ F Cmass + hA hWwin hF hCmass hBφ hDφ] with L hrate + dsimp only + intro lo hi hlo hhi hwindow Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern primes hprimes base + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain ν hν + rw [movingPatternBulkMean_twoPrimeObservable] + · exact hrate lo hi hlo hhi hwindow Bidx Cidx Cell N e tierB tierC t small slot perm pattern + (fun i => (base i : ℕ)) primes hprimes (fun i _ => hprimes _ (base i).property) + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets Qfreq xg y X A₀ j₀ φ G XL U u v deleted + hsmall hB htier hsmallLen hR hr hV hsets hsetsp hamp hxg hy hpupper hMQ hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout hA₀ hlocal c₀ + initial hsub hretain + · exact hν + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternUniformBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternUniformBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..a58430ce0a7a0e7f64cd618ce28f0806fe3a50e1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternUniformBudget.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePatternBudget + +namespace OAI + +/-! # Uniform costs of the actual internal equality patterns -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_class_card_le {C : Type*} [Fintype C] (n : ℕ) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) : + Fintype.card C ≤ 4 * n * 2 ^ n := by + have hinj : Function.Injective (fun c => (rep c).val) := by + intro c d h + have hh := congrArg pattern h + simpa only [(rep c).property, (rep d).property] using hh + simpa only [card_movingSamplePairIndex] using Fintype.card_le_of_injective _ hinj + +/-- The representative-prior loss is bounded independently of how the +internal slots coincide. -/ +theorem movingPattern_loss_le (n r : ℕ) (hr : r ≤ 4 * n * 2 ^ n) + (E : ℝ) (hE : 0 ≤ E) : + (2 : ℝ) ^ r * E ^ (4 * n * 2 ^ n - r) ≤ + (max 2 E) ^ (4 * n * 2 ^ n) := by + have hK : 0 ≤ max (2 : ℝ) E := (by norm_num : (0 : ℝ) ≤ 2).trans (le_max_left _ _) + calc + _ ≤ (max 2 E) ^ r * (max 2 E) ^ (4 * n * 2 ^ n - r) := + mul_le_mul (pow_le_pow_left₀ (by norm_num) (le_max_left _ _) r) + (pow_le_pow_left₀ hE (le_max_right _ _) _) (by positivity) (pow_nonneg hK _) + _ = _ := by rw [← pow_add, Nat.add_sub_of_le hr] + +theorem movingPattern_quotient_card_le (n : ℕ) + (s : Setoid (Bool × MovingSampleIndex n)) : + Fintype.card (Quotient s) ≤ 4 * n * 2 ^ n := by + have h := Fintype.card_le_of_surjective + (Quotient.mk'' : Bool × MovingSampleIndex n → Quotient s) Quotient.mk''_surjective + simpa only [card_movingSamplePairIndex] using h + +/-- Summing every original equality pattern introduces only a depth-dependent +factor. The number of protected bulk slots never appears in this cost. -/ +theorem movingPattern_error_sum_le (n : ℕ) (E D : ℝ) (hE : 0 ≤ E) (hD : 0 ≤ D) : + letI := sampleSetoidFintype (Bool × MovingSampleIndex n) + ∀ R : Setoid (Bool × MovingSampleIndex n) → ℂ, + (∀ s, ‖R s‖ ≤ D * ((2 : ℝ) ^ Fintype.card (Quotient s) * + E ^ (4 * n * 2 ^ n - Fintype.card (Quotient s)))) → + ‖∑ s, R s‖ ≤ (2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) * + (D * (max 2 E) ^ (4 * n * 2 ^ n)) := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + intro R hR + have hp := movingSamplePair_pattern_count n + dsimp only at hp + have hcard : (Fintype.card (Setoid (Bool × MovingSampleIndex n)) : ℝ) ≤ + (2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) := by exact_mod_cast hp + calc + ‖∑ s, R s‖ ≤ ∑ s, ‖R s‖ := norm_sum_le _ _ + _ ≤ ∑ _s : Setoid (Bool × MovingSampleIndex n), D * (max 2 E) ^ (4 * n * 2 ^ n) := by + apply Finset.sum_le_sum + intro s _ + exact (hR s).trans (mul_le_mul_of_nonneg_left + (movingPattern_loss_le n _ (movingPattern_quotient_card_le n s) E hE) hD) + _ = (Fintype.card (Setoid (Bool × MovingSampleIndex n)) : ℝ) * + (D * (max 2 E) ^ (4 * n * 2 ^ n)) := by + rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right hcard (by positivity) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWeightedMatchedNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWeightedMatchedNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..68a00998e46fd219e76dec790095f927ad1d1ac4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWeightedMatchedNorm.lean @@ -0,0 +1,212 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMatchedObservable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMatchedHaarComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCoefficientMass +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternRegularSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalOuterWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularCollisionSupport + +namespace OAI + +/-! # The original signed matched-history sum and its arithmetic integral -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_weighted_original_matched_norm + (input : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (Afreq Wwin Bφ Dφ : ℝ) (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B C J : Type) [Fintype B] [Fintype C] [Fintype J] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (_rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] (_hinjp : Function.Injective p) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (reg : J → Fin (N + 1)) (active : J → Bool) (sreg : ℤ) + (other : (Fin (N + 1) → primes) → J → ℤ) (greg : ∀ q : ℕ, ZMod q → ℂ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (R : ℤ) (r : ℕ) [NeZero r] (V : ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) (diagonal : Bool) + (E U u v a b center : ℝ) + (wgt : (Fin (N + 1) → primes) → ℂ), + (∀ x, ‖wgt x‖ ≤ 1) → + let : ∀ q : primes, Fact (q : ℕ).Prime := fun q => ⟨hprimes _ q.property⟩ + let T := movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern + let coeff := movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun _ => 1) + let Pi := fun x => movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x + let M := fun x => ∏ z, movingArithmeticModuli r p (Pi x) Finset.univ z + let Reg := fun x => MovingSlotReversal.naturalProduct (fun i => (x i : ℕ)) + (movingPatternRegularSlots e n m small slot) + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ E → 0 ≤ U → (∀ j (q : primes), (q : ℝ) * μ j q ≤ E) → + (∀ q : primes, (q : ℝ) ≤ U) → + (∀ b, n ≤ tierB b) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ V) → + (∀ s, ‖f s‖ ≤ 1) → (∀ i, g i 0 = 0) → (∀ i z, ‖g i z‖ ≤ (p i : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + (∀ b, (T b).frequencyProduct ∣ R) → R ^ (n + 1) ∣ (r : ℤ) → + (∀ i, r.Coprime (p i)) → (∀ i, V < p i) → + (V : ℝ) ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ z, |φ z| ≤ Bφ) → (∀ z w, |φ z - φ w| ≤ Dφ * |z - w|) → + (∀ z, 1 ≤ |z| → φ z = 0) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → u ≤ v → v ≤ u + 1 → v ≤ center + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ a → a ≤ b → b ≤ a + 1 → + (∀ x, Reg x = ∏ j, (x (reg j) : ℕ)) → + (∀ x, coeff x ≠ 0 → + (∀ b, movingRegularOutsidePairwise (fun i => (x i : ℕ)) outside (T b)) → + (∀ i j, (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) ∧ + (∀ i, V < (x i : ℕ)) ∧ + (∀ i, IsCoprime ((x i : ℕ) : ℤ) R) ∧ + (∀ i, r.Coprime (x i : ℕ)) ∧ + (∀ i j, ((x j : ℕ) : ZMod (p i)) ≠ 0) ∧ + (Reg x).Coprime (M x) ∧ Reg x * M x ≤ giantProgressionCutoff L ∧ + pageAtModulus (Reg x * M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) ∧ + pageAtModulus (M x) (selectedPageZero input (giantProgressionCutoff L)) = + pageAtModulus r (selectedPageZero input (giantProgressionCutoff L)) ∧ + Pairwise (fun i j => (x (reg i) : ℕ).Coprime (x (reg j) : ℕ)) ∧ + (∀ i, (sreg : ZMod (x (reg i) : ℕ)) ≠ 0) ∧ + (∀ i, (other x i : ZMod (x (reg i) : ℕ)) ≠ 0) ∧ + (∀ i, greg (x (reg i) : ℕ) 0 = 0) ∧ + (∀ i, (∑ z : ZMod (x (reg i) : ℕ), ‖greg (x (reg i) : ℕ) z‖ ^ 2) = (x (reg i) : ℕ))) → + let actual := movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p g Dq reg active sreg other greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center + let integral := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * + movingPatternPrimeObservable e t (fun _ => small) slot perm pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x) * + (Real.exp (z - center) : ℂ) / (y : ℂ) + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun x => wgt x * actual x) x‖ ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun x => wgt x * integral x) x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t (fun _ => small) (movingPatternBulkLeaves n m slot perm) pattern x‖ := by + filter_upwards [input.moving_pattern_matched_haar_rate ψ n r₀ k Afreq Wwin Bφ Dφ + hAfreq hWwin hBφ hDφ] with L hL + dsimp only + intro B C J _ _ _ N e tierB tierC t small slot perm pattern rep primes hprimes μ ν + p _ hinjp g Dq reg active sreg other greg f outside childBound pivotBound R r _ V hfreq + X lo hi hlo hhi φ G Jleft Jright diagonal E U u v a b center wgt hwgt + hμ hν hμmass hνmass hE hU hbound hsize hB htier hV hf hg hgnorm hout hR + hprecision hrp hspecLarge hVA hwindow hpupper hφ hlip hφout hcenter huv hv hvcenter + ha hab hb hRegEq hdata + let m := spectatorBulkCount k L + let T := movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern + let Pi := fun x => movingPatternInternalPrimes e (fun q : primes => (q : ℕ)) x + let haar := movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t (fun _ => small) (movingPatternBulkLeaves n m slot perm) pattern + let actual := movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p g Dq reg active sreg other greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center + let integral := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * + movingPatternPrimeObservable e t (fun _ => small) slot perm pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x) * + (Real.exp (z - center) : ℂ) / (y : ℂ) + let ε := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) + have hcompare (x : Fin (N + 1) → primes) + (hx : movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun _ => 1) x ≠ 0) : + ‖actual x - integral x * haar x‖ ≤ ε := by + by_cases hgood : ∀ b, movingRegularOutsidePairwise (fun i => (x i : ℕ)) outside (T b) + · + obtain ⟨hdisjoint, hlarge, hsmallR, hrcop, hres, hcop, hfull, hpageReg, hpage, + hreg, hsreg, hother, hgreg, henergy⟩ := hdata x hx hgood + have hprime (i) : (x i : ℕ).Prime := hprimes _ (x i).property + let : ∀ j, Fact (x (reg j) : ℕ).Prime := fun j => ⟨hprime _⟩ + have hPi := movingPatternInternalPrimes_prime e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) x + let : ∀ q : Pi x, Fact q.val.Prime := fun q => ⟨hPi _ q.property⟩ + have hnz (z) : movingArithmeticModuli r p (Pi x) Finset.univ z ≠ 0 := + movingArithmeticModuli_ne_zero r p (Pi x) Finset.univ (NeZero.ne r) hPi + (fun i _ => (Fact.out : (p i).Prime)) z + let : ∀ z, NeZero (movingArithmeticModuli r p (Pi x) Finset.univ z) := fun z => ⟨hnz z⟩ + let : NeZero (∏ z, movingArithmeticModuli r p (Pi x) Finset.univ z) := + ⟨Finset.prod_ne_zero_iff.mpr (fun z _ => hnz z)⟩ + have hsep (i : Fin m) (j : Fin (N + 1)) : (x j : ℕ) ≠ p i := by + intro heq + apply hres i j + rw [heq] + exact ZMod.natCast_self (p i) + have hc := movingPattern_prime_moduli_coprime e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) x r p (fun i => (Fact.out : (p i).Prime)) + hinjp hrcop hrp hsep + have hinj := movingPattern_nonzero_internal_injective e μ ν (fun q : primes => (q : ℕ)) + Subtype.val_injective pattern (fun _ => 1) x hx + have hqs (i : Fin m) : (∏ j, (x (reg j) : ℕ)).Coprime (p i) := by + apply Nat.coprime_prod_left_iff.mpr + intro j _ + exact (Nat.coprime_primes (hprime _) (Fact.out : (p i).Prime)).mpr (hsep i _) + have hh := hL B C J N e tierB tierC t small slot perm pattern primes hprimes x p g Dq + (fun j => (x (reg j) : ℕ)) active sreg (fun j => (other x j : ZMod (x (reg j) : ℕ))) + (fun j => greg (x (reg j) : ℕ)) f outside childBound pivotBound R r (Pi x) hfreq V + X lo hi hlo hhi φ G Jleft Jright diagonal hB htier hdisjoint hV hlarge hf hg hgnorm + hout hR hprecision hsmallR hres hspecLarge rfl hinj hc (hRegEq x) hcop hfull hpageReg hpage + hgood hreg hqs hsreg hother hgreg henergy hVA hwindow hpupper hφ hlip hφout + u v a b center hcenter huv hv hvcenter ha hab hb + exact hh + · have ha0 (XL XR : ℕ) : movingOriginalSupportedOuterPair p (fun i => (x i : ℕ)) outside + childBound pivotBound (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) g + (fun _ => Dq) Finset.univ ψ X lo hi φ G Jleft Jright diagonal T t XL XR = 0 := + movingOriginalSupportedOuterPair_zero_of_not_regular p _ outside childBound pivotBound + _ _ g _ Finset.univ ψ X lo hi φ G Jleft Jright diagonal T t hgood XL XR + have hraw (z y : ℝ) : movingPatternPrimeObservable e t (fun _ => small) slot perm + pattern primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x = 0 := by + change _ * (movingFrequencyPageAverage (fun i => (x i : ℕ)) outside + (fun _ {_} _ => f) (fun _ {_} _ _ _ _ => 1) T _ R r input + (giantProgressionCutoff L) y * _) = 0 + rw [movingFrequencyPageAverage_zero_of_not_regular _ outside _ _ T _ R r input + (giantProgressionCutoff L) y hgood, zero_mul, mul_zero] + dsimp only [T, m] at ha0 + have hactual : actual x = 0 := by + simp only [actual, movingOriginalPatternMatchedObservable, ha0, zero_mul, + complexIntegerInterval, complexPrimeInterval, ite_self, Finset.sum_const_zero] + have hideal : integral x = 0 := by + simp only [integral, hraw, mul_zero, zero_mul, zero_div, integral_zero] + rw [hactual, hideal, zero_mul, sub_self, norm_zero] + dsimp only [ε] + positivity + have hcompareW (x : Fin (N + 1) → primes) + (hx : movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun _ => 1) x ≠ 0) : + ‖wgt x * actual x - wgt x * (integral x * haar x)‖ ≤ ε := by + rw [← mul_sub, norm_mul] + exact (mul_le_mul_of_nonneg_right (hwgt x) (norm_nonneg _)).trans + (by simpa only [one_mul] using hcompare x hx) + have hbnd := movingPattern_comparison_norm e μ ν (fun q : primes => (q : ℕ)) pattern rep + E U ε hE hU (by dsimp only [ε]; positivity) (fun q => hprimes _ q.property) + hμ hν hμmass hνmass hbound hsize (fun x => wgt x * actual x) (fun x => wgt x * (integral x * haar x)) hcompareW + have he : (∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern + (fun x => wgt x * (integral x * haar x)) x) = + ∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun x => wgt x * integral x) x * haar x := by + apply Finset.sum_congr rfl + intro x _ + conv_lhs => rw [movingOriginalPatternWeight_eq_coefficient_mul] + conv_rhs => rw [movingOriginalPatternWeight_eq_coefficient_mul] + ring + simpa only [he] using hbnd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWeightedMatchedRanges.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWeightedMatchedRanges.lean new file mode 100644 index 0000000000000000000000000000000000000000..a6a74165a611f702a2816dcf0e6604985edf41bc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWeightedMatchedRanges.lean @@ -0,0 +1,144 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWeightedMatchedNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMatchedConditions + +namespace OAI + +/-! # The original signed matched-history bound from actual prime ranges and conductor deletion -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_weighted_matched_prime_ranges + (input : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (Afreq Wwin Bφ Dφ : ℝ) (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B C : Type) [Fintype B] [Fintype C] (N : ℕ) + (e : Fin (N + 1) ≃ B ⊕ C) (tierB : B → ℕ) (tierC : C → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (pattern : Bool × MovingSampleIndex n → C) + (_rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] (_hinjp : Function.Injective p) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (active : Fin (movingPatternRegularSlots e n m small slot).length → Bool) + (sreg : ℤ) (sets : ∀ q : ℕ, Finset (ZMod q)) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (S : Finset ℤ) (ft : FrequencyTree (S × S) n) + [NeZero (frequencyModelBase S n ft ^ (n - 1 + 2))] (V : ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList n (t b), s ≠ 0) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) (diagonal : Bool) + (E U u v a b center : ℝ) + (wgt : (Fin (N + 1) → primes) → ℂ), + let reg := (movingPatternRegularSlots e n m small slot).get + let other := fun (x : Fin (N + 1) → primes) => + movingRegularOther (fun i => (x i : ℕ)) outside (movingPatternRegularSlots e n m small slot) + let greg := normalizedResidueFamily sets + let R : ℤ := frequencyModelBase S n ft + let r := frequencyModelBase S n ft ^ (n - 1 + 2) + (∀ x, ‖wgt x‖ ≤ 1) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ E → 0 ≤ U → (∀ j (q : primes), (q : ℝ) * μ j q ≤ E) → + (∀ q : primes, (q : ℝ) ≤ U) → + (∀ b, n ≤ tierB b) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, ∀ s ∈ allFrequencyList n (t b), s.natAbs ≤ V) → + (∀ s, ‖f s‖ ≤ 1) → (∀ i, g i 0 = 0) → (∀ i z, ‖g i z‖ ≤ (p i : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → + (V : ℝ) ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ z, |φ z| ≤ Bφ) → (∀ z w, |φ z - φ w| ≤ Dφ * |z - w|) → + (∀ z, 1 ≤ |z| → φ z = 0) → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → u ≤ v → v ≤ u + 1 → v ≤ center + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ a → a ≤ b → b ≤ a + 1 → + t = (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection S n b ft)) → + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) → + ∀ (tier : primes → ℕ) (lower cutoff : ℕ), + V ≤ lower → V < cutoff → cutoff ≤ lower → + (∀ j, j < n → ∀ q, μ j q ≠ 0 → tier q = j) → + (∀ j q, ν j q ≠ 0 → tier q = tierB j) → + (∀ j q, μ j q ≠ 0 → lower < (q : ℕ)) → + (∀ j q, ν j q ≠ 0 → lower < (q : ℕ)) → + (∀ q : primes, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ lower) → + MovingLeafLengthLE n small r₀ → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, μ j a ≠ 0 → (a : ℕ) ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero input (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → + ∀ j a, ν j a ≠ 0 → (a : ℕ) ≠ q) → + sreg ≠ 0 → sreg.natAbs ≤ V → + (∀ q, q.Prime → (sets q).Nonempty ∧ (sets q).card < q) → + let actual := movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes + p g Dq reg active sreg other greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center + let integral := fun x => ∫ z in Set.Ioc u v, ∫ y in Set.Ioc a b, + ((giantOuterWeight φ Jleft Jright diagonal (Real.exp z) (Real.exp y) * + (inactiveRegularDensity (fun q : primes => (q : ℕ)) reg active x : ℂ)) * + movingPatternPrimeObservable e t (fun _ => small) slot perm pattern + primes hprimes childBound pivotBound hfreq (fun _ {_} _ => f) + (fun _ {_} _ _ _ _ => 1) outside R r p g (fun i _ => Dq i) input + (giantProgressionCutoff L) y ψ X lo hi hlo hhi φ G (Real.exp z) (Real.exp y) x) * + (Real.exp (z - center) : ℂ) / (y : ℂ) + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun x => wgt x * actual x) x‖ ≤ + (((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * U ^ Fintype.card C) * + (Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L))) + + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) n pattern (fun x => wgt x * integral x) x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + n t (fun _ => small) (movingPatternBulkLeaves n m slot perm) pattern x‖ := by + filter_upwards [input.movingPattern_weighted_original_matched_norm ψ n r₀ k Afreq Wwin Bφ Dφ + hAfreq hWwin hBφ hDφ, movingPattern_matched_conditions input n r₀ k Afreq hAfreq] + with L hnorm hconditions + dsimp only + intro B C _ _ N e tierB tierC t small slot perm pattern rep primes hprimes μ ν p _ hinjp + g Dq active sreg sets f outside childBound pivotBound S ft _ V hfreq + X lo hi hlo hhi φ G Jleft Jright diagonal E U u v a b center wgt + hwgt hμ hν hμmass hνmass hE hU hbound hsize hB htier hV hf hg hgnorm hout + hVA hwindow hpupper hφ hlip hφout hcenter huv hv hvcenter ha hab hb + ht hS tier lower cutoff hVlo hVcut hcutlo hμtier hνtier hμlo hνlo hupper + hp hsmall hdeleteμ hdeletep hdeleteν hsreg hsregV hsets + let m := spectatorBulkCount k L + let R := frequencyModelBase S n ft + let r := R ^ (n - 1 + 2) + let slots := movingPatternRegularSlots e n m small slot + let reg := slots.get + let other := fun (x : Fin (N + 1) → primes) => movingRegularOther (fun i => (x i : ℕ)) outside slots + have hR (b : Bool) : + (movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern b).frequencyProduct ∣ + (R : ℤ) := by + simpa only [ht, R] using + movingPattern_frequencyProduct_dvd e S ft (fun _ => small) slot perm pattern b + have hrp (i) : r.Coprime (p i) := by + exact ((prime_coprime_frequencyModelBase S V (p i) n Fact.out + (hVcut.trans_le (hp i).1) hS ft).pow_right _).symm + apply hnorm B C (Fin slots.length) N e tierB tierC t small slot perm pattern rep primes hprimes μ ν + p hinjp g Dq reg active sreg other (normalizedResidueFamily sets) f outside + childBound pivotBound (R : ℤ) r V hfreq X lo hi hlo hhi φ G Jleft Jright diagonal + E U u v a b center wgt hwgt hμ hν hμmass hνmass hE hU hbound hsize hB htier hV hf hg hgnorm hout + hR (frequencyModelModulus_precision R n) hrp (fun i => hVcut.trans_le (hp i).1) + hVA hwindow hpupper hφ hlip hφout hcenter huv hv hvcenter ha hab hb + · intro x + exact naturalProduct_eq_finprod (fun i => (x i : ℕ)) slots + · intro x hx hgood + have hh := hconditions primes B C N e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) tier tierB μ ν pattern rep S V ft small slot perm p lower cutoff E + sreg sets Subtype.val_injective hμ hν hbound hμtier hνtier hB hS hVA hVlo hVcut hcutlo + hμlo hνlo hupper (fun i => ⟨Fact.out, (hp i).1, (hp i).2, hpupper i⟩) hsmall + hdeleteμ hdeletep hdeleteν hsreg hsregV hsets x hx outside + have hteq : tierC = fun c => movingSampleTier (rep c).val.2 := by + funext c + have hh := htier (rep c).val + simpa only [(rep c).property] using hh + simpa only [← ht, ← hteq] using hh (by simpa only [← ht] using hgood) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWholeShellArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWholeShellArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e4c9e8b4c1583f90c4d7a3a6ff02d555ed3e482 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWholeShellArithmetic.lean @@ -0,0 +1,211 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternOriginalArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.WholeShellGeometry +import OAI.NumberTheory.Ostmann.Construction.WholeShellMass +import OAI.NumberTheory.Ostmann.Construction.FrozenPrimeDeletions + +namespace OAI + +/-! # The arithmetic estimate for the original full bulk shell -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_whole_shell_arithmetic_rate + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (global : Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, ν (slot j) = primeSubsetPrior primes (S \ global)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_original_arithmetic_rate ψ n r₀ k A lo hi Bφ Dφ F Cmass gain + hA hlo hhi hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + have hlarge := (Real.tendsto_exp_atTop.comp + (tendsto_id.const_mul_atTop (by norm_num : (0 : ℝ) < 4 / 1000))).eventually + (eventually_ge_atTop (2 * (Real.log 2 + 2 * C))) + filter_upwards [hrate, wholePrimeGridCount_eventual (6 / 1000) (by norm_num), + hlarge, eventually_ge_atTop (max 0 (max (Real.log 4) (500 * Real.log 2)))] + with L hrate hgrid hlarge hL + have hL0 : 0 ≤ L := (le_max_left _ _).trans hL + have hL4 : Real.log 4 ≤ L := (le_max_left _ _).trans ((le_max_right _ _).trans hL) + have hL2 : 500 * Real.log 2 ≤ L := (le_max_right _ _).trans ((le_max_right _ _).trans hL) + dsimp only + intro Bidx Cidx _ _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β y X j₀ φ G U global + μ ν Eprior αall βint Vint Uall hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hS hdel hout hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let a : ℝ := (4 / 1000) * L + let b : ℝ := (6 / 1000) * L + let u := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellLower a b + let v := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellUpper a b + let M := ∏ i, bulkResidueModuli r p i + let S := primeLogCellSet 1 0 (Real.exp a) (Real.exp b) + let D := fun x : Fin (N + 1) → primes => global ∪ + frozenPrimeDeletions (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside + have hab : a ≤ b := by dsimp only [a, b]; nlinarith + have hgeometry := whole_shell_geometry a b hab + have ha0 : 0 ≤ a := mul_nonneg (by norm_num) hL0 + have hlow (j) (c) : Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c := by + exact (Real.exp_le_exp.mpr (by dsimp only [a]; nlinarith)).trans (hgeometry.1 c) + have hMbase : (M : ℝ) ≤ Real.exp (Real.exp a) := + modulus_le_exp_bulk_endpoint hMQ hL0 + (Real.exp_le_exp.mpr (by dsimp only [a]; nlinarith)) + have hsupport (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) = S := + whole_shell_support M a b hab hMbase + have hunit (j) (c) : 1 ≤ u j c := + (Real.one_le_exp_iff.mpr ha0).trans (hgeometry.1 c) + have hMcell (j) (c) : (M : ℝ) ≤ Real.exp (u j c) := + hMbase.trans (Real.exp_le_exp.mpr (hgeometry.1 c)) + have hcard : (Fintype.card (Fin (wholePrimeGridCount b)) : ℝ) ≤ + Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) := by + simpa only [Fintype.card_fin] using hgrid b (le_refl _) + have htwo : 2 * Real.exp a ≤ Real.exp b := by + have he : Real.log 2 + a ≤ b := by dsimp only [a, b]; nlinarith + have hh := Real.exp_le_exp.mpr he + simpa only [Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 2)] using hh + have hmass : Real.exp (-Cmass * L) ≤ ∑ q ∈ S, (q : ℝ)⁻¹ := by + have he : Real.exp (-Cmass * L) ≤ (1 / 4 : ℝ) := by + calc + _ ≤ Real.exp (-Real.log 4) := Real.exp_le_exp.mpr (by nlinarith) + _ = _ := by rw [Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 4)]; norm_num + exact he.trans (whole_shell_mass_lower hM (Real.exp a) (Real.exp b) + (Real.one_le_exp_iff.mpr ha0) hlarge htwo) + have hDcard (x) : ((D x).card : ℝ) ≤ Real.exp (Cmass * L) := by + have hh : (D x).card ≤ global.card + (N + 1) + outside.length := by + have ht := (Finset.card_union_le global _).trans + (Nat.add_le_add_left (frozenPrimeDeletions_card_le + (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside) global.card) + simpa only [Fintype.card_fin, Nat.add_assoc] using ht + exact (Nat.cast_le.mpr hh).trans hdel + have hsub (j) : S \ global ⊆ primeCellSupport M + (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) := by + rw [hsupport j]; exact Finset.sdiff_subset + have hretain (x) (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ D x ⊆ S \ global := by + rw [hsupport j] + intro q hq + exact Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hq).1, + fun hg => (Finset.mem_sdiff.mp hq).2 (Finset.mem_union_left _ hg)⟩ + dsimp only [M] at hsupport + have hfinal := hrate Bidx Cidx (Fin (wholePrimeGridCount b)) N e tierB tierC t small + slot perm pattern rep primes hprimes childBound pivotBound hfreq Fw Ew outside R r p hc + twist sets β y X j₀ φ G U u v (fun x _ => D x) (fun _ => S \ global) + μ ν Eprior αall βint Vint Uall hm hsmall hB htier hsmallLen hR hr hV hp hfreqp + hsmallp hsamplesp hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage + hφ hlip hφout hcard hunit hlow (fun _ => hgeometry.2.1) + (fun _ => hgeometry.2.2.1) (fun _ => hgeometry.2.2.2) hMcell + (fun j => by simpa only [hsupport j] using hS) (fun x _ _ => hDcard x) + (fun j => by simpa only [hsupport j] using hmass) + (fun x _ _ i hi => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_base (fun i => (x i : ℕ)) _ outside i hi)) hout + (fun x _ _ q hq => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_outside (fun i => (x i : ℕ)) _ outside q hq)) + (⟨0, wholePrimeGridCount_pos b⟩, 1) hsub (fun x _ => hretain x) hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + exact hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowArithmeticRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowArithmeticRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..d826cd09d5d4311bf68139157ef5bf7411d74e29 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowArithmeticRate.lean @@ -0,0 +1,193 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowSelectedRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate + +namespace OAI + +/-! # The complete arithmetic bound under the original union-of-cells prior -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_original_arithmetic_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_selected_prime_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted initial + μ ν Eprior αall βint Vint Uall hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let obs := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U + let cost := (2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + have hpoint (x) : ‖obs x‖ ≤ cost := + movingPatternPrimeObservable_norm e tierB tierC t small slot perm pattern hB htier + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hminor (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ‖movingPatternBulkMean e ν slot obs x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + exact hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern primes hprimes x + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X j₀ φ G XL U u v (deleted x) + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp (hsmallp x hx) (hsamplesp x hx) + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS (hdel x hx) hmass (hdelbase x hx) hout (hdelout x hx) + c₀ initial hsub (hretain x hx) ν hν + have hfinal := movingPattern_signed_arithmetic_on_support e (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) tierB tierC t small + (movingPatternBulkLeaves (n + 2) m slot perm) pattern rep + (fun b j _ => hB j) (fun b j _ => hB j) htier + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hUall + (movingPatternFinBulkData_size e t small slot perm pattern hsmallLen) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hV) + (fun q => by + simpa only [Int.cast_natCast, abs_of_nonneg (show (0 : ℝ) ≤ (q : ℕ) from Nat.cast_nonneg _)] + using hvalues q) + μ ν hμ0 hν0 hμmass hνmass Eprior αall βint Vint hEprior hαall hβint hVint + hμbound hμall hνall hμmax hμmin obs cost (by dsimp only [cost]; positivity) + hpoint hdisjoint hcross hfmod m slot perm rfl + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hminor + (fun _ => Classical.arbitrary primes) + simpa only [movingInternalArithmeticError, obs, cost, data, m] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowGain.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowGain.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2c99108f4baaf2097204157483b425fdead9f26 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowGain.lean @@ -0,0 +1,46 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternKernelGain + +namespace OAI + +/-! # Uniform quartet gain for the actual moving Fourier windows -/ + +namespace Ostmann +open scoped SchwartzMap + +/-- The tolerance is selected after the fixed Fourier profile and frequency +cost, and before the bulk length. All sharp cutoffs are included in `W`. -/ +theorem exists_movingPatternKernelGain_window (ψ : 𝓢(ℝ, ℂ)) (n r₀ : ℕ) + (A H B D F gain : ℝ) (hA : 0 ≤ A) (hH : 0 ≤ H) : + ∃ C : ℝ, 0 < C ∧ ∀ m : ℕ, 1 ≤ m → ∀ lo hi : ℝ, lo ≤ hi → + hi - lo ≤ Real.exp (H * m) → ∀ amp δ : ℝ, + 0 ≤ amp → amp ≤ Real.exp (F * m) → 0 ≤ δ → + δ ≤ signedBulkGainTarget n (C + F) gain → + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + (W * amp) * 4 ^ Fintype.card (TreeLeafIndex n × Fin m) * δ ^ m ≤ + Real.exp (-gain * m) := by + obtain ⟨C, hC, hcost⟩ := movingPatternKernelBudget_exp_window ψ n r₀ A H B D hA hH + refine ⟨2 * C, by positivity, ?_⟩ + intro m hm lo hi hhi hwidth amp δ hamp hampBound hδ hgain + dsimp only + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 + have hW : 0 ≤ W := sq_nonneg _ + have hm' : (1 : ℝ) ≤ m := by exact_mod_cast hm + have hWbound : W ≤ Real.exp (2 * C * m) := by + apply (bulkKernelPair_smooth_le_budget ψ (Real.exp (A * m)) lo hi n + (2 ^ n * (r₀ + m + 4 * n + 4)) (2 ^ n * (r₀ + m + 4 * n)) 0 B D).trans + apply (hcost m lo hi hhi hwidth).trans + exact Real.exp_le_exp.mpr (by nlinarith) + have hamp' : W * amp ≤ Real.exp ((2 * C + F) * m) := by + apply (mul_le_mul hWbound hampBound hamp (Real.exp_nonneg _)).trans_eq + rw [← Real.exp_add] + congr 1 + ring + have h := signedBulkGainTarget_bound n m (2 * C + F) gain 1 (W * amp) δ + (by norm_num) (mul_nonneg hW hamp) hδ hamp' hgain + simpa only [one_mul] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowInitialRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowInitialRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa7c5ca2c8d77e9ef64df791ba6f8dc51ced4bab --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowInitialRate.lean @@ -0,0 +1,176 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowPrimeRate +import OAI.NumberTheory.Ostmann.Construction.NestedPrimePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeNorm + +namespace OAI + +/-! # Signed cancellation under the initial, unconditioned bulk law -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_initial_prime_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) → + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ‖∑ x : (TreeLeafIndex (n + 2) × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (initial j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hconditional⟩ := + P.movingPattern_original_prime_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hconditional, movingPattern_bad_event_rate_window ψ (n + 2) r₀ k + A H Bφ Dφ F (Cmass + 1) hA hH hF, + P.original_harmonic_box_rate Cmass hCmass, eventually_ge_atTop (2000 : ℝ)] + with L hconditional hbad hnormal hL + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hbd := hbad lo hi hhi hwidth p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hdeletedBound := hconditional lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X + j₀ φ G XL U u v deleted hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * W + have hpoint (x : (TreeLeafIndex (n + 2) × Fin m) → primes) : + ‖movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U x‖ ≤ cost := + movingPatternPrimeBulkHaar_norm e tierB tierC t small slot perm pattern hB htier + base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hcollision : 0 ≤ cost * (Fintype.card (TreeLeafIndex (n + 2) × Fin m) : ℝ) ^ 2 * + Real.exp ((Cmass + 1) * L - Real.exp ((39 / 10000 : ℝ) * L)) := by + dsimp only [cost, W, amp] + positivity + have hreturnCost := (le_add_of_nonneg_left hcollision).trans hbd + have hcost0 : 0 ≤ cost := by dsimp only [cost, W, amp]; positivity + have hfinal := @nested_prime_prior_three_errors (TreeLeafIndex (n + 2) × Fin m) + inferInstance primes S initial deleted hS hsub hretain (fun j => (hnorm j).1) + (fun x => movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U x) + cost (Real.exp (-gain * m)) (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L))) + (Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcost0 hpoint + (by simpa only [finite_univ_canonical, m, S, M] using hdeletedBound) + (by simpa only [finite_univ_canonical, cost, W, m, Z] using hreturnCost) + simpa only [finite_univ_canonical, m, S, M] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowPrimeGain.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowPrimeGain.lean new file mode 100644 index 0000000000000000000000000000000000000000..453c09d003b42188234eae130a67e0eae9c1711c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowPrimeGain.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowGain +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCost + +namespace OAI + +/-! # A window-uniform local tolerance for the literal prime comparison -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- A single mixed-character tolerance and prime threshold work for all +actual pattern trees and bulk lengths. No local cancellation bound is an +assumption here: it is derived from the quartet theorem. -/ +theorem exists_movingPatternPrimeGain_window (ψ : 𝓢(ℝ, ℂ)) (n r₀ : ℕ) + (A H B D F gain : ℝ) (hA : 0 ≤ A) (hH : 0 ≤ H) : + ∃ ε δ : ℝ, 0 < ε ∧ ε ≤ 1 ∧ 0 < δ ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ (m : ℕ), 1 ≤ m → ∀ lo hi : ℝ, lo ≤ hi → + hi - lo ≤ Real.exp (H * m) → ∀ (Bidx Cidx : Type) (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (base : Fin (N + 1) → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime], + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0 ∧ s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) → + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) → + ∀ (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)), + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + ∀ S : ∀ i, Finset (ZMod (p i)), + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (S i)) → + (∀ i, residueDensity (S i) ≤ 2 / 3) → + (∀ i, (S i).Nonempty) → (∀ i, (S i).card < p i) → + ∀ β : Fin m → ℝ, (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((S i).card : ℂ)⁻¹ * ∑ x ∈ S i, χ⁻¹ (-a - x)‖ ≤ β i) → + ∀ amp : ℝ, 0 ≤ amp → amp ≤ Real.exp (F * m) → + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + (∀ i, ‖(Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) (twist i) perm + (normalizedResidueTransform (S i)) z‖ ≤ δ) ∧ + (W * amp) * 4 ^ Fintype.card (TreeLeafIndex (n + 2) × Fin m) * + δ ^ m ≤ Real.exp (-gain * m) := by + obtain ⟨C, _, hkernel⟩ := exists_movingPatternKernelGain_window ψ (n + 2) r₀ + A H B D F gain hA hH + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hlocal⟩ := exists_frozenSpectatorGain n (C + F) gain + let δ := signedBulkGainTarget (n + 2) (C + F) gain + refine ⟨ε, δ, hε, hε1, signedBulkGainTarget_pos _ _ _, cutoff, hcutoff, ?_⟩ + intro m hm lo hi hhi hwidth Bidx Cidx N e base t small pattern p _ hp hfreq hsmall hsamples twist perm hgood + S hlo hupper hS hSp β hβ hbias amp hamp hampBound + dsimp only + have hlocalBound (i : Fin m) : + ‖(Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod (p i))ˣ) : ℂ)⁻¹ * + ∑ z, frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) (twist i) perm + (normalizedResidueTransform (S i)) z‖ ≤ δ := + hlocal (p i) (hp i) (Fin (N + 1)) base m (by omega) t _ _ + (fun b => movingGiantFrequencyUnits_of_bounds (t b) (hfreq i b)) + (fun b => movingPatternFiniteSmall_unit e base (small b) (hsmall i b)) + (movingPatternFiniteSamples_units e base pattern (hsamples i)) + (twist i) perm hgood (S i) (hlo i) (hupper i) (hS i) (hSp i) (β i) (hβ i) (hbias i) + exact ⟨hlocalBound, hkernel m hm lo hi hhi hwidth amp δ hamp hampBound + (signedBulkGainTarget_pos _ _ _).le le_rfl⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowPrimeRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowPrimeRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..eef25a7c0065c302f314d651baac8a547edc878c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowPrimeRate.lean @@ -0,0 +1,193 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedPrimeSignedBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowPrimeGain +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternCellError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBadEventRate +import OAI.NumberTheory.Ostmann.Construction.OriginalHarmonicRate +import OAI.NumberTheory.Ostmann.ZeroDensity.BulkProgressionCutoff + +namespace OAI + +/-! # One original-prior signed bulk estimate at the manuscript scales -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The three arithmetic costs are combined for the literal original prime +mean. The only analytic input is the published progression theorem; local +cancellation is proved from the balanced spectator sets and their mixed +Fourier bounds. All prime normalizers are those before idealization. -/ +theorem PublishedProgressionInput.movingPattern_original_prime_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (base : Fin (N + 1) → ℕ) (primes : Finset ℕ) + (hprimes : ∀ p ∈ primes, p.Prime) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) → + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → base i ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ‖∑ x : (TreeLeafIndex (n + 2) × Fin m) → primes, + ((∏ j, primeSubsetPrior primes (S j \ deleted j) (x j) : ℝ) : ℂ) * + movingPatternPrimeBulkHaar e t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, δ, hε, hε1, hδ, cutoff, hcutoff, hgain⟩ := + exists_movingPatternPrimeGain_window ψ n r₀ A H Bφ Dφ F gain hA hH + obtain ⟨Cerr, hCerr, hCnorm, hcellRate⟩ := + P.movingPattern_cell_error_rate_window ψ (n + 2) r₀ k A H Bφ Dφ F (Cmass + 1) hA hH hF + obtain ⟨Tcell, _, hcellTwo⟩ := P.short_prime_cell_mass_two + have hlarge : ∀ᶠ L : ℝ in atTop, Tcell ≤ Real.exp ((39 / 10000 : ℝ) * L) := + (Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num))).eventually + (eventually_ge_atTop Tcell) + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hcellRate, movingPattern_bad_event_rate_window ψ (n + 2) r₀ k + A H Bφ Dφ F (Cmass + 1) hA hH hF, + P.original_harmonic_box_rate Cmass hCmass, hlarge, eventually_ge_atTop (2000 : ℝ)] + with L herror hbad hnormal hlarge hL + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern base primes hprimes hbase + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let Z := fun j => (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹)⁻¹ + let W := (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + let freq := frozenBulkFrequencyFactor base (movingPatternBulkEmbedding e slot) outside + Fw Ew data childBound R r P Qfreq y + let spec := fun i => frozenBulkSpectatorHaar base (n + 2) m t + (fun b => movingPatternFiniteSmall e (n + 2) (small b)) + (movingPatternFiniteSamples e (n + 2) pattern) (twist i) perm + (normalizedResidueTransform (sets i)) + let a := fun z => freq (bulkResidueEquiv r p hc z).1 * + ∏ i, spec i ((bulkResidueEquiv r p hc z).2 i) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hg := hgain m hm lo hi hhi hwidth Bidx Cidx N e base t small pattern p hp + (fun i b s hs => ⟨hfreq b s hs, hfreqp i b s hs⟩) hsmallp hsamplesp + twist perm hgood sets hdlo hdhi hsets hsetsp β hβ hbias amp hamp0 hamp + have hQ := bulkProgressionCutoff_bounds L hL + have hnorm (j) : 0 < (∑ q ∈ S j \ deleted j, (q : ℝ)⁻¹) ∧ + Z j ≤ Real.exp ((Cmass + 1) * L) ∧ + Z j * (∑ c, ∫ x in Set.Ioc (u j c) (v j c), (x : ℝ)⁻¹) ≤ 2 := by + have heq := unitPrimeCellSupport_eq M (u j) (v j) (hMcell j) + have hh := hnormal Cell (bulkProgressionCutoff L) hQ.1 hQ.2 hcard + (u j) (v j) (deleted j) (hu j) (hulow j) (huv j) (hshort j) (hsep j) (hdel j) + simpa only [← heq, S, Z] using hh (by simpa only [← heq, S] using hmass j) + have hlow (j) (q : ℕ) (hq : q ∈ S j) : + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ) := by + obtain ⟨c, _, hqc⟩ := Finset.mem_biUnion.mp hq + obtain ⟨hqp, _, hql, _⟩ := mem_primeLogCellSet_iff.mp hqc + exact (Real.le_log_iff_exp_le (by exact_mod_cast hqp.pos)).mp ((hulow j c.1).trans hql.le) + have hZ0 (j) : 0 ≤ Z j := inv_nonneg.mpr (hnorm j).1.le + have hZ (j) : Z j ≤ Real.exp (Cerr * L) := (hnorm j).2.1.trans + (Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hCnorm (by linarith))) + have hunit : (Fintype.card (ZMod M)ˣ : ℝ) ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * L)) := + bulkResidueModulus_unit_card hMQ (Nat.floor_le (Real.exp_nonneg _)) + have ha (z) : ‖a z‖ ≤ amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1)) := by + exact moving_frozen_residue_coefficient_norm base (movingPatternBulkEmbedding e slot) outside + Fw Ew (n + 2) m data childBound R r P Qfreq y hy p sets hsets hsetsp + t _ _ twist perm (bulkResidueEquiv r p hc z).1 (bulkResidueEquiv r p hc z).2 + have he := herror lo hi hhi hwidth Cell M (bulkProgressionCutoff L) hQ.1 hQ.2 p Z a amp + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 hZ hcard hunit hamp0 hamp ha le_rfl u hulow + have hbd := hbad lo hi hhi hwidth p S deleted Z amp ((Cmass + 1) * L) + (Real.exp ((39 / 10000 : ℝ) * L)) hpupper hZ0 (fun j => (hnorm j).2.1) + (fun j => (hdel j).trans (Real.exp_le_exp.mpr (by nlinarith))) le_rfl hamp0 hamp le_rfl hlow + have hb := P.movingPattern_mixed_prime_signed_bound e tierB tierC t small slot perm pattern + hsmall hB htier base primes hprimes hbase childBound pivotBound hfreq Fw Ew outside R r + hR hr p hc (fun i => normalizedResidueTransform (sets i)) + (fun i => normalizedResidueTransform_zero (sets i)) twist (bulkProgressionCutoff L) Qfreq y + j₀ ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U + r₀ hsmallLen hy hQ.1 hMQ hpage u v hu huv hshort + (fun j c z => hcellTwo M z.val.val (u j c) (v j c) (hlarge.trans (hulow j c)) (hshort j c)) + c₀ hS (fun j => unitPrimeCells_separated M (u j) (v j) (hsep j)) deleted + (fun j => (hnorm j).1.ne') hdelbase hout hdelout (fun i => (p i : ℝ)) + (fun i => Nat.cast_nonneg _) (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) + δ hδ.le ((Cmass + 1) * L) (Real.exp ((39 / 10000 : ℝ) * L)) + hg.1 (fun j => (hnorm j).2.2) (fun j => (hnorm j).2.1) + (fun j q hq => hlow j q (Finset.mem_sdiff.mp hq).1) + dsimp only at hb + calc + _ ≤ _ := hb + _ ≤ Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + have hh := add_le_add (add_le_add hg.2 he) hbd + simpa only [add_assoc, W, amp, Z, a, spec, freq, data, M, S] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowSelectedRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowSelectedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1795a6b9572fedf6678ef7773d8ca45da8effa5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowSelectedRate.lean @@ -0,0 +1,118 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowInitialRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeObservable + +namespace OAI + +/-! # The published prime estimate in the original selected-coordinate mean -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_selected_prime_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (base : Fin (N + 1) → primes) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((base (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ i c, ((base (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ j, ((deleted j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (base i : ℕ) ∈ deleted j) → + (∀ q ∈ outside, q.Prime) → (∀ j q, q ∈ outside → q ∈ deleted j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + ∀ initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ, + (∀ j, initial j ⊆ S j) → (∀ j, S j \ deleted j ⊆ initial j) → + ∀ ν : Bidx → primes → ℝ, + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + ‖movingPatternBulkMean e ν slot + (movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U) base‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_initial_prime_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx Cell _ N e tierB tierC t small slot perm pattern primes hprimes base + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain ν hν + rw [movingPatternBulkMean_primeObservable] + · exact hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern + (fun i => (base i : ℕ)) primes hprimes (fun i _ => hprimes _ (base i).property) + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X j₀ φ G XL U u v deleted + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ initial hsub hretain + · exact hν + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWeightedArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWeightedArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0eeb62d0cbf90086d7426afe80c343d63b99c0a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWeightedArithmetic.lean @@ -0,0 +1,206 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowSelectedRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMultiplier + +namespace OAI + +/-! # The complete arithmetic bound under the original union-of-cells prior -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_weighted_arithmetic_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (W : (Fin (N + 1) → primes) → ℂ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U + let obs := fun x => W x * raw x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, ‖W x‖ ≤ 1) → + (∀ x z, W (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) = W x) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_selected_prime_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U u v deleted initial + μ ν W Eprior αall βint Vint Uall hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hW hWbulk hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let raw := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U + let obs := fun x => W x * raw x + let cost := (2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + have hraw (x) : ‖raw x‖ ≤ cost := + movingPatternPrimeObservable_norm e tierB tierC t small slot perm pattern hB htier + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout XL U + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hpoint (x) : ‖obs x‖ ≤ cost := by + change ‖W x * raw x‖ ≤ cost + rw [norm_mul] + exact (mul_le_mul_of_nonneg_right (hW x) (norm_nonneg _)).trans (by simpa using hraw x) + have hminor (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ‖movingPatternBulkMean e ν slot obs x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + rw [movingPatternBulkMean_weight e ν slot W raw hWbulk x, norm_mul] + apply (mul_le_mul_of_nonneg_right (hW x) (norm_nonneg _)).trans + simp only [one_mul] + exact hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern primes hprimes x + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X j₀ φ G XL U u v (deleted x) + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp (hsmallp x hx) (hsamplesp x hx) + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS (hdel x hx) hmass (hdelbase x hx) hout (hdelout x hx) + c₀ initial hsub (hretain x hx) ν hν + have hfinal := movingPattern_signed_arithmetic_on_support e (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) tierB tierC t small + (movingPatternBulkLeaves (n + 2) m slot perm) pattern rep + (fun b j _ => hB j) (fun b j _ => hB j) htier + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hUall + (movingPatternFinBulkData_size e t small slot perm pattern hsmallLen) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hV) + (fun q => by + simpa only [Int.cast_natCast, abs_of_nonneg (show (0 : ℝ) ≤ (q : ℕ) from Nat.cast_nonneg _)] + using hvalues q) + μ ν hμ0 hν0 hμmass hνmass Eprior αall βint Vint hEprior hαall hβint hVint + hμbound hμall hνall hμmax hμmin obs cost (by dsimp only [cost]; positivity) + hpoint hdisjoint hcross hfmod m slot perm rfl + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hminor + (fun _ => Classical.arbitrary primes) + simpa only [movingInternalArithmeticError, obs, raw, cost, data, m] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWeightedIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWeightedIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a1d57c0f191dd5e082739b3243fcdee2c2c093e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWeightedIntegral.lean @@ -0,0 +1,208 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowWeightedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedMeasurable +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMixedHarmonicIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSumRate + +namespace OAI + +/-! # Signed quartet cancellation under both giant-cell integrals -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_weighted_mixed_integral_rate_window + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (Cell : Type) [Fintype Cell] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (u v : (TreeLeafIndex (n + 2) × Fin m) → Cell → ℝ) + (deleted : (Fin (N + 1) → primes) → + (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (initial : (TreeLeafIndex (n + 2) × Fin m) → Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (W : ℝ → ℝ → (Fin (N + 1) → primes) → ℂ) + (Eprior αall βint Vint Uall uG vG rG sG center : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => primeCellSupport M (fun c : Cell × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := fun xg y => movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + let obs := fun xg y x => W xg y x * raw xg y x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (Fintype.card Cell : ℝ) ≤ Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) → + (∀ j c, 1 ≤ u j c) → (∀ j c, Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c) → + (∀ j c, u j c ≤ v j c) → (∀ j c, v j c ≤ u j c + 1) → + (∀ j c d, c ≠ d → v j c ≤ u j d ∨ v j d ≤ u j c) → + (∀ j c, (M : ℝ) ≤ Real.exp (u j c)) → + (∀ j, S j ⊆ primes) → + (∀ x, productPrior law x ≠ 0 → + ∀ j, ((deleted x j).card : ℝ) ≤ Real.exp (Cmass * L)) → + (∀ j, Real.exp (-Cmass * L) ≤ ∑ q ∈ S j, (q : ℝ)⁻¹) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ j i, i ∉ Set.range (movingPatternBulkEmbedding e slot) → (x i : ℕ) ∈ deleted x j) → + (∀ q ∈ outside, q.Prime) → + (∀ x, productPrior law x ≠ 0 → ∀ j q, q ∈ outside → q ∈ deleted x j) → + ∀ _c₀ : Cell × (ZMod M)ˣ, + (∀ j, initial j ⊆ S j) → + (∀ x, productPrior law x ≠ 0 → ∀ j, S j \ deleted x j ⊆ initial j) → + (∀ j, ν (slot j) = primeSubsetPrior primes (initial j)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, Measurable (fun z : ℝ × ℝ => W z.1 z.2 x)) → + (∀ xg y x, ‖W xg y x‖ ≤ 1) → + (∀ xg y x z, W xg y (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) = W xg y x) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ xg ∈ Set.Ioc uG vG, ∀ y ∈ Set.Ioc rG sG, ∀ x, productPrior law x ≠ 0 → obs xg y x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (fun x => ∫ xg in Set.Ioc uG vG, ∫ y in Set.Ioc rG sG, + obs xg y x * (Real.exp (xg - center) : ℂ) / (y : ℂ)) x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + (2 * Real.exp 1 * (((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))))) / rG := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_weighted_arithmetic_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ Cell _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq X j₀ φ G u v deleted initial + μ ν W Eprior αall βint Vint Uall uG vG rG sG center + huG hrG huvG hrsG hvG hsG hcenter hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hWmeas hW hWbulk hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let raw := fun xg y => movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G (Real.exp xg) (Real.exp y) + let obs := fun xg y x => W xg y x * raw xg y x + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + let bound := ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) + have hmean (xg : ℝ) (hxg : xg ∈ Set.Ioc uG vG) (y : ℝ) (hy : y ∈ Set.Ioc rG sG) : + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern + (obs xg y) x * movingPatternHaarProduct e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) (n + 2) t small + (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ bound := by + exact hrate lo hi hlo hhi hwidth Bidx Cidx Cell N e tierB tierC t small slot perm pattern rep primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β Qfreq y X j₀ φ G + (Real.exp xg) (Real.exp y) u v deleted initial μ ν (W xg y) Eprior αall βint Vint Uall + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp (by linarith [hy.1]) hpupper hMQ hpage hφ hlip hφout + hcard hu hulow huv hshort hsep hMcell hS hdel hmass hdelbase hout hdelout c₀ hsub hretain hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues (hW xg y) (hWbulk xg y) + (hdisjoint xg hxg y hy) (hcross xg hxg y hy) (hfmod xg hxg y hy) + have hcost : 0 ≤ cost := by dsimp only [cost, amp]; positivity + have herr := movingInternalArithmeticError_nonneg (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + (Real.one_le_exp (mul_nonneg hA (Nat.cast_nonneg m))) hUall hαall hβint hVint.le + have hbound : 0 ≤ bound := by dsimp only [bound]; positivity + apply movingPattern_mixed_harmonic_integral_bound e (fun q : primes => (q : ℕ)) + (fun q => hprimes _ q.property) μ ν t small (movingPatternBulkLeaves (n + 2) m slot perm) + pattern (fun x xg y => obs xg y x) _ uG vG rG sG center bound huG hrG huvG hrsG hvG hsG hcenter + hbound (fun _ => cost) (fun _ => hcost) _ hmean + · intro x + exact (hWmeas x).mul (movingPatternPrimeObservable_measurable e t small slot perm pattern + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + ψ X lo hi hlo hhi φ G Bφ Dφ hBφ hDφ hφ hlip hφout x) + · intro x xg hxg y hy + have hh := movingPatternPrimeObservable_norm e tierB tierC t small slot perm pattern + hB htier primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout (Real.exp xg) (Real.exp y) + (by linarith [hy.1]) (fun i => (p i : ℝ)) (fun _ => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + change ‖W xg y x * raw xg y x‖ ≤ cost + rw [norm_mul] + exact (mul_le_mul (hW xg y x) hh (norm_nonneg _) (by norm_num)).trans_eq (one_mul _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWeightedWholeShell.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWeightedWholeShell.lean new file mode 100644 index 0000000000000000000000000000000000000000..74a949018949c0777ef3d672e6ca2b14b65d2895 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWeightedWholeShell.lean @@ -0,0 +1,216 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowWeightedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.WholeShellGeometry +import OAI.NumberTheory.Ostmann.Construction.WholeShellMass +import OAI.NumberTheory.Ostmann.Construction.FrozenPrimeDeletions + +namespace OAI + +/-! # The arithmetic estimate for the original full bulk shell -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_weighted_whole_shell_arithmetic_rate_window + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (global : Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (W : (Fin (N + 1) → primes) → ℂ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let raw := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U + let obs := fun x => W x * raw x + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, ν (slot j) = primeSubsetPrior primes (S \ global)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, ‖W x‖ ≤ 1) → + (∀ x z, W (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z (fun i => x i)) = W x) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_weighted_arithmetic_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + have hlarge := (Real.tendsto_exp_atTop.comp + (tendsto_id.const_mul_atTop (by norm_num : (0 : ℝ) < 4 / 1000))).eventually + (eventually_ge_atTop (2 * (Real.log 2 + 2 * C))) + filter_upwards [hrate, wholePrimeGridCount_eventual (6 / 1000) (by norm_num), + hlarge, eventually_ge_atTop (max 0 (max (Real.log 4) (500 * Real.log 2)))] + with L hrate hgrid hlarge hL + have hL0 : 0 ≤ L := (le_max_left _ _).trans hL + have hL4 : Real.log 4 ≤ L := (le_max_left _ _).trans ((le_max_right _ _).trans hL) + have hL2 : 500 * Real.log 2 ≤ L := (le_max_right _ _).trans ((le_max_right _ _).trans hL) + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U global + μ ν W Eprior αall βint Vint Uall hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hS hdel hout hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hW hWbulk hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let a : ℝ := (4 / 1000) * L + let b : ℝ := (6 / 1000) * L + let u := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellLower a b + let v := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellUpper a b + let M := ∏ i, bulkResidueModuli r p i + let S := primeLogCellSet 1 0 (Real.exp a) (Real.exp b) + let D := fun x : Fin (N + 1) → primes => global ∪ + frozenPrimeDeletions (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside + have hab : a ≤ b := by dsimp only [a, b]; nlinarith + have hgeometry := whole_shell_geometry a b hab + have ha0 : 0 ≤ a := mul_nonneg (by norm_num) hL0 + have hlow (j) (c) : Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c := by + exact (Real.exp_le_exp.mpr (by dsimp only [a]; nlinarith)).trans (hgeometry.1 c) + have hMbase : (M : ℝ) ≤ Real.exp (Real.exp a) := + modulus_le_exp_bulk_endpoint hMQ hL0 + (Real.exp_le_exp.mpr (by dsimp only [a]; nlinarith)) + have hsupport (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) = S := + whole_shell_support M a b hab hMbase + have hunit (j) (c) : 1 ≤ u j c := + (Real.one_le_exp_iff.mpr ha0).trans (hgeometry.1 c) + have hMcell (j) (c) : (M : ℝ) ≤ Real.exp (u j c) := + hMbase.trans (Real.exp_le_exp.mpr (hgeometry.1 c)) + have hcard : (Fintype.card (Fin (wholePrimeGridCount b)) : ℝ) ≤ + Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) := by + simpa only [Fintype.card_fin] using hgrid b (le_refl _) + have htwo : 2 * Real.exp a ≤ Real.exp b := by + have he : Real.log 2 + a ≤ b := by dsimp only [a, b]; nlinarith + have hh := Real.exp_le_exp.mpr he + simpa only [Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 2)] using hh + have hmass : Real.exp (-Cmass * L) ≤ ∑ q ∈ S, (q : ℝ)⁻¹ := by + have he : Real.exp (-Cmass * L) ≤ (1 / 4 : ℝ) := by + calc + _ ≤ Real.exp (-Real.log 4) := Real.exp_le_exp.mpr (by nlinarith) + _ = _ := by rw [Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 4)]; norm_num + exact he.trans (whole_shell_mass_lower hM (Real.exp a) (Real.exp b) + (Real.one_le_exp_iff.mpr ha0) hlarge htwo) + have hDcard (x) : ((D x).card : ℝ) ≤ Real.exp (Cmass * L) := by + have hh : (D x).card ≤ global.card + (N + 1) + outside.length := by + have ht := (Finset.card_union_le global _).trans + (Nat.add_le_add_left (frozenPrimeDeletions_card_le + (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside) global.card) + simpa only [Fintype.card_fin, Nat.add_assoc] using ht + exact (Nat.cast_le.mpr hh).trans hdel + have hsub (j) : S \ global ⊆ primeCellSupport M + (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) := by + rw [hsupport j]; exact Finset.sdiff_subset + have hretain (x) (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ D x ⊆ S \ global := by + rw [hsupport j] + intro q hq + exact Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hq).1, + fun hg => (Finset.mem_sdiff.mp hq).2 (Finset.mem_union_left _ hg)⟩ + dsimp only [M] at hsupport + have hfinal := hrate lo hi hlo hhi hwidth Bidx Cidx (Fin (wholePrimeGridCount b)) N e tierB tierC t small + slot perm pattern rep primes hprimes childBound pivotBound hfreq Fw Ew outside R r p hc + twist sets β Qfreq y X j₀ φ G XL U u v (fun x _ => D x) (fun _ => S \ global) + μ ν W Eprior αall βint Vint Uall hm hsmall hB htier hsmallLen hR hr hV hp hfreqp + hsmallp hsamplesp hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage + hφ hlip hφout hcard hunit hlow (fun _ => hgeometry.2.1) + (fun _ => hgeometry.2.2.1) (fun _ => hgeometry.2.2.2) hMcell + (fun j => by simpa only [hsupport j] using hS) (fun x _ _ => hDcard x) + (fun j => by simpa only [hsupport j] using hmass) + (fun x _ _ i hi => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_base (fun i => (x i : ℕ)) _ outside i hi)) hout + (fun x _ _ q hq => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_outside (fun i => (x i : ℕ)) _ outside q hq)) + (⟨0, wholePrimeGridCount_pos b⟩, 1) hsub (fun x _ => hretain x) hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hW hWbulk hdisjoint hcross hfmod + exact hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWholeShellArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWholeShellArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..07069a303536994a5a4d4f10441c69c777061d8d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWindowWholeShellArithmetic.lean @@ -0,0 +1,212 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWindowArithmeticRate +import OAI.NumberTheory.Ostmann.Arithmetic.WholeShellGeometry +import OAI.NumberTheory.Ostmann.Construction.WholeShellMass +import OAI.NumberTheory.Ostmann.Construction.FrozenPrimeDeletions + +namespace OAI + +/-! # The arithmetic estimate for the original full bulk shell -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_whole_shell_arithmetic_rate_window + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A H Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hH : 0 ≤ H) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi), hi - lo ≤ Real.exp (H * m) → + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (Qfreq : ℕ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (XL U : ℝ) + (global : Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P Qfreq + y ψ X lo hi hlo hhi φ G XL U + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + S ⊆ primes → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ q ∈ outside, q.Prime) → + (∀ j, ν (slot j) = primeSubsetPrior primes (S \ global)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_original_arithmetic_rate_window ψ n r₀ k A H Bφ Dφ F Cmass gain + hA hH hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + have hlarge := (Real.tendsto_exp_atTop.comp + (tendsto_id.const_mul_atTop (by norm_num : (0 : ℝ) < 4 / 1000))).eventually + (eventually_ge_atTop (2 * (Real.log 2 + 2 * C))) + filter_upwards [hrate, wholePrimeGridCount_eventual (6 / 1000) (by norm_num), + hlarge, eventually_ge_atTop (max 0 (max (Real.log 4) (500 * Real.log 2)))] + with L hrate hgrid hlarge hL + have hL0 : 0 ≤ L := (le_max_left _ _).trans hL + have hL4 : Real.log 4 ≤ L := (le_max_left _ _).trans ((le_max_right _ _).trans hL) + have hL2 : 500 * Real.log 2 ≤ L := (le_max_right _ _).trans ((le_max_right _ _).trans hL) + dsimp only + intro lo hi hlo hhi hwidth Bidx Cidx _ _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β Qfreq y X j₀ φ G XL U global + μ ν Eprior αall βint Vint Uall hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hS hdel hout hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let a : ℝ := (4 / 1000) * L + let b : ℝ := (6 / 1000) * L + let u := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellLower a b + let v := fun (_ : TreeLeafIndex (n + 2) × Fin m) => wholeShellUpper a b + let M := ∏ i, bulkResidueModuli r p i + let S := primeLogCellSet 1 0 (Real.exp a) (Real.exp b) + let D := fun x : Fin (N + 1) → primes => global ∪ + frozenPrimeDeletions (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside + have hab : a ≤ b := by dsimp only [a, b]; nlinarith + have hgeometry := whole_shell_geometry a b hab + have ha0 : 0 ≤ a := mul_nonneg (by norm_num) hL0 + have hlow (j) (c) : Real.exp ((39 / 10000 : ℝ) * L) ≤ u j c := by + exact (Real.exp_le_exp.mpr (by dsimp only [a]; nlinarith)).trans (hgeometry.1 c) + have hMbase : (M : ℝ) ≤ Real.exp (Real.exp a) := + modulus_le_exp_bulk_endpoint hMQ hL0 + (Real.exp_le_exp.mpr (by dsimp only [a]; nlinarith)) + have hsupport (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) = S := + whole_shell_support M a b hab hMbase + have hunit (j) (c) : 1 ≤ u j c := + (Real.one_le_exp_iff.mpr ha0).trans (hgeometry.1 c) + have hMcell (j) (c) : (M : ℝ) ≤ Real.exp (u j c) := + hMbase.trans (Real.exp_le_exp.mpr (hgeometry.1 c)) + have hcard : (Fintype.card (Fin (wholePrimeGridCount b)) : ℝ) ≤ + Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) := by + simpa only [Fintype.card_fin] using hgrid b (le_refl _) + have htwo : 2 * Real.exp a ≤ Real.exp b := by + have he : Real.log 2 + a ≤ b := by dsimp only [a, b]; nlinarith + have hh := Real.exp_le_exp.mpr he + simpa only [Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 2)] using hh + have hmass : Real.exp (-Cmass * L) ≤ ∑ q ∈ S, (q : ℝ)⁻¹ := by + have he : Real.exp (-Cmass * L) ≤ (1 / 4 : ℝ) := by + calc + _ ≤ Real.exp (-Real.log 4) := Real.exp_le_exp.mpr (by nlinarith) + _ = _ := by rw [Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 4)]; norm_num + exact he.trans (whole_shell_mass_lower hM (Real.exp a) (Real.exp b) + (Real.one_le_exp_iff.mpr ha0) hlarge htwo) + have hDcard (x) : ((D x).card : ℝ) ≤ Real.exp (Cmass * L) := by + have hh : (D x).card ≤ global.card + (N + 1) + outside.length := by + have ht := (Finset.card_union_le global _).trans + (Nat.add_le_add_left (frozenPrimeDeletions_card_le + (fun i => (x i : ℕ)) (movingPatternBulkEmbedding e slot) outside) global.card) + simpa only [Fintype.card_fin, Nat.add_assoc] using ht + exact (Nat.cast_le.mpr hh).trans hdel + have hsub (j) : S \ global ⊆ primeCellSupport M + (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) := by + rw [hsupport j]; exact Finset.sdiff_subset + have hretain (x) (j) : + primeCellSupport M (fun c : Fin (wholePrimeGridCount b) × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ D x ⊆ S \ global := by + rw [hsupport j] + intro q hq + exact Finset.mem_sdiff.mpr ⟨(Finset.mem_sdiff.mp hq).1, + fun hg => (Finset.mem_sdiff.mp hq).2 (Finset.mem_union_left _ hg)⟩ + dsimp only [M] at hsupport + have hfinal := hrate lo hi hlo hhi hwidth Bidx Cidx (Fin (wholePrimeGridCount b)) N e tierB tierC t small + slot perm pattern rep primes hprimes childBound pivotBound hfreq Fw Ew outside R r p hc + twist sets β Qfreq y X j₀ φ G XL U u v (fun x _ => D x) (fun _ => S \ global) + μ ν Eprior αall βint Vint Uall hm hsmall hB htier hsmallLen hR hr hV hp hfreqp + hsmallp hsamplesp hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage + hφ hlip hφout hcard hunit hlow (fun _ => hgeometry.2.1) + (fun _ => hgeometry.2.2.1) (fun _ => hgeometry.2.2.2) hMcell + (fun j => by simpa only [hsupport j] using hS) (fun x _ _ => hDcard x) + (fun j => by simpa only [hsupport j] using hmass) + (fun x _ _ i hi => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_base (fun i => (x i : ℕ)) _ outside i hi)) hout + (fun x _ _ q hq => Finset.mem_union_right _ + (mem_frozenPrimeDeletions_outside (fun i => (x i : ℕ)) _ outside q hq)) + (⟨0, wholePrimeGridCount_pos b⟩, 1) hsub (fun x _ => hretain x) hν + hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + exact hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWordArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWordArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..067a2ad7aa8f1b156c6304c6290dbb53880a7ead --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWordArithmetic.lean @@ -0,0 +1,179 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternWordCellRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSupportedArithmetic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternObservableCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalErrorRate + +namespace OAI + +/-! # The complete original per-pattern arithmetic estimate from the published progression input -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_word_arithmetic_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx : Type) [Fintype Bidx] [Fintype Cidx] (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (rep : ∀ c, {i : Bool × MovingSampleIndex (n + 2) // pattern i = c}) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (a b : (TreeLeafIndex (n + 2) × Fin m) → ℝ) + (h : (TreeLeafIndex (n + 2) × Fin m) → ℕ) (global : Finset ℕ) + (μ : ℕ → primes → ℝ) (ν : Bidx → primes → ℝ) + (Eprior αall βint Vint Uall : ℝ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => wordCellSupport (a j) (b j) (h j) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let obs := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U + let cost := (amp * ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((x (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ x : Fin (N + 1) → primes, productPrior law x ≠ 0 → + ∀ i c, ((x (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (∀ j, Real.exp ((39 / 10000 : ℝ) * L) ≤ a j) → + (∀ j, S j ⊆ primes) → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ j, Real.exp (-Cmass * L) ≤ + finiteCellMass (primeLogCellSet 1 0 (a j) (b j) \ global) + primeLogIndex (fun p => (p : ℝ)⁻¹) (h j)) → + (∀ q ∈ outside, q.Prime) → + (∀ j, ν (slot j) = primeSubsetPrior primes (S j \ global)) → + (∀ j q, 0 ≤ μ j q) → (∀ j q, 0 ≤ ν j q) → + (∀ j, ∑ q, μ j q = 1) → (∀ j, ∑ q, ν j q = 1) → + 0 ≤ Eprior → 0 ≤ αall → 0 ≤ βint → 0 < Vint → 1 ≤ Uall → + (∀ j (q : primes), (q : ℝ) * μ j q ≤ Eprior) → + (∀ j q, μ j q ≤ αall) → (∀ j q, ν j q ≤ αall) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≤ βint) → + (∀ c q, μ (movingSampleTier (rep c).val.2) q ≠ 0 → Real.exp Vint ≤ (q : ℝ)) → + (∀ q : primes, (q : ℝ) ≤ Uall) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → + (x i : ℕ) ≠ (x j : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ b c, + (x (e.symm (.inl b)) : ℕ) ≠ (x (e.symm (.inr c)) : ℕ)) → + (∀ x, productPrior law x ≠ 0 → obs x ≠ 0 → ∀ c b, (data b).Frequencies + (fun s => (s : ZMod (x (e.symm (.inr c)) : ℕ)) ≠ 0)) → + ‖∑ x, movingOriginalPatternWeight e μ ν (fun q : primes => (q : ℕ)) (n + 2) pattern obs x * + movingPatternHaarProduct e (fun q : primes => (q : ℕ)) (fun q => hprimes _ q.property) + (n + 2) t small (movingPatternBulkLeaves (n + 2) m slot perm) pattern x‖ ≤ + ((2 : ℝ) ^ Fintype.card Cidx * Eprior ^ (4 * (n + 2) * 2 ^ (n + 2) - Fintype.card Cidx)) * + (cost * movingInternalArithmeticError (n + 2) (Fintype.card Cidx) + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall αall βint Vint + + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_word_cell_rate ψ n r₀ k A lo hi Bφ Dφ F Cmass gain + hA hlo hhi hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate] with L hrate + dsimp only + intro Bidx Cidx _ _ N e tierB tierC t small slot perm pattern rep primes hprimes _ + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β y X j₀ φ G U a b h global + μ ν Eprior αall βint Vint Uall hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + ha hS hdel hmass hout hν hμ0 hν0 hμmass hνmass hEprior hαall hβint hVint hUall + hμbound hμall hνall hμmax hμmin hvalues hdisjoint hcross hfmod + let m := spectatorBulkCount k L + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let obs := movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U + let cost := (2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 2 + 1))) * + (movingFourierVariationBudget ψ (Real.exp (A * m)) lo hi (n + 2) * + (2 * Bφ + Dφ * (Real.exp 2 - 1)) ^ (2 ^ (n + 2) - 1)) ^ 2 + have hpoint (x) : ‖obs x‖ ≤ cost := + movingPatternPrimeObservable_norm e tierB tierC t small slot perm pattern hB htier + primes hprimes childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) y j₀ + ψ X lo hi (Real.exp (A * m)) hlo hhi hV φ G Bφ Dφ hBφ hDφ hφ hlip hφout L U + hy (fun i => (p i : ℝ)) (fun i => Nat.cast_nonneg _) + (fun i z => normalizedResidueTransform_norm_le_prime (sets i) (hsets i) (hsetsp i) z) x + have hminor (x : Fin (N + 1) → primes) + (hx : productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0) : + ‖movingPatternBulkMean e ν slot obs x‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + exact hrate Bidx Cidx N e tierB tierC t small slot perm pattern primes hprimes x + childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β y X j₀ φ G U a b h global + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp (hsmallp x hx) (hsamplesp x hx) + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + ha hS hdel hmass hout ν hν + have hfinal := movingPattern_signed_arithmetic_on_support e (fun q : primes => (q : ℕ)) + Subtype.val_injective (fun q => hprimes _ q.property) tierB tierC t small + (movingPatternBulkLeaves (n + 2) m slot perm) pattern rep + (fun b j _ => hB j) (fun b j _ => hB j) htier + (2 ^ (n + 2) * (r₀ + m + 4 * (n + 2) + 4)) (Real.exp (A * m)) Uall + (Real.one_le_exp_iff.mpr (mul_nonneg hA (Nat.cast_nonneg _))) hUall + (movingPatternFinBulkData_size e t small slot perm pattern hsmallLen) + (movingPatternFinBulkData_frequencies e t small slot perm pattern _ hV) + (fun q => by + simpa only [Int.cast_natCast, abs_of_nonneg (show (0 : ℝ) ≤ (q : ℕ) from Nat.cast_nonneg _)] + using hvalues q) + μ ν hμ0 hν0 hμmass hνmass Eprior αall βint Vint hEprior hαall hβint hVint + hμbound hμall hνall hμmax hμmin obs cost (by dsimp only [cost]; positivity) + hpoint hdisjoint hcross hfmod m slot perm rfl + (Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hminor + (fun _ => Classical.arbitrary primes) + simpa only [movingInternalArithmeticError, obs, cost, data, m] using hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWordCellRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWordCellRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..efdf055bcf9883e9506a43921de93ac83706266b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPatternWordCellRate.lean @@ -0,0 +1,150 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSelectedRate +import OAI.NumberTheory.Ostmann.Construction.WordCellBulkGeometry + +namespace OAI + +/-! # Signed bulk cancellation for the actual selected harmonic word cells -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.movingPattern_word_cell_rate + (P : PublishedProgressionInput) (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) + (A lo hi Bφ Dφ F Cmass gain : ℝ) + (hA : 0 ≤ A) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hF : 0 ≤ F) (hCmass : 1 ≤ Cmass) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ cutoff : ℕ, 3 ≤ cutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (Bidx Cidx : Type) (N : ℕ) + (e : Fin (N + 1) ≃ Bidx ⊕ Cidx) (tierB : Bidx → ℕ) (tierC : Cidx → ℕ) + (t : Bool → FrequencyTree ℤ (n + 2)) + (small : Bool → TreeLeafTuple (List Bidx) (n + 2)) + (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ Bidx) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (pattern : Bool × MovingSampleIndex (n + 2) → Cidx) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (base : Fin (N + 1) → primes) + (childBound pivotBound : ℕ → ℕ) + (hfreq : ∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), s ≠ 0) + (Fw : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (Ew : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (R : ℤ) (r : ℕ) [NeZero r] + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (_hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + [NeZero (∏ i, bulkResidueModuli r p i)] + (twist : ∀ i, Bool → (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) (y X : ℝ) (_j₀ : TreeLeafIndex (n + 2) × Fin m) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (U : ℝ) + (a b : (TreeLeafIndex (n + 2) × Fin m) → ℝ) + (h : (TreeLeafIndex (n + 2) × Fin m) → ℕ) (global : Finset ℕ), + let data := movingPatternFinBulkData e (n + 2) m t small slot perm pattern + let M := ∏ i, bulkResidueModuli r p i + let S := fun j => wordCellSupport (a j) (b j) (h j) + let amp := 2 * (‖movingDataWeight (Fw false) (Ew false) (data false)‖ * + ‖movingDataWeight (Fw true) (Ew true) (data true)‖) + 1 ≤ m → + (∀ b, ∀ i ∈ flattenMovingSlots (n + 2) (small b), i ∉ Set.range slot) → + (∀ i, n + 2 ≤ tierB i) → (∀ i, tierC (pattern i) = movingSampleTier i.2) → + (∀ b, MovingLeafLengthLE (n + 2) (small b) r₀) → + (∀ b, (data b).frequencyProduct ∣ R) → R ^ (n + 2 + 1) ∣ (r : ℤ) → + (∀ b, ∀ s ∈ allFrequencyList (n + 2) (t b), |(s : ℝ)| ≤ Real.exp (A * m)) → + (∀ i, cutoff ≤ p i) → + (∀ i b, ∀ s ∈ allFrequencyList (n + 2) (t b), s.natAbs < p i) → + (∀ i b, ∀ j ∈ flattenMovingSlots (n + 2) (small b), + ((base (e.symm (.inl j)) : ℕ) : ZMod (p i)) ≠ 0) → + (∀ i c, ((base (e.symm (.inr c)) : ℕ) : ZMod (p i)) ≠ 0) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + amp ≤ Real.exp (F * m) → 0 ≤ y → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + M ≤ bulkProgressionCutoff L → + pageAtModulus M (selectedPageZero P (bulkProgressionCutoff L)) = + pageAtModulus r (selectedPageZero P (bulkProgressionCutoff L)) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → + (∀ j, Real.exp ((39 / 10000 : ℝ) * L) ≤ a j) → + (∀ j, S j ⊆ primes) → + ((global.card + (N + 1) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cmass * L) → + (∀ j, Real.exp (-Cmass * L) ≤ + finiteCellMass (primeLogCellSet 1 0 (a j) (b j) \ global) + primeLogIndex (fun p => (p : ℝ)⁻¹) (h j)) → + (∀ q ∈ outside, q.Prime) → + ∀ ν : Bidx → primes → ℝ, + (∀ j, ν (slot j) = primeSubsetPrior primes (S j \ global)) → + ‖movingPatternBulkMean e ν slot + (movingPatternPrimeObservable e t small slot perm pattern primes hprimes + childBound pivotBound hfreq Fw Ew outside R r p + (fun i => normalizedResidueTransform (sets i)) twist P (bulkProgressionCutoff L) + y ψ X lo hi hlo hhi φ G L U) base‖ ≤ + Real.exp (-gain * m) + Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 2 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, cutoff, hcutoff, hrate⟩ := + P.movingPattern_selected_prime_rate ψ n r₀ k A lo hi Bφ Dφ F Cmass gain + hA hlo hhi hF hCmass hBφ hDφ + refine ⟨ε, hε, hε1, cutoff, hcutoff, ?_⟩ + filter_upwards [hrate, eventually_ge_atTop (0 : ℝ)] with L hrate hL + dsimp only + intro Bidx Cidx N e tierB tierC t small slot perm pattern primes hprimes base + childBound pivotBound hfreq Fw Ew outside R r _ p _ hc _ twist sets β y X j₀ φ G U a b h global + hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp hgood + hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + ha hS hdel hmass hout ν hν + let m := spectatorBulkCount k L + let M := ∏ i, bulkResidueModuli r p i + let u := fun j (_ : Unit) => max (a j) (h j : ℝ) + let v := fun j (_ : Unit) => min (b j) ((h j : ℝ) + 1) + let S := fun j => wordCellSupport (a j) (b j) (h j) + let D := global ∪ frozenPrimeDeletions (fun i => (base i : ℕ)) + (movingPatternBulkEmbedding e slot) outside + have hlow (j) : Real.exp ((39 / 10000 : ℝ) * L) ≤ u j () := + (ha j).trans (le_max_left _ _) + have hMcell (j) (_ : Unit) : (M : ℝ) ≤ Real.exp (u j ()) := + modulus_le_exp_bulk_endpoint hMQ hL (hlow j) + have hsupport (j) : primeCellSupport M (fun c : Unit × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) = S j := + wordCellSupport_unit_residues M (a j) (b j) (h j) (hMcell j ()) + dsimp only [M] at hsupport + have hgeometry (j) : u j () ≤ v j () ∧ v j () ≤ u j () + 1 := + wordCellSupport_geometry (a j) (b j) global (h j) + ((Real.exp_pos _).trans_le (hmass j)) + have hD (j) := wordCellSupport_frozen_deletions (a j) (b j) (h j) global + (fun i => (base i : ℕ)) (movingPatternBulkEmbedding e slot) outside + have hDcard : (D.card : ℝ) ≤ Real.exp (Cmass * L) := by + have hcard : D.card ≤ global.card + (N + 1) + outside.length := by + simpa only [Fintype.card_fin] using (hD j₀).2.2.1 + exact (Nat.cast_le.mpr hcard).trans hdel + have hcard : (Fintype.card Unit : ℝ) ≤ + Real.exp (Real.exp ((14 / 10000 : ℝ) * L)) := by + simp only [Fintype.card_unit, Nat.cast_one] + exact Real.one_le_exp_iff.mpr (Real.exp_nonneg _) + have hunit (j) (_ : Unit) : 1 ≤ u j () := + (Real.one_le_exp_iff.mpr (mul_nonneg (by norm_num) hL)).trans (hlow j) + have hsep (j) (c d : Unit) (hcd : c ≠ d) : v j c ≤ u j d ∨ v j d ≤ u j c := + False.elim (hcd (Subsingleton.elim _ _)) + have hfinal := hrate Bidx Cidx Unit N e tierB tierC t small slot perm pattern + primes hprimes base childBound pivotBound hfreq Fw Ew outside R r p hc twist sets β y X + j₀ φ G U u v (fun _ => D) hm hsmall hB htier hsmallLen hR hr hV hp hfreqp hsmallp hsamplesp + hgood hdlo hdhi hsets hsetsp hβ hbias hamp hy hpupper hMQ hpage hφ hlip hφout + hcard hunit (fun j _ => hlow j) (fun j _ => (hgeometry j).1) + (fun j _ => (hgeometry j).2) hsep hMcell + (fun j => by simpa only [hsupport, S] using hS j) (fun _ => hDcard) + (fun j => by + simpa only [hsupport, S] using + wordCellSupport_mass_lower (a j) (b j) global (h j) _ (hmass j)) + (fun j i hi => (hD j).2.2.2.1 i hi) hout (fun j q hq => (hD j).2.2.2.2 q hq) + ((), 1) (fun j => S j \ global) + (fun j => by simpa only [hsupport, S] using (hD j).1) + (fun j => by simpa only [hsupport, S, D] using (hD j).2.1) ν + (by simpa only [hsupport, S] using hν) + exact hfinal + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPeriodBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPeriodBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..0b9d9052616ff5931cea9432e2fa770fea986453 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPeriodBound.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDenominators + +namespace OAI + +/-! # Quantitative size of the constructed top-giant residue modulus -/ + +namespace Ostmann +open scoped Classical BigOperators + +def MovingSlotData.CompensationBound {σ : Type*} (value : σ → ℕ) (B : ℕ) : + {n : ℕ} → MovingSlotData σ n → Prop + | _, .leaf _ _ => True + | _, .node _ _ _ u left right => + MovingSlotReversal.naturalProduct value u ≤ B ∧ + left.CompensationBound value B ∧ right.CompensationBound value B + +def movingPeriodExponent (n d : ℕ) : ℕ := 2 * (4 ^ n - 1) * (d + 2) + +theorem movingPeriodExponent_step (n d : ℕ) : + 5 * d + 5 + 2 * movingPeriodExponent n (2 * d + 2) ≤ movingPeriodExponent (n + 1) d := by + have ht : 4 ^ (n + 1) - 1 = 4 * (4 ^ n - 1) + 3 := by + have hp : 1 ≤ 4 ^ n := Nat.one_le_pow _ _ (by omega) + rw [pow_succ] + omega + unfold movingPeriodExponent + rw [ht] + nlinarith + +theorem MovingSlotReversal.giantFormula_denominator_bound {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) (hs : step.rootFrequency ≠ 0) + (hu : MovingSlotReversal.naturalProduct value step.compensationSlots ≠ 0) + (L R : HistoryFormula Bool) (B d : ℕ) + (hS : step.rootFrequency.natAbs ≤ B) + (hU : MovingSlotReversal.naturalProduct value step.compensationSlots ≤ B) + (hL : L.cleared.denominator.natAbs ≤ B ^ d) (hR : R.cleared.denominator.natAbs ≤ B ^ d) : + (step.giantFormula value hs hu L R).cleared.denominator.natAbs ≤ B ^ (2 * d + 2) := by + rw [step.giantFormula_denominator value hs hu L R] + simp only [Int.natAbs_mul, Int.natAbs_natCast] + calc + _ ≤ B * B * B ^ d * B ^ d := by gcongr + _ = B ^ 2 * (B ^ d * B ^ d) := by ring + _ = B ^ (2 + (d + d)) := by rw [← pow_add, ← pow_add] + _ = _ := by congr 1; omega + +theorem movingNode_residuePeriod_bound {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) (hs : step.rootFrequency ≠ 0) + (hu : MovingSlotReversal.naturalProduct value step.compensationSlots ≠ 0) + (childBound pivotBound : ℕ) (L R : HistoryFormula Bool) (B d : ℕ) + (hS : step.rootFrequency.natAbs ≤ B) (hW : step.rightFrequency.natAbs ≤ B) + (hU : MovingSlotReversal.naturalProduct value step.compensationSlots ≤ B) + (hL : L.cleared.denominator.natAbs ≤ B ^ d) (hR : R.cleared.denominator.natAbs ≤ B ^ d) : + ({ guard := movingNodeGuard (MovingSlotReversal.naturalProduct value step.leftSlots) + (MovingSlotReversal.naturalProduct value step.rightSlots) + step.rootFrequency step.leftFrequency step.rightFrequency hs childBound pivotBound L R + newGiant := step.giantFormula value hs hu L R } : MovingFormulaNode).residuePeriod ≤ B ^ (5 * d + 5) := by + rw [movingNode_residuePeriod] + calc + _ ≤ B ^ 3 * B * B * (B ^ d) ^ 2 * (B ^ d) ^ 3 := by gcongr + _ = _ := by simp only [← pow_mul, ← pow_add, ← pow_succ]; congr 1; omega + +/-- All repeated ancestor denominators are counted in this estimate; no +squarefree simplification or independence of those factors is used. -/ +theorem MovingSlotData.formulaNodes_period_bound {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (L R : HistoryFormula Bool) + (B d : ℕ) (hB : 1 ≤ B) (hfreq : T.Frequencies (fun s => s.natAbs ≤ B)) + (hcomp : T.CompensationBound value B) + (hL : L.cleared.denominator.natAbs ≤ B ^ d) (hR : R.cleared.denominator.natAbs ≤ B ^ d) : + movingArithmeticPeriod (T.formulaNodes value hvalue childBound pivotBound hf L R) ≤ + B ^ movingPeriodExponent n d := by + induction T generalizing L R d with + | leaf s regular => simp [formulaNodes, movingArithmeticPeriod, movingPeriodExponent] + | @node n s CL CR u left right ihL ihR => + let step := MovingSlotData.step s CL CR u left right false + let hu := MovingSlotReversal.naturalProduct_ne_zero value hvalue u + let G := step.giantFormula value hf.1 hu L R + have hG := step.giantFormula_denominator_bound value hf.1 hu L R B d hfreq.1 hcomp.1 hL hR + have hd : d ≤ 2 * d + 2 := by omega + have hL' := hL.trans (Nat.pow_le_pow_right hB hd) + have hR' := hR.trans (Nat.pow_le_pow_right hB hd) + have hl := ihL hf.2.1 G L (2 * d + 2) hfreq.2.1 hcomp.2.1 hG hL' + have hr := ihR hf.2.2 G R (2 * d + 2) hfreq.2.2 hcomp.2.2 hG hR' + have hhead := movingNode_residuePeriod_bound step value hf.1 hu + (childBound (n + 1)) (pivotBound (n + 1)) L R B d hfreq.1 hfreq.2.2.root hcomp.1 hL hR + simp only [MovingSlotData.formulaNodes, movingArithmeticPeriod, List.map_cons, + List.map_append, List.prod_cons, List.prod_append] + calc + _ ≤ B ^ (5 * d + 5) * + (B ^ movingPeriodExponent n (2 * d + 2) * B ^ movingPeriodExponent n (2 * d + 2)) := + Nat.mul_le_mul hhead (Nat.mul_le_mul hl hr) + _ = B ^ (5 * d + 5 + 2 * movingPeriodExponent n (2 * d + 2)) := by + rw [← pow_add, ← pow_add]; congr 1; omega + _ ≤ _ := Nat.pow_le_pow_right hB (movingPeriodExponent_step n d) + +theorem movingTopPeriod_bound {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (B : ℕ) (hB : 1 ≤ B) + (hfreq : T.Frequencies (fun s => s.natAbs ≤ B)) (hcomp : T.CompensationBound value B) : + movingTopPeriod value hvalue childBound pivotBound T hf ≤ B ^ (4 * (4 ^ n - 1)) := by + have h := T.formulaNodes_period_bound value hvalue childBound pivotBound hf (.prime false) (.prime true) + B 0 hB hfreq hcomp (by simp [HistoryFormula.cleared, ClearedHistoryValue.ofVariable]) + (by simp [HistoryFormula.cleared, ClearedHistoryValue.ofVariable]) + have he : movingPeriodExponent n 0 = 4 * (4 ^ n - 1) := by + unfold movingPeriodExponent + ring + simpa only [movingTopPeriod, he] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPeriodScale.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPeriodScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea4f23306803f96514509a7e52d4493ad6d86b07 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPeriodScale.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePeriod +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticErrorRates + +namespace OAI + +/-! # The constructed moving modulus fits the giant progression range -/ + +namespace Ostmann +open Filter Asymptotics +open scoped Classical + +theorem movingSample_topPeriod_exp {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (P V : ℕ) (hP : 1 ≤ P) (hV : 1 ≤ V) + (hvalueP : ∀ i, value i ≤ P) (childBound pivotBound : ℕ → ℕ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) + (hf : (buildMovingSlotData n t small bulk samples).Frequencies (· ≠ 0)) + (hfreq : (buildMovingSlotData n t small bulk samples).Frequencies (fun s => s.natAbs ≤ V)) + (v p : ℝ) (hv : (V : ℝ) ≤ Real.exp v) (hp : (P : ℝ) ≤ Real.exp p) : + (movingTopPeriod value hvalue childBound pivotBound + (buildMovingSlotData n t small bulk samples) hf : ℝ) ≤ + Real.exp ((4 * (4 ^ n - 1) : ℕ) * (v + (4 * 2 ^ n : ℕ) * p)) := by + have h := movingSample_topPeriod_bound value hvalue P V hP hV hvalueP + childBound pivotBound n t small bulk samples hf hfreq + calc + _ ≤ ((V : ℝ) * (P : ℝ) ^ (4 * 2 ^ n)) ^ (4 * (4 ^ n - 1)) := by exact_mod_cast h + _ ≤ (Real.exp v * (Real.exp p) ^ (4 * 2 ^ n)) ^ (4 * (4 ^ n - 1)) := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_nat_mul] + +/-- Fixed depth and all fixed constants are absorbed by the strict .010/.012 +exponent gap in the source. The cutoff is uniform in the sampled primes. -/ +theorem movingSample_period_exponent_budget (n : ℕ) (C : ℝ) : + ∀ᶠ L : ℝ in atTop, + ((4 * (4 ^ n - 1) : ℕ) : ℝ) * + (C * L + (4 * 2 ^ n : ℕ) * (C * Real.exp ((1 / 100 : ℝ) * L))) ≤ + Real.exp ((12 / 1000 : ℝ) * L) := by + let E : ℝ := (4 * (4 ^ n - 1) : ℕ) + let F : ℝ := (4 * 2 ^ n : ℕ) + have hlin : (fun L : ℝ => (E * C) * L) =o[atTop] + (fun L => Real.exp ((12 / 1000 : ℝ) * L)) := by + simpa only [pow_one] using + (isLittleO_pow_exp_pos_mul_atTop 1 (by norm_num : (0 : ℝ) < 12 / 1000)).const_mul_left (E * C) + have hexp : (fun L : ℝ => (E * F * C) * Real.exp ((1 / 100 : ℝ) * L)) =o[atTop] + (fun L => Real.exp ((12 / 1000 : ℝ) * L)) := by + simpa only [Real.rpow_zero, mul_one] using + (isLittleO_exp_mul_rpow_of_lt 0 (by norm_num : (1 / 100 : ℝ) < 12 / 1000)).const_mul_left (E * F * C) + filter_upwards [(hlin.add hexp).bound (by norm_num : (0 : ℝ) < 1)] with L hL + simp only [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), one_mul] at hL + have h := (le_abs_self _).trans hL + change E * (C * L + F * (C * Real.exp ((1 / 100 : ℝ) * L))) ≤ _ + nlinarith only [h] + +/-- An actual integer modulus bound for the published giant progression input. +Neither the tree, frequencies, primes nor top giants enter the eventual cutoff. -/ +theorem movingSample_topPeriod_progression_range {σ : Type*} (n : ℕ) (C : ℝ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (P V : ℕ), 1 ≤ P → 1 ≤ V → (∀ i, value i ≤ P) → + (V : ℝ) ≤ Real.exp (C * L) → (P : ℝ) ≤ Real.exp (C * Real.exp ((1 / 100 : ℝ) * L)) → + ∀ (childBound pivotBound : ℕ → ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (samples : MovingSampleSlots σ n) + (hf : (buildMovingSlotData n t small bulk samples).Frequencies (· ≠ 0)), + (buildMovingSlotData n t small bulk samples).Frequencies (fun s => s.natAbs ≤ V) → + movingTopPeriod value hvalue childBound pivotBound + (buildMovingSlotData n t small bulk samples) hf ≤ + ⌊Real.exp (Real.exp ((12 / 1000 : ℝ) * L))⌋₊ := by + filter_upwards [movingSample_period_exponent_budget n C] with L hL + intro value hvalue P V hP hV hvalueP hfreqV hprimeP childBound pivotBound t small bulk samples hf hfreq + apply Nat.le_floor + exact (movingSample_topPeriod_exp value hvalue P V hP hV hvalueP childBound pivotBound + n t small bulk samples hf hfreq _ _ hfreqV hprimeP).trans (Real.exp_le_exp.mpr hL) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPivotDerivative.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPivotDerivative.lean new file mode 100644 index 0000000000000000000000000000000000000000..66540897098ee322a2a813454c5cd0b156297567 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPivotDerivative.lean @@ -0,0 +1,103 @@ +import Mathlib.Analysis.SpecialFunctions.Log.Deriv +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantArchimedean + +namespace OAI + +/-! # Logarithmic differentiation through the actual moving pivot -/ + +namespace Ostmann + +/-- The cancellation cost is derived from the actual child-product and +pivot ranges. The large common logarithmic center cancels exactly. -/ +theorem moving_pivot_cancellation_budget (v w HL HR d p T Δ E C : ℝ) + (hv : |v| ≤ Real.exp E) (hw : |w| ≤ Real.exp E) + (hHL : |HL| ≤ Real.exp (T + C)) (hHR : |HR| ≤ Real.exp (T + C)) + (hden : Real.exp (T - Δ - C) ≤ |d| * p) : + |v * HR| + |w * HL| ≤ Real.exp (Real.log 2 + E + Δ + 2 * C) * (|d| * p) := by + calc + _ ≤ Real.exp E * Real.exp (T + C) + Real.exp E * Real.exp (T + C) := by + rw [abs_mul, abs_mul] + exact add_le_add (mul_le_mul hv hHR (abs_nonneg _) (Real.exp_pos _).le) + (mul_le_mul hw hHL (abs_nonneg _) (Real.exp_pos _).le) + _ = Real.exp (Real.log 2 + E + Δ + 2 * C) * Real.exp (T - Δ - C) := by + symm + rw [← Real.exp_add, show Real.log 2 + E + Δ + 2 * C + (T - Δ - C) = + Real.log 2 + (E + (T + C)) by ring, Real.exp_add, Real.exp_add, + Real.exp_log (by norm_num : (0 : ℝ) < 2)] + ring + _ ≤ _ := mul_le_mul_of_nonneg_left hden (Real.exp_pos _).le + +/-- Relative derivatives are stable through a linear pivot, with precisely +the cancellation factor supplied by the range estimate above. -/ +theorem moving_pivot_relative_derivative (a b d X Y dX dY p A D : ℝ) + (hd : d ≠ 0) (hX : 0 ≤ X) (hY : 0 ≤ Y) (hD : 0 ≤ D) + (hDX : |dX| ≤ D * X) (hDY : |dY| ≤ D * Y) + (hcancel : |a * Y| + |b * X| ≤ A * |d| * p) : + |(a * dY - b * dX) / d| ≤ A * D * p := by + have hleft : |a * dY| ≤ D * |a * Y| := by + rw [abs_mul, abs_mul, abs_of_nonneg hY] + calc + _ ≤ |a| * (D * Y) := mul_le_mul_of_nonneg_left hDY (abs_nonneg _) + _ = _ := by ring + have hright : |b * dX| ≤ D * |b * X| := by + rw [abs_mul, abs_mul, abs_of_nonneg hX] + calc + _ ≤ |b| * (D * X) := mul_le_mul_of_nonneg_left hDX (abs_nonneg _) + _ = _ := by ring + rw [abs_div] + apply (div_le_iff₀ (abs_pos.mpr hd)).mpr + calc + _ ≤ |a * dY| + |b * dX| := by + simpa only [sub_eq_add_neg, abs_neg] using (abs_add_le (a * dY) (-(b * dX))) + _ ≤ D * (|a * Y| + |b * X|) := by nlinarith only [hleft, hright] + _ ≤ D * (A * |d| * p) := mul_le_mul_of_nonneg_left hcancel hD + _ = _ := by ring + +theorem MovingSlotReversal.realPivot_hasDerivAt {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) + {L R : ℝ → ℝ} {x dL dR : ℝ} (hL : HasDerivAt L dL x) (hR : HasDerivAt R dR x) : + HasDerivAt (fun z => step.realPivot value (L z) (R z)) + (step.realPivot value dL dR) x := by + exact ((hR.const_mul ((step.leftFrequency : ℝ) * + (MovingSlotReversal.naturalProduct value step.rightSlots : ℝ))).sub + (hL.const_mul ((step.rightFrequency : ℝ) * + (MovingSlotReversal.naturalProduct value step.leftSlots : ℝ)))).div_const _ + +/-- This is the derivative of the logarithm used by every internal smooth +cutoff. It applies to the literal moving-pivot formula. -/ +theorem MovingSlotReversal.log_realPivot_derivative {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) + {L R : ℝ → ℝ} {x dL dR : ℝ} (hL : HasDerivAt L dL x) (hR : HasDerivAt R dR x) + (hp : 0 < step.realPivot value (L x) (R x)) : + HasDerivAt (fun z => Real.log (step.realPivot value (L z) (R z))) + (step.realPivot value dL dR / step.realPivot value (L x) (R x)) x := + (step.realPivot_hasDerivAt value hL hR).log (ne_of_gt hp) + +/-- The logarithmic derivative costs at most the cancellation factor times +the incoming logarithmic derivative bound. -/ +theorem MovingSlotReversal.log_realPivot_derivative_bound {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) + (X Y dX dY A D : ℝ) (hs : step.rootFrequency ≠ 0) + (hu : MovingSlotReversal.naturalProduct value step.compensationSlots ≠ 0) + (hX : 0 ≤ X) (hY : 0 ≤ Y) (hD : 0 ≤ D) + (hDX : |dX| ≤ D * X) (hDY : |dY| ≤ D * Y) + (hp : 0 < step.realPivot value X Y) + (hcancel : |(step.leftFrequency : ℝ) * + (MovingSlotReversal.naturalProduct value step.rightSlots : ℝ) * Y| + + |(step.rightFrequency : ℝ) * + (MovingSlotReversal.naturalProduct value step.leftSlots : ℝ) * X| ≤ + A * |(step.rootFrequency : ℝ) * + (MovingSlotReversal.naturalProduct value step.compensationSlots : ℝ)| * + step.realPivot value X Y) : + |step.realPivot value dX dY / step.realPivot value X Y| ≤ A * D := by + have hd : (step.rootFrequency : ℝ) * + (MovingSlotReversal.naturalProduct value step.compensationSlots : ℝ) ≠ 0 := + mul_ne_zero (Int.cast_ne_zero.mpr hs) (Nat.cast_ne_zero.mpr hu) + have h := moving_pivot_relative_derivative _ _ _ X Y dX dY + (step.realPivot value X Y) A D hd hX hY hD hDX hDY hcancel + rw [abs_div, abs_of_pos hp] + exact (div_le_iff₀ hp).mpr h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPolynomialRelabel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPolynomialRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..657b95508cf50cd61952da3e2b1f80c1da834c29 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPolynomialRelabel.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotRelabel + +namespace OAI + +/-! # Polynomial transport when repeated prime labels are identified -/ + +namespace Ostmann +open scoped Classical + +noncomputable def PolynomialGiantRows.rename {σ τ : Type*} (f : σ → τ) + (T : PolynomialGiantRows σ) : PolynomialGiantRows τ := + ⟨⟨MvPolynomial.rename f T.rows.a, MvPolynomial.rename f T.rows.b, + MvPolynomial.rename f T.rows.c, MvPolynomial.rename f T.rows.d⟩, + MvPolynomial.rename f T.denominator⟩ + +noncomputable def PolynomialReversal.rename {σ τ : Type*} (f : σ → τ) + (s : PolynomialReversal σ) : PolynomialReversal τ := + ⟨s.left, MvPolynomial.rename f s.v, MvPolynomial.rename f s.w, MvPolynomial.rename f s.u⟩ + +theorem PolynomialGiantRows.rename_movingReverse {σ τ : Type*} (f : σ → τ) + (T : PolynomialGiantRows σ) (b : Bool) (v w u : MvPolynomial σ ℤ) : + (T.movingReverse b v w u).rename f = + (T.rename f).movingReverse b (MvPolynomial.rename f v) + (MvPolynomial.rename f w) (MvPolynomial.rename f u) := by + cases b <;> simp [rename, movingReverse, reverse, swap, GiantRows.swap] + +theorem movingSlotCoefficient_rename {σ τ : Type*} (f : σ → τ) + (s : ℤ) (slots : List σ) : + MvPolynomial.rename f (movingSlotCoefficient s slots) = + movingSlotCoefficient s (slots.map f) := by + simp [movingSlotCoefficient, movingSlotProduct, map_list_prod, List.map_map, Function.comp_def] + +theorem MovingSlotReversal.polynomial_map {σ τ : Type*} (f : σ → τ) + (s : MovingSlotReversal σ) : (s.map f).polynomial = s.polynomial.rename f := by + simp [polynomial, map, PolynomialReversal.rename, movingSlotCoefficient_rename] + +theorem movingPolynomialAncestors_rename {σ τ : Type*} (f : σ → τ) + (steps : List (PolynomialReversal σ)) : + movingPolynomialAncestors (steps.map (PolynomialReversal.rename f)) = + (movingPolynomialAncestors steps).rename f := by + induction steps with + | nil => simp [movingPolynomialAncestors, PolynomialGiantRows.identity, + PolynomialGiantRows.rename, GiantRows.identity] + | cons s steps ih => + simp only [List.map_cons, movingPolynomialAncestors, ih, + PolynomialReversal.rename, PolynomialGiantRows.rename_movingReverse] + +/-- In particular, identifying repeated labels preserves the cleared line +polynomials, including every ancestor denominator. -/ +theorem movingSlotLine_map {σ τ : Type*} (f : σ → τ) + (path : List (MovingSlotReversal σ)) (current : MovingSlotReversal σ) : + let L := movingSlotLine path current + let L' := movingSlotLine (path.map (MovingSlotReversal.map f)) (current.map f) + L'.a = MvPolynomial.rename f L.a ∧ + L'.b = MvPolynomial.rename f L.b ∧ + L'.denominator = MvPolynomial.rename f L.denominator := by + have hs : (path.map (MovingSlotReversal.map f)).map MovingSlotReversal.polynomial = + (path.map MovingSlotReversal.polynomial).map (PolynomialReversal.rename f) := by + simp only [List.map_map] + congr 1 + funext s + exact MovingSlotReversal.polynomial_map f s + simp only [movingSlotLine, hs, movingPolynomialAncestors_rename, movingHistoryLine, + MovingSlotReversal.polynomial_map, PolynomialReversal.rename] + simp [PolynomialGiantRows.numeratorLine, PolynomialGiantRows.rename] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeActualLineComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeActualLineComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f8bcc5b2215a92f6000a2f5c4efc5f8d4c08041 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeActualLineComparison.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeIndexedProbability +import OAI.NumberTheory.Ostmann.Arithmetic.MovingLineProductComparison + +namespace OAI + +/-! # Symbolic replacement for the actual two-history internal line factors -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem moving_prime_actual_line_product_comparison {A J : Type*} + [Fintype A] [Nonempty A] [Fintype J] {N n : ℕ} + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (T : Bool → MovingSlotData (Fin (N + 1)) n) (tier : Fin (N + 1) → ℕ) + (hlevels : ∀ side, (T side).Levels tier) + (rep : J → Fin (N + 1)) (base : ∀ j, MovingPairRepresentativeOccurrences T (rep j)) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ side, (T side).SizeLE d) + (hfreq : ∀ side, (T side).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : Fin (N + 1) → A → ℝ) (hμ : ∀ i a, 0 ≤ μ i a) + (hmass : ∀ i, ∑ a, μ i a = 1) + (α β V : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hmax : ∀ i a, μ i a ≤ α) (hpmax : ∀ j a, μ (rep j) a ≤ β) + (hprimeSize : ∀ j a, μ (rep j) a ≠ 0 → V ≤ Real.log (prime a : ℝ)) + (weight : (Fin (N + 1) → A) → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hweight : ∀ x, ‖weight x‖ * ∏ j, internalLineScalar false (prime (x (rep j))) ≤ B) + (hdisjoint : ∀ x, weight x ≠ 0 → ∀ i j, + tier i ≠ tier j → prime (x i) ≠ prime (x j)) + (hunique : ∀ x, weight x ≠ 0 → ∀ j i, prime (x i) = prime (x (rep j)) → i = rep j) + (hfmod : ∀ x, weight x ≠ 0 → ∀ j side, + (T side).Frequencies (fun s => (s : ZMod (prime (x (rep j)))) ≠ 0)) : + ‖∑ x, (productPrior μ x : ℂ) * weight x * + ((∏ j, (movingSampledInternalPrimeProbability prime hprime T x (rep j) : ℂ)) - + ∏ j, (internalLineFlagWeight false (prime (x (rep j))) + (fun s => arithmeticTestFlag (lineTestPolynomials + (movingIndexedLine T (rep j) (base j)) ⟨(base j).1, (base j).2.val⟩ s = 0)) : ℂ))‖ ≤ + 2 * B * (Fintype.card J * (2 + Fintype.card (MovingPairOccurrenceIndex T))) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β) := by + let path := fun j o => (movingIndexedOccurrence T (rep j) (base j) o).path + let current := fun j o => (movingIndexedOccurrence T (rep j) (base j) o).current + let b : J → MovingPairOccurrenceIndex T := fun j => ⟨(base j).1, (base j).2.val⟩ + have hi : Function.Injective (fun a => (prime a : ℤ)) := by + intro a b h + apply hpInj + exact Int.ofNat.inj h + have hu (x : Fin (N + 1) → A) (hx : weight x ≠ 0) (j : J) (o : MovingPairOccurrenceIndex T) := + movingIndexedOccurrence_units T tier (fun i => prime (x i)) (fun i => hprime (x i)) + (hdisjoint x hx) hlevels (rep j) (base j) (hfmod x hx j) o + have h := moving_slot_line_product_comparison (fun a => (prime a : ℤ)) hi prime hpInj hprime + path current b rep (fun _ => false) n d F U hF hU + (fun j o => movingIndexedOccurrence_path_length T tier hlevels (rep j) (base j) o) + (fun j o => movingIndexedOccurrence_size T d F hsize hfreq (rep j) (base j) o) + (fun j o => movingIndexedOccurrence_absent T tier hlevels (rep j) (base j) o) + hvalues μ hμ hmass α β V hα hβ hV hmax hpmax hprimeSize weight B hB hweight + (by + intro x hx j o s hs + simpa only [integerLineReduction, MovingSlotReversal.naturalReduction, Int.cast_natCast] using + (hu x hx j o).1 s hs) + (by + intro x hx j + simpa only [integerLineReduction, MovingSlotReversal.naturalReduction, Int.cast_natCast] using + (hu x hx j (b j)).2) + have he (x : Fin (N + 1) → A) : + weight x * (∏ j, (movingSampledInternalPrimeProbability prime hprime T x (rep j) : ℂ)) = + weight x * ∏ j, (movingSlotLineProbability (fun a => (prime a : ℤ)) prime hprime + (path j) (current j) false x (x (rep j)) : ℂ) := by + by_cases hx : weight x = 0 + · simp only [hx, zero_mul] + · congr 1 + apply Finset.prod_congr rfl + intro j _ + exact congrArg (fun r : ℝ => (r : ℂ)) + (movingSampledIndexedPrimeProbability prime hprime x T tier (hdisjoint x hx) hlevels + (rep j) (base j) (hunique x hx j) (hfmod x hx j)) + convert h using 1 + congr 1 + apply Finset.sum_congr rfl + intro x _ + rw [mul_assoc, mul_sub, he, ← mul_sub, ← mul_assoc] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeArithmeticTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeArithmeticTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..970b233847b22dbe33c2e63627513ffd260124d0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeArithmeticTransfer.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeRowTransfer +import OAI.NumberTheory.Ostmann.Construction.OriginalPivotTransfer + +namespace OAI + +/-! # The weighted giant-only integer substitution of Section 7.5 -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- The inserted giant is `N / (s * U)`. The compensation product `U` is +retained, so the reconstructed integer is the giant and not the whole pivot. -/ +noncomputable def movingGiantOffDiagonal {A : Type*} [Fintype A] + (I : Finset ℕ) (V U : ℕ) (L : A → ℕ) (v : A → ℤ) + (w : ℕ → ℝ) (c : ℕ → A → ℂ) : ℂ := + ∑ s ∈ transferFrequencyRange V, ∑ a, ∑ b, + if validTransferredPivot I (v a * L b - v b * L a) (s * U) then + let p := reconstructedPivot (v a * L b - v b * L a) (s * U) + (w p : ℂ) * c p a * conj (c p b) + else 0 + +/-- The exact weighted off-diagonal, with the original coefficient support +and without any multiplicity factor in the integer substitution. -/ +theorem movingGiantOffDiagonal_eq {A : Type*} [Fintype A] + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) (U : ℕ) (hU : 0 < U) + (B H V : ℕ) (L : A → ℕ) (v : A → ℤ) (w : ℕ → ℝ) (c : ℕ → A → ℂ) + (hv : ∀ p ∈ I, ∀ a, c p a ≠ 0 → (v a).natAbs ≤ B) + (hL : ∀ p ∈ I, ∀ a, c p a ≠ 0 → L a ≤ H) + (hscale : ∀ p ∈ I, 2 * B * H ≤ V * (p * U)) : + (∑ p ∈ I, (w p : ℂ) * pivotOffDiagonal (p * U) L v (c p)) = + movingGiantOffDiagonal I V U L v w c := by + have hUnz : (U : ℤ) ≠ 0 := by exact_mod_cast hU.ne' + have he (p : ℕ) (s : ℤ) (a b : A) : + (s ≠ 0 ∧ v a * L b - v b * L a = s * ((p * U : ℕ) : ℤ)) ↔ + (s * (U : ℤ) ≠ 0 ∧ v a * L b - v b * L a = (s * U) * p) := by + have hmul : s * ((p * U : ℕ) : ℤ) = (s * U) * p := by push_cast; ring + rw [hmul] + constructor + · rintro ⟨hs, hh⟩ + exact ⟨mul_ne_zero hs hUnz, hh⟩ + · rintro ⟨hs, hh⟩ + exact ⟨left_ne_zero_of_mul hs, hh⟩ + calc + _ = ∑ p ∈ I, ∑ s ∈ transferFrequencyRange V, ∑ a, ∑ b, + if s * (U : ℤ) ≠ 0 ∧ v a * L b - v b * L a = (s * U) * p + then (w p : ℂ) * c p a * conj (c p b) else 0 := by + apply Finset.sum_congr rfl + intro p hp + rw [pivotOffDiagonal_frequency_on_support (p * U) B H V + (Nat.mul_pos (hI p hp) hU) L v (c p) (hv p hp) (hL p hp) (hscale p hp)] + simp only [Finset.mul_sum, mul_ite, mul_zero] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + simp only [he p s a b, mul_assoc] + _ = movingGiantOffDiagonal I V U L v w c := by + unfold movingGiantOffDiagonal + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro s _ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro b _ + exact transferred_pivot_substitution I hI _ (s * U) + (fun p => (w p : ℂ) * c p a * conj (c p b)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeAverages.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeAverages.lean new file mode 100644 index 0000000000000000000000000000000000000000..0bb02fe1532ac7995982016c940b311d435ecffd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeAverages.lean @@ -0,0 +1,130 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeFrequencyAverage +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSpectatorAbsolute + +namespace OAI + +/-! # The exact local factors in the final two-prime environment -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingInternalPrimeAverage {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : ℂ := + (Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + ∑ z : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ, + movingInternalPairFactor value T p z.1 z.2 + +noncomputable def movingSpectatorPrimeAverage {σ : Type*} (value : σ → ℕ) + (p : ℕ) [Fact p.Prime] (g : ZMod p → ℂ) (D : Bool → (ZMod p)ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) : ℂ := + (Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) : ℂ)⁻¹ * + ∑ z : (ZMod p)ˣ × (ZMod p)ˣ, movingSpectatorPairFactor value p g D T z.1 z.2 + +noncomputable def frozenBulkSpectatorPrime {σ : Type*} {p : ℕ} [Fact p.Prime] + (base : σ → ℕ) (n m : ℕ) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List σ) n) (samples : Bool → MovingSampleSlots σ n) + (D : Bool → (ZMod p)ˣ) (e : Equiv.Perm (TreeLeafIndex n × Fin m)) (g : ZMod p → ℂ) + (z : TreeLeafIndex n × Fin m → (ZMod p)ˣ) : ℂ := + (Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) : ℂ)⁻¹ * + ∑ a, frozenBulkSpectatorPair base n m t small samples D e g a z + +theorem movingArithmeticPrimePageFactor_averages {σ I : Type*} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : Bool → ∀ i, (ZMod (q i))ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (P : Finset ℕ) (S : Finset I) + [∀ p : P, Fact p.val.Prime] [∀ b, NeZero (movingArithmeticModuli r q P S b)] + (input : PublishedProgressionInput) (Q : ℕ) (x y : ℝ) : + (∏ b, (Fintype.card ((ZMod (movingArithmeticModuli r q P S b))ˣ × + (ZMod (movingArithmeticModuli r q P S b))ˣ) : ℂ)⁻¹ * + ∑ z, movingArithmeticPrimePageFactor r q P S input Q x y + (movingArithmeticLocalFactor q value outside F E g D T nodes R r P S) b z) = + movingFrequencyPrimeAverage value outside F E T nodes R r input Q x y * + (∏ p : P, movingInternalPrimeAverage value T p.val) * + ∏ i : S, movingSpectatorPrimeAverage value (q i.val) (g i.val) + (fun side => D side i.val) T := by + simp only [Fintype.prod_sum_type, Fintype.prod_unique, movingArithmeticPrimePageFactor, + movingArithmeticLocalFactor, movingArithmeticModuli, movingFrequencyPrimeAverage, + correctedPrimePairAverage, movingInternalPrimeAverage, movingSpectatorPrimeAverage] + rw [← mul_assoc] + congr 4 + +/-- Both exceptional-character multipliers remain in the frequency factor. +All internal and spectator factors have the literal two-unit law. -/ +theorem movingSeparatedPairResidueCoefficient_prime_page_factorization {σ I : Type*} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : Bool → ∀ i, (ZMod (q i))ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (P : Finset ℕ) (S : Finset I) + [∀ p : P, Fact p.val.Prime] [∀ b, NeZero (movingArithmeticModuli r q P S b)] + [NeZero (∏ b, movingArithmeticModuli r q P S b)] + (hf : ∀ side, (T side).Frequencies (· ≠ 0)) + (hR : ∀ side, (T side).frequencyProduct ∣ R) + (hfrequency : R ^ (n + 1) ∣ (r : ℤ)) + (hcover : ∀ side, ∀ o ∈ (T side).occurrences, + ∀ i ∈ o.current.compensationSlots, value i ∈ P) + (hc : Pairwise (fun b c => (movingArithmeticModuli r q P S b).Coprime + (movingArithmeticModuli r q P S c))) + (input : PublishedProgressionInput) (Q : ℕ) + (hpage : pageAtModulus (∏ b, movingArithmeticModuli r q P S b) (selectedPageZero input Q) = + pageAtModulus r (selectedPageZero input Q)) (x y : ℝ) : + correctedPrimePairAverage input Q (∏ b, movingArithmeticModuli r q P S b) + (movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R) x y = + movingFrequencyPrimeAverage value outside F E T nodes R r input Q x y * + (∏ p : P, movingInternalPrimeAverage value T p.val) * + ∏ i : S, movingSpectatorPrimeAverage value (q i.val) (g i.val) + (fun side => D side i.val) T := by + rw [movingSeparatedPairResidueCoefficient_prime_page_average q value outside F E g D T nodes + R r P S hf hR hfrequency hcover hc input Q hpage] + exact movingArithmeticPrimePageFactor_averages q value outside F E g D T nodes R r P S input Q x y + +theorem frozenBulkSpectatorPrime_actual {σ : Type*} {q : ℕ} [Fact q.Prime] + (base : σ → ℕ) (n m : ℕ) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List σ) n) (samples : Bool → MovingSampleSlots σ n) + (D : Bool → (ZMod q)ˣ) (e : Equiv.Perm (TreeLeafIndex n × Fin m)) + (value : σ → ℕ) + (hv : ∀ b, movingSlotValues value n (small b) = movingSlotValues base n (small b)) + (hs : ∀ b, (samples b).values value = (samples b).values base) + (slot : TreeLeafIndex n × Fin m → σ) (g : ZMod q → ℂ) + (z : TreeLeafIndex n × Fin m → (ZMod q)ˣ) + (hz : ∀ j, (value (slot j) : ZMod q) = (z j : ZMod q)) : + movingSpectatorPrimeAverage value q g D + (fun b => buildMovingSlotData n (t b) (small b) + (if b then bulkSlotLeaves n m (slot ∘ e.symm) else bulkSlotLeaves n m slot) + (samples b)) = frozenBulkSpectatorPrime base n m t small samples D e g z := by + unfold movingSpectatorPrimeAverage frozenBulkSpectatorPrime + apply congrArg ((Fintype.card ((ZMod q)ˣ × (ZMod q)ˣ) : ℂ)⁻¹ * ·) + apply Finset.sum_congr rfl + intro a _ + exact frozenBulkSpectatorPair_actual base n m t small samples D e value hv hs slot g a z hz + +/-- The original two-prime spectator average has the same absolute third +moment bound, without a density correction. -/ +theorem frozenBulkSpectatorPrime_absolute_mean_le {σ : Type*} {q : ℕ} [Fact q.Prime] + (hq : 3 ≤ q) (base : σ → ℕ) (n m : ℕ) (hm : 0 < m) + (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List σ) n) (samples : Bool → MovingSampleSlots σ n) + (hfreq : ∀ b, movingGiantFrequencyUnits q n (t b)) + (hsmall : ∀ b, ((treeLeafProduct n (movingSlotValues base n (small b)) : ℕ) : ZMod q) ≠ 0) + (hsamples : ∀ b, ((samples b).values base).UnitsAt q) + (D : Bool → (ZMod q)ˣ) (e : Equiv.Perm (TreeLeafIndex n × Fin m)) + (g : ZMod q → ℂ) (hg : g 0 = 0) (henergy : ∑ x : ZMod q, ‖g x‖ ^ 2 ≤ (q : ℝ)) : + (Fintype.card (TreeLeafIndex n × Fin m → (ZMod q)ˣ) : ℝ)⁻¹ * + (∑ z : TreeLeafIndex n × Fin m → (ZMod q)ˣ, + ‖frozenBulkSpectatorPrime base n m t small samples D e g z‖) ≤ (3 : ℝ) ^ (2 ^ n) := by + have h := uniform_average_norm_average_mul_le + (A := TreeLeafIndex n × Fin m → (ZMod q)ˣ) + (B := (ZMod q)ˣ × (ZMod q)ˣ) + (fun z a => frozenBulkSpectatorPair base n m t small samples D e g a z) + (fun _ => 1) 1 ((3 : ℝ) ^ (2 ^ n)) (by norm_num) (fun _ => by simp) + (fun a => frozenBulkSpectatorPair_absolute_mean_le hq base n m hm t small samples + hfreq hsmall hsamples D e g hg henergy a) + simpa only [mul_one, one_mul, frozenBulkSpectatorPrime] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeBaseAverage.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeBaseAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..08f177ea976ffa4489ac8c0f308552f16be33da6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeBaseAverage.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalBaseAverage +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticLineIntegration + +namespace OAI + +/-! # Actual internal-prime averages after removing their square exclusions -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The field average is the exact simultaneous line probability for all +occurrences of the prime in both original histories. -/ +theorem movingInternalBaseFactor_prime_average {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : + (Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) : ℂ)⁻¹ * + (∑ z : (ZMod p)ˣ × (ZMod p)ˣ, movingInternalBaseFactor value T p z.1 z.2) = + (internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) : ℂ) := by + classical + let P := fun z : (ZMod p)ˣ × (ZMod p)ˣ => ∀ j : MovingPrimeOccurrences value T p, + let φ := MovingSlotReversal.naturalReduction p value + let L := movingPrimeOccurrenceLine value T p j + φ L.a * z.1 + φ L.b * z.2 = 0 + have hs : (∑ z : (ZMod p)ˣ × (ZMod p)ˣ, movingInternalBaseFactor value T p z.1 z.2) = + (Fintype.card {z : (ZMod p)ˣ × (ZMod p)ˣ // P z} : ℂ) := by + rw [Fintype.card_subtype] + simp only [movingInternalBaseFactor, P, ← Finset.sum_filter, Finset.sum_const, + nsmul_eq_mul, mul_one] + dsimp only [P] at hs + rw [hs] + simp only [internalLineProbability, Bool.false_eq_true, ite_false, Complex.ofReal_div, Complex.ofReal_natCast] + rw [mul_comm, ← div_eq_mul_inv] + simp only [← Nat.card_eq_fintype_card] + +/-- All rows and all cleared denominators in this line probability come from +the actual moving trees. Thus the polynomial flags used later are exact. -/ +theorem movingInternalPrimeProbability_eq_flags {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) [Fact p.Prime] + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) + (base : MovingPrimeOccurrences value T p) : + internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) = + internalLineFlagWeight false p (fun s => arithmeticTestFlag + (MovingSlotReversal.naturalReduction p value + (lineTestPolynomials (movingPrimeOccurrenceLine value T p) base s) = 0)) := by + classical + let φ := MovingSlotReversal.naturalReduction p value + let L := movingPrimeOccurrenceLine value T p + have hd := movingPrimeOccurrenceLine_denominator_ne_zero tier value hprime hdisjoint T hlevels p hf + have hr := movingPrimeOccurrenceLine_nonzero tier value hprime hdisjoint T hlevels p hf base + have he (x y : ZMod p) : (∀ j, φ (L j).a * x + φ (L j).b * y = 0) ↔ + (∀ j, ((L j).normalized φ).1 * x + ((L j).normalized φ).2 * y = 0) := by + apply forall_congr' + intro j + simp only [PolynomialGiantLine.normalized] + rw [div_mul_eq_mul_div, div_mul_eq_mul_div, ← add_div, div_eq_zero_iff, or_iff_left (hd j)] + have hc := Nat.card_congr (Equiv.subtypeEquivRight + (fun z : (ZMod p)ˣ × (ZMod p)ˣ => he z.1 z.2)) + have hr' : ((L base).normalized φ).1 ≠ 0 ∨ ((L base).normalized φ).2 ≠ 0 := by + have hz := (L base).normalized_zero_iff φ (hd base) + exact hr.imp (fun h h0 => h (hz.1.mp h0)) (fun h h0 => h (hz.2.mp h0)) + have hext := unit_lineSystem_integral_eq_flags L base φ hd hr' + unfold internalLineProbability + simp only [Bool.false_eq_true, ite_false, ← Nat.card_eq_fintype_card] + simp only [← Nat.card_eq_fintype_card] at hext + change (Nat.card {z : (ZMod p)ˣ × (ZMod p)ˣ // + ∀ j, φ (L j).a * z.1 + φ (L j).b * z.2 = 0} : ℝ) / + Nat.card ((ZMod p)ˣ × (ZMod p)ˣ) = _ + rw [hc] + exact hext + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeBulkSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeBulkSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..4546d98452ff3f1c9a871a86271dee6b7423c932 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeBulkSupport.lean @@ -0,0 +1,243 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenPrimeArithmeticNorm +import OAI.NumberTheory.Ostmann.Arithmetic.BulkCollisionSupport + +namespace OAI + +/-! # The unchanged nonbulk guards and bulk residues under two giant primes -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingFrequencyCorePrimeAverage_bulk_residues {σ J : Type*} + (base value : σ → ℕ) (e : J ↪ σ) (hv : ∀ i ∉ Set.range e, value i = base i) + (r : ℕ) [NeZero r] (a : J → (ZMod r)ˣ) + (ha : ∀ j, (value (e j) : ZMod r) = (a j : ZMod r)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (R : ℤ) + (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hT : ∀ b j, (T b).CompensationAbsent (e j)) + (hR : ∀ b, (T b).frequencyProduct ∣ R) (hr : R ^ (n + 1) ∣ (r : ℤ)) + (input : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) : + movingFrequencyCorePrimeAverage value F E T R r input Q xg y = + movingFrequencyCorePrimeAverage (Function.extend e (fun j => (a j).val.val) base) + F E T R r input Q xg y := by + unfold movingFrequencyCorePrimeAverage + apply congrArg ((Fintype.card ((ZMod r)ˣ × (ZMod r)ˣ) : ℂ)⁻¹ * ·) + apply Finset.sum_congr rfl + intro z _ + rw [movingFrequencyCore_bulk_residues value e r a ha F E T R hf hT hR hr, + extend_eq_of_eq_off_range e _ value base hv] + +theorem movingFrequencyPrimeAverage_nonbulk {σ : Type*} + (value base : σ → ℕ) (bulk : σ → Bool) (outside : List ℕ) + (hv : ∀ i, bulk i = false → value i = base i) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (hprime : ∀ b, ∀ L ∈ (T b).regularLists, ∀ i ∈ L, (value i).Prime) + (hnodup : ∀ b, ∀ L ∈ (T b).regularLists, (L.filter bulk).Nodup) + (hinj : ∀ i j, bulk i = true → bulk j = true → value i = value j → i = j) + (hcross : ∀ b, ∀ L ∈ (T b).regularLists, ∀ i ∈ L, ∀ j ∈ L, + bulk i ≠ bulk j → value i ≠ value j) + (hout : ∀ b, ∀ L ∈ (T b).regularLists, ∀ i ∈ L, bulk i = true → + ∀ p ∈ outside, (value i).Coprime p) + (R : ℤ) (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) : + movingFrequencyPrimeAverage value outside F E T nodes R r input Q xg y = + (if ∀ b, movingNonbulkOutsidePairwise base bulk outside (T b) ∧ + (∀ f ∈ nodes b, f.guard.frequencyBounds) then (1 : ℂ) else 0) * + movingFrequencyCorePrimeAverage value F E T R r input Q xg y := by + have hsupport : (∀ b, movingRegularOutsidePairwise value outside (T b) ∧ + (∀ f ∈ nodes b, f.guard.frequencyBounds)) ↔ + (∀ b, movingNonbulkOutsidePairwise base bulk outside (T b) ∧ + (∀ f ∈ nodes b, f.guard.frequencyBounds)) := by + apply forall_congr' + intro b + exact and_congr (movingRegularOutsidePairwise_frozen value base bulk outside (T b) + hv (hprime b) (hnodup b) hinj (hcross b) (hout b)) Iff.rfl + rw [movingFrequencyPrimeAverage_core] + simp only [hsupport] + +/-- For the literal formula-node list, the remaining frequency-size tests +depend on the frequency tree alone. -/ +theorem movingFrequencyPrimeAverage_actual_nonbulk {σ : Type*} + (value base : σ → ℕ) (bulk : σ → Bool) (outside : List ℕ) + (hv : ∀ i, bulk i = false → value i = base i) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hprime : ∀ b, ∀ L ∈ (T b).regularLists, ∀ i ∈ L, (value i).Prime) + (hnodup : ∀ b, ∀ L ∈ (T b).regularLists, (L.filter bulk).Nodup) + (hinj : ∀ i j, bulk i = true → bulk j = true → value i = value j → i = j) + (hcross : ∀ b, ∀ L ∈ (T b).regularLists, ∀ i ∈ L, ∀ j ∈ L, + bulk i ≠ bulk j → value i ≠ value j) + (hout : ∀ b, ∀ L ∈ (T b).regularLists, ∀ i ∈ L, bulk i = true → + ∀ p ∈ outside, (value i).Coprime p) + (R : ℤ) (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) : + movingFrequencyPrimeAverage value outside F E T + (fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) + (.prime false) (.prime true)) R r input Q xg y = + (if ∀ b, movingNonbulkOutsidePairwise base bulk outside (T b) ∧ + (T b).FrequencyBounds childBound then (1 : ℂ) else 0) * + movingFrequencyCorePrimeAverage value F E T R r input Q xg y := by + rw [movingFrequencyPrimeAverage_nonbulk value base bulk outside hv F E T _ + hprime hnodup hinj hcross hout] + have he : (∀ b, movingNonbulkOutsidePairwise base bulk outside (T b) ∧ + ∀ f ∈ (T b).formulaNodes value hvalue childBound pivotBound (hf b) + (.prime false) (.prime true), f.guard.frequencyBounds) ↔ + (∀ b, movingNonbulkOutsidePairwise base bulk outside (T b) ∧ + (T b).FrequencyBounds childBound) := by + apply forall_congr' + intro b + exact and_congr Iff.rfl ((T b).formulaNodes_frequencyBounds value hvalue childBound + pivotBound (hf b) (.prime false) (.prime true)) + simp only [he] + +theorem movingPrimeCoreSpectator_bulk_residues {σ I : Type*} [Fintype I] + (base value : σ → ℕ) (n m : ℕ) (slot : (TreeLeafIndex n × Fin m) ↪ σ) + (hv : ∀ i ∉ Set.range slot, value i = base i) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List σ) n) + (samples : Bool → MovingSampleSlots σ n) + (hvsmall : ∀ b, movingSlotValues value n (small b) = movingSlotValues base n (small b)) + (hvsamples : ∀ b, (samples b).values value = (samples b).values base) + (e : Equiv.Perm (TreeLeafIndex n × Fin m)) + (T : Bool → MovingSlotData σ n) + (hT : ∀ b, T b = buildMovingSlotData n (t b) (small b) + (if b then bulkSlotLeaves n m (slot ∘ e.symm) else bulkSlotLeaves n m slot) (samples b)) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℤ → ℤ → ℝ) + (R : ℤ) (r : ℕ) [NeZero r] + (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hcomp : ∀ b j, (T b).CompensationAbsent (slot j)) + (hR : ∀ b, (T b).frequencyProduct ∣ R) (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (D : ∀ i, Bool → (ZMod (p i))ˣ) + (z : TreeLeafIndex n × Fin m → (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hz : ∀ j, (value (slot j) : ZMod (∏ i, bulkResidueModuli r p i)) = (z j : ZMod _)) + (input : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) : + movingFrequencyCorePrimeAverage value F E T R r input Q xg y * + ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (D i) T = + movingFrequencyCorePrimeAverage + (Function.extend slot (fun j => ((bulkResidueEquiv r p hc z).1 j).val.val) base) + F E T R r input Q xg y * + ∏ i, frozenBulkSpectatorPrime base n m t small samples (D i) e (g i) + ((bulkResidueEquiv r p hc z).2 i) := by + rw [movingFrequencyCorePrimeAverage_bulk_residues base value slot hv r + (bulkResidueEquiv r p hc z).1 + (bulkResidueEquiv_frequency_lift r p hc (value ∘ slot) z hz) + F E T R hf hcomp hR hr input Q xg y] + congr 1 + apply Finset.prod_congr rfl + intro i _ + have ht : T = fun b => buildMovingSlotData n (t b) (small b) + (if b then bulkSlotLeaves n m (slot ∘ e.symm) else bulkSlotLeaves n m slot) (samples b) := + funext hT + rw [ht] + exact frozenBulkSpectatorPrime_actual base n m t small samples (D i) e value + hvsmall hvsamples slot (g i) ((bulkResidueEquiv r p hc z).2 i) + (bulkResidueEquiv_spectator_lift r p hc (value ∘ slot) z hz i) + +theorem movingSupportedPrimeArithmetic_bulk_residues {σ I : Type*} [Fintype I] + (base value : σ → ℕ) (n m : ℕ) (slot : (TreeLeafIndex n × Fin m) ↪ σ) + (hv : ∀ i ∉ Set.range slot, value i = base i) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List σ) n) + (samples : Bool → MovingSampleSlots σ n) + (hvsmall : ∀ b, movingSlotValues value n (small b) = movingSlotValues base n (small b)) + (hvsamples : ∀ b, (samples b).values value = (samples b).values base) + (e : Equiv.Perm (TreeLeafIndex n × Fin m)) + (T : Bool → MovingSlotData σ n) + (hT : ∀ b, T b = buildMovingSlotData n (t b) (small b) + (if b then bulkSlotLeaves n m (slot ∘ e.symm) else bulkSlotLeaves n m slot) (samples b)) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℤ → ℤ → ℝ) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hprime : ∀ b, ∀ L ∈ (T b).regularLists, ∀ i ∈ L, (value i).Prime) + (hnodup : ∀ b, ∀ L ∈ (T b).regularLists, + (L.filter (bulkIndexPredicate slot)).Nodup) + (hinj : Function.Injective (value ∘ slot)) + (hcross : ∀ b, ∀ L ∈ (T b).regularLists, ∀ i ∈ L, ∀ j ∈ L, + bulkIndexPredicate slot i ≠ bulkIndexPredicate slot j → value i ≠ value j) + (hout : ∀ b, ∀ L ∈ (T b).regularLists, ∀ i ∈ L, i ∈ Set.range slot → + ∀ p ∈ outside, (value i).Coprime p) + (R : ℤ) (r : ℕ) [NeZero r] + (hcomp : ∀ b j, (T b).CompensationAbsent (slot j)) + (hR : ∀ b, (T b).frequencyProduct ∣ R) (hr : R ^ (n + 1) ∣ (r : ℤ)) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (hc : Pairwise (fun i j => (bulkResidueModuli r p i).Coprime (bulkResidueModuli r p j))) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (D : ∀ i, Bool → (ZMod (p i))ˣ) + (z : TreeLeafIndex n × Fin m → (ZMod (∏ i, bulkResidueModuli r p i))ˣ) + (hz : ∀ j, (value (slot j) : ZMod (∏ i, bulkResidueModuli r p i)) = (z j : ZMod _)) + (input : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) : + movingFrequencyPrimeAverage value outside F E T + (fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) + (.prime false) (.prime true)) R r input Q xg y * + ∏ i, movingSpectatorPrimeAverage value (p i) (g i) (D i) T = + frozenBulkFrequencyPrime base slot outside F E T childBound R r input Q xg y + (bulkResidueEquiv r p hc z).1 * + ∏ i, frozenBulkSpectatorPrime base n m t small samples (D i) e (g i) + ((bulkResidueEquiv r p hc z).2 i) := by + have hinj' : ∀ i j, bulkIndexPredicate slot i = true → + bulkIndexPredicate slot j = true → value i = value j → i = j := by + intro i j hi hj hij + obtain ⟨a, rfl⟩ := (bulkIndexPredicate_eq_true slot i).mp hi + obtain ⟨b, rfl⟩ := (bulkIndexPredicate_eq_true slot j).mp hj + exact congrArg slot (hinj hij) + rw [movingFrequencyPrimeAverage_actual_nonbulk value base + (bulkIndexPredicate slot) outside + (fun i hi => hv i ((bulkIndexPredicate_eq_false slot i).mp hi)) hvalue childBound pivotBound F E T hf + hprime hnodup hinj' hcross (fun b L hL i hi hb => hout b L hL i hi ((bulkIndexPredicate_eq_true slot i).mp hb))] + rw [mul_assoc, movingPrimeCoreSpectator_bulk_residues base value n m slot hv t small samples + hvsmall hvsamples e T hT F E R r hf hcomp hR hr p hc g hg D z hz input Q xg y] + simp only [frozenBulkFrequencyPrime, mul_assoc, finite_univ_canonical] + +theorem movingFrequencyPrimeAverage_zero_of_bulk_collision {σ : Type*} + (value : σ → ℕ) (n m : ℕ) (slot : (TreeLeafIndex n × Fin m) ↪ σ) + (t : FrequencyTree ℤ n) (small : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) (outside : List ℕ) + (hprime : ∀ i, (value i).Prime) (hbad : ¬Function.Injective (value ∘ slot)) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℤ → ℤ → ℝ) + (T : Bool → MovingSlotData σ n) + (hT : T false = buildMovingSlotData n t small (bulkSlotLeaves n m slot) samples) + (nodes : Bool → List MovingFormulaNode) (R : ℤ) + (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) : + movingFrequencyPrimeAverage value outside F E T nodes R r input Q xg y = 0 := by + have hsupport : ¬(∀ b, movingRegularOutsidePairwise value outside (T b) ∧ + ∀ f ∈ nodes b, f.guard.frequencyBounds) := by + intro hs + apply hbad + apply buildMovingSlotData_injective_of_support value n m slot t small samples outside hprime + rw [← hT] + exact (hs false).1 + rw [movingFrequencyPrimeAverage_core] + simp only [hsupport, ite_false, zero_mul] + +/-- Inserting the distinctness gate leaves the literal supported arithmetic +coefficient unchanged. -/ +theorem movingFrequencyPrimeAverage_collision_gate {σ : Type*} + (value : σ → ℕ) (n m : ℕ) (slot : (TreeLeafIndex n × Fin m) ↪ σ) + (t : FrequencyTree ℤ n) (small : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) (outside : List ℕ) + (hprime : ∀ i, (value i).Prime) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℤ → ℤ → ℝ) + (T : Bool → MovingSlotData σ n) + (hT : T false = buildMovingSlotData n t small (bulkSlotLeaves n m slot) samples) + (nodes : Bool → List MovingFormulaNode) (R : ℤ) + (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) (xg y : ℝ) (A : ℂ) : + movingFrequencyPrimeAverage value outside F E T nodes R r input Q xg y * A = + if Function.Injective (value ∘ slot) then + movingFrequencyPrimeAverage value outside F E T nodes R r input Q xg y * A else 0 := by + by_cases h : Function.Injective (value ∘ slot) + · simp only [h, ite_true] + · rw [ite_eq_right h, movingFrequencyPrimeAverage_zero_of_bulk_collision value n m slot + t small samples outside hprime h F E T hT nodes R r input Q xg y, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeCoefficientNode.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeCoefficientNode.lean new file mode 100644 index 0000000000000000000000000000000000000000..8f9e4ecd078f0a49a97ed98d94e21cedc9dbc293 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeCoefficientNode.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeNodeFactor +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRootedSum + +namespace OAI + +/-! # The complete coefficient recursion at actual top primes -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingFrequencyCoefficient_zero {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) + (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) : + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G + n 0 small bulk XL XR = 0 := by + unfold movingFrequencyCoefficient + apply Finset.sum_eq_zero + intro t _ + apply movingSupportedSampledWeight_zero_frequency value outside μ childBound pivotBound + F _ hF n _ small bulk XL XR + intro h + apply h 0 + · cases n with + | zero => exact List.mem_singleton_self _ + | succ n => exact List.mem_cons_self + · rfl + +/-- At actual prime giants, the original coefficient is the product recursion +in the two complete child coefficients. The shared compensation prior occurs +once, and every child retains its own descendant frequency and prime samples. -/ +theorem movingFrequencyCoefficient_prime_node {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (hs : s ≠ 0) (hsV : s.natAbs ≤ V (n + 1)) + (small bulk : TreeLeafTuple (List σ) (n + 1)) (XL XR : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) + (hVL : V (n + 1) < XL) (hVR : V (n + 1) < XR) : + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G + (n + 1) s small bulk XL XR = + ∑ a : TreeLeafTuple (Fin 4 → σ) n, (movingCompensationPrior (μ n) n a : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let p := movingTopPivot value CL CR (flattenMovingSlots n u) XL XR s v.val w.val + movingPrimeNodeFactor value outside childBound pivotBound φ G n CL CR + (flattenMovingSlots n u) XL XR s v.val w.val * + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n v.val + (appendMovingSlotLeaves n u small.1) bulk.1 p XL * + star (movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n w.val + (appendMovingSlotLeaves n u small.2) bulk.2 p XR) := by + rw [movingFrequencyCoefficient_node] + simp_rw [movingPrimeNodeFactor_term value outside μ childBound pivotBound V hV F hF + φ G n s hs hsV _ _ small bulk _ XL XR hXL hXR hVL hVR] + conv_lhs => + arg 2 + ext l + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + simp_rw [← Finset.mul_sum] + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let P := fun v w : ℤ => movingTopPivot value CL CR (flattenMovingSlots n u) XL XR s v w + let W := fun v w : ℤ => movingPrimeNodeFactor value outside childBound pivotBound φ G n + CL CR (flattenMovingSlots n u) XL XR s v w + let L := fun v w t => movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n t + (appendMovingSlotLeaves n u small.1) bulk.1 (P v w) XL + let R := fun v w t => movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n t + (appendMovingSlotLeaves n u small.2) bulk.2 (P v w) XR + have h := scheduledFrequency_bilinear_sum V n W L R + unfold movingFrequencyCoefficient + apply congrArg (fun z : ℂ => (movingCompensationPrior (μ n) n a : ℂ) * z) + exact h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeDominatedLineComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeDominatedLineComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..1c100c786bcf419575264456b5f594d5278dc207 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeDominatedLineComparison.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeActualLineComparison +import OAI.NumberTheory.Ostmann.ZeroDensity.FinitePriorDensity + +namespace OAI + +/-! # Symbolic line comparison under the dominated equality-pattern law -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The complete original pattern weight may be used directly once its product +of line scalars is dominated by the representative priors. In particular, the +pattern law is not assumed to be independent. -/ +theorem moving_prime_dominated_line_product_comparison {A J : Type*} + [Fintype A] [Nonempty A] [Fintype J] {N n : ℕ} + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (T : Bool → MovingSlotData (Fin (N + 1)) n) (tier : Fin (N + 1) → ℕ) + (hlevels : ∀ side, (T side).Levels tier) + (rep : J → Fin (N + 1)) (base : ∀ j, MovingPairRepresentativeOccurrences T (rep j)) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ side, (T side).SizeLE d) + (hfreq : ∀ side, (T side).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : Fin (N + 1) → A → ℝ) (hμ : ∀ i a, 0 ≤ μ i a) + (hmass : ∀ i, ∑ a, μ i a = 1) + (α β V : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hmax : ∀ i a, μ i a ≤ α) (hpmax : ∀ j a, μ (rep j) a ≤ β) + (hprimeSize : ∀ j a, μ (rep j) a ≠ 0 → V ≤ Real.log (prime a : ℝ)) + (weight : (Fin (N + 1) → A) → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hweight : ∀ x, ‖weight x‖ * ∏ j, internalLineScalar false (prime (x (rep j))) ≤ B * productPrior μ x) + (hdisjoint : ∀ x, weight x ≠ 0 → ∀ i j, + tier i ≠ tier j → prime (x i) ≠ prime (x j)) + (hunique : ∀ x, weight x ≠ 0 → ∀ j i, prime (x i) = prime (x (rep j)) → i = rep j) + (hfmod : ∀ x, weight x ≠ 0 → ∀ j side, + (T side).Frequencies (fun s => (s : ZMod (prime (x (rep j)))) ≠ 0)) : + ‖∑ x, weight x * + ((∏ j, (movingSampledInternalPrimeProbability prime hprime T x (rep j) : ℂ)) - + ∏ j, (internalLineFlagWeight false (prime (x (rep j))) + (fun s => arithmeticTestFlag (lineTestPolynomials + (movingIndexedLine T (rep j) (base j)) ⟨(base j).1, (base j).2.val⟩ s = 0)) : ℂ))‖ ≤ + 2 * B * (Fintype.card J * (2 + Fintype.card (MovingPairOccurrenceIndex T))) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β) := by + let prior := fun x : Fin (N + 1) → A => productPrior μ x + let c := fun x : Fin (N + 1) → A => + ∏ j, internalLineScalar false (prime (x (rep j))) + have hc (x : Fin (N + 1) → A) : 0 < c x := by + apply Finset.prod_pos + intro j _ + simp only [internalLineScalar, Bool.false_eq_true, ite_false] + exact inv_pos.mpr (Nat.cast_pos.mpr (Nat.sub_pos_of_lt (hprime (x (rep j))).one_lt)) + have hprior (x : Fin (N + 1) → A) : 0 ≤ prior x := productPrior_nonneg μ hμ x + have hd (x : Fin (N + 1) → A) : finitePriorDensity prior weight x ≠ 0 → weight x ≠ 0 := + finitePriorDensity_ne_zero prior weight x + have h := moving_prime_actual_line_product_comparison prime hpInj hprime T tier hlevels rep base + d F U hF hU hsize hfreq hvalues μ hμ hmass α β V hα hβ hV hmax hpmax hprimeSize + (finitePriorDensity prior weight) B hB + (finitePriorDensity_bound prior weight c B hprior hB hweight) + (fun x hx => hdisjoint x (hd x hx)) (fun x hx => hunique x (hd x hx)) + (fun x hx => hfmod x (hd x hx)) + convert h using 1 + congr 1 + apply Finset.sum_congr rfl + intro x _ + rw [finitePriorDensity_cancel prior weight c B hc hweight x] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeFrequencyAverage.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeFrequencyAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..857d1d07032106ff8822a86ac22f99e4b1771b00 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeFrequencyAverage.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.FrequencyBulkNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePageCRT + +namespace OAI + +/-! # The retained frequency norm when both top giants are primes -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingFrequencyCorePrimeAverage {σ : Type*} (value : σ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (R : ℤ) + (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) (x y : ℝ) : ℂ := + (Fintype.card ((ZMod r)ˣ × (ZMod r)ˣ) : ℂ)⁻¹ * + ∑ z : (ZMod r)ˣ × (ZMod r)ˣ, + movingFrequencyCore value F E T R z.1.val.val z.2.val.val * + (pageGiantWeight input Q r z.1.val.val x * pageGiantWeight input Q r z.2.val.val y) + +noncomputable def movingFrequencyPrimeAverage {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) (x y : ℝ) : ℂ := + correctedPrimePairAverage input Q r + (fun a b => movingFrequencyPairFactor value outside F E T nodes R a b) x y + +theorem movingFrequencyPrimeAverage_core {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) (x y : ℝ) : + movingFrequencyPrimeAverage value outside F E T nodes R r input Q x y = + (if ∀ b, movingRegularOutsidePairwise value outside (T b) ∧ + (∀ f ∈ nodes b, f.guard.frequencyBounds) then (1 : ℂ) else 0) * + movingFrequencyCorePrimeAverage value F E T R r input Q x y := by + simp only [movingFrequencyPrimeAverage, correctedPrimePairAverage, + movingFrequencyPairFactor_core, movingFrequencyCorePrimeAverage, Finset.mul_sum] + apply Finset.sum_congr rfl + intro z _ + ring + +section +variable {σ : Type*} (base : σ → ℕ) (tier : σ → ℕ) (S : Finset ℤ) (n m R : ℕ) + [NeZero (R ^ (n - 1 + 2))] (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0) (hR : ∀ b (j : Fin (2 ^ n - 1)), + (singleTreeNodeFrequencies S n (frequencyPairProjection S n b t) j.val).root.natAbs ∣ R) + (slot : (TreeLeafIndex n × Fin m) ↪ σ) + (small : Bool → TreeLeafTuple (List σ) n) (a : Bool → MovingSampleSlots σ n) + (hslot : ∀ j, n ≤ tier (slot j)) + (hsmall : ∀ b i, i ∈ flattenMovingSlots n (small b) → i ∉ Set.range slot) + (ha : ∀ b, (a b).Levels tier) + (hbase : ∀ i ∉ Set.range slot, IsCoprime (base i : ℤ) (R : ℤ)) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℤ → ℤ → ℝ) + (N : ℕ) (D : ℝ) (hD : 0 ≤ D) (hN : ∀ s ∈ S, s.natAbs ≤ N) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) + (hm : 0 < m) + +include hslot hsmall ha hbase hS hR hD hN hdiv hm in +/-- Two giant Page multipliers cost four. Their residue restrictions do not +change the previously proved conditional split probabilities. -/ +theorem frequencyModelBulkPrime_mean_le (input : PublishedProgressionInput) + (Q : ℕ) (X Y : ℝ) (hX : 0 ≤ X) (hY : 0 ≤ Y) : + let T := fun b => buildMovingSlotData n + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n b t)) + (small b) (bulkSlotLeaves n m slot) (a b) + (Fintype.card (TreeLeafIndex n × Fin m → (ZMod (R ^ (n - 1 + 2)))ˣ) : ℝ)⁻¹ * + (∑ z : TreeLeafIndex n × Fin m → (ZMod (R ^ (n - 1 + 2)))ˣ, + ‖movingFrequencyCorePrimeAverage (Function.extend slot (fun j => (z j).val.val) base) + F E T R (R ^ (n - 1 + 2)) input Q X Y‖) ≤ + 4 * ((‖movingDataWeight (F false) (E false) (T false)‖ * + ‖movingDataWeight (F true) (E true) (T true)‖) * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod) := by + intro T + have h := uniform_average_norm_average_mul_le + (A := TreeLeafIndex n × Fin m → (ZMod (R ^ (n - 1 + 2)))ˣ) + (B := (ZMod (R ^ (n - 1 + 2)))ˣ × (ZMod (R ^ (n - 1 + 2)))ˣ) + (fun z (xy : (ZMod (R ^ (n - 1 + 2)))ˣ × (ZMod (R ^ (n - 1 + 2)))ˣ) => + movingFrequencyCore (Function.extend slot (fun j => (z j).val.val) base) F E T R + xy.1.val.val xy.2.val.val) + (fun xy => pageGiantWeight input Q (R ^ (n - 1 + 2)) xy.1.val.val X * + pageGiantWeight input Q (R ^ (n - 1 + 2)) xy.2.val.val Y) + 4 ((‖movingDataWeight (F false) (E false) (T false)‖ * + ‖movingDataWeight (F true) (E true) (T true)‖) * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod) (by norm_num) + (fun xy => by + rw [norm_mul] + exact (mul_le_mul + (pageGiantWeight_norm_le_two input Q (R ^ (n - 1 + 2)) _ X hX) + (pageGiantWeight_norm_le_two input Q (R ^ (n - 1 + 2)) _ Y hY) + (norm_nonneg _) (by norm_num)).trans_eq (by norm_num)) + (fun xy => frequencyModelBulkCore_mean_le base tier S n m R t hS hR slot small a + hslot hsmall ha hbase F E N D hD hN hdiv hm xy.1.val.val xy.2.val.val) + simpa only [movingFrequencyCorePrimeAverage] using h + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeHaarError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeHaarError.lean new file mode 100644 index 0000000000000000000000000000000000000000..0350e2c5fba98b937f49692df8f197a5d0d4c060 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeHaarError.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalAverageError +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeSquareFibers +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeAverages + +namespace OAI + +/-! # Averaging the relative square loss under the original mixed Haar law -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingInternalPrimeAverage_base_norm_le {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : + ‖(Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + (∑ z : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ, movingInternalPairFactor value T p z.1 z.2)‖ ≤ + (Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) : ℝ)⁻¹ * + ∑ z : (ZMod p)ˣ × (ZMod p)ˣ, ‖movingInternalBaseFactor value T p z.1 z.2‖ := by + rw [primeSquare_raw_average p (movingInternalPairFactor value T p), norm_mul, + norm_inv, Complex.norm_natCast] + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (Nat.cast_nonneg _)) + exact (norm_sum_le _ _).trans (Finset.sum_le_sum fun z _ => + movingInternalPairFactor_normalized_fiber_norm_le value T p z.1 z.2) + +theorem movingInternalPrimeAverage_base_error {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) [Fact p.Prime] + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) : + ‖(Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + (∑ z : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ, movingInternalPairFactor value T p z.1 z.2) - + (Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) : ℂ)⁻¹ * + (∑ z : (ZMod p)ˣ × (ZMod p)ˣ, movingInternalBaseFactor value T p z.1 z.2)‖ ≤ + (2 * (2 ^ n - 1 : ℕ) / (p : ℝ)) * + ((Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) : ℝ)⁻¹ * + ∑ z : (ZMod p)ˣ × (ZMod p)ˣ, ‖movingInternalBaseFactor value T p z.1 z.2‖) := by + let c : ℂ := (Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) : ℂ)⁻¹ + let w : ℝ := (Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) : ℝ)⁻¹ + let K : ℝ := 2 * (2 ^ n - 1 : ℕ) / (p : ℝ) + let H := fun z : (ZMod p)ˣ × (ZMod p)ˣ => ((p : ℂ) ^ 2)⁻¹ * + ∑ v : SquareLiftPairs p z.1 (z.2 : ZMod p), movingInternalPairFactor value T p v.1.1 v.2.1 + let G := fun z : (ZMod p)ˣ × (ZMod p)ˣ => movingInternalBaseFactor value T p z.1 z.2 + have havg : (Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + (∑ z : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ, movingInternalPairFactor value T p z.1 z.2) = + c * ∑ z, H z := by + exact primeSquare_raw_average p (movingInternalPairFactor value T p) + have he (z : (ZMod p)ˣ × (ZMod p)ˣ) : ‖H z - G z‖ ≤ K * ‖G z‖ := + movingInternalPairFactor_normalized_fiber_error tier value hprime hdisjoint T hlevels p hf + z.1 z.2 (Units.ne_zero z.2) + have hc : ‖c‖ = w := by simp only [c, w, norm_inv, Complex.norm_natCast] + have hw : 0 ≤ w := inv_nonneg.mpr (Nat.cast_nonneg _) + rw [havg] + change ‖c * (∑ z, H z) - c * (∑ z, G z)‖ ≤ K * (w * ∑ z, ‖G z‖) + rw [← mul_sub, ← Finset.sum_sub_distrib, norm_mul, hc] + calc + w * ‖∑ z, (H z - G z)‖ ≤ w * ∑ z, ‖H z - G z‖ := + mul_le_mul_of_nonneg_left (norm_sum_le _ _) hw + _ ≤ w * ∑ z, K * ‖G z‖ := + mul_le_mul_of_nonneg_left (Finset.sum_le_sum fun z _ => he z) hw + _ = _ := by rw [← Finset.mul_sum]; ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeIndexedProbability.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeIndexedProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea2a3818bea687e72473b2ba330129528be5db6f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeIndexedProbability.lean @@ -0,0 +1,136 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampledIndexedProbability + +namespace OAI + +/-! # Fixed polynomial coordinates for the two-unit line probabilities -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingInternalPrimeProbability_representative {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (rep : σ) + [Fact (value rep).Prime] (hunique : ∀ i, value i = value rep → i = rep) : + internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).a) + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).b) = + internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingRepresentativeLine T rep j).a) + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingRepresentativeLine T rep j).b) := by + unfold internalLineProbability + simp only [Bool.false_eq_true, ite_false, ← Nat.card_eq_fintype_card] + apply congrArg (fun k : ℕ => (k : ℝ) / Nat.card ((ZMod (value rep))ˣ × (ZMod (value rep))ˣ)) + exact Nat.card_congr (Equiv.subtypeEquivRight + (fun z : (ZMod (value rep))ˣ × (ZMod (value rep))ˣ => + movingPrimeLineSystem_representative_iff value T rep hunique z.1 z.2)) + +theorem movingInternalPrimeProbability_indexed {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (rep : σ) + [Fact (value rep).Prime] (hunique : ∀ i, value i = value rep → i = rep) + (base : MovingPairRepresentativeOccurrences T rep) : + internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).a) + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).b) = + internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingIndexedLine T rep base j).a) + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingIndexedLine T rep base j).b) := by + rw [movingInternalPrimeProbability_representative value T rep hunique] + have he (x y : ZMod (value rep)) : + (∀ j : MovingPairRepresentativeOccurrences T rep, + let φ := MovingSlotReversal.naturalReduction (value rep) value + let L := movingRepresentativeLine T rep j + φ L.a * x + φ L.b * y = 0) ↔ + (∀ o : MovingPairOccurrenceIndex T, + let φ := MovingSlotReversal.naturalReduction (value rep) value + let L := movingIndexedLine T rep base o + φ L.a * x + φ L.b * y = 0) := + (movingRepresentativeIndex_surjective T rep base).forall + unfold internalLineProbability + simp only [Bool.false_eq_true, ite_false, ← Nat.card_eq_fintype_card] + apply congrArg (fun k : ℕ => (k : ℝ) / Nat.card ((ZMod (value rep))ˣ × (ZMod (value rep))ˣ)) + exact Nat.card_congr (Equiv.subtypeEquivRight + (fun z : (ZMod (value rep))ˣ × (ZMod (value rep))ˣ => he z.1 z.2)) + +theorem unitLineProbability_normalized {σ J : Type*} {p : ℕ} [Fact p.Prime] + (L : J → PolynomialGiantLine σ) (φ : MvPolynomial σ ℤ →+* ZMod p) + (hd : ∀ j, φ (L j).denominator ≠ 0) : + internalLineProbability false (fun j => φ (L j).a) (fun j => φ (L j).b) = + internalLineProbability false (fun j => ((L j).normalized φ).1) + (fun j => ((L j).normalized φ).2) := by + have he (x y : ZMod p) : (∀ j, φ (L j).a * x + φ (L j).b * y = 0) ↔ + (∀ j, ((L j).normalized φ).1 * x + ((L j).normalized φ).2 * y = 0) := by + apply forall_congr' + intro j + simp only [PolynomialGiantLine.normalized] + rw [div_mul_eq_mul_div, div_mul_eq_mul_div, ← add_div, div_eq_zero_iff, or_iff_left (hd j)] + unfold internalLineProbability + simp only [Bool.false_eq_true, ite_false, ← Nat.card_eq_fintype_card] + apply congrArg (fun k : ℕ => (k : ℝ) / Nat.card ((ZMod p)ˣ × (ZMod p)ˣ)) + exact Nat.card_congr (Equiv.subtypeEquivRight (fun z : (ZMod p)ˣ × (ZMod p)ˣ => he z.1 z.2)) + +theorem movingInternalPrimeProbability_indexed_normalized {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (hlevels : ∀ side, (T side).Levels tier) + (rep : σ) [Fact (value rep).Prime] (base : MovingPairRepresentativeOccurrences T rep) + (hunique : ∀ i, value i = value rep → i = rep) + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod (value rep)) ≠ 0)) : + internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).a) + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).b) = + internalLineProbability false + (fun j => ((movingIndexedLine T rep base j).normalized + (MovingSlotReversal.naturalReduction (value rep) value)).1) + (fun j => ((movingIndexedLine T rep base j).normalized + (MovingSlotReversal.naturalReduction (value rep) value)).2) := by + rw [movingInternalPrimeProbability_indexed value T rep hunique base] + exact unitLineProbability_normalized (movingIndexedLine T rep base) + (MovingSlotReversal.naturalReduction (value rep) value) + (movingIndexedLine_denominator_ne_zero T tier value hprime hdisjoint hlevels rep base hf) + +noncomputable def movingSampledInternalPrimeProbability {A : Type*} {N n : ℕ} + (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (T : Bool → MovingSlotData (Fin N) n) (x : Fin N → A) (rep : Fin N) : ℝ := + letI : Fact (prime (x rep)).Prime := ⟨hprime (x rep)⟩ + internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction (prime (x rep)) (fun i => prime (x i)) + (movingPrimeOccurrenceLine (fun i => prime (x i)) T (prime (x rep)) j).a) + (fun j => MovingSlotReversal.naturalReduction (prime (x rep)) (fun i => prime (x i)) + (movingPrimeOccurrenceLine (fun i => prime (x i)) T (prime (x rep)) j).b) + +theorem movingSampledIndexedPrimeProbability {A : Type*} {N n : ℕ} + (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) (x : Fin N → A) + (T : Bool → MovingSlotData (Fin N) n) (tier : Fin N → ℕ) + (hdisjoint : ∀ i j, tier i ≠ tier j → prime (x i) ≠ prime (x j)) + (hlevels : ∀ side, (T side).Levels tier) + (rep : Fin N) (base : MovingPairRepresentativeOccurrences T rep) + (hunique : ∀ i, prime (x i) = prime (x rep) → i = rep) + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod (prime (x rep))) ≠ 0)) : + letI : Fact (prime (x rep)).Prime := ⟨hprime (x rep)⟩ + internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction (prime (x rep)) (fun i => prime (x i)) + (movingPrimeOccurrenceLine (fun i => prime (x i)) T (prime (x rep)) j).a) + (fun j => MovingSlotReversal.naturalReduction (prime (x rep)) (fun i => prime (x i)) + (movingPrimeOccurrenceLine (fun i => prime (x i)) T (prime (x rep)) j).b) = + movingSlotLineProbability (fun a => (prime a : ℤ)) prime hprime + (fun o => (movingIndexedOccurrence T rep base o).path) + (fun o => (movingIndexedOccurrence T rep base o).current) false x (x rep) := by + let : Fact (prime (x rep)).Prime := ⟨hprime (x rep)⟩ + have h := movingInternalPrimeProbability_indexed_normalized T tier (fun i => prime (x i)) + (fun i => hprime (x i)) hdisjoint hlevels rep base hunique hf + simpa only [movingSlotLineProbability, integerLineReduction, + MovingSlotReversal.naturalReduction, Int.cast_natCast, movingIndexedLine] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeInternalNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeInternalNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..53bd2f0a49fedad72bbdf99630cffb7ba2202504 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeInternalNorm.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeAverages + +namespace OAI + +/-! # Retaining the internal line factor in the two-prime environment -/ + +namespace Ostmann +open scoped Classical BigOperators + +private theorem internal_sum_norm {σ A : Type*} [Fintype A] {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) + (v : A → ZMod (p ^ 2) × ZMod (p ^ 2)) : + ‖(Fintype.card A : ℂ)⁻¹ * ∑ a, movingInternalPairFactor value T p (v a).1 (v a).2‖ = + (Fintype.card A : ℝ)⁻¹ * ∑ a, ‖movingInternalPairFactor value T p (v a).1 (v a).2‖ := by + have he (a : A) : movingInternalPairFactor value T p (v a).1 (v a).2 = + (‖movingInternalPairFactor value T p (v a).1 (v a).2‖ : ℂ) := by + unfold movingInternalPairFactor + split_ifs <;> simp + have hs : (∑ a, movingInternalPairFactor value T p (v a).1 (v a).2) = + ((∑ a, ‖movingInternalPairFactor value T p (v a).1 (v a).2‖ : ℝ) : ℂ) := by + rw [Complex.ofReal_sum] + exact Finset.sum_congr rfl (fun a _ => he a) + rw [hs, ← Complex.ofReal_natCast, ← Complex.ofReal_inv, + ← Complex.ofReal_mul, Complex.norm_real, Real.norm_of_nonneg (by positivity)] + +private theorem unit_pair_average_le_twice_mixed (p : ℕ) [Fact p.Prime] + (f : ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ → ℝ) (hf : ∀ z, 0 ≤ f z) : + (Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℝ)⁻¹ * + (∑ z : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ, f (z.1.val, z.2)) ≤ + 2 * ((Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) : ℝ)⁻¹ * ∑ z, f z) := by + let e : ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) ↪ + (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) := + Function.Embedding.prodMap + (⟨Units.val, fun _ _ h => Units.ext h⟩ : (ZMod (p ^ 2))ˣ ↪ ZMod (p ^ 2)) + (Function.Embedding.refl _) + have hs : (∑ z : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ, f (e z)) ≤ ∑ z, f z := by + calc + _ = ∑ z ∈ Finset.univ.map e, f z := (Finset.sum_map _ _ _).symm + _ ≤ _ := Finset.sum_le_sum_of_subset_of_nonneg (fun _ _ => Finset.mem_univ _) + (fun z _ _ => hf z) + have hp : p.Prime := Fact.out + have hphi : Nat.totient (p ^ 2) = p * (p - 1) := by + simpa only [pow_one] using Nat.totient_prime_pow_succ hp 1 + have hsize : p ^ 2 ≤ 2 * Nat.totient (p ^ 2) := by + rw [hphi] + have hsub := Nat.sub_add_cancel hp.one_le + have htwo := hp.two_le + nlinarith + have hc : (Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) : ℝ) ≤ + 2 * (Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℝ) := by + simp only [Fintype.card_prod, ZMod.card, ZMod.card_units_eq_totient, Nat.cast_mul] + have hmul := Nat.mul_le_mul_right (Nat.totient (p ^ 2)) hsize + exact_mod_cast (by simpa only [mul_assoc] using hmul) + have hcp : (0 : ℝ) < Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) := by + exact_mod_cast Fintype.card_pos + have hcm : (0 : ℝ) < Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) := by + exact_mod_cast Fintype.card_pos + have hi : (Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℝ)⁻¹ ≤ + 2 * (Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) : ℝ)⁻¹ := by + have h : (1 : ℝ) / (Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℝ) ≤ + 2 / (Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) : ℝ) := by + apply (div_le_div_iff₀ hcp hcm).mpr + simpa only [one_mul] using hc + simpa only [div_eq_mul_inv, one_mul] using h + calc + _ ≤ (Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℝ)⁻¹ * ∑ z, f z := + mul_le_mul_of_nonneg_left hs (inv_nonneg.mpr hcp.le) + _ ≤ (2 * (Fintype.card (ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ) : ℝ)⁻¹) * ∑ z, f z := + mul_le_mul_of_nonneg_right hi (Finset.sum_nonneg (fun z _ => hf z)) + _ = _ := by ring + +/-- Restricting the first giant to units costs at most two at each distinct +internal prime, while retaining the full simultaneous line probability. -/ +theorem movingInternalPrimeAverage_norm_le {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : + ‖movingInternalPrimeAverage value T p‖ ≤ 2 * movingInternalLineProbability value T p := by + have hpavg := internal_sum_norm value T p + (fun z : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ => + ((z.1 : ZMod (p ^ 2)), (z.2 : ZMod (p ^ 2)))) + have hmavg := internal_sum_norm value T p + (fun z : ZMod (p ^ 2) × (ZMod (p ^ 2))ˣ => (z.1, (z.2 : ZMod (p ^ 2)))) + have hunit := unit_pair_average_le_twice_mixed p + (fun z => ‖movingInternalPairFactor value T p z.1 z.2‖) (fun _ => norm_nonneg _) + have hmix := movingInternalPairFactor_probability_norm_le value T p + exact hpavg.le.trans (hunit.trans + (mul_le_mul_of_nonneg_left (hmavg.symm.le.trans hmix) (by norm_num))) + +/-- Only a fixed factor per equality class is paid, and every class retains +its original inverse-prime line probability. -/ +theorem movingInternalPrimeAverage_product_norm_le {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) + (P : Finset ℕ) [∀ p : P, Fact p.val.Prime] : + ‖∏ p : P, movingInternalPrimeAverage value T p.val‖ ≤ + (2 : ℝ) ^ P.card * ∏ p : P, movingInternalLineProbability value T p.val := by + rw [norm_prod] + calc + _ ≤ ∏ p : P, (2 * movingInternalLineProbability value T p.val) := + Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + (fun p _ => movingInternalPrimeAverage_norm_le value T p.val) + _ = _ := by simp only [Finset.prod_mul_distrib, Finset.prod_const, + Finset.card_univ, Fintype.card_coe] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeInternalProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeInternalProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..395729835448fda519c34140bcc48ab63d8d48b8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeInternalProduct.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeProbabilityError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeIndexedProbability +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSquareError + +namespace OAI + +/-! # Relative square error under the original two-prime law -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingInternalPrimeLineProbability {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : ℝ := + internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) + +theorem movingInternalPrimeLineProbability_nonneg {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : + 0 ≤ movingInternalPrimeLineProbability value T p := internalLineProbability_nonneg _ _ _ + +theorem movingInternalPrimeLineProbability_le_scalar {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) [Fact p.Prime] + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) + (base : MovingPrimeOccurrences value T p) : + movingInternalPrimeLineProbability value T p ≤ internalLineScalar false p := by + unfold movingInternalPrimeLineProbability + rw [movingInternalPrimeProbability_eq_flags tier value hprime hdisjoint T hlevels p hf base] + exact internalLineFlagWeight_le_scalar _ _ _ + +theorem movingPrimeRepresentativeProduct_error {σ C : Type*} [Fintype C] + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hlevels : ∀ b, (T b).Levels tier) + (rep : C → σ) (base : ∀ c, MovingPairRepresentativeOccurrences T (rep c)) + (hf : ∀ c b, (T b).Frequencies (fun s => (s : ZMod (value (rep c))) ≠ 0)) + (V : ℝ) (hsize : ∀ c, Real.exp V ≤ value (rep c)) : + letI : ∀ c, Fact (value (rep c)).Prime := fun _ => ⟨hprime _⟩ + ‖(∏ c, movingInternalPrimeAverage value T (value (rep c))) - + ∏ c, (movingInternalPrimeLineProbability value T (value (rep c)) : ℂ)‖ ≤ + ((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) * + ∏ c, internalLineScalar false (value (rep c)) := by + let _ : ∀ c, Fact (value (rep c)).Prime := fun _ => ⟨hprime _⟩ + have hprob (c) : 0 ≤ movingInternalPrimeLineProbability value T (value (rep c)) := + movingInternalPrimeLineProbability_nonneg value T _ + have hline (c) : movingInternalPrimeLineProbability value T (value (rep c)) ≤ + internalLineScalar false (value (rep c)) := by + let j : MovingPrimeOccurrences value T (value (rep c)) := + ⟨(base c).1, ⟨(base c).2.val, ⟨rep c, (base c).2.property, rfl⟩⟩⟩ + exact movingInternalPrimeLineProbability_le_scalar tier value hprime hdisjoint T hlevels _ (hf c) j + have hs : (∑ c, (value (rep c) : ℝ)⁻¹) ≤ (Fintype.card C : ℝ) * Real.exp (-V) := by + calc + _ ≤ ∑ _c : C, Real.exp (-V) := by + apply Finset.sum_le_sum + intro c _ + simpa only [Real.exp_neg] using inv_anti₀ (Real.exp_pos V) (hsize c) + _ = _ := by rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + have h := finite_relative_product_error (Finset.univ : Finset C) + (fun c => movingInternalPrimeAverage value T (value (rep c))) + (fun c => (movingInternalPrimeLineProbability value T (value (rep c)) : ℂ)) + (fun c => movingInternalPrimeLineProbability value T (value (rep c))) + (fun c => 2 * (2 ^ n - 1 : ℕ) / (value (rep c) : ℝ)) + (fun c _ => hprob c) (fun c _ => by positivity) + (fun c _ => movingInternalPrimeAverage_probability_norm_le value T _) + (fun c _ => by rw [Complex.norm_real, Real.norm_of_nonneg (hprob c)]) + (fun c _ => movingInternalPrimeAverage_probability_error tier value hprime hdisjoint T hlevels _ (hf c)) + have hp : (∏ c, movingInternalPrimeLineProbability value T (value (rep c))) ≤ + ∏ c, internalLineScalar false (value (rep c)) := + Finset.prod_le_prod₀ (fun c _ => hprob c) (fun c _ => hline c) + have hk : (∑ c, 2 * (2 ^ n - 1 : ℕ) / (value (rep c) : ℝ)) ≤ + (2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V) := by + simp only [div_eq_mul_inv, ← Finset.mul_sum] + exact (mul_le_mul_of_nonneg_left hs (by positivity)).trans_eq (by ring) + exact h.trans (mul_le_mul hk hp (Finset.prod_nonneg (fun c _ => hprob c)) (by positivity)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeLineGate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeLineGate.lean new file mode 100644 index 0000000000000000000000000000000000000000..602f3d67772e147d8a3206b1a23bdcf69bcbab62 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeLineGate.lean @@ -0,0 +1,149 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingLineComposition + +namespace OAI + +/-! # The internal-prime gate on the original top giant pair -/ + +namespace Ostmann +open scoped Classical + +noncomputable def movingPrimeLineSupport {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (x y : ℤ) : Prop := + ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, + let φ := MovingSlotReversal.naturalReduction (value i) value + φ (movingSlotLine o.path o.current).a * (x : ZMod (value i)) + + φ (movingSlotLine o.path o.current).b * (y : ZMod (value i)) = 0 + +theorem movingPrimeLineSupport_leaf {σ : Type*} (value : σ → ℕ) + (s : ℤ) (C : List σ) (x y : ℤ) : + movingPrimeLineSupport value (.leaf s C) x y := by + simp [movingPrimeLineSupport, MovingSlotData.occurrences] + +theorem movingPrimeLineSupport_root {σ : Type*} (value : σ → ℕ) {n : ℕ} + (s : ℤ) (CL CR U : List σ) (left right : MovingSlotData σ n) (x y : ℤ) + (h : movingPrimeLineSupport value (.node s CL CR U left right) x y) : + ∀ i ∈ U, (value i : ℤ) ∣ + (MovingSlotData.step s CL CR U left right false).signedNumerator value x y := by + intro i hi + have he := h ⟨n + 1, MovingSlotData.step s CL CR U left right false, []⟩ + List.mem_cons_self i hi + have hh : ((MovingSlotData.step s CL CR U left right false).signedNumerator value x y : + ZMod (value i)) = 0 := by + dsimp only at he + rw [movingSlotLine_eval] at he + simpa only [MovingSlotReversal.naturalReduction, MovingSlotReversal.signedNumerator, + MovingSlotReversal.polynomial, MovingSlotReversal.coefficient_nat_eval, + PolynomialGiantRows.evalNumerator, movingPolynomialAncestors, List.map_nil, + PolynomialGiantRows.identity, GiantRows.identity, map_one, map_zero, one_mul, + zero_mul, mul_zero, mul_one, add_zero, zero_add, Int.cast_sub, Int.cast_mul, Int.cast_natCast, + mul_assoc, mul_comm, mul_left_comm] using he + exact (ZMod.intCast_zmod_eq_zero_iff_dvd _ _).mp hh + +/-- Decomposition of the top-coordinate line gate after just the current +integer relation is known; descendant integrality is not an assumption. -/ +theorem movingPrimeLineSupport_node {σ : Type*} (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) {n : ℕ} + (s : ℤ) (CL CR U : List σ) (left right : MovingSlotData σ n) (x y p : ℤ) + (hrel : (MovingSlotData.step s CL CR U left right false).signedNumerator value x y = + s * (MovingSlotReversal.naturalProduct value U : ℤ) * p) + (hUL : ∀ o ∈ left.occurrences, ∀ i ∈ o.current.compensationSlots, + MovingSlotReversal.naturalReduction (value i) value + (MovingSlotData.step s CL CR U left right true).polynomial.u ≠ 0) + (hUR : ∀ o ∈ right.occurrences, ∀ i ∈ o.current.compensationSlots, + MovingSlotReversal.naturalReduction (value i) value + (MovingSlotData.step s CL CR U left right false).polynomial.u ≠ 0) : + movingPrimeLineSupport value (.node s CL CR U left right) x y ↔ + (∀ i ∈ U, (value i : ℤ) ∣ + (MovingSlotData.step s CL CR U left right false).signedNumerator value x y) ∧ + movingPrimeLineSupport value left p x ∧ movingPrimeLineSupport value right p y := by + let step := MovingSlotData.step s CL CR U left right + have hleft (o : MovingSlotOccurrence σ) (ho : o ∈ left.occurrences) + (i : σ) (hi : i ∈ o.current.compensationSlots) : + let φ := MovingSlotReversal.naturalReduction (value i) value + φ (movingSlotLine (o.path ++ [step true]) o.current).a * (x : ZMod (value i)) + + φ (movingSlotLine (o.path ++ [step true]) o.current).b * (y : ZMod (value i)) = 0 ↔ + φ (movingSlotLine o.path o.current).a * (p : ZMod (value i)) + + φ (movingSlotLine o.path o.current).b * (x : ZMod (value i)) = 0 := by + let : Fact (value i).Prime := ⟨hprime i⟩ + exact movingSlotLine_append_singleton_zero_iff value o.path o.current (step true) + x y p hrel (hUL o ho i hi) + have hright (o : MovingSlotOccurrence σ) (ho : o ∈ right.occurrences) + (i : σ) (hi : i ∈ o.current.compensationSlots) : + let φ := MovingSlotReversal.naturalReduction (value i) value + φ (movingSlotLine (o.path ++ [step false]) o.current).a * (x : ZMod (value i)) + + φ (movingSlotLine (o.path ++ [step false]) o.current).b * (y : ZMod (value i)) = 0 ↔ + φ (movingSlotLine o.path o.current).a * (p : ZMod (value i)) + + φ (movingSlotLine o.path o.current).b * (y : ZMod (value i)) = 0 := by + let : Fact (value i).Prime := ⟨hprime i⟩ + exact movingSlotLine_append_singleton_zero_iff value o.path o.current (step false) + x y p hrel (hUR o ho i hi) + constructor + · intro h + refine ⟨movingPrimeLineSupport_root value s CL CR U left right x y h, ?_, ?_⟩ + · intro o ho i hi + apply (hleft o ho i hi).mp + exact h (o.extend (step true)) (List.mem_cons_of_mem _ + (List.mem_append_left _ (List.mem_map.mpr ⟨o, ho, rfl⟩))) i hi + · intro o ho i hi + apply (hright o ho i hi).mp + exact h (o.extend (step false)) (List.mem_cons_of_mem _ + (List.mem_append_right _ (List.mem_map.mpr ⟨o, ho, rfl⟩))) i hi + · rintro ⟨hroot, hL, hR⟩ o ho i hi + rcases List.mem_cons.mp ho with ho | ho + · subst o + have hz := (ZMod.intCast_zmod_eq_zero_iff_dvd _ (value i)).mpr (hroot i hi) + dsimp only + rw [movingSlotLine_eval] + simpa only [MovingSlotReversal.naturalReduction, MovingSlotReversal.signedNumerator, + MovingSlotReversal.polynomial, MovingSlotReversal.coefficient_nat_eval, + PolynomialGiantRows.evalNumerator, movingPolynomialAncestors, List.map_nil, + PolynomialGiantRows.identity, GiantRows.identity, map_one, map_zero, one_mul, + zero_mul, mul_zero, mul_one, add_zero, zero_add, Int.cast_sub, Int.cast_mul, Int.cast_natCast, + mul_assoc, mul_comm, mul_left_comm] using hz + · rcases List.mem_append.mp ho with ho | ho + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + exact (hleft o' ho' i hi).mpr (hL o' ho' i hi) + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + exact (hright o' ho' i hi).mpr (hR o' ho' i hi) + +theorem MovingSlotData.compensation_ancestor_unit {σ : Type*} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + {n : ℕ} (T : MovingSlotData σ n) (hlevels : T.Levels tier) + (hf : ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (o : MovingSlotOccurrence σ) (ho : o ∈ T.occurrences) + (i : σ) (hi : i ∈ o.current.compensationSlots) : + ∀ root ∈ o.path, + MovingSlotReversal.naturalReduction (value i) value root.polynomial.u ≠ 0 := by + have h := T.occurrence_units_of_prime_types tier value hprime hdisjoint hlevels o ho i + (T.occurrence_compensation_level tier hlevels o ho i hi) (hf i) + exact fun root hr => (h.1 root hr).2.2 + +theorem movingPrimeLineSupport_node_of_levels {σ : Type*} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + {n : ℕ} (s : ℤ) (CL CR U : List σ) (left right : MovingSlotData σ n) + (hlevels : (MovingSlotData.node s CL CR U left right).Levels tier) + (hf : ∀ i, (MovingSlotData.node s CL CR U left right).Frequencies + (fun f => (f : ZMod (value i)) ≠ 0)) (x y p : ℤ) + (hrel : (MovingSlotData.step s CL CR U left right false).signedNumerator value x y = + s * (MovingSlotReversal.naturalProduct value U : ℤ) * p) : + movingPrimeLineSupport value (.node s CL CR U left right) x y ↔ + (∀ i ∈ U, (value i : ℤ) ∣ + (MovingSlotData.step s CL CR U left right false).signedNumerator value x y) ∧ + movingPrimeLineSupport value left p x ∧ movingPrimeLineSupport value right p y := by + apply movingPrimeLineSupport_node value hprime s CL CR U left right x y p hrel + · intro o ho i hi + exact (MovingSlotData.node s CL CR U left right).compensation_ancestor_unit + tier value hprime hdisjoint hlevels hf (o.extend (MovingSlotData.step s CL CR U left right true)) + (List.mem_cons_of_mem _ (List.mem_append_left _ (List.mem_map.mpr ⟨o, ho, rfl⟩))) + i hi _ (by simp [MovingSlotOccurrence.extend]) + · intro o ho i hi + exact (MovingSlotData.node s CL CR U left right).compensation_ancestor_unit + tier value hprime hdisjoint hlevels hf (o.extend (MovingSlotData.step s CL CR U left right false)) + (List.mem_cons_of_mem _ (List.mem_append_right _ (List.mem_map.mpr ⟨o, ho, rfl⟩))) + i hi _ (by simp [MovingSlotOccurrence.extend]) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeNodeFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeNodeFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..c53ad4454a8845b97038f7d91b7d267f240a833b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeNodeFactor.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeRootGuard + +namespace OAI + +/-! # The actual top node factor before summing descendant histories -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original nine arithmetic tests at a node, in terms of its products. -/ +def movingNodeArithmeticGuard (N B LH RH : ℕ) (s v w : ℤ) (P : ℕ) : Prop := + s ≠ 0 ∧ IsCoprime s (RH : ℤ) ∧ v * RH - w * LH = s * P ∧ + 0 < P ∧ P ≤ B ∧ v.natAbs ≤ N ∧ w.natAbs ≤ N ∧ + 2 * B * N < RH ∧ P.Coprime w.natAbs + +theorem movingRootState_arithmetic_guard {σ : Type*} + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (n : ℕ) (t : FrequencyTree ℤ (n + 1)) (CL CR u : List σ) + (XL XR P : ℕ) (s v w : ℤ) : + ValidTransferNode (movingSlotSystem value childBound pivotBound) + (movingRootState n t CL CR u XL XR) s v w P ↔ + movingNodeArithmeticGuard (childBound (n + 1)) (pivotBound (n + 1)) + (XL * MovingSlotReversal.naturalProduct value CL) + (XR * MovingSlotReversal.naturalProduct value CR) s v w P := by + constructor + · intro h + exact ⟨h.root_ne_zero, h.root_unit, h.relation, h.pivot_pos, h.pivot_bound, + h.left_bound, h.right_bound, h.range_gap, h.pivot_unit⟩ + · rintro ⟨hs, hu, he, hp, hB, hv, hw, hgap, hunit⟩ + exact ⟨hs, hu, he, hp, hB, hv, hw, hgap, hunit⟩ + +noncomputable def movingTopPivot {σ : Type*} (value : σ → ℕ) + (CL CR u : List σ) (XL XR : ℕ) (s v w : ℤ) : ℕ := + reconstructedPivot + (v * (XR * MovingSlotReversal.naturalProduct value CR : ℕ) - + w * (XL * MovingSlotReversal.naturalProduct value CL : ℕ)) + (s * MovingSlotReversal.naturalProduct value u) + +/-- This factor uses only the current lists and three root frequencies. +Descendant support is retained in the two child coefficients. -/ +noncomputable def movingPrimeNodeFactor {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (CL CR u : List σ) (XL XR : ℕ) (s v w : ℤ) : ℂ := + let U := MovingSlotReversal.naturalProduct value u + let p := movingTopPivot value CL CR u XL XR s v w + if (XL :: XR :: ((CL ++ CR).map value ++ outside)).Pairwise Nat.Coprime ∧ + (movingNodeArithmeticGuard (childBound (n + 1)) (pivotBound (n + 1)) + (XL * MovingSlotReversal.naturalProduct value CL) + (XR * MovingSlotReversal.naturalProduct value CR) s v w (p * U) ∧ 0 < U) + then ((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) else 0 + +/-- The original guarded summand is exactly a root-only factor times the +original two supported child coefficients. This is used only at actual prime +outer giants, where the extra cross-branch frequency tests follow from size. -/ +theorem movingPrimeNodeFactor_term {σ : Type*} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (hs : s ≠ 0) (hsV : s.natAbs ≤ V (n + 1)) + (l r : ScheduledFrequencyIndex V n) + (small bulk : TreeLeafTuple (List σ) (n + 1)) + (a : TreeLeafTuple (Fin 4 → σ) n) (XL XR : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) + (hVL : V (n + 1) < XL) (hVR : V (n + 1) < XR) : + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let t := (s, scheduledFrequencyHistory V n l, scheduledFrequencyHistory V n r) + let x := movingRootState n t CL CR (flattenMovingSlots n u) XL XR + let U := x.compensation value + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let p := reconstructedPivot + (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) (s * U) + let L := movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n t.2.1 + (appendMovingSlotLeaves n u small.1) bulk.1 p XL + let R := movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n t.2.2 + (appendMovingSlotLeaves n u small.2) bulk.2 p XR + (if movingLocalSupport value outside x ∧ + (ValidTransferNode (movingSlotSystem value childBound pivotBound) x s v w (p * U) ∧ + 0 < U) then (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) * L * star R else 0) = + movingPrimeNodeFactor value outside childBound pivotBound φ G n CL CR + (flattenMovingSlots n u) XL XR s v w * L * star R := by + intro u CL CR t x U v w p L R + have h := movingRootState_prime_guard_product value outside μ childBound pivotBound V hV F hF + φ G n s hs hsV l r small bulk a XL XR hXL hXR hVL hVR + ((((U : ℝ) * φ (Real.log p - G (n + 1))) : ℝ) : ℂ) + (ValidTransferNode (movingSlotSystem value childBound pivotBound) x s v w (p * U) ∧ 0 < U) + calc + _ = (if (XL :: XR :: ((CL ++ CR).map value ++ outside)).Pairwise Nat.Coprime ∧ + (ValidTransferNode (movingSlotSystem value childBound pivotBound) x s v w (p * U) ∧ + 0 < U) then ((((U : ℝ) * φ (Real.log p - G (n + 1))) : ℝ) : ℂ) * L * star R + else 0) := by + convert h using 1 <;> split_ifs <;> rfl + _ = _ := by + simp only [x, movingRootState_arithmetic_guard] + unfold movingPrimeNodeFactor movingTopPivot + dsimp only [x, U, p, v, w, t, movingRootState, MovingSlotState.compensation, + MovingSlotState.leftProduct, MovingSlotState.rightProduct] + simp only [ite_mul, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeNodeSubstitution.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeNodeSubstitution.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb66864004726cc078c57ee22fb6c05fa4b781ac --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeNodeSubstitution.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeNodeTransfer +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantIntervalBridge + +namespace OAI + +/-! # Exact identification of the coefficient node with integer substitution -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Every nonzero original node factor comes from the unique positive integer +substitution in its cutoff range. -/ +theorem movingPrimeNodeFactor_valid {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (CL CR u : List σ) + (XL XR : ℕ) (s v w : ℤ) (I : Finset ℕ) + (hI : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hf : movingPrimeNodeFactor value outside childBound pivotBound φ G n CL CR u XL XR s v w ≠ 0) : + validTransferredPivot I + (v * (XR * MovingSlotReversal.naturalProduct value CR : ℕ) - + w * (XL * MovingSlotReversal.naturalProduct value CL : ℕ)) + (s * MovingSlotReversal.naturalProduct value u) := by + let U := MovingSlotReversal.naturalProduct value u + let p := movingTopPivot value CL CR u XL XR s v w + unfold movingPrimeNodeFactor at hf + dsimp only at hf + split_ifs at hf with hguard + · rcases hguard with ⟨_, hnode, hU⟩ + rcases hnode with ⟨hs, _, hrel, hpU, _, _, _, _, _⟩ + change (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) ≠ 0 at hf + have hp : 0 < p := Nat.pos_of_mul_pos_right hpU + have hφ : φ (Real.log p - G (n + 1)) ≠ 0 := by + intro hz + exact hf (by simp only [hz, mul_zero, Complex.ofReal_zero]) + apply validTransferredPivot_of_eq I _ _ (mul_ne_zero hs (by exact_mod_cast hU.ne')) + p hp (hI p hp hφ) + change _ = (s * (U : ℤ)) * (p : ℤ) + calc + _ = s * (p * U : ℕ) := hrel + _ = _ := by rw [Nat.cast_mul]; ring + · exact (hf rfl).elim + +/-- For the concrete giant cell, the original node's support gives exactly +its integer pivot range; endpoint primes and integers are retained. -/ +theorem movingPrimeNodeFactor_valid_cell {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (φ : ℝ → ℝ) (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (n : ℕ) (CL CR u : List σ) (XL XR : ℕ) (s v w : ℤ) + (hf : movingPrimeNodeFactor value outside childBound pivotBound φ G n CL CR u XL XR s v w ≠ 0) : + validTransferredPivot + (Finset.Ioc ⌊Real.exp (G (n + 1) - 1)⌋₊ ⌊Real.exp (G (n + 1) + 1)⌋₊) + (v * (XR * MovingSlotReversal.naturalProduct value CR : ℕ) - + w * (XL * MovingSlotReversal.naturalProduct value CL : ℕ)) + (s * MovingSlotReversal.naturalProduct value u) := + movingPrimeNodeFactor_valid value outside childBound pivotBound φ G n CL CR u XL XR s v w _ + (fun p hp hφ => smoothGiant_nonzero_in_log_cell φ (G (n + 1)) hout p hp hφ) hf + +/-- The new coefficient term is exactly the off-diagonal integer-substitution +term from the full transform transfer, with its original two child factors. -/ +theorem movingPrimeNodeFactor_substitution {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) + (u : TreeLeafTuple (List σ) n) (small bulk : TreeLeafTuple (List σ) (n + 1)) + (XL XR : ℕ) (s v w : ℤ) (I : Finset ℕ) + (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hsV : s.natAbs ≤ V (n + 1)) + (hv : v.natAbs ≤ childBound (n + 1)) (hw : w.natAbs ≤ childBound (n + 1)) : + let U := MovingSlotReversal.naturalProduct value (flattenMovingSlots n u) + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let LH := XL * MovingSlotReversal.naturalProduct value CL + let RH := XR * MovingSlotReversal.naturalProduct value CR + let p := movingTopPivot value CL CR (flattenMovingSlots n u) XL XR s v w + let A := movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n v + (appendMovingSlotLeaves n u small.1) bulk.1 p XL + let B := movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n w + (appendMovingSlotLeaves n u small.2) bulk.2 p XR + (∀ p ∈ I, p * U ≤ pivotBound (n + 1)) → + 2 * pivotBound (n + 1) * childBound (n + 1) < RH → + (∀ q, q.Prime → q ∣ RH → V (n + 1) < q) → + (∀ q, q.Prime → q ∣ U → childBound (n + 1) < q) → + movingPrimeNodeFactor value outside childBound pivotBound φ G n CL CR + (flattenMovingSlots n u) XL XR s v w * A * star B = + if validTransferredPivot I (v * RH - w * LH) (s * U) then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) * A * star B else 0 := by + intro U CL CR LH RH p A B hbound hgap hRH hU + by_cases h : validTransferredPivot I (v * RH - w * LH) (s * U) + · rw [ite_eq_left h] + exact movingPrimeNodeFactor_transfer_product value outside μ childBound pivotBound V F hF φ G n + u small bulk XL XR s v w I hI hsV hv hw h hbound hgap hRH hU + · rw [ite_eq_right h] + have hz : movingPrimeNodeFactor value outside childBound pivotBound φ G n CL CR + (flattenMovingSlots n u) XL XR s v w = 0 := by + by_contra hf + exact h (movingPrimeNodeFactor_valid value outside childBound pivotBound φ G n CL CR + (flattenMovingSlots n u) XL XR s v w I hφ hf) + rw [hz, zero_mul, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeNodeTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeNodeTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..acd19857ba5b860f4ef56fba1cb3556dc749d67c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeNodeTransfer.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingChildListSupport + +namespace OAI + +/-! # The arithmetic guard is automatic in the genuine off-diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- On a retained integer substitution, the supported child coefficients +supply the pairwise and frequency-unit tests of the new node. Its remaining +bounds are exactly the range inequalities used by the full transfer theorem. -/ +theorem movingPrimeNodeFactor_transfer_product {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) + (u : TreeLeafTuple (List σ) n) (small bulk : TreeLeafTuple (List σ) (n + 1)) + (XL XR : ℕ) (s v w : ℤ) (I : Finset ℕ) + (hI : ∀ p ∈ I, 0 < p) + (hsV : s.natAbs ≤ V (n + 1)) + (hv : v.natAbs ≤ childBound (n + 1)) (hw : w.natAbs ≤ childBound (n + 1)) : + let U := MovingSlotReversal.naturalProduct value (flattenMovingSlots n u) + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let LH := XL * MovingSlotReversal.naturalProduct value CL + let RH := XR * MovingSlotReversal.naturalProduct value CR + let p := movingTopPivot value CL CR (flattenMovingSlots n u) XL XR s v w + let A := movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n v + (appendMovingSlotLeaves n u small.1) bulk.1 p XL + let B := movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n w + (appendMovingSlotLeaves n u small.2) bulk.2 p XR + validTransferredPivot I (v * RH - w * LH) (s * U) → + (∀ p ∈ I, p * U ≤ pivotBound (n + 1)) → + 2 * pivotBound (n + 1) * childBound (n + 1) < RH → + (∀ q, q.Prime → q ∣ RH → V (n + 1) < q) → + (∀ q, q.Prime → q ∣ U → childBound (n + 1) < q) → + movingPrimeNodeFactor value outside childBound pivotBound φ G n CL CR + (flattenMovingSlots n u) XL XR s v w * A * star B = + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) * A * star B := by + intro U CL CR LH RH p A B htrans hbound hgap hRH hU + by_cases hA : A = 0 + · simp only [hA, mul_zero, zero_mul] + by_cases hB : B = 0 + · simp only [hB, star_zero, mul_zero] + have hs : s ≠ 0 := left_ne_zero_of_mul htrans.1 + have hUpos : 0 < U := Nat.pos_of_ne_zero (fun hz => htrans.1 (by simp [hz])) + have hpI : p ∈ I := htrans.2.2.2 + have hrel : v * (RH : ℤ) - w * (LH : ℤ) = s * (p * U : ℕ) := by + have he := validTransferredPivot_equation I (v * RH - w * LH) (s * U) htrans + change v * (RH : ℤ) - w * (LH : ℤ) = (s * U) * p at he + calc + _ = (s * U) * p := he + _ = _ := by rw [Nat.cast_mul]; ring + have hleft := movingFrequencyCoefficient_child_products value outside μ childBound pivotBound V + F φ G n v u small.1 bulk.1 p XL hA + have hright := movingFrequencyCoefficient_child_products value outside μ childBound pivotBound V + F φ G n w u small.2 bulk.2 p XR hB + have hLunit : LH.Coprime (p * U) := hleft.2 + have hcop : LH.Coprime RH := transferred_products_coprime LH RH v w s (p * U) hs hrel + (fun q hq _ hd => hsV.trans_lt (hRH q hq hd)) + (common_prime_pivot_unit (p * U) LH RH hLunit) + have hmerged := pairwise_coprime_merge_shared (XL :: CL.map value) (XR :: CR.map value) + outside hleft.1 hright.1 (by simpa only [LH, RH, List.prod_cons, MovingSlotReversal.naturalProduct] using hcop) + have hperm : ((XL :: CL.map value) ++ (XR :: CR.map value) ++ outside).Perm + (XL :: XR :: ((CL ++ CR).map value ++ outside)) := by + apply List.perm_iff_count.mpr + intro a + simp only [List.count_cons, List.count_append, List.map_append] + omega + have hpair := (hperm.pairwise_iff (fun h => h.symm)).mp hmerged + have hw0 : w ≠ 0 := by + intro hz + apply hB + subst w + exact movingFrequencyCoefficient_zero value outside μ childBound pivotBound V F hF φ G + n (appendMovingSlotLeaves n u small.2) bulk.2 p XR + have hpw := (movingFrequencyCoefficient_nonzero_support value outside μ childBound pivotBound V + F φ G n w (appendMovingSlotLeaves n u small.2) bulk.2 p XR hB).2.1 + have hpw' : p.Coprime w.natAbs := by + simpa only [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast] using hpw + have hUw : U.Coprime w.natAbs := large_prime_factors_coprime_frequency U w hw0 + (fun q hq hd => hw.trans_lt (hU q hq hd)) + have hroot : IsCoprime s (RH : ℤ) := by + have h := large_prime_factors_coprime_frequency RH s hs + (fun q hq hd => hsV.trans_lt (hRH q hq hd)) + simpa only [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast] using h.symm + have hguard : movingNodeArithmeticGuard (childBound (n + 1)) (pivotBound (n + 1)) + LH RH s v w (p * U) := + ⟨hs, hroot, hrel, Nat.mul_pos (hI p hpI) hUpos, hbound p hpI, hv, hw, hgap, + hpw'.mul_left hUw⟩ + have hfactor : movingPrimeNodeFactor value outside childBound pivotBound φ G n CL CR + (flattenMovingSlots n u) XL XR s v w = + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) := by + unfold movingPrimeNodeFactor + exact ite_eq_left ⟨hpair, hguard, hUpos⟩ + rw [hfactor] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeOccurrences.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeOccurrences.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c65c3daf505c8cbfb7068972e09a0a6737ab951 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeOccurrences.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalLocalFactor +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRepresentativeSquares + +namespace OAI + +/-! # Simultaneous occurrences of one actual internal prime in both histories -/ + +namespace Ostmann +open scoped Classical BigOperators + +abbrev MovingPrimeOccurrences {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) := + Σ side : Bool, {j : Fin (T side).occurrences.length // + ∃ i ∈ ((T side).occurrences.get j).current.compensationSlots, value i = p} + +def movingPrimeOccurrence {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) + (j : MovingPrimeOccurrences value T p) : MovingSlotOccurrence σ := + (T j.1).occurrences.get j.2.val + +noncomputable def movingPrimeOccurrenceLine {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) + (j : MovingPrimeOccurrences value T p) : PolynomialGiantLine σ := + let o := movingPrimeOccurrence value T p j + movingSlotLine o.path o.current + +theorem movingPrimeOccurrences_card {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) : + Fintype.card (MovingPrimeOccurrences value T p) ≤ 2 * (2 ^ n - 1) := by + have h (side : Bool) : Fintype.card {j : Fin (T side).occurrences.length // + ∃ i ∈ ((T side).occurrences.get j).current.compensationSlots, value i = p} ≤ 2 ^ n - 1 := by + calc + _ ≤ Fintype.card (Fin (T side).occurrences.length) := + Fintype.card_le_of_injective Subtype.val Subtype.val_injective + _ = _ := by rw [Fintype.card_fin, MovingSlotData.occurrences_length] + rw [Fintype.card_sigma, Fintype.sum_bool] + have h0 := h false + have h1 := h true + omega + +theorem movingInternalLocalSupport_occurrences {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) + (x y : ZMod (p ^ 2)) : + (∀ side, movingInternalLocalSupport value (T side) p x y) ↔ + ∀ j : MovingPrimeOccurrences value T p, + let L := movingPrimeOccurrenceLine value T p j + let φ := MovingSlotReversal.naturalReduction (p ^ 2) value + squareReduction p (φ L.a * x + φ L.b * y) = 0 ∧ φ L.a * x + φ L.b * y ≠ 0 := by + constructor + · intro h j + obtain ⟨i, hi, hpi⟩ := j.2.property + exact h j.1 _ (List.get_mem _ _) i hi hpi + · intro h side o ho i hi hpi + obtain ⟨k, hk, hko⟩ := List.mem_iff_getElem.mp ho + let j : MovingPrimeOccurrences value T p := + ⟨side, ⟨⟨k, hk⟩, by simpa only [List.get_eq_getElem, hko] using ⟨i, hi, hpi⟩⟩⟩ + simpa only [movingPrimeOccurrenceLine, movingPrimeOccurrence, j, List.get_eq_getElem, hko] using h j + +/-- Every row used by the simultaneous lift estimate is nonzero, by the +actual prime tiers and frequencies of its original occurrence. -/ +theorem movingPrimeOccurrenceLine_nonzero {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) + (j : MovingPrimeOccurrences value T p) : + let φ := MovingSlotReversal.naturalReduction p value + let L := movingPrimeOccurrenceLine value T p j + φ L.a ≠ 0 ∨ φ L.b ≠ 0 := by + obtain ⟨i, hi, hpi⟩ := j.2.property + subst p + let : Fact (value i).Prime := ⟨hprime i⟩ + let o := movingPrimeOccurrence value T (value i) j + have hu := (T j.1).occurrence_units_of_prime_types tier value hprime hdisjoint (hlevels j.1) + o (List.get_mem _ _) i + ((T j.1).occurrence_compensation_level tier (hlevels j.1) o (List.get_mem _ _) i hi) (hf j.1) + change MovingSlotReversal.naturalReduction (value i) value (movingSlotLine o.path o.current).a ≠ 0 ∨ + MovingSlotReversal.naturalReduction (value i) value (movingSlotLine o.path o.current).b ≠ 0 + apply movingHistoryLine_nonzero (o.path.map MovingSlotReversal.polynomial) + o.current.polynomial.v o.current.polynomial.w (MovingSlotReversal.naturalReduction (value i) value) + · intro s hs + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs + exact hu.1 t ht + · exact hu.2.1 + · exact hu.2.2 + +/-- Ancestor denominators are also units at the current internal prime. -/ +theorem movingPrimeOccurrenceLine_denominator_ne_zero {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) + (j : MovingPrimeOccurrences value T p) : + MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).denominator ≠ 0 := by + obtain ⟨i, hi, hpi⟩ := j.2.property + subst p + let : Fact (value i).Prime := ⟨hprime i⟩ + let o := movingPrimeOccurrence value T (value i) j + have hu := (T j.1).occurrence_units_of_prime_types tier value hprime hdisjoint (hlevels j.1) + o (List.get_mem _ _) i + ((T j.1).occurrence_compensation_level tier (hlevels j.1) o (List.get_mem _ _) i hi) (hf j.1) + apply movingPolynomialAncestors_denominator (o.path.map MovingSlotReversal.polynomial) + (MovingSlotReversal.naturalReduction (value i) value) + intro s hs + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs + exact (hu.1 t ht).2.2 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeOffDiagonalCoefficient.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeOffDiagonalCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..cad3d5e7b212e48329bf5d1d8496f72ee84bf224 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeOffDiagonalCoefficient.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeNodeSubstitution + +namespace OAI + +/-! # The complete next coefficient as the original integer off-diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingPrimeOffDiagonalCoefficient {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (small bulk : TreeLeafTuple (List σ) (n + 1)) (XL XR : ℕ) (I : Finset ℕ) : ℂ := + ∑ a : TreeLeafTuple (Fin 4 → σ) n, (movingCompensationPrior (μ n) n a : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + let u := movingCompensationSlots n a + let U := MovingSlotReversal.naturalProduct value (flattenMovingSlots n u) + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let p := movingTopPivot value CL CR (flattenMovingSlots n u) XL XR s v.val w.val + if validTransferredPivot I + (v.val * (XR * MovingSlotReversal.naturalProduct value CR : ℕ) - + w.val * (XL * MovingSlotReversal.naturalProduct value CL : ℕ)) (s * U) then + (((U : ℝ) * φ (Real.log p - G (n + 1)) : ℝ) : ℂ) * + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n v.val + (appendMovingSlotLeaves n u small.1) bulk.1 p XL * + star (movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n w.val + (appendMovingSlotLeaves n u small.2) bulk.2 p XR) + else 0 + +/-- This identifies the full next coefficient, rather than a history-wise +surrogate. Only compensation samples with nonzero original prior need the +range bounds. -/ +theorem movingFrequencyCoefficient_eq_offDiagonal {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (hs : s ≠ 0) (hsV : s.natAbs ≤ V (n + 1)) + (small bulk : TreeLeafTuple (List σ) (n + 1)) (XL XR : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) + (hVL : V (n + 1) < XL) (hVR : V (n + 1) < XR) + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) : + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let RH := XR * MovingSlotReversal.naturalProduct value CR + 2 * pivotBound (n + 1) * childBound (n + 1) < RH → + (∀ q, q.Prime → q ∣ RH → V (n + 1) < q) → + (∀ a : TreeLeafTuple (Fin 4 → σ) n, movingCompensationPrior (μ n) n a ≠ 0 → + let U := MovingSlotReversal.naturalProduct value (flattenMovingSlots n (movingCompensationSlots n a)) + (∀ p ∈ I, p * U ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ U → childBound (n + 1) < q)) → + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G (n + 1) s small bulk XL XR = + movingPrimeOffDiagonalCoefficient value outside μ childBound pivotBound V F φ G n s small bulk XL XR I := by + intro CR RH hgap hRH hU + rw [movingFrequencyCoefficient_prime_node value outside μ childBound pivotBound V hV F hF + φ G n s hs hsV small bulk XL XR hXL hXR hVL hVR] + unfold movingPrimeOffDiagonalCoefficient + apply Finset.sum_congr rfl + intro a _ + by_cases ha : movingCompensationPrior (μ n) n a = 0 + · simp only [ha, Complex.ofReal_zero, zero_mul] + · apply congrArg (fun z : ℂ => (movingCompensationPrior (μ n) n a : ℂ) * z) + apply Finset.sum_congr rfl + intro v _ + apply Finset.sum_congr rfl + intro w _ + exact movingPrimeNodeFactor_substitution value outside μ childBound pivotBound V F hF φ G n + (movingCompensationSlots n a) small bulk XL XR s v.val w.val I hI hφ hsV + (((mem_transferFrequencyRange _ _).mp v.property).trans hchild) + (((mem_transferFrequencyRange _ _).mp w.property).trans hchild) + (hU a ha).1 hgap hRH (hU a ha).2 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePageCRT.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePageCRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..1f2eca201cf2c20be397cbf93731fae11f4df72f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePageCRT.lean @@ -0,0 +1,141 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedPageCRT + +namespace OAI + +/-! # Both giant prime coordinates in the exact arithmetic CRT average -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Restricting the first external CRT coordinate to a unit gives the +original two-prime CRT coordinates. -/ +theorem crtUnitPairEquiv_to_external {B : Type*} [Fintype B] (a : B → ℕ) + (hc : Pairwise (fun i j => (a i).Coprime (a j))) + (z : (ZMod (∏ i, a i))ˣ × (ZMod (∏ i, a i))ˣ) (i : B) : + crtExternalPairEquiv a hc ((z.1 : ZMod (∏ i, a i)), z.2) i = + ((crtUnitPairEquiv a hc z i).1.val, (crtUnitPairEquiv a hc z i).2) := by + rcases z with ⟨x, y⟩ + simp only [crtExternalPairEquiv_apply, crtUnitPairEquiv_apply, + crtUnitEquiv_apply, ZMod.prodEquivPi_apply] + rfl + +/-- Both Page factors stay in the frequency block; the other blocks have +exactly their uniform two-unit laws. -/ +noncomputable def movingArithmeticPrimePageFactor {I : Type*} + (r : ℕ) (q : I → ℕ) (P : Finset ℕ) (S : Finset I) + (input : PublishedProgressionInput) (Q : ℕ) (x y : ℝ) + (f : ∀ b, ZMod (movingArithmeticModuli r q P S b) × + (ZMod (movingArithmeticModuli r q P S b))ˣ → ℂ) : + ∀ b, (ZMod (movingArithmeticModuli r q P S b))ˣ × + (ZMod (movingArithmeticModuli r q P S b))ˣ → ℂ + | .inl u, z => f (.inl u) (z.1.val, z.2) * + pageGiantWeight input Q r (show (ZMod r)ˣ from z.1).val.val x * + pageGiantWeight input Q r (show (ZMod r)ˣ from z.2).val.val y + | .inr b, z => f (.inr b) (z.1.val, z.2) + +theorem movingArithmeticPrimePageFactor_product {I : Type*} + (r : ℕ) (q : I → ℕ) (P : Finset ℕ) (S : Finset I) + (input : PublishedProgressionInput) (Q : ℕ) (x y : ℝ) + (f : ∀ b, ZMod (movingArithmeticModuli r q P S b) × + (ZMod (movingArithmeticModuli r q P S b))ˣ → ℂ) + (v : ∀ b, (ZMod (movingArithmeticModuli r q P S b))ˣ × + (ZMod (movingArithmeticModuli r q P S b))ˣ) : + (∏ b, movingArithmeticPrimePageFactor r q P S input Q x y f b (v b)) = + (∏ b, f b ((v b).1.val, (v b).2)) * + pageGiantWeight input Q r + (show (ZMod r)ˣ from (v (.inl ())).1).val.val x * + pageGiantWeight input Q r + (show (ZMod r)ˣ from (v (.inl ())).2).val.val y := by + simp only [Fintype.prod_sum_type, Fintype.prod_unique, movingArithmeticPrimePageFactor] + ring + +section +variable {σ I : Type*} (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : Bool → ∀ i, (ZMod (q i))ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (P : Finset ℕ) (S : Finset I) + [∀ b, NeZero (movingArithmeticModuli r q P S b)] + [NeZero (∏ b, movingArithmeticModuli r q P S b)] + (hf : ∀ side, (T side).Frequencies (· ≠ 0)) + (hR : ∀ side, (T side).frequencyProduct ∣ R) + (hfrequency : R ^ (n + 1) ∣ (r : ℤ)) + (hcover : ∀ side, ∀ o ∈ (T side).occurrences, + ∀ i ∈ o.current.compensationSlots, value i ∈ P) + (hc : Pairwise (fun b c => (movingArithmeticModuli r q P S b).Coprime + (movingArithmeticModuli r q P S c))) + (input : PublishedProgressionInput) (Q : ℕ) + (hpage : pageAtModulus (∏ b, movingArithmeticModuli r q P S b) (selectedPageZero input Q) = + pageAtModulus r (selectedPageZero input Q)) + +include hf hR hfrequency hcover hc hpage + +/-- The literal two-prime giant average, with both exceptional-character +multipliers, factors over the same concrete arithmetic blocks. -/ +theorem movingSeparatedPairResidueCoefficient_prime_page_average (x y : ℝ) : + correctedPrimePairAverage input Q (∏ b, movingArithmeticModuli r q P S b) + (movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R) x y = + ∏ b, (Fintype.card ((ZMod (movingArithmeticModuli r q P S b))ˣ × + (ZMod (movingArithmeticModuli r q P S b))ˣ) : ℂ)⁻¹ * + ∑ z, movingArithmeticPrimePageFactor r q P S input Q x y + (movingArithmeticLocalFactor q value outside F E g D T nodes R r P S) b z := by + let a := movingArithmeticModuli r q P S + let e := crtUnitPairEquiv a hc + let f := movingArithmeticLocalFactor q value outside F E g D T nodes R r P S + let fP := movingArithmeticPrimePageFactor r q P S input Q x y f + have hpageA : pageAtModulus (∏ b, a b) (selectedPageZero input Q) = + pageAtModulus r (selectedPageZero input Q) := hpage + have he (z : (ZMod (∏ b, a b))ˣ × (ZMod (∏ b, a b))ˣ) : + movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R + z.1.val.val z.2.val.val * + pageGiantWeight input Q (∏ b, a b) z.1.val.val x * + pageGiantWeight input Q (∏ b, a b) z.2.val.val y = + ∏ b, fP b (e z b) := by + have hp (i : Bool) (w : ℝ) : + pageGiantWeight input Q (∏ b, a b) (if i then z.1.val.val else z.2.val.val) w = + pageGiantWeight input Q r + (if i then (e z (.inl ())).1.val.val else (e z (.inl ())).2.val.val) w := by + have hcast := crtExternalPairEquiv_casts a hc (z.1.val, z.2) (.inl ()) + rw [crtUnitPairEquiv_to_external] at hcast + have hm : Nat.ModEq r (if i then z.1.val.val else z.2.val.val) + (if i then (e z (.inl ())).1.val.val else (e z (.inl ())).2.val.val) := by + apply (ZMod.natCast_eq_natCast_iff _ _ _).mp + cases i + · change (z.2.val.val : ZMod r) = ((e z (.inl ())).2.val.val : ZMod r) + calc + _ = (show ZMod r from (e z (.inl ())).2.val) := congrArg Prod.snd hcast + _ = _ := (ZMod.natCast_zmod_val (show ZMod r from (e z (.inl ())).2.val)).symm + · change (z.1.val.val : ZMod r) = ((e z (.inl ())).1.val.val : ZMod r) + calc + _ = (show ZMod r from (e z (.inl ())).1.val) := congrArg Prod.fst hcast + _ = _ := (ZMod.natCast_zmod_val (show ZMod r from (e z (.inl ())).1.val)).symm + calc + _ = pageGiantWeight input Q r (if i then z.1.val.val else z.2.val.val) w := by + simp only [pageGiantWeight, hpageA] + _ = _ := pageGiantWeight_modEq input Q r _ _ hm w + have hleft := hp true x + have hright := hp false y + simp only [ite_true, Bool.false_eq_true, ite_false] at hleft hright + rw [movingSeparatedPairResidueCoefficient_crt q value outside F E g D T nodes + R r P S hf hR hfrequency hcover hc (z.1.val, z.2), hleft, hright] + simp_rw [crtUnitPairEquiv_to_external] + exact (movingArithmeticPrimePageFactor_product r q P S input Q x y f (e z)).symm + unfold correctedPrimePairAverage + have hsum : (∑ z : (ZMod (∏ b, a b))ˣ × (ZMod (∏ b, a b))ˣ, + movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R + z.1.val.val z.2.val.val * + pageGiantWeight input Q (∏ b, a b) z.1.val.val x * + pageGiantWeight input Q (∏ b, a b) z.2.val.val y) = + ∑ z : (ZMod (∏ b, a b))ˣ × (ZMod (∏ b, a b))ˣ, ∏ b, fP b (e z b) := + Finset.sum_congr rfl (fun z _ => he z) + rw [hsum, e.sum_comp (fun z => ∏ b, fP b (z b)), Fintype.card_congr e, Fintype.card_pi] + rw [← Fintype.prod_sum] + simp only [Nat.cast_prod, Finset.prod_mul_distrib, Finset.prod_inv_distrib] + rfl + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternArithmeticComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternArithmeticComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..8c6b3bcd2198f030ed08ff09977662a0937e382d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternArithmeticComparison.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternSquareError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternLineComparison + +namespace OAI + +/-! # Original-pattern arithmetic for two prime giant residues -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Remove the actual prime-square exclusions and replace the remaining +simultaneous line probabilities by their symbolic flags under the original +pattern law. No injectivity assumption is imposed on the sampling measure. -/ +theorem movingPrimePattern_arithmetic_comparison {A B C : Type*} + [Fintype A] [Nonempty A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ b, (movingPatternFinData e n t small bulk pattern b).SizeLE d) + (hfreq : ∀ b, (movingPatternFinData e n t small bulk pattern b).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E α β V : ℝ) (hE : 0 ≤ E) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hmax : ∀ j a, μ j a ≤ α) (hnmax : ∀ j a, ν j a ≤ α) + (hpmax : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≤ β) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + Real.exp V ≤ prime a) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hcross : ∀ x, G x ≠ 0 → ∀ b c, + prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (hfmod : ∀ x, G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) : + let κ := D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternPrimeHaarProduct e prime hprime n t small bulk pattern x - + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x)‖ ≤ + κ * (((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) + + 2 * ((Fintype.card C * (2 + 2 * (2 ^ n - 1)) : ℕ) : ℝ) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β)) := by + let H := movingPatternInjectionGuard e G + have hH : ∀ x, ‖H x‖ ≤ D := movingPatternInjectionGuard_norm e G D hD hG + have hsupp (x) (hx : H x ≠ 0) : G x ≠ 0 := + (movingPatternInjectionGuard_nonzero e G x hx).2 + have hsq := movingPrimePattern_averaged_square_error e prime hprime tierB tierC t small bulk pattern rep + hsmall hbulk htier μ ν hμ hν hmass hnmass E V hbound hprimeSize H D hD hH + (fun x hx => hdisjoint x (hsupp x hx)) (fun x hx => hfmod x (hsupp x hx)) + have hline := movingPrimePattern_line_comparison e prime hpInj hprime tierB tierC t small bulk pattern rep + hsmall hbulk htier d F U hF hU hsize hfreq hvalues μ ν hμ hν hmass hnmass E α β V + hE hα hβ hV hbound hmax hnmax hpmax + (fun c a ha => (Real.le_log_iff_exp_le (Nat.cast_pos.mpr (hprime a).pos)).mpr + (hprimeSize c a ha)) + H D hD hH (fun x hx => hdisjoint x (hsupp x hx)) + (fun x hx => (movingPatternInjectionGuard_nonzero e G x hx).1) + (fun x hx => hcross x (hsupp x hx)) (fun x hx => hfmod x (hsupp x hx)) + dsimp only at hsq hline ⊢ + have heq : (∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternPrimeHaarProduct e prime hprime n t small bulk pattern x - + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x)) = + (∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPrimePatternSquareDifference e prime hprime n t small bulk pattern x) + + ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternPrimeLineProduct e prime hprime n t small bulk pattern x - + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x) := by + rw [← Finset.sum_add_distrib] + apply Finset.sum_congr rfl + intro x _ + unfold movingPatternPrimeHaarProduct movingPrimePatternSquareDifference movingPatternPrimeLineProduct + ring + rw [heq] + apply (norm_add_le _ _).trans + calc + _ ≤ _ + _ := add_le_add hsq hline + _ = _ := by ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternBulkFubini.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternBulkFubini.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f069b2cb39a9417e35012ba3cc4e6a3a320314a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternBulkFubini.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternFrozenMultiplier +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkFubini + +namespace OAI + +/-! # Original bulk law for the two-prime symbolic factors -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingPrimePatternBulkMultiplier {A B C : Type*} [Fintype A] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (x : Fin (N + 1) → A) : ℂ := + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x + +theorem movingPrimePatternBulkMultiplier_frozen {A B C : Type*} [Fintype A] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (x y : TreeLeafIndex n × Fin m → A) + (a : {i : Fin (N + 1) // i ∉ Set.range (movingPatternBulkEmbedding e slot)} → A) : + movingPrimePatternBulkMultiplier e μ prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) x a) = + movingPrimePatternBulkMultiplier e μ prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) y a) := by + unfold movingPrimePatternBulkMultiplier + rw [movingPairCompensatedMass_bulk_frozen e μ prime slot pattern x y a, + movingPatternPrimeFlagProduct_bulk_frozen e prime t small slot perm pattern rep x y a] + +theorem movingPrimePattern_original_bulk_fubini {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (G : (Fin (N + 1) → A) → ℂ) (seed : TreeLeafIndex n × Fin m → A) : + let bulk := movingPatternBulkLeaves n m slot perm + let lift := movingPatternBulkEmbedding e slot + let law := movingPatternExternalLaw e ν + (∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x) = + ∑ a : {i : Fin (N + 1) // i ∉ Set.range lift} → A, + ((∏ i : {i : Fin (N + 1) // i ∉ Set.range lift}, law i (a i) : ℝ) : ℂ) * + (movingPrimePatternBulkMultiplier e μ prime n t small bulk pattern rep (joinBulkNonbulk lift seed a) * + ∑ x : TreeLeafIndex n × Fin m → A, + ((∏ j, ν (slot j) (x j) : ℝ) : ℂ) * + movingPatternInjectionGuard e G (joinBulkNonbulk lift x a)) := by + dsimp only + let lift := movingPatternBulkEmbedding e slot + let law := movingPatternExternalLaw e ν + let bulk := movingPatternBulkLeaves n m slot perm + let M := movingPrimePatternBulkMultiplier e μ prime n t small bulk pattern rep + have heq : (∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x) = + ∑ x, ((∏ i, law i (x i) : ℝ) : ℂ) * (M x * movingPatternInjectionGuard e G x) := by + apply Finset.sum_congr rfl + intro x _ + rw [show (∏ i, law i (x i)) = ∏ b, ν b (x (e.symm (.inl b))) from + movingPatternExternalLaw_product e ν x] + unfold movingOriginalPatternWeight M movingPrimePatternBulkMultiplier + ring + rw [heq] + have hsplit := finite_prior_selected_fubini lift law + (fun x => M x * movingPatternInjectionGuard e G x) + simp only [finite_univ_canonical] at hsplit ⊢ + rw [hsplit] + apply Finset.sum_congr rfl + intro a _ + congr 1 + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + have hm := movingPrimePatternBulkMultiplier_frozen e μ prime t small slot perm pattern rep x seed a + change M (joinBulkNonbulk lift x a) = M (joinBulkNonbulk lift seed a) at hm + rw [hm] + have hlaw (j : TreeLeafIndex n × Fin m) : law (lift j) (x j) = ν (slot j) (x j) := by + change Sum.elim ν (fun _ _ => 1) (e (e.symm (.inl (slot j)))) (x j) = _ + rw [Equiv.apply_symm_apply] + rfl + simp only [hlaw] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternBulkMajorant.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternBulkMajorant.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d44a2d5227ec4aca3f0f50b7640109aa2682a6d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternBulkMajorant.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternBulkMean + +namespace OAI + +/-! # Integrating nonuniform errors under the original pattern law -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPrimePattern_flagged_pointwise_bound {A B C : Type*} + [Fintype B] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (x : Fin (N + 1) → A) : + ‖movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x‖ ≤ + (‖G x‖ * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + productPrior (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x := by + have h := movingPrimePattern_flagged_weight_bound e μ ν prime n t small bulk pattern rep E hprime hμ hν hbound + (fun _ => G x) ‖G x‖ (norm_nonneg _) (fun _ => le_rfl) x + by_cases hi : Function.Injective (fun c => x (e.symm (.inr c))) <;> + simpa only [movingOriginalPatternWeight, movingPatternInjectionGuard, hi, ite_true, ite_false] using h + +/-- A variable bound for the literal signed bulk mean is integrated against +the original external and representative priors. In particular the large +pointwise spectator error is averaged, rather than replaced by its supremum. -/ +theorem movingPrimePattern_signed_bulk_majorant {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) (hE : 0 ≤ E) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hnmass : ∀ j, ∑ a, ν j a = 1) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : (Fin (N + 1) → A) → ℝ) + (hG : ∀ x, ‖movingPatternBulkMean e ν slot G x‖ ≤ D x) + (seed : TreeLeafIndex n × Fin m → A) : + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep x‖ ≤ + ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * + ∑ x, productPrior law x * D x := by + intro law + let κ := (4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C) + have hκ : 0 ≤ κ := mul_nonneg (by positivity) (pow_nonneg hE _) + have hlaw (i : Fin (N + 1)) (a : A) : 0 ≤ law i a := by + dsimp only [law] + cases e i with + | inl b => exact hν b a + | inr c => exact hμ _ a + rw [movingPrimePattern_original_bulk_mean_eq e μ ν prime hnmass t small slot perm pattern rep G seed] + calc + _ ≤ ∑ x, (D x * κ) * productPrior law x := norm_sum_le_of_le _ (fun x _ => + (movingPrimePattern_flagged_pointwise_bound e μ ν prime n t small + (movingPatternBulkLeaves n m slot perm) pattern rep E hprime hμ hν hbound + (movingPatternBulkMean e ν slot G) x).trans + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right (hG x) hκ) + (productPrior_nonneg law hlaw x))) + _ = κ * ∑ x, productPrior law x * D x := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternBulkMean.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternBulkMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..dbc6633446043ce0b21336c86574b61a3f386c9f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternBulkMean.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternBulkFubini +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternFlagBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkMean + +namespace OAI + +/-! # Original bulk law for the two-prime symbolic factors -/ + +namespace Ostmann +open scoped Classical BigOperators + +private theorem movingPatternBulkMean_guard_average {A B C : Type*} [Fintype A] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (ν : B → A → ℝ) + (hmass : ∀ j, ∑ a, ν j a = 1) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (G : (Fin (N + 1) → A) → ℂ) + (a : {i : Fin (N + 1) // i ∉ Set.range (movingPatternBulkEmbedding e slot)} → A) : + (∑ z : TreeLeafIndex n × Fin m → A, ((∏ j, ν (slot j) (z j) : ℝ) : ℂ) * + movingPatternInjectionGuard e (movingPatternBulkMean e ν slot G) + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z a)) = + ∑ z : TreeLeafIndex n × Fin m → A, ((∏ j, ν (slot j) (z j) : ℝ) : ℂ) * + movingPatternInjectionGuard e G (joinBulkNonbulk (movingPatternBulkEmbedding e slot) z a) := by + have hmR : (∑ z : TreeLeafIndex n × Fin m → A, ∏ j, ν (slot j) (z j)) = 1 := by + rw [← Fintype.prod_sum] + simp only [hmass, Finset.prod_const_one] + have hm : (∑ z : TreeLeafIndex n × Fin m → A, ((∏ j, ν (slot j) (z j) : ℝ) : ℂ)) = 1 := by + exact_mod_cast hmR + simp_rw [movingPatternInjectionGuard_join, movingPatternBulkMean_join] + by_cases h : Function.Injective + (fun c => a ⟨e.symm (.inr c), movingPatternBulkEmbedding_internal_absent e slot c⟩) + · simp only [h, ite_true] + rw [← Finset.sum_mul, hm, one_mul] + · simp only [h, ite_false, mul_zero, Finset.sum_const_zero] + +/-- Averaging only selected bulk coordinates preserves the original signed +pattern expression, including the class-injectivity guard. -/ +theorem movingPrimePattern_original_bulk_mean_eq {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (hmass : ∀ j, ∑ a, ν j a = 1) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (G : (Fin (N + 1) → A) → ℂ) (seed : TreeLeafIndex n × Fin m → A) : + (∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep x) = + ∑ x, movingOriginalPatternWeight e μ ν prime n pattern (movingPatternBulkMean e ν slot G) x * + movingPatternPrimeFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep x := by + rw [movingPrimePattern_original_bulk_fubini e μ ν prime t small slot perm pattern rep G seed, + movingPrimePattern_original_bulk_fubini e μ ν prime t small slot perm pattern rep + (movingPatternBulkMean e ν slot G) seed] + apply Finset.sum_congr rfl + intro a _ + rw [movingPatternBulkMean_guard_average e ν hmass slot G a] + +/-- A bound proved for the actual signed bulk mean lifts to the full original +pattern law with only its depth-dependent representative-prior cost. -/ +theorem movingPrimePattern_signed_bulk_mean_bound {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) + (hG : ∀ x, ‖movingPatternBulkMean e ν slot G x‖ ≤ D) + (seed : TreeLeafIndex n × Fin m → A) : + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep x‖ ≤ + D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) := by + rw [movingPrimePattern_original_bulk_mean_eq e μ ν prime hnmass t small slot perm pattern rep G seed] + exact movingPrimePattern_flagged_mean_bound e μ ν prime n t small _ pattern rep E hprime hμ hν + hmass hnmass hbound _ D hD hG + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternFlagBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternFlagBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9039fa1276d477371e2532134fab6b4c3f6fb10 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternFlagBound.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternProducts +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeLineScalar + +namespace OAI + +/-! # Original bulk law for the two-prime symbolic factors -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPrimePattern_flagged_weight_bound {A B C : Type*} [Fintype B] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (x : Fin (N + 1) → A) : + ‖movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x‖ ≤ + (D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x := by + have h := movingPattern_fin_prime_prior_bound e μ ν prime n pattern rep E hprime hμ hν hbound + (movingPatternInjectionGuard e G) D hD (movingPatternInjectionGuard_norm e G D hD hG) x + change ‖movingOriginalPatternWeight e μ ν prime n pattern G x‖ * + (∏ c, internalLineScalar false (prime (x (e.symm (.inr c))))) ≤ _ at h + apply le_trans _ h + rw [norm_mul] + apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) + unfold movingPatternPrimeFlagProduct + rw [norm_prod] + apply Finset.prod_le_prod₀ + · intro c _ + exact norm_nonneg _ + · intro c _ + rw [Complex.norm_real, Real.norm_of_nonneg (internalLineFlagWeight_nonneg _ _ _)] + exact internalLineFlagWeight_le_scalar _ _ _ + +/-- After normalization, all the symbolic internal factors cost only the +number of internal draws. There is no factor counting the external slots. -/ +theorem movingPrimePattern_flagged_mean_bound {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) : + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x‖ ≤ + D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) := by + let law := fun i : Fin (N + 1) => + Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + have hlaw (i) : ∑ a, law i a = 1 := by + dsimp only [law] + cases e i with + | inl b => exact hnmass b + | inr c => exact hmass _ + calc + _ ≤ ∑ x, (D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + productPrior law x := norm_sum_le_of_le _ (fun x _ => + movingPrimePattern_flagged_weight_bound e μ ν prime n t small bulk pattern rep E + hprime hμ hν hbound G D hD hG x) + _ = _ := by rw [← Finset.mul_sum, productPrior_mass law hlaw, mul_one] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternFrozenMultiplier.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternFrozenMultiplier.lean new file mode 100644 index 0000000000000000000000000000000000000000..0ef09d69c2852c503c69cdf61085c666bce269c3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternFrozenMultiplier.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternProducts +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternFrozenMultiplier + +namespace OAI + +/-! # Original bulk law for the two-prime symbolic factors -/ + +namespace Ostmann +open scoped Classical BigOperators + +def movingPrimePatternFeasible {B C : Type*} {N : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) : Prop := + let T := movingPatternFinData e n t small bulk pattern + let base := movingPatternFinRepresentative e n t small bulk pattern rep + ∀ c, lineFeasibleFlags false (fun s => arithmeticTestFlag (lineTestPolynomials + (movingIndexedLine T (e.symm (.inr c)) (base c)) ⟨(base c).1, (base c).2.val⟩ s = 0)) + +/-- The only value-dependent part of the symbolic factor is one reciprocal +prime per class. All feasibility decisions are formal polynomial identities. -/ +theorem movingPatternPrimeFlagProduct_eq {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (x : Fin (N + 1) → A) : + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x = + if movingPrimePatternFeasible e n t small bulk pattern rep then + ∏ c : C, (internalLineScalar false (prime (x (e.symm (.inr c)))) : ℂ) else 0 := by + by_cases h : movingPrimePatternFeasible e n t small bulk pattern rep + · rw [ite_eq_left h] + unfold movingPatternPrimeFlagProduct + apply Finset.prod_congr rfl + intro c _ + simp only [internalLineFlagWeight, h c, ite_true] + · rw [ite_eq_right h] + obtain ⟨c, hc⟩ := not_forall.mp h + unfold movingPatternPrimeFlagProduct + apply Finset.prod_eq_zero (Finset.mem_univ c) + simp only [internalLineFlagWeight, hc, ite_false, Complex.ofReal_zero] + +theorem movingPatternPrimeFlagProduct_congr {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (x y : Fin (N + 1) → A) (h : ∀ c, x (e.symm (.inr c)) = y (e.symm (.inr c))) : + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x = + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep y := by + rw [movingPatternPrimeFlagProduct_eq, movingPatternPrimeFlagProduct_eq] + simp only [h] + +/-- In the exact Fubini decomposition of the original law, these factors +belong wholly to the fixed nonbulk coefficient. -/ +theorem movingPatternPrimeFlagProduct_bulk_frozen {A B C : Type*} [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (x y : TreeLeafIndex n × Fin m → A) + (a : {i : Fin (N + 1) // i ∉ Set.range (movingPatternBulkEmbedding e slot)} → A) : + movingPatternPrimeFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) x a) = + movingPatternPrimeFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep + (joinBulkNonbulk (movingPatternBulkEmbedding e slot) y a) := by + apply movingPatternPrimeFlagProduct_congr + intro c + exact (joinBulkNonbulk_nonbulk _ x a + ⟨e.symm (.inr c), movingPatternBulkEmbedding_internal_absent e slot c⟩).trans + (joinBulkNonbulk_nonbulk _ y a + ⟨e.symm (.inr c), movingPatternBulkEmbedding_internal_absent e slot c⟩).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternLineComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternLineComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..16c1f47011019d906f6d8b071fb83442a5ea1dde --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternLineComparison.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternProducts +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeLineScalar +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeDominatedLineComparison + +namespace OAI + +/-! # Original-pattern arithmetic for two prime giant residues -/ + +namespace Ostmann +open scoped Classical BigOperators + +open scoped Classical BigOperators + +/-- Apply the proved comparison to the actual pattern tree and its original +external priors. All occurrence rows and unique representatives are derived +from that constructor. The loss involves internal classes, not bulk size. -/ +theorem movingPrimePattern_line_comparison {A B C : Type*} + [Fintype A] [Nonempty A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ b, (movingPatternFinData e n t small bulk pattern b).SizeLE d) + (hfreq : ∀ b, (movingPatternFinData e n t small bulk pattern b).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E α β V : ℝ) (hE : 0 ≤ E) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hmax : ∀ j a, μ j a ≤ α) (hnmax : ∀ j a, ν j a ≤ α) + (hpmax : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≤ β) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + V ≤ Real.log (prime a : ℝ)) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hclasses : ∀ x, G x ≠ 0 → Function.Injective (fun c => x (e.symm (.inr c)))) + (hcross : ∀ x, G x ≠ 0 → ∀ b c, + prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (hfmod : ∀ x, G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) : + let T := movingPatternFinData e n t small bulk pattern + let base := movingPatternFinRepresentative e n t small bulk pattern rep + let W := fun x : Fin (N + 1) → A => + ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * G x + ‖∑ x, W x * + ((∏ c, (movingSampledInternalPrimeProbability prime hprime T x (e.symm (.inr c)) : ℂ)) - + ∏ c, (internalLineFlagWeight false (prime (x (e.symm (.inr c)))) + (fun s => arithmeticTestFlag (lineTestPolynomials + (movingIndexedLine T (e.symm (.inr c)) (base c)) + ⟨(base c).1, (base c).2.val⟩ s = 0)) : ℂ))‖ ≤ + 2 * (D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + ((Fintype.card C * (2 + 2 * (2 ^ n - 1)) : ℕ) : ℝ) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β) := by + dsimp only + let T := movingPatternFinData e n t small bulk pattern + let prior := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let W := fun x : Fin (N + 1) → A => + ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * G x + have hnz (x) (hx : W x ≠ 0) : G x ≠ 0 := by + intro hz + exact hx (by simp only [W, hz, mul_zero]) + have hprior (i a) : 0 ≤ prior i a := by + dsimp only [prior] + cases e i with + | inl b => exact hν b a + | inr c => exact hμ _ a + have hmass' (i) : ∑ a, prior i a = 1 := by + dsimp only [prior] + cases e i with + | inl b => exact hnmass b + | inr c => exact hmass _ + have hmax' (i a) : prior i a ≤ α := by + dsimp only [prior] + cases e i with + | inl b => exact hnmax b a + | inr c => exact hmax _ a + have hpmax' (c a) : prior (e.symm (.inr c)) a ≤ β := by + simpa only [prior, Equiv.apply_symm_apply, Sum.elim_inr] using hpmax c a + have h := moving_prime_dominated_line_product_comparison prime hpInj hprime T + ((Sum.elim tierB tierC) ∘ e) + (movingPatternFinData_levels e tierB tierC n t small bulk pattern hsmall hbulk htier) + (fun c => e.symm (.inr c)) (movingPatternFinRepresentative e n t small bulk pattern rep) + d F U hF hU hsize hfreq hvalues prior hprior hmass' α β V hα hβ hV hmax' hpmax' + (fun c a ha => hprimeSize c a (by + simpa only [prior, Equiv.apply_symm_apply, Sum.elim_inr] using ha)) W (D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) + (by positivity) + (fun x => movingPattern_fin_prime_prior_bound e μ ν prime n pattern rep E hprime hμ hν hbound G D hD hG x) + (fun x hx => hdisjoint x (hnz x hx)) + (fun x hx c i hi => movingPatternFin_unique e prime hpInj x + (hclasses x (hnz x hx)) (hcross x (hnz x hx)) c i hi) + (fun x hx c b => hfmod x (hnz x hx) c b) + simpa only [movingPairOccurrenceIndex_card, Nat.cast_mul, Nat.cast_add, Nat.cast_ofNat] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternPriorSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternPriorSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a9d17c129b64d9c29dcb42a094ecfe8707252fc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternPriorSupport.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPriorSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternArithmeticComparison + +namespace OAI + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPrimePattern_arithmetic_comparison_on_support {A B C : Type*} + [Fintype A] [Nonempty A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ b, (movingPatternFinData e n t small bulk pattern b).SizeLE d) + (hfreq : ∀ b, (movingPatternFinData e n t small bulk pattern b).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E α β V : ℝ) (hE : 0 ≤ E) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hmax : ∀ j a, μ j a ≤ α) (hnmax : ∀ j a, ν j a ≤ α) + (hpmax : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≤ β) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + Real.exp V ≤ prime a) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hcross : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ b c, + prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (hfmod : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) : + let κ := D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternPrimeHaarProduct e prime hprime n t small bulk pattern x - + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x)‖ ≤ + κ * (((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) + + 2 * ((Fintype.card C * (2 + 2 * (2 ^ n - 1)) : ℕ) : ℝ) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β)) := by + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let H := fun x => if productPrior law x = 0 then 0 else G x + have hsupp (x) (hx : H x ≠ 0) : productPrior law x ≠ 0 ∧ G x ≠ 0 := by + dsimp only [H] at hx + split_ifs at hx with hz + · exact False.elim (hx rfl) + · exact ⟨hz, hx⟩ + have hH (x) : ‖H x‖ ≤ D := by + dsimp only [H] + split_ifs + · simpa only [norm_zero] using hD + · exact hG x + have hh := movingPrimePattern_arithmetic_comparison e prime hpInj hprime tierB tierC t small bulk + pattern rep hsmall hbulk htier d F U hF hU hsize hfreq hvalues μ ν hμ hν hmass hnmass + E α β V hE hα hβ hV hbound hmax hnmax hpmax hprimeSize H D hD hH + (fun x hx => hdisjoint x (hsupp x hx).1 (hsupp x hx).2) + (fun x hx => hcross x (hsupp x hx).1 (hsupp x hx).2) + (fun x hx => hfmod x (hsupp x hx).1 (hsupp x hx).2) + have heq (x) : movingOriginalPatternWeight e μ ν prime n pattern H x = + movingOriginalPatternWeight e μ ν prime n pattern G x := + movingOriginalPatternWeight_support_restrict e μ ν prime pattern rep E hprime hμ hν hbound G x + simp_rw [heq] at hh + exact hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternProducts.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e1b8d1bea7d0312ba224b099bd535b86560261b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternProducts.lean @@ -0,0 +1,41 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternArithmeticComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeInternalProduct + +namespace OAI + +/-! # The original pattern products in the two-prime environment -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingPatternPrimeLineProduct {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (x : Fin (N + 1) → A) : ℂ := + ∏ c, (movingSampledInternalPrimeProbability prime hprime + (movingPatternFinData e n t small bulk pattern) x (e.symm (.inr c)) : ℂ) + +noncomputable def movingPatternPrimeHaarProduct {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (x : Fin (N + 1) → A) : ℂ := + let T := movingPatternFinData e n t small bulk pattern + letI : ∀ c : C, Fact (prime (x (e.symm (.inr c)))).Prime := fun _ => ⟨hprime _⟩ + ∏ c, movingInternalPrimeAverage (fun i => prime (x i)) T (prime (x (e.symm (.inr c)))) + +noncomputable def movingPatternPrimeFlagProduct {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (x : Fin (N + 1) → A) : ℂ := + let T := movingPatternFinData e n t small bulk pattern + let base := movingPatternFinRepresentative e n t small bulk pattern rep + ∏ c, (internalLineFlagWeight false (prime (x (e.symm (.inr c)))) + (fun s => arithmeticTestFlag (lineTestPolynomials + (movingIndexedLine T (e.symm (.inr c)) (base c)) + ⟨(base c).1, (base c).2.val⟩ s = 0)) : ℂ) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternSquareError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternSquareError.lean new file mode 100644 index 0000000000000000000000000000000000000000..c4e3f558d5b4ce540302cea2d7ff7e829c69bc49 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternSquareError.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternProducts +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeLineScalar +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternAveragedSquare + +namespace OAI + +/-! # Original-pattern arithmetic for two prime giant residues -/ + +namespace Ostmann +open scoped Classical BigOperators + +open scoped Classical BigOperators + +noncomputable def movingPrimePatternSquareDifference {A B C : Type*} [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) (x : Fin (N + 1) → A) : ℂ := + let T := movingPatternFinData e n t small bulk pattern + letI : ∀ c : C, Fact (prime (x (e.symm (.inr c)))).Prime := fun _ => ⟨hprime _⟩ + (∏ c, movingInternalPrimeAverage (fun i => prime (x i)) T (prime (x (e.symm (.inr c))))) - + ∏ c, (movingSampledInternalPrimeProbability prime hprime T x (e.symm (.inr c)) : ℂ) + +/-- All square exclusions can be removed under the literal dependent pattern +law. The loss keeps the inverse-prime scale from every internal class. -/ +theorem movingPrimePattern_averaged_square_error {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E V : ℝ) (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + Real.exp V ≤ prime a) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hfmod : ∀ x, G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) : + let W := fun x : Fin (N + 1) → A => + ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * G x + ‖∑ x, W x * movingPrimePatternSquareDifference e prime hprime n t small bulk pattern x‖ ≤ + (D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + ((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) := by + dsimp only + let T := movingPatternFinData e n t small bulk pattern + let prior := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let W := fun x : Fin (N + 1) → A => + ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * G x + have hm (i) : ∑ a, prior i a = 1 := by + dsimp only [prior] + cases e i with + | inl b => exact hnmass b + | inr c => exact hmass _ + have hdom (x) : ‖W x‖ * + (∏ c, internalLineScalar false (prime (x (e.symm (.inr c))))) ≤ + (D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + productPrior prior x := + movingPattern_fin_prime_prior_bound e μ ν prime n pattern rep E hprime hμ hν hbound G D hD hG x + apply productPrior_relative_error prior hm W + (movingPrimePatternSquareDifference e prime hprime n t small bulk pattern) + (fun x => ∏ c, internalLineScalar false (prime (x (e.symm (.inr c))))) + (D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) + ((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) (by positivity) + hdom + intro x hx + have hg : G x ≠ 0 := by + intro hz + exact hx (by simp only [W, hz, mul_zero]) + have hscalar : 0 < ∏ c, internalLineScalar false (prime (x (e.symm (.inr c)))) := by + apply Finset.prod_pos + intro c _ + simp only [internalLineScalar, Bool.false_eq_true, ite_false] + exact inv_pos.mpr (Nat.cast_pos.mpr (Nat.sub_pos_of_lt (hprime _).one_lt)) + have hprior : productPrior prior x ≠ 0 := by + intro hz + have hh := hdom x + rw [hz, mul_zero] at hh + exact (not_le_of_gt (mul_pos (norm_pos_iff.mpr hx) hscalar)) hh + have hsample (c) : μ (movingSampleTier (rep c).val.2) (x (e.symm (.inr c))) ≠ 0 := by + have hh := (Finset.prod_ne_zero_iff.mp hprior) (e.symm (.inr c)) (Finset.mem_univ _) + simpa only [prior, Equiv.apply_symm_apply, Sum.elim_inr] using hh + have h := movingPrimeRepresentativeProduct_error ((Sum.elim tierB tierC) ∘ e) + (fun i => prime (x i)) (fun i => hprime _) (hdisjoint x hg) T + (movingPatternFinData_levels e tierB tierC n t small bulk pattern hsmall hbulk htier) + (fun c => e.symm (.inr c)) (movingPatternFinRepresentative e n t small bulk pattern rep) + (hfmod x hg) V (fun c => hprimeSize c _ (hsample c)) + simpa only [movingPrimePatternSquareDifference, movingInternalPrimeLineProbability, + movingSampledInternalPrimeProbability] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternSupportedArithmetic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternSupportedArithmetic.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a4f0d89221a0a11d7831d90f78c43844cde5d08 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternSupportedArithmetic.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternSupportedMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternPriorSupport + +namespace OAI + +/-! # Combining arithmetic and bulk cancellation on the original support -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPrimePattern_signed_arithmetic_on_support {A B C : Type*} + [Fintype A] [Nonempty A] [Fintype B] [Fintype C] {N n : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (prime : A → ℕ) + (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (tierB : B → ℕ) (tierC : C → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List B) n) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) + (hsmall : ∀ b, ∀ i ∈ flattenMovingSlots n (small b), n ≤ tierB i) + (hbulk : ∀ b, ∀ i ∈ flattenMovingSlots n (bulk b), n ≤ tierB i) + (htier : ∀ i, tierC (pattern i) = movingSampleTier i.2) + (d : ℕ) (F U : ℝ) (hF : 1 ≤ F) (hU : 1 ≤ U) + (hsize : ∀ b, (movingPatternFinData e n t small bulk pattern b).SizeLE d) + (hfreq : ∀ b, (movingPatternFinData e n t small bulk pattern b).Frequencies (fun s => |(s : ℝ)| ≤ F)) + (hvalues : ∀ a, |((prime a : ℤ) : ℝ)| ≤ U) + (μ : ℕ → A → ℝ) (ν : B → A → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (E α β V : ℝ) (hE : 0 ≤ E) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (hmax : ∀ j a, μ j a ≤ α) (hnmax : ∀ j a, ν j a ≤ α) + (hpmax : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≤ β) + (hprimeSize : ∀ c a, μ (movingSampleTier (rep c).val.2) a ≠ 0 → + Real.exp V ≤ prime a) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (hdisjoint : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ i j, + (Sum.elim tierB tierC) (e i) ≠ (Sum.elim tierB tierC) (e j) → prime (x i) ≠ prime (x j)) + (hcross : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ b c, + prime (x (e.symm (.inl b))) ≠ prime (x (e.symm (.inr c)))) + (hfmod : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + G x ≠ 0 → ∀ c b, + (movingPatternFinData e n t small bulk pattern b).Frequencies + (fun s => (s : ZMod (prime (x (e.symm (.inr c))))) ≠ 0)) + (m : ℕ) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (hbulkEq : bulk = movingPatternBulkLeaves n m slot perm) + (Dminor : ℝ) + (hminor : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + ‖movingPatternBulkMean e ν slot G x‖ ≤ Dminor) + (seed : TreeLeafIndex n × Fin m → A) : + let κ := (4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C) + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeHaarProduct e prime hprime n t small bulk pattern x‖ ≤ + κ * (D * (((2 * (2 ^ n - 1 : ℕ)) * Fintype.card C * Real.exp (-V)) + + 2 * ((Fintype.card C * (2 + 2 * (2 ^ n - 1)) : ℕ) : ℝ) * + ((2 * ((n + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * U ^ d)) ^ (n + 1)) ^ 2) / V) * β)) + Dminor) := by + have ha := movingPrimePattern_arithmetic_comparison_on_support e prime hpInj hprime tierB tierC t small bulk pattern rep + hsmall hbulk htier d F U hF hU hsize hfreq hvalues μ ν hμ hν hmass hnmass + E α β V hE hα hβ hV hbound hmax hnmax hpmax hprimeSize G D hD hG hdisjoint hcross hfmod + have hb : ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x‖ ≤ + Dminor * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) := by + rw [hbulkEq] + simpa only [mul_comm] using + movingPrimePattern_signed_bulk_mean_on_support e μ ν prime t small slot perm pattern rep E hE + hprime hμ hν hmass hnmass hbound G Dminor hminor seed + dsimp only at ha ⊢ + let X := ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeHaarProduct e prime hprime n t small bulk pattern x + let Y := ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x + have heq : X - Y = ∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + (movingPatternPrimeHaarProduct e prime hprime n t small bulk pattern x - + movingPatternPrimeFlagProduct e prime n t small bulk pattern rep x) := by + dsimp only [X, Y] + rw [← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro x _ + ring + have htriangle : ‖X‖ ≤ ‖X - Y‖ + ‖Y‖ := by + simpa only [sub_add_cancel] using norm_add_le (X - Y) Y + rw [heq] at htriangle + exact htriangle.trans ((add_le_add ha hb).trans_eq (by ring)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternSupportedMean.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternSupportedMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd0e85eb75c3c5474ea44769dd140ec05f0dd142 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePatternSupportedMean.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimePatternBulkMajorant + +namespace OAI + +/-! # Signed bulk estimates needed only on the original pattern prior -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Invalid role assignments outside the original product law require no +analytic estimate. This retains the original harmonic priors when applying +an estimate proved with their precise prime ranges. -/ +theorem movingPrimePattern_signed_bulk_mean_on_support {A B C : Type*} + [Fintype A] [Fintype B] [Fintype C] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) (hE : 0 ≤ E) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hmass : ∀ j, ∑ a, μ j a = 1) (hnmass : ∀ j, ∑ a, ν j a = 1) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) + (hG : ∀ x, productPrior + (fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x ≠ 0 → + ‖movingPatternBulkMean e ν slot G x‖ ≤ D) + (seed : TreeLeafIndex n × Fin m → A) : + ‖∑ x, movingOriginalPatternWeight e μ ν prime n pattern G x * + movingPatternPrimeFlagProduct e prime n t small (movingPatternBulkLeaves n m slot perm) pattern rep x‖ ≤ + ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C)) * D := by + let law := fun i => Sum.elim ν (fun c => μ (movingSampleTier (rep c).val.2)) (e i) + let minor := fun x => if productPrior law x = 0 then ‖movingPatternBulkMean e ν slot G x‖ else D + have hminor (x) : ‖movingPatternBulkMean e ν slot G x‖ ≤ minor x := by + dsimp only [minor] + split_ifs with h + · exact le_rfl + · exact hG x h + have hlaw (i) : ∑ a, law i a = 1 := by + dsimp only [law] + cases e i with + | inl b => exact hnmass b + | inr c => exact hmass _ + have hmean : (∑ x, productPrior law x * minor x) = D := by + calc + _ = ∑ x, productPrior law x * D := by + apply Finset.sum_congr rfl + intro x _ + dsimp only [minor] + split_ifs with h + · simp only [h, zero_mul] + · rfl + _ = D := by rw [← Finset.sum_mul, productPrior_mass law hlaw, one_mul] + have hh := movingPrimePattern_signed_bulk_majorant e μ ν prime t small slot perm pattern rep E hE + hprime hμ hν hnmass hbound G minor hminor seed + dsimp only at hh + dsimp only [law] at hmean + rw [hmean] at hh + exact hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePointwiseNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePointwiseNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe2445fc75f5a39ccccfe5d584a4145391785bd5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimePointwiseNorm.lean @@ -0,0 +1,143 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenPrimeArithmeticNorm +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSpectatorNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCost + +namespace OAI + +/-! # Pointwise costs for the literal two-prime arithmetic factors -/ + +namespace Ostmann +open scoped Classical BigOperators + +private theorem finite_mean_norm_le {A : Type*} [Fintype A] [Nonempty A] + (f : A → ℂ) (B : ℝ) (hf : ∀ a, ‖f a‖ ≤ B) : + ‖(Fintype.card A : ℂ)⁻¹ * ∑ a, f a‖ ≤ B := by + have hc : (Fintype.card A : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + rw [norm_mul, norm_inv, Complex.norm_natCast] + calc + _ ≤ (Fintype.card A : ℝ)⁻¹ * ∑ _a : A, B := + mul_le_mul_of_nonneg_left ((norm_sum_le _ _).trans (Finset.sum_le_sum fun a _ => hf a)) + (inv_nonneg.mpr (Nat.cast_nonneg _)) + _ = B := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + rw [← mul_assoc, inv_mul_cancel₀ hc, one_mul] + +theorem movingFrequencyCorePrimeAverage_norm_le {σ : Type*} (value : σ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (R : ℤ) + (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) + (x y : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) : + ‖movingFrequencyCorePrimeAverage value F E T R r input Q x y‖ ≤ + 4 * (‖movingDataWeight (F false) (E false) (T false)‖ * + ‖movingDataWeight (F true) (E true) (T true)‖) := by + apply finite_mean_norm_le + intro z + have hcore : ‖movingFrequencyCore value F E T R z.1.val.val z.2.val.val‖ ≤ + ‖movingDataWeight (F false) (E false) (T false)‖ * + ‖movingDataWeight (F true) (E true) (T true)‖ := by + unfold movingFrequencyCore + split_ifs + · simp only [norm_mul, Complex.norm_conj, le_refl] + · simp only [norm_zero] + positivity + have hw : ‖pageGiantWeight input Q r z.1.val.val x * + pageGiantWeight input Q r z.2.val.val y‖ ≤ 4 := by + rw [norm_mul] + exact (mul_le_mul (pageGiantWeight_norm_le_two input Q r _ x hx) + (pageGiantWeight_norm_le_two input Q r _ y hy) (norm_nonneg _) (by norm_num)).trans_eq + (by norm_num) + rw [norm_mul] + exact (mul_le_mul hcore hw (norm_nonneg _) (by positivity)).trans_eq (mul_comm _ _) + +theorem frozenBulkFrequencyPrime_norm_le {σ J : Type*} + (base : σ → ℕ) (slot : J ↪ σ) (outside : List ℕ) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (childBound : ℕ → ℕ) + (R : ℤ) (r : ℕ) [NeZero r] (input : PublishedProgressionInput) + (Q : ℕ) (x y : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) (a : J → (ZMod r)ˣ) : + ‖frozenBulkFrequencyPrime base slot outside F E T childBound R r input Q x y a‖ ≤ + 4 * (‖movingDataWeight (F false) (E false) (T false)‖ * + ‖movingDataWeight (F true) (E true) (T true)‖) := by + unfold frozenBulkFrequencyPrime + split_ifs + · rw [one_mul] + exact movingFrequencyCorePrimeAverage_norm_le _ F E T R r input Q x y hx hy + · rw [zero_mul, norm_zero] + positivity + +theorem frozenBulkSpectatorPrime_norm_le {σ : Type*} {q : ℕ} [Fact q.Prime] + (base : σ → ℕ) (n m : ℕ) (t : Bool → FrequencyTree ℤ n) + (small : Bool → TreeLeafTuple (List σ) n) (samples : Bool → MovingSampleSlots σ n) + (D : Bool → (ZMod q)ˣ) (e : Equiv.Perm (TreeLeafIndex n × Fin m)) + (g : ZMod q → ℂ) (K : ℝ) (hK : 0 ≤ K) (hg : ∀ x, ‖g x‖ ≤ K) + (z : TreeLeafIndex n × Fin m → (ZMod q)ˣ) : + ‖frozenBulkSpectatorPrime base n m t small samples D e g z‖ ≤ K ^ (2 ^ (n + 1)) := by + apply finite_mean_norm_le + exact fun a => frozenBulkSpectatorPair_norm_le base n m t small samples D e g K hK hg a z + +theorem movingFrequencyPrimeAverage_norm_le {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) + (x y : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) : + ‖movingFrequencyPrimeAverage value outside F E T nodes R r input Q x y‖ ≤ + 4 * (‖movingDataWeight (F false) (E false) (T false)‖ * + ‖movingDataWeight (F true) (E true) (T true)‖) := by + rw [movingFrequencyPrimeAverage_core] + split_ifs + · simpa only [one_mul] using + movingFrequencyCorePrimeAverage_norm_le value F E T R r input Q x y hx hy + · simp only [zero_mul, norm_zero] + positivity + +theorem movingSpectatorPrimeAverage_norm_le {σ : Type*} (value : σ → ℕ) + (q : ℕ) [Fact q.Prime] (g : ZMod q → ℂ) (D : Bool → (ZMod q)ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (B : ℝ) (hB : 0 ≤ B) + (hg : ∀ z, ‖g z‖ ≤ B) : + ‖movingSpectatorPrimeAverage value q g D T‖ ≤ B ^ (2 ^ (n + 1)) := by + apply finite_mean_norm_le + intro z + rw [movingSpectatorPairFactor, norm_mul, Complex.norm_conj] + calc + _ ≤ B ^ (2 ^ n) * B ^ (2 ^ n) := + mul_le_mul (movingModularSpectator_norm value q g (D false) B hB hg (T false) z.1 z.2) + (movingModularSpectator_norm value q g (D true) B hB hg (T true) z.1 z.2) + (norm_nonneg _) (pow_nonneg hB _) + _ = _ := by rw [← pow_add, pow_succ]; congr 1; omega + +theorem moving_frozen_prime_residue_coefficient_norm {σ J : Type*} + (base : σ → ℕ) (slot : J ↪ σ) (outside : List ℕ) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℤ → ℤ → ℝ) + (n m : ℕ) (data : Bool → MovingSlotData σ n) (childBound : ℕ → ℕ) + (R : ℤ) (r : ℕ) [NeZero r] (P : PublishedProgressionInput) (Q : ℕ) + (x y : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (S : ∀ i, Finset (ZMod (p i))) (hS : ∀ i, (S i).Nonempty) + (hSp : ∀ i, (S i).card < p i) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List σ) n) + (samples : Bool → MovingSampleSlots σ n) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (a : J → (ZMod r)ˣ) (z : ∀ i, TreeLeafIndex n × Fin m → (ZMod (p i))ˣ) : + ‖frozenBulkFrequencyPrime base slot outside F E data childBound R r P Q x y a * + ∏ i, frozenBulkSpectatorPrime base n m t small samples (twist i) perm + (normalizedResidueTransform (S i)) (z i)‖ ≤ + (4 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖)) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) := by + rw [norm_mul, norm_prod] + apply mul_le_mul + (frozenBulkFrequencyPrime_norm_le base slot outside F E data childBound R r P Q x y hx hy a) + (Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) (fun i _ => + frozenBulkSpectatorPrime_norm_le base n m t small samples (twist i) perm + (normalizedResidueTransform (S i)) (p i) (Nat.cast_nonneg _) + (normalizedResidueTransform_norm_le_prime (S i) (hS i) (hSp i)) (z i))) + (Finset.prod_nonneg fun _ _ => norm_nonneg _) (by positivity) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeProbabilityError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeProbabilityError.lean new file mode 100644 index 0000000000000000000000000000000000000000..30d4e78f457d74088887980582d53304be89e11e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeProbabilityError.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeHaarError +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeBaseAverage + +namespace OAI + +/-! # The square error retains the one-over-prime line factor -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The base coefficient is a nonnegative indicator, so its absolute average +is exactly its simultaneous line probability. -/ +theorem movingInternalBaseFactor_prime_norm_average {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : + (Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) : ℝ)⁻¹ * + (∑ z : (ZMod p)ˣ × (ZMod p)ˣ, ‖movingInternalBaseFactor value T p z.1 z.2‖) = + internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) := by + have he (z : (ZMod p)ˣ × (ZMod p)ˣ) : + (movingInternalBaseFactor value T p z.1 z.2).re = + ‖movingInternalBaseFactor value T p z.1 z.2‖ := by + unfold movingInternalBaseFactor + split_ifs <;> simp + have h := congrArg Complex.re (movingInternalBaseFactor_prime_average value T p) + simpa only [← Complex.ofReal_natCast, ← Complex.ofReal_inv, Complex.mul_re, + Complex.ofReal_re, Complex.ofReal_im, zero_mul, sub_zero, Complex.re_sum, he] using h + +theorem movingInternalPrimeAverage_probability_error {σ : Type*} {n : ℕ} + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (p : ℕ) [Fact p.Prime] + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod p) ≠ 0)) : + let prob := internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) + ‖(Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + (∑ z : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ, movingInternalPairFactor value T p z.1 z.2) - + (prob : ℂ)‖ ≤ (2 * (2 ^ n - 1 : ℕ) / (p : ℝ)) * prob := by + have h := movingInternalPrimeAverage_base_error tier value hprime hdisjoint T hlevels p hf + rw [movingInternalBaseFactor_prime_average, movingInternalBaseFactor_prime_norm_average] at h + exact h + +theorem movingInternalPrimeAverage_probability_norm_le {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (p : ℕ) [Fact p.Prime] : + ‖(Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + (∑ z : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ, movingInternalPairFactor value T p z.1 z.2)‖ ≤ + internalLineProbability false + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).a) + (fun j => MovingSlotReversal.naturalReduction p value + (movingPrimeOccurrenceLine value T p j).b) := by + have h := movingInternalPrimeAverage_base_norm_le value T p + rwa [movingInternalBaseFactor_prime_norm_average] at h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeResidueRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeResidueRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..33f6a653bf826cd1b0d6b3092aa8829eb3fcc00e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeResidueRate.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingJointGiantRate +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePairResidues +import OAI.NumberTheory.Ostmann.Construction.GiantResidueSumBound + +namespace OAI + +/-! # Simultaneous giant idealization summed over every unit residue pair -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_prime_residue_sum_rate (P : PublishedProgressionInput) + {σ : Type*} (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), T.Frequencies (fun s => |(s : ℝ)| ≤ V) → + ∀ Q q : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + ∀ c : ℕ → ℕ → ℂ, + (∀ a ∈ reducedResidues q, ∀ b ∈ reducedResidues q, + 2 * ‖c a b‖ * (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + ‖(∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c a b * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y)))) - + (∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + ∫ x, ∫ y, c a b * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂primeGiantMeasure P Q q a u v)‖ ≤ + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_joint_prime_rate (σ := σ) n C d, + giant_residue_sum_error_rate (Real.exp 1 + 2) (by positivity)] with L hL hR + intro value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c hbudget + dsimp only + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let err := Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + have hm (b : ℕ) : reciprocalPrimeInterval q b (Real.exp r) (Real.exp s) ≤ Real.exp 1 := + (reciprocalPrimeInterval_le_exp q b r s).trans (Real.exp_le_exp.mpr (by linarith)) + have hpoint (b : ℕ) (hb : b ∈ reducedResidues q) (a : ℕ) (ha : a ∈ reducedResidues q) : + ‖complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v (fun x => + c a b * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y))) - + ∫ x, ∫ y, c a b * movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) + ∂primeGiantMeasure P Q q b r s ∂primeGiantMeasure P Q q a u v‖ ≤ err * (Real.exp 1 + 2) := by + exact (hL value hvalue childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q a b hQ hq hqQ (Finset.mem_filter.mp ha).2 (Finset.mem_filter.mp hb).2 hlog + u v r s hu huv hshort hr hrs hrshort (c a b) (hbudget a ha b hb)).trans + (mul_le_mul_of_nonneg_left (by linarith [hm b]) (Real.exp_pos _).le) + apply (finite_pair_comparison (reducedResidues q) (reducedResidues q) _ _ _ hpoint).trans + have hc : ((reducedResidues q).card : ℝ) ≤ q := Nat.cast_le.mpr (reducedResidues_card_le q) + calc + _ ≤ (q : ℝ) * q * (err * (Real.exp 1 + 2)) := by gcongr + _ = (q : ℝ) ^ 2 * (Real.exp 1 + 2) * err := by ring + _ ≤ _ := hR q (by omega) hqlog + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeRootGuard.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeRootGuard.lean new file mode 100644 index 0000000000000000000000000000000000000000..16cdcd20676b4576e0736d0d923cdad23d9014c9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeRootGuard.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTransferSupport +import OAI.NumberTheory.Ostmann.ZeroDensity.MovingZeroFrequency + +namespace OAI + +/-! # The top frequency guards at actual prime giants -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem MovingSlotData.Follows.frequencies {σ : Type*} {n : ℕ} + {T : MovingSlotData σ n} {t : FrequencyTree ℤ n} (hT : T.Follows t) + (P : ℤ → Prop) (h : ∀ s ∈ allFrequencyList n t, P s) : T.Frequencies P := by + induction T with + | leaf s regular => exact h s (by simpa only [allFrequencyList, hT, List.mem_singleton]) + | node s CL CR U left right ihL ihR => + refine ⟨h s (by simp only [allFrequencyList, List.mem_cons, hT.1, true_or]), ?_, ?_⟩ + · exact ihL hT.2.1 (fun a ha => h a (List.mem_cons_of_mem _ (List.mem_append_left _ ha))) + · exact ihR hT.2.2 (fun a ha => h a (List.mem_cons_of_mem _ (List.mem_append_right _ ha))) + +theorem movingFrequencySkeleton_follows (σ : Type*) (n : ℕ) (t : FrequencyTree ℤ n) : + (movingFrequencySkeleton σ n t).Follows t := by + induction n with + | zero => rfl + | succ n ih => exact ⟨rfl, ih t.2.1, ih t.2.2⟩ + +theorem movingRootState_prime_support_iff {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) (n : ℕ) (t : FrequencyTree ℤ (n + 1)) + (CL CR U : List σ) (XL XR V : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) (hVL : V < XL) (hVR : V < XR) + (hf : ∀ s ∈ allFrequencyList (n + 1) t, s ≠ 0 ∧ s.natAbs ≤ V) : + movingLocalSupport value outside (movingRootState n t CL CR U XL XR) ↔ + (XL :: XR :: ((CL ++ CR).map value ++ outside)).Pairwise Nat.Coprime := by + constructor + · exact fun h => h.1 + · intro hp + apply moving_local_support_prime_giants value outside + (movingRootState n t CL CR U XL XR).data XL XR V hXL hXR hVL hVR hp + apply MovingSlotData.Follows.frequencies + (T := (movingRootState n t CL CR U XL XR).data) (t := t) _ _ hf + exact ⟨rfl, movingFrequencySkeleton_follows σ n t.2.1, + movingFrequencySkeleton_follows σ n t.2.2⟩ + +/-- Nonzero child coefficients remove the zero-history cases. Thus the +remaining top guard depends only on the actual prime lists and the two root +frequencies, as required before the child sums are multiplied. -/ +theorem movingRootState_prime_guard_product {σ : Type*} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) + (hs : s ≠ 0) (hsV : s.natAbs ≤ V (n + 1)) + (l r : ScheduledFrequencyIndex V n) + (small bulk : TreeLeafTuple (List σ) (n + 1)) + (a : TreeLeafTuple (Fin 4 → σ) n) (XL XR : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) + (hVL : V (n + 1) < XL) (hVR : V (n + 1) < XR) (C : ℂ) (guard : Prop) : + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let t := (s, scheduledFrequencyHistory V n l, scheduledFrequencyHistory V n r) + let x := movingRootState n t CL CR (flattenMovingSlots n u) XL XR + let p := reconstructedPivot + (frequencyRoot n t.2.1 * (x.rightProduct value : ℤ) - + frequencyRoot n t.2.2 * (x.leftProduct value : ℤ)) (s * x.compensation value) + let L := movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n t.2.1 + (appendMovingSlotLeaves n u small.1) bulk.1 p XL + let R := movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n t.2.2 + (appendMovingSlotLeaves n u small.2) bulk.2 p XR + (if movingLocalSupport value outside x ∧ guard then C * L * star R else 0) = + (if (XL :: XR :: ((CL ++ CR).map value ++ outside)).Pairwise Nat.Coprime ∧ guard + then C * L * star R else 0) := by + dsimp only + by_cases hl : ∀ z ∈ allFrequencyList n (scheduledFrequencyHistory V n l), z ≠ 0 + · by_cases hr : ∀ z ∈ allFrequencyList n (scheduledFrequencyHistory V n r), z ≠ 0 + · have hf : ∀ z ∈ allFrequencyList (n + 1) + (s, scheduledFrequencyHistory V n l, scheduledFrequencyHistory V n r), + z ≠ 0 ∧ z.natAbs ≤ V (n + 1) := by + intro z hz + rcases List.mem_cons.mp hz with rfl | hz + · exact ⟨hs, hsV⟩ + · rcases List.mem_append.mp hz with hz | hz + · exact ⟨hl z hz, (scheduledFrequencyHistory_all_bound V hV n l z hz).trans + (hV (Nat.le_succ n))⟩ + · exact ⟨hr z hz, (scheduledFrequencyHistory_all_bound V hV n r z hz).trans + (hV (Nat.le_succ n))⟩ + rw [movingRootState_prime_support_iff value outside n _ _ _ _ XL XR (V (n + 1)) + hXL hXR hVL hVR hf] + split_ifs <;> rfl + · simp only [movingSupportedSampledWeight_zero_frequency value outside μ childBound + pivotBound F _ hF n _ _ _ _ _ hr, star_zero, mul_zero, ite_self] + · simp only [movingSupportedSampledWeight_zero_frequency value outside μ childBound + pivotBound F _ hF n _ _ _ _ _ hl, mul_zero, zero_mul, ite_self] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeRowNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeRowNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..4f8de2ff0e90b8502912070875a731ab99c4e9e9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeRowNorm.lean @@ -0,0 +1,130 @@ +import OAI.NumberTheory.Ostmann.Characters.TupleCRTFourier +import OAI.NumberTheory.Ostmann.Characters.NormalizedResidueIndicator +import OAI.NumberTheory.Ostmann.Construction.FiniteEnumeration + +namespace OAI + +/-! # The exact CRT row norm used by the giant-only transfer -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Both the giant's bounded row and the exact compensation-prime energies +enter multiplicatively, at their actual modulus sizes. -/ +theorem moving_crt_row_energy {J : Type*} [Fintype J] + (p : J → ℕ) [∀ j, NeZero (p j)] [NeZero (∏ j, p j)] + (hc : Pairwise (fun i j => (p i).Coprime (p j))) + (g : ∀ j, ZMod (p j) → ℂ) + (henergy : ∀ j, (∑ x, ‖g j x‖ ^ 2) ≤ (p j : ℝ)) : + (∑ x : ZMod (∏ j, p j), ‖tupleCRTFunction p hc g x‖ ^ 2) ≤ (∏ j, p j : ℕ) := by + have he := (ZMod.prodEquivPi p hc).toEquiv.sum_comp + (fun x : ∀ j, ZMod (p j) => ∏ j, ‖g j (x j)‖ ^ 2) + change (∑ x : ZMod (∏ j, p j), ∏ j, + ‖g j (ZMod.prodEquivPi p hc x j)‖ ^ 2) = _ at he + calc + _ = ∑ x : ∀ j, ZMod (p j), ∏ j, ‖g j (x j)‖ ^ 2 := by + simpa only [tupleCRTFunction, norm_prod, Finset.prod_pow] using he + _ = ∏ j, ∑ x : ZMod (p j), ‖g j x‖ ^ 2 := (Fintype.prod_sum (fun j (x : ZMod (p j)) => ‖g j x‖ ^ 2)).symm + _ ≤ ∏ j, (p j : ℝ) := Finset.prod_le_prod₀ + (fun j _ => Finset.sum_nonneg (fun _ _ => sq_nonneg _)) (fun j _ => henergy j) + _ = _ := (Nat.cast_prod _ _).symm + +/-- The cofactor and outside-denominator units merely permute each local row. -/ +theorem moving_crt_scaled_row_energy {J : Type*} [Fintype J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] [NeZero (∏ j, p j)] + (hc : Pairwise (fun i j => (p i).Coprime (p j))) + (g : ∀ j, ZMod (p j) → ℂ) (u : ∀ j, (ZMod (p j))ˣ) + (henergy : ∀ j, (∑ x, ‖g j x‖ ^ 2) ≤ (p j : ℝ)) : + (∑ x : ZMod (∏ j, p j), + ‖tupleCRTFunction p hc (fun j x => g j ((u j : ZMod (p j)) * x)) x‖ ^ 2) ≤ + (∏ j, p j : ℕ) := by + apply moving_crt_row_energy p hc + intro j + have he := Equiv.sum_comp (Equiv.mulLeft₀ (u j : ZMod (p j)) (Units.ne_zero _)) + (fun x => ‖g j x‖ ^ 2) + exact he.trans_le (henergy j) + +/-- This is the counting row indexed by `Fin modulus` in the finite transfer. -/ +theorem moving_crt_fin_row_energy {J : Type*} [Fintype J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] [NeZero (∏ j, p j)] + (hc : Pairwise (fun i j => (p i).Coprime (p j))) + (g : ∀ j, ZMod (p j) → ℂ) (u : ∀ j, (ZMod (p j))ˣ) + (henergy : ∀ j, (∑ x, ‖g j x‖ ^ 2) ≤ (p j : ℝ)) : + (∑ x : Fin (∏ j, p j), + ‖tupleCRTFunction p hc (fun j x => g j ((u j : ZMod (p j)) * x)) + (ZMod.finEquiv (∏ j, p j) x)‖ ^ 2) ≤ (∏ j, p j : ℕ) := by + have he := (ZMod.finEquiv (∏ j, p j)).toEquiv.sum_comp + (fun x => ‖tupleCRTFunction p hc (fun j x => g j ((u j : ZMod (p j)) * x)) x‖ ^ 2) + change (∑ x : Fin (∏ j, p j), + ‖tupleCRTFunction p hc (fun j x => g j ((u j : ZMod (p j)) * x)) + (ZMod.finEquiv (∏ j, p j) x)‖ ^ 2) = _ at he + exact he.trans_le (moving_crt_scaled_row_energy p hc g u henergy) + +/-- The giant factor is bounded by one; all other factors are the paper's +normalized compensation transforms. No bound on an individual compensation +transform is required. -/ +theorem moving_crt_compensation_row_energy {J : Type*} [Fintype J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] [NeZero (∏ j, p j)] + (hc : Pairwise (fun i j => (p i).Coprime (p j))) (giant : J) + (g : ∀ j, ZMod (p j) → ℂ) (u : ∀ j, (ZMod (p j))ˣ) + (S : ∀ j, Finset (ZMod (p j))) + (hg : ∀ x, ‖g giant x‖ ≤ 1) + (hregular : ∀ j, j ≠ giant → g j = normalizedResidueTransform (S j)) + (hS : ∀ j, j ≠ giant → (S j).Nonempty) + (hSp : ∀ j, j ≠ giant → (S j).card < p j) : + (∑ x : Fin (∏ j, p j), + ‖tupleCRTFunction p hc (fun j x => g j ((u j : ZMod (p j)) * x)) + (ZMod.finEquiv (∏ j, p j) x)‖ ^ 2) ≤ (∏ j, p j : ℕ) := by + apply moving_crt_fin_row_energy p hc g u + intro j + by_cases hj : j = giant + · subst j + calc + (∑ x, ‖g giant x‖ ^ 2) ≤ ∑ _x : ZMod (p giant), (1 : ℝ) := by + apply Finset.sum_le_sum + intro x _ + nlinarith [hg x, norm_nonneg (g giant x)] + _ = _ := by simp + · rw [hregular j hj, normalizedResidueTransform_energy (S j) (hS j hj) (hSp j hj)] + +private theorem finEquiv_eq_natCast (M : ℕ) [NeZero M] (x : Fin M) : + ZMod.finEquiv M x = (x.val : ZMod M) := by + cases M with + | zero => exact (NeZero.ne 0 rfl).elim + | succ M => + apply Fin.ext + exact (Nat.mod_eq_of_lt x.isLt).symm + +/-- The actual extracted row `G_P(t/d)`: each local argument includes the +outside denominator and the cofactor of that prime. Their inverses are units, +so the exact counting energy remains at most the modulus. -/ +theorem moving_compensation_fourier_row_energy {J : Type*} [Fintype J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] [NeZero (∏ j, p j)] + (hc : Pairwise (fun i j => (p i).Coprime (p j))) (giant : J) + (g : ∀ j, ZMod (p j) → ℂ) (S : ∀ j, Finset (ZMod (p j))) + (hg : ∀ x, ‖g giant x‖ ≤ 1) + (hregular : ∀ j, j ≠ giant → g j = normalizedResidueTransform (S j)) + (hS : ∀ j, j ≠ giant → (S j).Nonempty) + (hSp : ∀ j, j ≠ giant → (S j).card < p j) + (D : ℕ) (hD : ∀ j, D.Coprime (p j)) : + (∑ x : Fin (∏ j, p j), ‖∏ j, + g j ((x.val : ZMod (p j)) / ((D * tupleCofactor p j : ℕ) : ZMod (p j)))‖ ^ 2) ≤ + (∏ j, p j : ℕ) := by + let u : ∀ j, (ZMod (p j))ˣ := fun j => + (ZMod.unitOfCoprime (D * tupleCofactor p j) + ((hD j).mul_left (tupleCofactor_coprime p hc j)))⁻¹ + have hh := moving_crt_compensation_row_energy p hc giant g u S hg hregular hS hSp + convert hh using 1 + apply Finset.sum_congr rfl + intro x _ + congr 2 + unfold tupleCRTFunction + apply Finset.prod_congr rfl + intro j _ + simp only [u, Units.val_inv_eq_inv_val, ZMod.coe_unitOfCoprime, + finEquiv_eq_natCast, map_natCast, Pi.natCast_apply, div_eq_mul_inv] + rw [mul_comm] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeRowTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeRowTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e8cac41e59dbcbeed4b58e71fa257562ab1d138 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeRowTransfer.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.Preliminaries.TransferCauchy +import OAI.NumberTheory.Ostmann.Construction.HarmonicWordPriors +import OAI.NumberTheory.Ostmann.Construction.FiniteEnumeration + +namespace OAI + +/-! # The giant-only prime-to-integer row transfer in Section 7.5 + +The compensation product stays in the modulus. Only the actual giant prime +is averaged with its smooth harmonic prior, so no tuple-factorial loss occurs. +-/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem moving_prime_row_transfer {A : Type*} [Fintype A] + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (μ : A → ℝ) (hμ : ∀ a, 0 ≤ μ a) (hμmass : ∑ a, μ a = 1) + (w : ℕ → ℝ) (hw : ∀ p ∈ I, 0 ≤ w p) (Z : ℝ) (hZ : 0 ≤ Z) + (hmass : ∑ p : P, Z * w p / (p : ℝ) = 1) + (U : A → ℕ) + (row : ∀ a, (p : P) → Fin ((p : ℕ) * U a) → ℂ) + (B : ∀ a p, Fin (p * U a) → ℂ) + (hrow : ∀ a p, (∑ t, ‖row a p t‖ ^ 2) ≤ (p : ℕ) * (U a : ℝ)) : + ‖∑ a, (μ a : ℂ) * ∑ p : P, ((Z * w p / (p : ℝ) : ℝ) : ℂ) * + ∑ t, row a p t * B a p t‖ ^ 2 ≤ + Z * ∑ a, μ a * (U a : ℝ) * ∑ p ∈ I, w p * ∑ t, ‖B a p t‖ ^ 2 := by + let ν := fun ap : A × P => μ ap.1 * (Z * w ap.2 / (ap.2 : ℝ)) + have hν (ap) : 0 ≤ ν ap := + mul_nonneg (hμ ap.1) (div_nonneg (mul_nonneg hZ (hw _ (hPI ap.2.property))) + (Nat.cast_nonneg _)) + have hνmass : ∑ ap, ν ap = 1 := by + rw [Fintype.sum_prod_type] + simp only [ν, ← Finset.mul_sum, hmass, mul_one, hμmass] + have hh := finite_transfer_row_bound ν hν hνmass + (fun ap => row ap.1 ap.2) (fun ap => B ap.1 ap.2) + (fun ap => (ap.2 : ℕ) * (U ap.1 : ℝ)) (fun ap => hrow ap.1 ap.2) + have hleft : (∑ ap : A × P, (ν ap : ℂ) * ∑ t, row ap.1 ap.2 t * B ap.1 ap.2 t) = + ∑ a, (μ a : ℂ) * ∑ p : P, ((Z * w p / (p : ℝ) : ℝ) : ℂ) * + ∑ t, row a p t * B a p t := by + rw [Fintype.sum_prod_type] + simp only [ν, Complex.ofReal_mul, Finset.mul_sum, mul_assoc] + rw [hleft] at hh + apply hh.trans + have hcancel (a) (p : P) : + (Z * w p / (p : ℝ)) * ((p : ℕ) * (U a : ℝ)) = Z * (U a : ℝ) * w p := by + have hp : (p : ℝ) ≠ 0 := Nat.cast_ne_zero.mpr (hP _ p.property).ne_zero + field_simp + rw [Fintype.sum_prod_type] + calc + (∑ a, ∑ p : P, ν (a, p) * ((p : ℕ) * (U a : ℝ) * ∑ t, ‖B a p t‖ ^ 2)) = + Z * ∑ a, μ a * (U a : ℝ) * ∑ p ∈ P, w p * ∑ t, ‖B a p t‖ ^ 2 := by + simp only [ν] + simp_rw [show ∀ a (p : P), μ a * (Z * w p / (p : ℝ)) * + ((p : ℕ) * (U a : ℝ) * ∑ t, ‖B a p t‖ ^ 2) = + Z * (μ a * (U a : ℝ) * (w p * ∑ t, ‖B a p t‖ ^ 2)) from fun a p => by + calc + _ = μ a * ((Z * w p / (p : ℝ)) * ((p : ℕ) * (U a : ℝ))) * + (∑ t, ‖B a p t‖ ^ 2) := by ring + _ = _ := by rw [hcancel]; ring] + simp only [← Finset.mul_sum] + congr 1 + apply Finset.sum_congr rfl + intro a _ + congr 1 + simpa only [finite_univ_canonical] using + (Finset.sum_coe_sort P (fun p => w p * ∑ t, ‖B a p t‖ ^ 2)) + _ ≤ _ := by + apply mul_le_mul_of_nonneg_left _ hZ + apply Finset.sum_le_sum + intro a _ + apply mul_le_mul_of_nonneg_left _ (mul_nonneg (hμ a) (Nat.cast_nonneg _)) + apply Finset.sum_le_sum_of_subset_of_nonneg hPI + intro p hp _ + exact mul_nonneg (hw p hp) (Finset.sum_nonneg fun _ _ => sq_nonneg _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeSquareBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeSquareBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a7df56acfb5c55eee4f9fe417cfff8fc9f5c765 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingPrimeSquareBudget.lean @@ -0,0 +1,126 @@ +import OAI.NumberTheory.Ostmann.ZeroDensity.MovingZeroFrequency +import OAI.NumberTheory.Ostmann.Arithmetic.PairedScheduledNormBound + +namespace OAI + +/-! # The original coefficient square and the scheduled arithmetic budget -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- The original external average of two sampled histories. The external +weights may in particular be the unchanged product of harmonic prime priors. -/ +noncomputable def movingOriginalPrimePairMean {σ I Ω : Type} + [Fintype σ] [Fintype Ω] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (ν : Ω → ℝ) (small bulk : Ω → TreeLeafTuple (List σ) n) + (u v r w : ℝ) (l h : FrequencyTree ℤ n) : ℂ := + ∑ z, (ν z : ℂ) * complexPrimeInterval 1 0 r w (fun y => + complexPrimeInterval 1 0 u v (fun x => + movingOriginalSampleAverage q value outside μ childBound pivotBound F g Dq S ψ X lo hi + φ G n l (small z) (bulk z) ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound F g Dq S ψ X lo hi + φ G n h (small z) (bulk z) ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊))) + +section +variable {σ I Ω : Type} [Fintype σ] [Fintype Ω] + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (ν : Ω → ℝ) (small bulk : Ω → TreeLeafTuple (List σ) n) + (u v r w : ℝ) + +theorem movingFrequencyCoefficient_original_mean_square : + (∑ s : transferFrequencyRange (V n), ∑ z, (ν z : ℂ) * + complexPrimeInterval 1 0 r w (fun y => complexPrimeInterval 1 0 u v (fun x => + (‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s.val + (small z) (bulk z) ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊‖ ^ 2 : ℂ)))) = + ∑ s : transferFrequencyRange (V n), ∑ a : MovingDescendantFrequencyIndex V n, + ∑ b : MovingDescendantFrequencyIndex V n, + movingOriginalPrimePairMean q value outside μ childBound pivotBound F g Dq S ψ X lo hi + φ G n ν small bulk u v r w + (movingRootedFrequencyTree V n s.val a) (movingRootedFrequencyTree V n s.val b) := by + apply Finset.sum_congr rfl + intro s _ + simp_rw [movingFrequencyCoefficient_original_prime_square, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + rw [Finset.sum_comm] + rfl + +/-- This uses the actual two-history mean and the exact coefficient-square +identity. Only the negligible error receives the full history count. -/ +theorem movingFrequencyCoefficient_original_arithmetic_budget + (hV : Monotone V) (hF : ∀ d (T : MovingSlotData σ d), F T 0 = 0) + (D K err : ℝ) (hD : 0 ≤ D) (hK : 0 ≤ K) + (hdiv : ∀ a : ℕ, a ≠ 0 → a ≤ V n ^ 2 → (a.divisors.card : ℝ) ≤ D) : + let M := movingOriginalPrimePairMean q value outside μ childBound pivotBound F g Dq S + ψ X lo hi φ G n ν small bulk u v r w + (∀ t : FrequencyTree (((transferFrequencyRange (V n)).erase 0) × + ((transferFrequencyRange (V n)).erase 0)) n, + ‖M (frequencyTreeMap Subtype.val n + (frequencyPairProjection ((transferFrequencyRange (V n)).erase 0) n false t)) + (frequencyTreeMap Subtype.val n + (frequencyPairProjection ((transferFrequencyRange (V n)).erase 0) n true t))‖ ≤ + err + K * (frequencyLeafWeight (pairedFrequencyLeaf ((transferFrequencyRange (V n)).erase 0) + (V 0)) n t * ((frequencySplitList ((transferFrequencyRange (V n)).erase 0) n t).map + (pairFrequencySupportBound D)).prod)) → + ‖∑ s : transferFrequencyRange (V n), ∑ z, (ν z : ℂ) * + complexPrimeInterval 1 0 r w (fun y => complexPrimeInterval 1 0 u v (fun x => + (‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s.val + (small z) (bulk z) ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊‖ ^ 2 : ℂ)))‖ ≤ + (Fintype.card (FrequencyTree (((transferFrequencyRange (V n)).erase 0) × + ((transferFrequencyRange (V n)).erase 0)) n) : ℝ) * err + + K * ((8 * D ^ 4 * (1 + Real.log (V n)) ^ 3) ^ (2 ^ n - 1) * + (2 * (V 0 : ℝ)) ^ (2 * 2 ^ n)) := by + intro M hpoint + have hzL (a : ScheduledFrequencyIndex V n) (t : FrequencyTree ℤ n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M (scheduledFrequencyHistory V n a) t = 0 := by + dsimp only [M, movingOriginalPrimePairMean] + simp_rw [movingOriginalSampleAverage_zero_frequency q value outside μ childBound pivotBound + F hF g Dq S ψ X lo hi φ G n _ _ _ _ _ ha, zero_mul] + simp only [complexPrimeInterval, zero_mul, ite_self, Finset.sum_const_zero, mul_zero] + have hzR (t : FrequencyTree ℤ n) (a : ScheduledFrequencyIndex V n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M t (scheduledFrequencyHistory V n a) = 0 := by + dsimp only [M, movingOriginalPrimePairMean] + simp_rw [movingOriginalSampleAverage_zero_frequency q value outside μ childBound pivotBound + F hF g Dq S ψ X lo hi φ G n _ _ _ _ _ ha, star_zero, mul_zero] + simp only [complexPrimeInterval, zero_mul, ite_self, Finset.sum_const_zero, mul_zero] + have hb := paired_scheduled_frequency_budget V hV n D K err hD hK hdiv + (fun a b => ‖M a b‖) (fun _ _ => norm_nonneg _) + (fun a t ha => by rw [hzL a t ha, norm_zero]) + (fun t a ha => by rw [hzR t a ha, norm_zero]) hpoint + rw [movingFrequencyCoefficient_original_mean_square q value outside μ childBound pivotBound V + F g Dq S ψ X lo hi φ G n ν small bulk u v r w] + have hs := same_root_scheduled_pair_sum_le V n + (fun a b => ‖M (scheduledFrequencyHistory V n a) (scheduledFrequencyHistory V n b)‖) + (fun _ _ => norm_nonneg _) + have hh (s : transferFrequencyRange (V n)) (a : MovingDescendantFrequencyIndex V n) : + scheduledFrequencyHistory V n ((scheduledFrequencyRootEquiv V n).symm (s, a)) = + movingRootedFrequencyTree V n s.val a := by + rw [scheduledFrequencyRootEquiv_history, Equiv.apply_symm_apply] + simp_rw [hh] at hs + apply le_trans _ (hs.trans hb) + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro s _ + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro a _ + exact norm_sum_le _ _ + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductFrequency.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductFrequency.lean new file mode 100644 index 0000000000000000000000000000000000000000..c74c9da51b0243f8fc2d97926d6567916dec6d09 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductFrequency.lean @@ -0,0 +1,108 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRecursiveTemplateCaps +import OAI.NumberTheory.Ostmann.Arithmetic.MovingIntegerRanges + +namespace OAI + +/-! # Integer frequency cutoffs that retain the actual product-window center -/ +namespace Ostmann + +/-- Centering at the measured terminal product avoids charging its rounding +error again at each subsequent transfer. -/ +noncomputable def movingProductFrequencyExponent (T : ℕ → ℝ) + (W Y m : ℝ) (n : ℕ) : ℝ := + movingProductExponent T W n - Y + (2 : ℝ) ^ n * Real.sqrt (4 * m) + +noncomputable def movingProductNaturalCutoff (T : ℕ → ℝ) + (W Y m : ℝ) (n : ℕ) : ℕ := + ⌊Real.exp (movingProductFrequencyExponent T W Y m n)⌋₊ + +theorem movingProductExponent_monotone (T : ℕ → ℝ) (W : ℝ) + (hgap : ∀ n, 2 * T n ≤ movingProductExponent T W n) : + Monotone (movingProductExponent T W) := by + apply monotone_nat_of_le_succ + intro n + rw [movingProductExponent] + linarith [hgap n] + +theorem movingProductNaturalCutoff_monotone (T : ℕ → ℝ) (W Y m : ℝ) + (hgap : ∀ n, 2 * T n ≤ movingProductExponent T W n) : + Monotone (movingProductNaturalCutoff T W Y m) := by + intro i j hij + apply Nat.floor_mono + apply Real.exp_le_exp.mpr + have hE := movingProductExponent_monotone T W hgap hij + have hpow : (2 : ℝ) ^ i ≤ 2 ^ j := pow_le_pow_right₀ (by norm_num) hij + have hs := mul_le_mul_of_nonneg_right hpow (Real.sqrt_nonneg (4 * m)) + dsimp only [movingProductFrequencyExponent] + linarith + +theorem movingProductFrequency_reserve (T : ℕ → ℝ) (W Y m : ℝ) (n : ℕ) : + movingProductFrequencyExponent T W Y m (n + 1) - + (movingProductFrequencyExponent T W Y m n + movingProductExponent T W n - 2 * T n) = + (2 : ℝ) ^ n * Real.sqrt (4 * m) := by + simp only [movingProductFrequencyExponent, movingProductExponent, pow_succ] + ring + +/-- The full ceiling product cap satisfies the next integer-frequency bound. +Only the actual lower bound on the inserted pivot product is needed. -/ +theorem movingProductNaturalCutoff_scale (T : ℕ → ℝ) (W Y m : ℝ) (n : ℕ) + (hm : 64 ≤ m) (hY : Y ≤ W) + (hgap : ∀ j, 2 * T j ≤ movingProductExponent T W j) + (hH : 0 ≤ movingProductExponent T W n - T n) + (M : ℕ) (hM : Real.exp (T n) ≤ (M : ℝ)) : + 2 * movingProductNaturalCutoff T W Y m n * + ⌈Real.exp (movingProductExponent T W n - T n)⌉₊ ≤ + movingProductNaturalCutoff T W Y m (n + 1) * M := by + let E := movingProductExponent T W n + let F := movingProductFrequencyExponent T W Y m n + let F' := movingProductFrequencyExponent T W Y m (n + 1) + have hroot : 8 ≤ Real.sqrt (4 * m) := by + apply Real.le_sqrt_of_sq_le + nlinarith + have hpow : 1 ≤ (2 : ℝ) ^ n := one_le_pow₀ (by norm_num) + have hpow' : 1 ≤ (2 : ℝ) ^ (n + 1) := one_le_pow₀ (by norm_num) + have hlog2 : Real.log (2 : ℝ) ≤ 1 := by + linarith [Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 2)] + have hlog4 : Real.log (4 : ℝ) ≤ 3 := by + linarith [Real.log_le_sub_one_of_pos (by norm_num : (0 : ℝ) < 4)] + have hE' : W ≤ movingProductExponent T W (n + 1) := + movingProductExponent_monotone T W hgap (Nat.zero_le _) + have hF' : Real.log 2 ≤ F' := by + dsimp only [F', movingProductFrequencyExponent] + nlinarith [Real.sqrt_nonneg (4 * m)] + have hreserve := movingProductFrequency_reserve T W Y m n + have hmargin : Real.log 4 + F + E - T n ≤ F' + T n - Real.log 2 := by + dsimp only [F, F', E] at * + nlinarith [Real.sqrt_nonneg (4 * m)] + have hHceil : (⌈Real.exp (E - T n)⌉₊ : ℝ) ≤ 2 * Real.exp (E - T n) := by + have hc := (Nat.ceil_lt_add_one (Real.exp_pos (E - T n)).le).le + have he := Real.one_le_exp hH + dsimp only [E] at * + linarith + have hV : (movingProductNaturalCutoff T W Y m n : ℝ) ≤ Real.exp F := + Nat.floor_le (Real.exp_pos F).le + have hV' : Real.exp F' / 2 ≤ (movingProductNaturalCutoff T W Y m (n + 1) : ℝ) := by + have hh := (natural_exp_cutoff_bounds F' hF').2.2 + change Real.exp F' ≤ 2 * (movingProductNaturalCutoff T W Y m (n + 1) : ℝ) at hh + linarith + have hscaled : (2 : ℝ) * movingProductNaturalCutoff T W Y m n * + (⌈Real.exp (E - T n)⌉₊ : ℝ) ≤ + (movingProductNaturalCutoff T W Y m (n + 1) : ℝ) * M := by + calc + _ ≤ (2 * Real.exp F) * (2 * Real.exp (E - T n)) := + mul_le_mul (mul_le_mul_of_nonneg_left hV (by norm_num)) hHceil + (Nat.cast_nonneg _) (by positivity) + _ = Real.exp (Real.log 4 + F + E - T n) := by + rw [show Real.log 4 + F + E - T n = Real.log 4 + (F + (E - T n)) by ring, + Real.exp_add, Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 4)] + ring + _ ≤ Real.exp (F' + T n - Real.log 2) := Real.exp_le_exp.mpr hmargin + _ = (Real.exp F' / 2) * Real.exp (T n) := by + rw [Real.exp_sub, Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 2)] + ring + _ ≤ _ := mul_le_mul hV' hM (Real.exp_nonneg _) (Nat.cast_nonneg _) + exact_mod_cast hscaled + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductGapBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductGapBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..89e3143d073d76f76dd44971c2f8a624732b41b1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductGapBudget.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRecursiveProductBounds +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationTargets + +namespace OAI + +/-! # The recursive product budget is the prescribed compensation gap -/ +namespace Ostmann + +noncomputable def movingTargetPivotExponent (G : ℝ) (ws : List ℝ) (n : ℕ) : ℝ := + G + (2 : ℝ) ^ n * (ws.drop n).headD 0 + +private theorem drop_sum_head (ws : List ℝ) (n : ℕ) : + (ws.drop n).sum = (ws.drop n).headD 0 + (ws.drop (n + 1)).sum := by + induction ws generalizing n with + | nil => simp + | cons w ws ih => + cases n with + | zero => simp + | succ n => simpa only [List.drop_succ_cons] using ih n + +/-- With exact target centers, the product remaining at depth `n` is precisely +that of the protected slots and the as-yet unused compensation types. -/ +theorem movingProductExponent_targets (G J : ℝ) (ws : List ℝ) (n : ℕ) : + movingProductExponent (movingTargetPivotExponent G ws) (2 * G + J + ws.sum) n = + 2 * G + (2 : ℝ) ^ n * (J + (ws.drop n).sum) := by + induction n with + | zero => simp only [movingProductExponent, pow_zero, List.drop_zero, one_mul, add_assoc] + | succ n ih => + rw [movingProductExponent, ih, movingTargetPivotExponent, pow_succ, drop_sum_head ws n] + ring + +private theorem target_drop_gap (J : ℝ) (ds : List ℝ) (n : ℕ) (hn : n < ds.length) : + J + ((movingCompensationTargets J ds).drop (n + 1)).sum - + ((movingCompensationTargets J ds).drop n).headD 0 = (ds.drop n).headD 0 := by + induction ds generalizing n with + | nil => simp at hn + | cons d ds ih => + cases n with + | zero => simp only [movingCompensationTargets, List.drop_zero, List.headD_cons, + List.drop_succ_cons]; ring + | succ n => + have hn' : n < ds.length := by simpa only [List.length_cons, Nat.succ_lt_succ_iff] using hn + simpa only [movingCompensationTargets, List.drop_succ_cons] using ih n hn' + +/-- This is the exact gap from the manuscript's backwards recursion, expressed +in the product budget used by the integer-extended coefficients. -/ +theorem movingProductExponent_target_gap (G J : ℝ) (ds : List ℝ) + (n : ℕ) (hn : n < ds.length) : + let ws := movingCompensationTargets J ds + movingProductExponent (movingTargetPivotExponent G ws) (2 * G + J + ws.sum) n - + 2 * movingTargetPivotExponent G ws n = (2 : ℝ) ^ n * (ds.drop n).headD 0 := by + dsimp only + rw [movingProductExponent_targets, movingTargetPivotExponent, drop_sum_head] + have hh := target_drop_gap J ds n hn + linear_combination (2 : ℝ) ^ n * hh + +/-- A finite center-rounding loss grows only linearly with the depth after +normalization by the number of leaves. -/ +theorem movingProductExponent_rounding_bound (T U : ℕ → ℝ) (W Z C R : ℝ) + (hW : W ≤ Z + C) (hTU : ∀ j, U j - (2 : ℝ) ^ j * R ≤ T j) (n : ℕ) : + movingProductExponent T W n ≤ movingProductExponent U Z n + + (2 : ℝ) ^ n * (C + n * R) := by + induction n with + | zero => simpa only [movingProductExponent, pow_zero, Nat.cast_zero, mul_zero, + zero_mul, add_zero, one_mul] using hW + | succ n ih => + rw [movingProductExponent, movingProductExponent, pow_succ, Nat.cast_add, Nat.cast_one] + have hh := hTU n + nlinarith only [ih, hh] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductInitialCutoff.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductInitialCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6454e7d216648b32a26b874f301a937c2418ad6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductInitialCutoff.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingProductFrequency +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyBudget + +namespace OAI + +/-! # Centered initial windows and the original energy cutoff -/ +namespace Ostmann +open Filter + +/-- The initial cutoff depends on the quotient of the two product scales. -/ +theorem movingProductNaturalCutoff_zero_translate (T : ℕ → ℝ) (W Y m D : ℝ) : + movingProductNaturalCutoff T (W - D) (Y - D) m 0 = + movingProductNaturalCutoff T W Y m 0 := by + unfold movingProductNaturalCutoff movingProductFrequencyExponent + simp only [movingProductExponent] + congr 2 + ring + +theorem movingProductFrequency_mono_mass (T : ℕ → ℝ) (W Y a b : ℝ) (n : ℕ) + (hab : a ≤ b) : + movingProductFrequencyExponent T W Y a n ≤ movingProductFrequencyExponent T W Y b n := by + have hh := Real.sqrt_le_sqrt (show 4 * a ≤ 4 * b by linarith) + have hmul := mul_le_mul_of_nonneg_left hh (show 0 ≤ (2 : ℝ) ^ n by positivity) + unfold movingProductFrequencyExponent + linarith + +/-- Using one quarter of the bulk mass in the frequency reserve leaves room +for the fixed width of the actual initial product window. The diagonal energy +estimate retains its original `sqrt (4m)` cutoff. -/ +theorem movingProductNaturalCutoff_zero_window (T : ℕ → ℝ) + (W Y Δ m H : ℝ) (hW : W - Y ≤ Δ + H) + (hwidth : H ≤ Real.sqrt m) : + (movingProductNaturalCutoff T W Y (m / 4) 0 : ℝ) ≤ + Real.exp (Δ + Real.sqrt (4 * m)) := by + have hs : Real.sqrt (4 * m) = 2 * Real.sqrt m := by + rw [Real.sqrt_mul (by norm_num : (0 : ℝ) ≤ 4)] + norm_num + have hq : 4 * (m / 4) = m := by ring + have he : movingProductFrequencyExponent T W Y (m / 4) 0 ≤ + Δ + Real.sqrt (4 * m) := by + simp only [movingProductFrequencyExponent, movingProductExponent, pow_zero, one_mul, hq] + rw [hs] + linarith + exact (Nat.floor_le (Real.exp_pos _).le).trans (Real.exp_le_exp.mpr he) + +theorem eventually_initial_product_reserve (H : ℝ) : + ∀ᶠ m : ℝ in atTop, 64 ≤ m / 4 ∧ H ≤ Real.sqrt m := by + filter_upwards [eventually_ge_atTop (256 : ℝ), + Real.tendsto_sqrt_atTop.eventually (eventually_ge_atTop H)] with m hm hH + exact ⟨by linarith, hH⟩ + +theorem movingProductNaturalCutoff_card_bound (T : ℕ → ℝ) + (W Y m A : ℝ) (n : ℕ) + (hF : 0 ≤ movingProductFrequencyExponent T W Y m n) + (hA : movingProductFrequencyExponent T W Y m n + Real.log 3 ≤ A) : + ((transferFrequencyRange (movingProductNaturalCutoff T W Y m n)).card : ℝ) ≤ + Real.exp A := by + have hv : (movingProductNaturalCutoff T W Y m n : ℝ) ≤ + Real.exp (movingProductFrequencyExponent T W Y m n) := + Nat.floor_le (Real.exp_pos _).le + have he := Real.one_le_exp hF + rw [card_transferFrequencyRange] + push_cast + calc + _ ≤ 3 * Real.exp (movingProductFrequencyExponent T W Y m n) := by linarith + _ = Real.exp (movingProductFrequencyExponent T W Y m n + Real.log 3) := by + rw [Real.exp_add, Real.exp_log (by norm_num : (0 : ℝ) < 3)] + ring + _ ≤ _ := Real.exp_le_exp.mpr hA + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductPoissonCutoff.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductPoissonCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f2f83eab902e47e1f6184d1e1c85eff56bfc4f3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductPoissonCutoff.lean @@ -0,0 +1,35 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingProductFrequency +import OAI.NumberTheory.Ostmann.Characters.CharacterPoissonCutoff + +namespace OAI + +/-! # The actual product-centered cutoff covers the initial Poisson window -/ +namespace Ostmann +open Filter + +theorem movingProductNaturalCutoff_zero (T : ℕ → ℝ) (W Y m : ℝ) : + movingProductNaturalCutoff T W Y m 0 = naturalTransferCutoff (W - Y) m 0 := by + simp only [movingProductNaturalCutoff, movingProductFrequencyExponent, + movingProductExponent, naturalTransferCutoff, transferErrorScale, + pow_zero, one_mul, mul_one, Real.sqrt_mul (show (0 : ℝ) ≤ 4 by norm_num)] + norm_num + +theorem eventual_moving_product_poisson_cutoff (H : ℝ) (hH : 0 ≤ H) : + ∀ᶠ m : ℝ in atTop, ∀ (T : ℕ → ℝ) (W Y : ℝ), Y ≤ W → + H * Real.exp (W - Y) ≤ movingProductNaturalCutoff T W Y m 0 := by + filter_upwards [eventual_character_poisson_cutoff 0 H hH] with m hm T W Y hYW + rw [movingProductNaturalCutoff_zero] + simpa only [add_zero] using hm (W - Y) (sub_nonneg.mpr hYW) + +theorem eventual_spectator_product_poisson_cutoff (k : ℕ) (hk : 0 < k) + (H : ℝ) (hH : 0 ≤ H) : + ∀ᶠ L : ℝ in atTop, ∀ (T : ℕ → ℝ) (W Y : ℝ), Y ≤ W → + H * Real.exp (W - Y) ≤ + movingProductNaturalCutoff T W Y ((spectatorBulkCount k L : ℝ) / 4) 0 := by + have ht : Tendsto (fun L : ℝ => (spectatorBulkCount k L : ℝ) / 4) atTop atTop := + (spectatorBulkCount_tendsto k hk).atTop_div_const (by norm_num) + exact ht.eventually (eventual_moving_product_poisson_cutoff H hH) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductPrescribedCutoff.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductPrescribedCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..72cfcb76ba7a7193996462fbd556f30e0409f10c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductPrescribedCutoff.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingProductFrequency +import OAI.NumberTheory.Ostmann.Arithmetic.MovingProductGapBudget +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationGapList + +namespace OAI + +/-! # The prescribed cutoff is the exact-target instance of the product schedule -/ +namespace Ostmann +open scoped BigOperators + +private theorem headD_drop_ofFn {k : ℕ} (f : Fin k → ℝ) (n : ℕ) (hn : n < k) : + ((List.ofFn f).drop n).headD 0 = f ⟨n, hn⟩ := by + induction k generalizing n with + | zero => omega + | succ k ih => + rw [List.ofFn_succ] + cases n with + | zero => simp + | succ n => + rw [List.drop_succ_cons] + exact (ih (fun i => f i.succ) n (by omega)).trans (congrArg f (Fin.ext (by rfl))) + +theorem movingProductExponent_sum_gaps (T : ℕ → ℝ) (W : ℝ) (n : ℕ) : + movingProductExponent T W n = W + + ∑ j ∈ Finset.range n, (movingProductExponent T W j - 2 * T j) := by + induction n with + | zero => simp [movingProductExponent] + | succ n ih => + rw [Finset.sum_range_succ, movingProductExponent] + linarith + +theorem movingProductFrequency_prescribed (G J Y Bs BD Bz L : ℝ) (k n : ℕ) + (hn : n ≤ k) + (hbase : 2 * G + J + (movingCompensationTargets J (movingCompensationGaps k BD Bz L)).sum - Y = + spectatorBaseGap Bs ((k : ℝ) ^ 4) (spectatorBulkCount k L)) : + let ws := movingCompensationTargets J (movingCompensationGaps k BD Bz L) + movingProductFrequencyExponent (movingTargetPivotExponent G ws) + (2 * G + J + ws.sum) Y (spectatorBulkCount k L) n = + movingCutoffExponent Bs BD Bz ((k : ℝ) ^ 4) (spectatorBulkCount k L) n := by + intro ws + unfold movingProductFrequencyExponent movingCutoffExponent + rw [movingProductExponent_sum_gaps] + have hsum : (∑ j ∈ Finset.range n, + (movingProductExponent (movingTargetPivotExponent G ws) (2 * G + J + ws.sum) j - + 2 * movingTargetPivotExponent G ws j)) = + ∑ j ∈ Finset.range n, spectatorStepGap BD Bz ((k : ℝ) ^ 4) + ((2 : ℝ) ^ j) (spectatorBulkCount k L) := by + apply Finset.sum_congr rfl + intro j hj + have hjk : j < k := (Finset.mem_range.mp hj).trans_le hn + rw [movingProductExponent_target_gap G J _ j (by simpa using hjk)] + unfold movingCompensationGaps + rw [headD_drop_ofFn _ j hjk] + dsimp only + exact mul_div_cancel₀ _ (by positivity) + rw [hsum] + dsimp only [ws] at * + linarith + +/-- Consequently this construction retains the original floor cutoffs when +there is no cell-center error. -/ +theorem movingProductNaturalCutoff_prescribed (G J Y Bs BD Bz L : ℝ) (k n : ℕ) + (hn : n ≤ k) + (hbase : 2 * G + J + (movingCompensationTargets J (movingCompensationGaps k BD Bz L)).sum - Y = + spectatorBaseGap Bs ((k : ℝ) ^ 4) (spectatorBulkCount k L)) : + let ws := movingCompensationTargets J (movingCompensationGaps k BD Bz L) + movingProductNaturalCutoff (movingTargetPivotExponent G ws) + (2 * G + J + ws.sum) Y (spectatorBulkCount k L) n = + movingNaturalCutoff Bs BD Bz ((k : ℝ) ^ 4) (spectatorBulkCount k L) n := by + intro ws + unfold movingProductNaturalCutoff movingNaturalCutoff + rw [movingProductFrequency_prescribed G J Y Bs BD Bz L k n hn hbase] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductRigidity.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductRigidity.lean new file mode 100644 index 0000000000000000000000000000000000000000..11fb81a15426637c44a4d64d0159cfd6476871c3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductRigidity.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingProductRounding + +namespace OAI + +/-! # The integer rigidity margin survives the actual selected cell centers -/ +namespace Ostmann + +theorem movingProductFrequency_gap (T : ℕ → ℝ) (W Y m : ℝ) (n : ℕ) : + (movingProductExponent T W n - 2 * T n) - movingProductFrequencyExponent T W Y m n = + Y - 2 * T n - (2 : ℝ) ^ n * Real.sqrt (4 * m) := by + unfold movingProductFrequencyExponent + ring + +/-- The initial center error cancels from this margin. Only the current +pivot-cell error remains, twice. -/ +theorem movingProductFrequency_rigidity_margin (T U : ℕ → ℝ) (W Z Y m R : ℝ) (n : ℕ) + (hT : T n ≤ U n + (2 : ℝ) ^ n * R) (hR : R ≤ m / 40) + (hideal : (3 / 20 : ℝ) * (2 : ℝ) ^ n * m ≤ + (movingProductExponent U Z n - 2 * U n) - + movingProductFrequencyExponent U Z Y m n) : + (1 / 10 : ℝ) * (2 : ℝ) ^ n * m ≤ + (movingProductExponent T W n - 2 * T n) - + movingProductFrequencyExponent T W Y m n := by + rw [movingProductFrequency_gap] at hideal ⊢ + have he := mul_le_mul_of_nonneg_left hR (by positivity : 0 ≤ (2 : ℝ) ^ n) + nlinarith only [hideal, hT, he] + +theorem movingProductFrequency_prescribed_margin (G J Y Bs BD Bz L : ℝ) (k n : ℕ) + (hn : n < k) (T : ℕ → ℝ) (W R : ℝ) + (hbase : 2 * G + J + (movingCompensationTargets J (movingCompensationGaps k BD Bz L)).sum - Y = + spectatorBaseGap Bs ((k : ℝ) ^ 4) (spectatorBulkCount k L)) + (hT : T n ≤ movingTargetPivotExponent G + (movingCompensationTargets J (movingCompensationGaps k BD Bz L)) n + (2 : ℝ) ^ n * R) + (hR : R ≤ (spectatorBulkCount k L : ℝ) / 40) + (hBD : Bs + 1 ≤ BD) (hBz : 8 ≤ Bz) (hk : 1 ≤ (k : ℝ) ^ 4) + (hm : 64 ≤ (spectatorBulkCount k L : ℝ)) : + (1 / 10 : ℝ) * (2 : ℝ) ^ n * spectatorBulkCount k L ≤ + (movingProductExponent T W n - 2 * T n) - + movingProductFrequencyExponent T W Y (spectatorBulkCount k L) n := by + let ds := movingCompensationGaps k BD Bz L + let ws := movingCompensationTargets J ds + let U := movingTargetPivotExponent G ws + let Z := 2 * G + J + ws.sum + apply movingProductFrequency_rigidity_margin T U W Z Y (spectatorBulkCount k L) R n hT hR + have he := movingProductExponent_target_gap G J ds n (by simpa only [ds, movingCompensationGaps_length] using hn) + have hfreq := movingProductFrequency_prescribed G J Y Bs BD Bz L k n hn.le hbase + change movingProductFrequencyExponent U Z Y (spectatorBulkCount k L) n = _ at hfreq + change movingProductExponent U Z n - 2 * U n = _ at he + rw [hfreq, he] + have hg : (2 : ℝ) ^ n * (ds.drop n).headD 0 = + spectatorStepGap BD Bz ((k : ℝ) ^ 4) ((2 : ℝ) ^ n) (spectatorBulkCount k L) := by + have hs := movingProductFrequency_prescribed G J Y Bs BD Bz L k (n + 1) (by omega) hbase + have hr := movingProductFrequency_reserve U Z Y (spectatorBulkCount k L) n + change movingProductFrequencyExponent U Z Y (spectatorBulkCount k L) (n + 1) = _ at hs + rw [hs, hfreq, movingCutoffExponent_succ] at hr + linarith only [hr, he] + rw [hg] + exact movingCutoff_diagonal_reserve Bs BD Bz ((k : ℝ) ^ 4) (spectatorBulkCount k L) + hBD hBz hk hm n + +theorem movingProductNaturalCutoff_rigidity (T : ℕ → ℝ) (W Y m C : ℝ) + (n P R : ℕ) + (hP : (P : ℝ) ≤ Real.exp (T n + C)) + (hR : Real.exp (movingProductExponent T W n - T n - C) ≤ (R : ℝ)) + (hmargin : Real.log 2 + 2 * C < + (movingProductExponent T W n - 2 * T n) - movingProductFrequencyExponent T W Y m n) : + 2 * P * movingProductNaturalCutoff T W Y m n < R := by + apply transfer_integer_rigidity_gap P (movingProductNaturalCutoff T W Y m n) R + (T n) (movingProductExponent T W n - 2 * T n) + (movingProductFrequencyExponent T W Y m n) C hP + (Nat.floor_le (Real.exp_pos _).le) _ hmargin + convert hR using 1 + congr 1 + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductRounding.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductRounding.lean new file mode 100644 index 0000000000000000000000000000000000000000..2182396e3d0aea2b5cceadc4a01bd2700b75ac8f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProductRounding.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingProductPrescribedCutoff +import OAI.NumberTheory.Ostmann.Construction.SelectedCellGap + +namespace OAI + +/-! # Actual cell rounding in the recursive product and frequency budgets -/ +namespace Ostmann + +private theorem productExponent_rounding_le (T U : ℕ → ℝ) (W Z C R : ℝ) (n : ℕ) + (hW : W ≤ Z + C) (hTU : ∀ j < n, U j - (2 : ℝ) ^ j * R ≤ T j) : + movingProductExponent T W n ≤ movingProductExponent U Z n + + (2 : ℝ) ^ n * (C + n * R) := by + induction n with + | zero => simpa only [movingProductExponent, pow_zero, Nat.cast_zero, mul_zero, + zero_mul, add_zero, one_mul] using hW + | succ n ih => + have hh := hTU n (Nat.lt_succ_self n) + have hprev := ih (fun j hj => hTU j (Nat.lt_trans hj (Nat.lt_succ_self n))) + rw [movingProductExponent, movingProductExponent, pow_succ, Nat.cast_add, Nat.cast_one] + nlinarith only [hprev, hh] + +theorem movingProductExponent_rounding_abs (T U : ℕ → ℝ) (W Z C R : ℝ) (n : ℕ) + (hW : |W - Z| ≤ C) (hTU : ∀ j < n, |T j - U j| ≤ (2 : ℝ) ^ j * R) : + |movingProductExponent T W n - movingProductExponent U Z n| ≤ + (2 : ℝ) ^ n * (C + n * R) := by + obtain ⟨hWlo, hWhi⟩ := abs_le.mp hW + have hu := productExponent_rounding_le T U W Z C R n (by linarith) + (fun j hj => by have hh := (abs_le.mp (hTU j hj)).1; linarith) + have hl := productExponent_rounding_le U T Z W C R n (by linarith) + (fun j hj => by have hh := (abs_le.mp (hTU j hj)).2; linarith) + exact abs_le.mpr ⟨by linarith, by linarith⟩ + +theorem movingProductFrequency_rounding_abs (T U : ℕ → ℝ) (W Z Y m C R : ℝ) (n : ℕ) + (hW : |W - Z| ≤ C) (hTU : ∀ j < n, |T j - U j| ≤ (2 : ℝ) ^ j * R) : + |movingProductFrequencyExponent T W Y m n - movingProductFrequencyExponent U Z Y m n| ≤ + (2 : ℝ) ^ n * (C + n * R) := by + convert movingProductExponent_rounding_abs T U W Z C R n hW hTU using 1 + congr 1 + unfold movingProductFrequencyExponent + ring + +/-- The selected integer center is close to its target in the exact pivot +exponent used by the product cap, including the lower-edge loss. -/ +theorem SelectedSmallTailCell.pivot_exponent_error + {A B : Set ℕ} {N hi j : ℕ} {a C L X w : ℝ} {D : Finset ℕ} + (h : SelectedSmallTailCell A B N a C L X hi D (w / 4) j) (G : ℝ) (n : ℕ) : + |(G - 1 + ((2 ^ n * 4 : ℕ) : ℝ) * ((j : ℝ) - 1)) - + (G + (2 : ℝ) ^ n * w)| ≤ + (2 : ℝ) ^ n * (256 * tailDefectBudget a C X + 9) := by + have hlo := h.1 + have hhi := h.2.1 + have hD : 0 ≤ 64 * tailDefectBudget a C X + 1 := by linarith + have hr : 1 ≤ (2 : ℝ) ^ n := one_le_pow₀ (by norm_num) + have hr0 : 0 ≤ (2 : ℝ) ^ n := by positivity + have hlow := mul_le_mul_of_nonneg_left hlo hr0 + have hupp := mul_le_mul_of_nonneg_left hhi hr0 + have hbudget := mul_le_mul_of_nonneg_left hD hr0 + simp only [Nat.cast_mul, Nat.cast_pow, Nat.cast_ofNat] + exact abs_le.mpr ⟨by nlinarith only [hlow, hbudget, hr], by nlinarith only [hupp, hr]⟩ + +/-- Rounding that fits the existing one-unit reserve preserves the already +proved uniform frequency-rate bound. -/ +theorem movingProductFrequency_prescribed_rate (G J Y Bs BD Bz L : ℝ) (k n : ℕ) + (hn : n ≤ k) (T : ℕ → ℝ) (W C R : ℝ) + (hbase : 2 * G + J + (movingCompensationTargets J (movingCompensationGaps k BD Bz L)).sum - Y = + spectatorBaseGap Bs ((k : ℝ) ^ 4) (spectatorBulkCount k L)) + (hW : |W - (2 * G + J + (movingCompensationTargets J (movingCompensationGaps k BD Bz L)).sum)| ≤ C) + (hT : ∀ j < n, |T j - movingTargetPivotExponent G + (movingCompensationTargets J (movingCompensationGaps k BD Bz L)) j| ≤ (2 : ℝ) ^ j * R) + (hbudget : C + n * R ≤ (spectatorBulkCount k L : ℝ)) + (hBs : 0 ≤ Bs) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) (hk : 1 ≤ (k : ℝ) ^ 4) + (hm : 4 ≤ (spectatorBulkCount k L : ℝ)) : + movingProductFrequencyExponent T W Y (spectatorBulkCount k L) n ≤ + movingFrequencyRate Bs BD Bz ((k : ℝ) ^ 4) n * spectatorBulkCount k L := by + have hh := movingProductFrequency_rounding_abs T + (movingTargetPivotExponent G (movingCompensationTargets J (movingCompensationGaps k BD Bz L))) + W _ Y (spectatorBulkCount k L) C R n hW hT + rw [movingProductFrequency_prescribed G J Y Bs BD Bz L k n hn hbase] at hh + have hb := movingCutoffExponent_bound Bs BD Bz ((k : ℝ) ^ 4) + (spectatorBulkCount k L) n hBs hBD hBz hk hm + have he := mul_le_mul_of_nonneg_left hbudget (by positivity : 0 ≤ (2 : ℝ) ^ n) + have hu := (abs_le.mp hh).2 + nlinarith only [hb, he, hu] + +/-- The actual initial-cell error and every subsequent pivot-cell error +fit the existing one-unit frequency allowance at polynomial bulk scale. -/ +theorem moving_cell_frequency_rounding_budget (k n : ℕ) (R D L : ℝ) + (hk : 2 ≤ k) (hn : n ≤ k) (hD : 0 ≤ D) + (hL : 1 ≤ L) (hDL : D ≤ R * L) + (hlarge : 2 * (704 * R + 26) ≤ (k : ℝ) ^ 3) + (hscale : 4 ≤ (k : ℝ) ^ 4 * L) : + (6 + 4 * k) * (64 * D + 1) + 2 * ((3 + 2 * k : ℕ) + 3) + + n * (256 * D + 9) ≤ (spectatorBulkCount k L : ℝ) := by + have hk2 : (2 : ℝ) ≤ k := by exact_mod_cast hk + have hnk : (n : ℝ) ≤ k := by exact_mod_cast hn + have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg _ + have hnterm := mul_le_mul_of_nonneg_right hnk (show 0 ≤ 256 * D + 9 by positivity) + have herror : (6 + 4 * k) * (64 * D + 1) + 2 * ((3 + 2 * k : ℕ) + 3) + + n * (256 * D + 9) ≤ (k : ℝ) * (704 * R + 26) * L := by + push_cast + have hkd : 0 ≤ ((k : ℝ) - 2) * D := mul_nonneg (by linarith) hD + have hdl := mul_le_mul_of_nonneg_left hDL (show 0 ≤ 704 * (k : ℝ) by positivity) + have hconst := mul_le_mul_of_nonneg_left hL (show 0 ≤ 26 * (k : ℝ) by positivity) + nlinarith only [hnterm, hkd, hdl, hconst, hk2] + apply herror.trans + calc + _ ≤ (k : ℝ) ^ 4 / 2 * L := by + have hh := mul_le_mul_of_nonneg_left hlarge hk0 + apply mul_le_mul_of_nonneg_right _ (by linarith) + nlinarith only [hh] + _ = (k : ℝ) ^ 4 * L / 2 := by ring + _ ≤ _ := spectatorBulkCount_half k L hscale + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProtectedTarget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProtectedTarget.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d2de3356e0304f2ecc63ce0c224757b4c922f5f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingProtectedTarget.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationGapList + +namespace OAI + +/-! # The protected target from the actual initial window -/ + +namespace Ostmann +open Filter + +noncomputable def movingProtectedTarget (k : ℕ) (logX G td totalGap : ℝ) : ℝ := + (logX - 2 * G - 2 * td + totalGap) / (2 : ℝ) ^ k + +/-- A fixed factor in the block width leaves room for every small prime +cell above `exp(exp(.01 L))`. It affects none of the asymptotic estimates. -/ +theorem movingProtectedTarget_bounds (k : ℕ) (hk : 2 ≤ k) + (h G₀ G td totalGap : ℝ) (hh : 0 ≤ h) + (hGlo : G₀ ≤ G) (hGhi : G ≤ G₀ + 12 * h) + (herror : |totalGap - 2 * td| ≤ h) : + 16 * h ≤ movingProtectedTarget k (2 * G₀ + 2 ^ (k + 1) * (12 * h)) G td totalGap ∧ + movingProtectedTarget k (2 * G₀ + 2 ^ (k + 1) * (12 * h)) G td totalGap ≤ 32 * h := by + have hp : (0 : ℝ) < 2 ^ k := by positivity + have hp4 : (4 : ℝ) ≤ 2 ^ k := by + have h := pow_le_pow_right₀ (by norm_num : (1 : ℝ) ≤ 2) hk + norm_num at h + exact h + have hph := mul_le_mul_of_nonneg_right hp4 hh + obtain ⟨herrlo, herrhi⟩ := abs_le.mp herror + unfold movingProtectedTarget + rw [le_div_iff₀ hp, div_le_iff₀ hp, pow_succ] + constructor <;> nlinarith only [hGlo, hGhi, herrlo, herrhi, hph, hh] + +theorem eventual_protected_target_error (C : ℝ) : + ∀ᶠ L : ℝ in atTop, ∀ totalGap td : ℝ, + 0 ≤ totalGap → totalGap ≤ C * L → + 0 ≤ td → td ≤ C * L * Real.exp ((1 / 1000 : ℝ) * L) → + |totalGap - 2 * td| ≤ Real.exp ((1 / 100 : ℝ) * L) := by + filter_upwards [arithmetic_exponent_absorption (1 / 1000) (1 / 100) 0 (2 * C) 1 1 + (by norm_num) (by norm_num) (by norm_num) (by norm_num)] with L hrate + intro totalGap td hgap0 hgap htd0 htd + simp only [pow_one, one_mul, zero_mul, Real.exp_zero] at hrate + rw [abs_le] + constructor <;> nlinarith only [hgap0, hgap, htd0, htd, hrate] + +theorem eventual_protected_cell_target_range : + ∀ᶠ L : ℝ in atTop, ∀ J cb : ℝ, + 16 * Real.exp ((1 / 100 : ℝ) * L) ≤ J → + J ≤ 32 * Real.exp ((1 / 100 : ℝ) * L) → + 0 ≤ cb → cb ≤ J / 4 → + Real.exp ((1 / 100 : ℝ) * L) ≤ (J - cb) / 6 ∧ + (J - cb) / 6 ≤ Real.exp ((105 / 10000 : ℝ) * L) := by + have ht : Tendsto (fun L : ℝ => Real.exp ((5 / 10000 : ℝ) * L)) atTop atTop := + Real.tendsto_exp_atTop.comp (tendsto_id.const_mul_atTop (by norm_num)) + filter_upwards [ht.eventually (eventually_ge_atTop (8 : ℝ))] with L hratio + intro J cb hJlo hJhi hcb0 hcb + have hs := mul_le_mul_of_nonneg_right hratio (Real.exp_nonneg ((1 / 100 : ℝ) * L)) + have heq : Real.exp ((5 / 10000 : ℝ) * L) * Real.exp ((1 / 100 : ℝ) * L) = + Real.exp ((105 / 10000 : ℝ) * L) := by rw [← Real.exp_add]; congr 1; ring + rw [heq] at hs + constructor <;> nlinarith only [hJlo, hJhi, hcb0, hcb, hs, + Real.exp_nonneg ((1 / 100 : ℝ) * L)] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealCells.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..8577493eff92dd26e1934253de20eddf4aca485f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealCells.lean @@ -0,0 +1,127 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRealWindows +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRootBudget + +namespace OAI + +/-! # Residue-independent cells for either real giant coordinate -/ + +namespace Ostmann +open scoped Classical BigOperators + +def movingRealPair (coord : Bool) (fixed z : ℝ) : Bool → ℝ := + if coord then topGiantReal fixed z else topGiantReal z fixed + +theorem movingRealPair_update (coord : Bool) (fixed z : ℝ) : + movingRealPair coord fixed z = movingRealUpdate (topGiantReal fixed fixed) coord z := by + funext b + cases coord <;> cases b <;> simp [movingRealPair, movingRealUpdate, topGiantReal] + +noncomputable def movingCoordinateLeft (coord : Bool) (fixed : ℝ) : Polynomial ℝ := + if coord then Polynomial.C fixed else Polynomial.X + +noncomputable def movingCoordinateRight (coord : Bool) (fixed : ℝ) : Polynomial ℝ := + if coord then Polynomial.X else Polynomial.C fixed + +theorem movingCoordinate_eval (coord : Bool) (fixed z : ℝ) : + (movingCoordinateLeft coord fixed).eval z = movingRealPair coord fixed z false ∧ + (movingCoordinateRight coord fixed).eval z = movingRealPair coord fixed z true := by + cases coord <;> simp [movingCoordinateLeft, movingCoordinateRight, movingRealPair, topGiantReal] + +noncomputable def movingRealGateWeight {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (X lo hi : ℝ) + (x : Bool → ℝ) : ℂ := + movingArchimedeanFlag nodes x * movingRealWindowFlag value T X lo hi (x false) (x true) + +theorem movingRealGateWeight_norm {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (X lo hi : ℝ) + (x : Bool → ℝ) : ‖movingRealGateWeight value T nodes X lo hi x‖ ≤ 1 := by + unfold movingRealGateWeight movingArchimedeanFlag movingRealWindowFlag + split_ifs <;> norm_num + +noncomputable def movingRealRootCuts {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (X lo hi : ℝ) + (coord : Bool) (fixed : ℝ) : Finset ℝ := + movingArchimedeanRootCuts nodes (topGiantReal fixed fixed) coord ∪ + movingWindowRootCuts value T (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) X lo hi + +theorem movingArchimedeanRootCuts_card (nodes : List MovingFormulaNode) + (a : Bool → ℝ) (coord : Bool) : + (movingArchimedeanRootCuts nodes a coord).card ≤ + ∑ f ∈ nodes.toFinset, ∑ j : Fin 3, (f.guard.realPolynomials a coord j).natDegree := by + apply (Finset.card_biUnion_le).trans + exact Finset.sum_le_sum fun f _ => polynomialRootCuts_card (f.guard.realPolynomials a coord) + +theorem movingRealRootCuts_card {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (X lo hi : ℝ) + (coord : Bool) (fixed : ℝ) : + (movingRealRootCuts value T + (T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true)) + X lo hi coord fixed).card ≤ (2 ^ n - 1) * (3 * (7 * 2 ^ n)) + 4 * 2 ^ n := by + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + have hcost := T.formulaNodes_cost value hvalue childBound pivotBound hf + (.prime false) (.prime true) 1 (by rfl) (by rfl) + have ha : (movingArchimedeanRootCuts nodes (topGiantReal fixed fixed) coord).card ≤ + (2 ^ n - 1) * (3 * (7 * 2 ^ n)) := by + apply (movingArchimedeanRootCuts_card nodes _ coord).trans + calc + _ ≤ ∑ _f ∈ nodes.toFinset, 3 * (7 * 2 ^ n) := by + apply Finset.sum_le_sum + intro f hf + calc + _ ≤ ∑ _j : Fin 3, 7 * 2 ^ n := by + apply Finset.sum_le_sum + intro j _ + apply (f.guard.realPolynomials_degree _ _ j).trans + simpa only [Nat.reduceAdd, mul_comm] using hcost f (List.mem_toFinset.mp hf) + _ = _ := by simp + _ = nodes.toFinset.card * (3 * (7 * 2 ^ n)) := by simp + _ ≤ nodes.length * (3 * (7 * 2 ^ n)) := + Nat.mul_le_mul_right _ (List.toFinset_card_le nodes) + _ = _ := by rw [MovingSlotData.formulaNodes_length] + have hw := movingWindowRootCuts_card value T (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) X lo hi + (by cases coord <;> simp [movingCoordinateLeft]) + (by cases coord <;> simp [movingCoordinateRight]) + exact (Finset.card_union_le _ _).trans (Nat.add_le_add ha hw) + +/-- These cells depend on the real fixed giant, never on residue representatives. -/ +theorem movingRealGateWeight_rootCell {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (X lo hi : ℝ) + (coord : Bool) (fixed x y : ℝ) (S : Finset ℝ) + (hS : movingRealRootCuts value T nodes X lo hi coord fixed ⊆ S) + (hcode : rootCellCode S x = rootCellCode S y) : + movingRealGateWeight value T nodes X lo hi (movingRealPair coord fixed x) = + movingRealGateWeight value T nodes X lo hi (movingRealPair coord fixed y) := by + have ha := movingArchimedeanGate_rootCell nodes (topGiantReal fixed fixed) coord S + (fun r hr => hS (Finset.mem_union_left _ hr)) x y hcode + rw [← movingRealPair_update, ← movingRealPair_update] at ha + have hw := movingPolynomialWindows_of_rootCell value T (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) X lo hi x y S + (fun r hr => hS (Finset.mem_union_right _ hr)) hcode + have hev (z : ℝ) (i : TreeLeafIndex n) : + (movingLeafNormalizedPolynomial value T (movingCoordinateLeft coord fixed) + (movingCoordinateRight coord fixed) X i).eval z = + T.realLeafModuli value (movingRealPair coord fixed z false) + (movingRealPair coord fixed z true) i / X := by + rw [movingLeafNormalizedPolynomial_eval, T.leafPolynomials_real] + rw [(movingCoordinate_eval coord fixed z).1, (movingCoordinate_eval coord fixed z).2] + simp only [hev] at hw + unfold movingRealGateWeight movingArchimedeanFlag movingRealWindowFlag + simp only [ha, hw] + +theorem movingSpectatorResidue_norm {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (g : ∀ i, ZMod (q i) → ℂ) + (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) (B : I → ℝ) + (hB : ∀ i ∈ S, 0 ≤ B i) (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : MovingSlotData σ n) (a b : ℤ) : + ‖movingSpectatorResidue q value g D S T a b‖ ≤ ∏ i ∈ S, B i ^ (2 ^ n) := by + unfold movingSpectatorResidue + rw [norm_prod] + exact Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + (fun i hi => movingSignedSpectator_norm value (g i) (D i) (B i) (hB i hi) (hg i hi) T a b) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealKernel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..18c1e49d44c764fe033ea30485a5874e3cfd41b4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealKernel.lean @@ -0,0 +1,185 @@ +import Mathlib.MeasureTheory.Integral.Prod +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRealSmooth + +namespace OAI + +/-! # Measurability and uniform bounds for the original two-giant kernel -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate SchwartzMap +open MeasureTheory + +theorem HistoryFormula.continuous_realEval {σ : Type*} (F : HistoryFormula σ) : + Continuous F.realEval := by + unfold realEval + simp only [MvPolynomial.eval₂_eq_eval_map] + exact (MvPolynomial.continuous_eval _).div_const _ + +theorem WordTransferGuard.isClosed_archimedeanAt {σ : Type*} (g : WordTransferGuard σ) : + IsClosed {x | g.archimedeanAt x} := + (isClosed_le continuous_const g.pivot.continuous_realEval).inter + ((isClosed_le g.pivot.continuous_realEval continuous_const).inter + (isClosed_le continuous_const g.rightProduct.continuous_realEval)) + +theorem isClosed_movingArchimedeanGate (nodes : List MovingFormulaNode) : + IsClosed {x | movingArchimedeanGate nodes x} := by + induction nodes with + | nil => simpa only [movingArchimedeanGate, List.not_mem_nil, IsEmpty.forall_iff, + implies_true, Set.ofPred_true] using isClosed_univ + | cons f nodes ih => + simpa only [movingArchimedeanGate, List.forall_mem_cons, Set.ofPred_and] using + f.guard.isClosed_archimedeanAt.inter ih + +theorem continuous_topGiantReal : Continuous (fun x : ℝ × ℝ => topGiantReal x.1 x.2) := by + apply continuous_pi + intro b + cases b + · exact continuous_fst + · exact continuous_snd + +theorem measurable_movingRealGateWeight {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (X lo hi : ℝ) : + Measurable (fun x : ℝ × ℝ => movingRealGateWeight value T nodes X lo hi (topGiantReal x.1 x.2)) := by + have ha : Measurable (fun x : ℝ × ℝ => movingArchimedeanFlag nodes (topGiantReal x.1 x.2)) := by + apply Measurable.ite _ measurable_const measurable_const + exact ((isClosed_movingArchimedeanGate nodes).preimage continuous_topGiantReal).measurableSet + have hw : Measurable (fun x : ℝ × ℝ => movingRealWindowFlag value T X lo hi x.1 x.2) := by + apply Measurable.ite _ measurable_const measurable_const + have hc : IsClosed {x : ℝ × ℝ | ∀ i, T.realLeafModuli value x.1 x.2 i / X ∈ Set.Icc lo hi} := by + simpa only [Set.ofPred_forall, Set.preimage] using isClosed_iInter (fun i : TreeLeafIndex n => + isClosed_Icc.preimage ((T.continuous_realLeafModuli value Prod.fst Prod.snd + continuous_fst continuous_snd i).div_const X)) + exact hc.measurableSet + exact ha.mul hw + +theorem movingRealFourierWeight_norm {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (L R : ℝ) : + ‖movingRealFourierWeight value T ψ X lo hi hlo hhi L R‖ ≤ + (SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) := by + have he : (SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) = + ∏ _i : TreeLeafIndex n, SchwartzMap.seminorm ℝ 0 0 ψ := by + simp only [Finset.prod_const, Finset.card_univ, card_treeLeafIndex] + rw [he, movingRealFourierWeight, norm_prod] + apply Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + intro i _ + have hb := (fourierPolynomialFactor Polynomial.X ψ (T.leafFrequencies i) lo hi hlo hhi).norm_value + (T.realLeafModuli value L R i / X) + change ‖(fourierPolynomialFactor Polynomial.X ψ (T.leafFrequencies i) lo hi hlo hhi).value + (T.realLeafModuli value L R i / X)‖ ≤ SchwartzMap.seminorm ℝ 0 0 ψ at hb + split_ifs + · simpa only [Complex.norm_conj] using hb + · exact hb + +theorem movingRealNodeCutoff_norm {σ : Type*} (value : σ → ℕ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B : ℝ) (hB : 0 ≤ B) (hφ : ∀ x, |φ x| ≤ B) + {n : ℕ} (T : MovingSlotData σ n) (L R : ℝ) : + ‖movingRealNodeCutoff value φ G T L R‖ ≤ B ^ (2 ^ n - 1) := by + have hb (G x : ℝ) : ‖(positiveLogCutoff φ G x : ℂ)‖ ≤ B := by + unfold positiveLogCutoff + split_ifs + · simpa only [Complex.norm_real, Real.norm_eq_abs] using hφ _ + · simpa only [Complex.ofReal_zero, norm_zero] using hB + induction T generalizing L R with + | leaf => simp [movingRealNodeCutoff] + | @node n s CL CR u left right ihL ihR => + simp only [movingRealNodeCutoff, norm_mul] + calc + _ ≤ (B * B ^ (2 ^ n - 1)) * B ^ (2 ^ n - 1) := by + apply mul_le_mul _ (ihR _ _) (norm_nonneg _) (mul_nonneg hB (pow_nonneg hB _)) + exact mul_le_mul (hb _ _) (ihL _ _) (norm_nonneg _) hB + _ = B ^ (2 ^ (n + 1) - 1) := by + rw [← pow_succ', ← pow_add] + congr 1 + have := Nat.one_le_two_pow (n := n) + rw [pow_succ] + omega + +theorem movingRealSmoothWeight_norm {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B : ℝ) (hB : 0 ≤ B) (hφ : ∀ x, |φ x| ≤ B) (L R : ℝ) : + ‖movingRealSmoothWeight value T ψ X lo hi hlo hhi φ G L R‖ ≤ + (SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1) := by + rw [movingRealSmoothWeight, norm_mul] + exact mul_le_mul (movingRealFourierWeight_norm value T ψ X lo hi hlo hhi L R) + (movingRealNodeCutoff_norm value φ G B hB hφ T L R) (norm_nonneg _) + (pow_nonneg ((norm_nonneg (ψ 0)).trans (ψ.norm_le_seminorm ℝ 0)) _) + +noncomputable def movingRealKernel {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) (L R : ℝ) : ℂ := + movingRealGateWeight value T nodes X lo hi (topGiantReal L R) * + movingRealSmoothWeight value T ψ X lo hi hlo hhi φ G L R + +theorem measurable_movingRealKernel {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) + (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (hout : ∀ x, 1 ≤ |x| → φ x = 0) : + Measurable (fun x : ℝ × ℝ => movingRealKernel value T nodes ψ X lo hi hlo hhi φ G x.1 x.2) := + (measurable_movingRealGateWeight value T nodes X lo hi).mul + (continuous_movingRealSmoothWeight value T ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + Prod.fst Prod.snd continuous_fst continuous_snd).measurable + +theorem movingRealKernel_norm {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B : ℝ) (hB : 0 ≤ B) (hφ : ∀ x, |φ x| ≤ B) (L R : ℝ) : + ‖movingRealKernel value T nodes ψ X lo hi hlo hhi φ G L R‖ ≤ + (SchwartzMap.seminorm ℝ 0 0 ψ) ^ (2 ^ n) * B ^ (2 ^ n - 1) := by + rw [movingRealKernel, norm_mul] + exact (mul_le_mul_of_nonneg_right (movingRealGateWeight_norm value T nodes X lo hi _) + (norm_nonneg _)).trans (by simpa only [one_mul] using + movingRealSmoothWeight_norm value T ψ X lo hi hlo hhi φ G B hB hφ L R) + +theorem integrable_movingRealKernel {σ A : Type*} [MeasurableSpace A] + (value : σ → ℕ) {n : ℕ} (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (μ : Measure A) [IsFiniteMeasure μ] + (L R : A → ℝ) (hL : Measurable L) (hR : Measurable R) : + Integrable (fun x => movingRealKernel value T nodes ψ X lo hi hlo hhi φ G (L x) (R x)) μ := by + refine ⟨((measurable_movingRealKernel value T nodes ψ X lo hi hlo hhi φ G B D hB hD + hφ hlip hout).comp (hL.prodMk hR)).aestronglyMeasurable, ?_⟩ + exact HasFiniteIntegral.of_bounded (Filter.Eventually.of_forall fun x => + movingRealKernel_norm value T nodes ψ X lo hi hlo hhi φ G B hB hφ (L x) (R x)) + +/-- The literal recursive coefficient, including all zero terms, is the +fixed residue coefficient times the single bounded real kernel. -/ +theorem moving_recursive_real_kernel {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hf : T.Frequencies (· ≠ 0)) (XL XR a b M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => (movingWindowLeaf value X lo hi (movingDataLeaf F) x s * + movingFourierLeaf value ψ X x s) * + ∏ i ∈ S, spectatorHistoryLeaf (movingSlotModulus value) (g i) (Dq i) x s) + (movingSlotCutoff value childBound pivotBound + (movingPhiExtra value childBound pivotBound (movingDataExtra E) φ G)) n ⟨n, T, XL, XR⟩ t = + movingResidueCoefficient q value F E g Dq S T nodes a b * + movingRealKernel value T nodes ψ X lo hi hlo hhi φ G XL XR := by + dsimp only + rw [moving_complete_coefficient_factor q value hvalue childBound pivotBound F E g hg Dq S + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout T t hT hf XL XR, + moving_original_canonical_coefficient q value hvalue childBound pivotBound F E X lo hi + g Dq S T hf XL XR a b M hM hMq hL hR, + movingSmoothPolynomialFactors_real value T Polynomial.X (Polynomial.C XR) ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip hout] + simp only [Polynomial.eval_X, Polynomial.eval_C, movingRealKernel, mul_assoc] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealResidues.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..b106810d8fd7b52c42e1565b3e85b7c14293d342 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealResidues.lean @@ -0,0 +1,155 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTopCells + +namespace OAI + +/-! # Separating the original arithmetic gate into residues and real inequalities -/ + +namespace Ostmann +open scoped Classical + +noncomputable def HistoryFormula.realEval {σ : Type*} (F : HistoryFormula σ) (x : σ → ℝ) : ℝ := + MvPolynomial.eval₂ (Int.castRingHom ℝ) x F.cleared.numerator / F.cleared.denominator + +noncomputable def WordTransferGuard.archimedeanAt {σ : Type*} + (g : WordTransferGuard σ) (x : σ → ℝ) : Prop := + 1 ≤ g.pivot.realEval x ∧ g.pivot.realEval x ≤ g.pivotBound ∧ + ((2 * g.pivotBound * g.childBound + 1 : ℕ) : ℝ) ≤ g.rightProduct.realEval x + +/-- Integrality turns the strict integer gap into the closed real inequality. +All divisibility and unit tests remain in the residue factor. -/ +theorem WordTransferGuard.validAt_residue_archimedean {σ : Type*} + (g : WordTransferGuard σ) (x : σ → ℤ) : + g.ValidAt x ↔ g.residueAt x ∧ g.frequencyBounds ∧ + g.archimedeanAt (fun i => (x i : ℝ)) := by + change g.ValidAt x ↔ g.residueAt x ∧ g.frequencyBounds ∧ + (1 ≤ g.pivot.realValue x ∧ g.pivot.realValue x ≤ g.pivotBound ∧ + ((2 * g.pivotBound * g.childBound + 1 : ℕ) : ℝ) ≤ g.rightProduct.realValue x) + constructor + · rintro ⟨hp, hr, hlo, hhi, hgap, hv, hw⟩ + exact ⟨⟨hp, hr⟩, ⟨hv, hw⟩, hlo, hhi, (g.gap_iff x ⟨hp, hr⟩).mp hgap⟩ + · rintro ⟨⟨hp, hr⟩, ⟨hv, hw⟩, hlo, hhi, hgap⟩ + exact ⟨hp, hr, hlo, hhi, (g.gap_iff x ⟨hp, hr⟩).mpr hgap, hv, hw⟩ + +theorem MovingFormulaNode.holds_residue_archimedean (f : MovingFormulaNode) (a : Bool → ℤ) : + (f.guard.ValidAt a ∧ f.newGiant.IntegralAt a) ↔ + f.residueTests a ∧ f.guard.frequencyBounds ∧ + f.guard.archimedeanAt (fun i => (a i : ℝ)) := by + rw [f.guard.validAt_residue_archimedean, f.residueTests_iff] + tauto + +noncomputable def movingResidueGate (nodes : List MovingFormulaNode) (a : Bool → ℤ) : Prop := + ∀ f ∈ nodes, f.residueTests a ∧ f.guard.frequencyBounds + +noncomputable def movingArchimedeanGate (nodes : List MovingFormulaNode) (x : Bool → ℝ) : Prop := + ∀ f ∈ nodes, f.guard.archimedeanAt x + +/-- The real factor is evaluated at the actual point, while the residue +factor may use any representative of the constructed common period. -/ +theorem movingFormulaNodes_residue_real (nodes : List MovingFormulaNode) + (x a : Bool → ℤ) (hres : ∀ i, x i ≡ a i [ZMOD movingArithmeticPeriod nodes]) : + (∀ f ∈ nodes, f.guard.ValidAt x ∧ f.newGiant.IntegralAt x) ↔ + movingResidueGate nodes a ∧ movingArchimedeanGate nodes (fun i => (x i : ℝ)) := by + have hfres (f : MovingFormulaNode) (hf : f ∈ nodes) : f.residueTests x ↔ f.residueTests a := + f.residueTests_modEq x a (fun i => (hres i).of_dvd + (by exact_mod_cast movingArithmeticPeriod_dvd nodes f hf)) + constructor + · intro h + constructor + · intro f hf + have hx := (f.holds_residue_archimedean x).mp (h f hf) + exact ⟨(hfres f hf).mp hx.1, hx.2.1⟩ + · intro f hf + exact ((f.holds_residue_archimedean x).mp (h f hf)).2.2 + · rintro ⟨hr, ha⟩ f hf + exact (f.holds_residue_archimedean x).mpr + ⟨(hfres f hf).mpr (hr f hf).1, (hr f hf).2, ha f hf⟩ + +def topGiantReal (XL XR : ℝ) (b : Bool) : ℝ := if b then XR else XL + +noncomputable def WordTransferGuard.realPolynomials {σ : Type*} + (g : WordTransferGuard σ) (a : σ → ℝ) (coord : σ) : Fin 3 → Polynomial ℝ := + ![formulaPolynomial g.pivot a coord - Polynomial.C 1, + Polynomial.C (g.pivotBound : ℝ) - formulaPolynomial g.pivot a coord, + formulaPolynomial g.rightProduct a coord - + Polynomial.C ((2 * g.pivotBound * g.childBound + 1 : ℕ) : ℝ)] + +theorem WordTransferGuard.archimedeanAt_polynomials {σ : Type*} + (g : WordTransferGuard σ) (a : σ → ℝ) (coord : σ) (z : ℝ) : + g.archimedeanAt (Function.update a coord z) ↔ + ∀ j, 0 ≤ (g.realPolynomials a coord j).eval z := by + simp only [archimedeanAt, realPolynomials, Fin.forall_fin_succ, + Matrix.cons_val_zero, Matrix.cons_val_succ, Matrix.cons_val_fin_one, Fin.forall_fin_zero, + Polynomial.eval_sub, Polynomial.eval_C, formulaPolynomial, normalizedHistoryPolynomial_eval, + HistoryFormula.realEval, sub_nonneg, and_true] + +theorem WordTransferGuard.realPolynomials_degree {σ : Type*} + (g : WordTransferGuard σ) (a : σ → ℝ) (coord : σ) (j : Fin 3) : + (g.realPolynomials a coord j).natDegree ≤ max g.pivot.cost g.rightProduct.cost := by + fin_cases j + · apply (Polynomial.natDegree_sub_le _ _).trans + simp only [Polynomial.natDegree_C, max_zero] + exact (formulaPolynomial_degree _ _ _).trans (Nat.le_max_left _ _) + · apply (Polynomial.natDegree_sub_le _ _).trans + simp only [Polynomial.natDegree_C, zero_max] + exact (formulaPolynomial_degree _ _ _).trans (Nat.le_max_left _ _) + · apply (Polynomial.natDegree_sub_le _ _).trans + simp only [Polynomial.natDegree_C, max_zero] + exact (formulaPolynomial_degree _ _ _).trans (Nat.le_max_right _ _) + +noncomputable def movingArchimedeanRootCuts (nodes : List MovingFormulaNode) + (a : Bool → ℝ) (coord : Bool) : Finset ℝ := + nodes.toFinset.biUnion fun f => polynomialRootCuts (f.guard.realPolynomials a coord) + +noncomputable def movingRealUpdate (a : Bool → ℝ) (coord : Bool) (z : ℝ) : Bool → ℝ := + @Function.update Bool (fun _ => ℝ) (fun x y => Classical.propDecidable (x = y)) a coord z + +theorem movingArchimedeanRootCuts_mem (nodes : List MovingFormulaNode) + (a : Bool → ℝ) (coord : Bool) (f : MovingFormulaNode) (hf : f ∈ nodes) + (j : Fin 3) (r : ℝ) (hr : r ∈ (f.guard.realPolynomials a coord j).roots) : + r ∈ movingArchimedeanRootCuts nodes a coord := by + exact Finset.mem_biUnion.mpr ⟨f, List.mem_toFinset.mpr hf, + Finset.mem_biUnion.mpr ⟨j, Finset.mem_univ _, Multiset.mem_toFinset.mpr hr⟩⟩ + +theorem movingArchimedeanGate_rootCell (nodes : List MovingFormulaNode) + (a : Bool → ℝ) (coord : Bool) (S : Finset ℝ) + (hS : movingArchimedeanRootCuts nodes a coord ⊆ S) (x y : ℝ) + (hcode : rootCellCode S x = rootCellCode S y) : + movingArchimedeanGate nodes (movingRealUpdate a coord x) ↔ + movingArchimedeanGate nodes (movingRealUpdate a coord y) := by + apply forall_congr' + intro f + apply imp_congr_right + intro hf + dsimp only [movingRealUpdate] + rw [f.guard.archimedeanAt_polynomials a coord x, f.guard.archimedeanAt_polynomials a coord y] + apply forall_congr' + intro j + exact polynomial_nonneg_iff_of_root_cell _ S + (fun r hr => hS (movingArchimedeanRootCuts_mem nodes a coord f hf j r hr)) hcode + +theorem movingArithmeticSupport_residue_real {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XL XR a b M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + T.ArithmeticSupport value childBound pivotBound XL XR ↔ + movingResidueGate nodes (topGiantInput a b) ∧ movingArchimedeanGate nodes (topGiantReal XL XR) := by + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + have hform := T.formulaNodes_iff value hvalue childBound pivotBound hf XL XR + (.prime false) (.prime true) (topGiantInput XL XR) (by simp [topGiantInput]) (by simp [topGiantInput]) + rw [← hform] + have hres : ∀ i, topGiantInput XL XR i ≡ topGiantInput a b i [ZMOD movingArithmeticPeriod nodes] := by + intro i + cases i + · exact hL.of_dvd (by exact_mod_cast hM) + · exact hR.of_dvd (by exact_mod_cast hM) + have h := movingFormulaNodes_residue_real nodes (topGiantInput XL XR) (topGiantInput a b) hres + have he : (fun i => (topGiantInput XL XR i : ℝ)) = topGiantReal XL XR := by + funext i + cases i <;> rfl + simpa only [he] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealSmooth.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealSmooth.lean new file mode 100644 index 0000000000000000000000000000000000000000..333695ab3e318a23f988586559d4d528bf59b197 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealSmooth.lean @@ -0,0 +1,114 @@ +import Mathlib.Topology.Algebra.MvPolynomial +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCanonicalComparison + +namespace OAI + +/-! # A single real smooth kernel for the two original giant coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate SchwartzMap + +theorem MovingSlotReversal.continuous_realPivot {σ : Type*} + (value : σ → ℕ) (s : MovingSlotReversal σ) {A : Type*} [TopologicalSpace A] + (L R : A → ℝ) (hL : Continuous L) (hR : Continuous R) : + Continuous (fun x => s.realPivot value (L x) (R x)) := by + unfold realPivot + exact ((continuous_const.mul hR).sub (continuous_const.mul hL)).div_const _ + +theorem MovingSlotData.continuous_realLeafModuli {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) {A : Type*} [TopologicalSpace A] + (L R : A → ℝ) (hL : Continuous L) (hR : Continuous R) (i : TreeLeafIndex n) : + Continuous (fun x => T.realLeafModuli value (L x) (R x) i) := by + induction T generalizing L R with + | leaf => exact (hL.mul hR).mul_const _ + | node s CL CR u left right ihL ihR => + have hp := (MovingSlotData.step s CL CR u left right false).continuous_realPivot value L R hL hR + cases i with + | inl i => exact ihL _ L hp hL i + | inr i => exact ihR _ R hp hR i + +noncomputable def movingRealFourierWeight {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (L R : ℝ) : ℂ := + ∏ i : TreeLeafIndex n, + let v := (fourierPolynomialFactor Polynomial.X ψ (T.leafFrequencies i) lo hi hlo hhi).value + (T.realLeafModuli value L R i / X) + if treeLeafTupleEquiv Bool n (transferConjugations n false) i then conj v else v + +theorem movingFourierPolynomialFactors_real {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (z : ℝ) : + smoothPolynomialWeight (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi) z = + movingRealFourierWeight value T ψ X lo hi hlo hhi (L.eval z) (R.eval z) := by + unfold smoothPolynomialWeight movingRealFourierWeight + rw [← (movingLeafIndexEquiv n).prod_comp + (fun j => (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi j).value z)] + apply Finset.prod_congr rfl + intro i _ + simp only [movingFourierPolynomialFactors, Equiv.symm_apply_apply] + split_ifs <;> + simp only [ClippedPolynomialFactor.conjugate, ClippedPolynomialFactor.value, + fourierPolynomialFactor, movingLeafNormalizedPolynomial_eval, T.leafPolynomials_real, + Polynomial.eval_X] + +theorem continuous_movingRealFourierWeight {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) {A : Type*} [TopologicalSpace A] + (L R : A → ℝ) (hL : Continuous L) (hR : Continuous R) : + Continuous (fun x => movingRealFourierWeight value T ψ X lo hi hlo hhi (L x) (R x)) := by + apply continuous_finsetProd + intro i _ + have hc := (fourierPolynomialFactor Polynomial.X ψ (T.leafFrequencies i) lo hi hlo hhi).continuous_value.comp + ((T.continuous_realLeafModuli value L R hL hR i).div_const X) + dsimp only + split_ifs + · exact Complex.continuous_conj.comp hc + · exact hc + +theorem continuous_movingRealNodeCutoff {σ : Type*} (value : σ → ℕ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : MovingSlotData σ n) {A : Type*} [TopologicalSpace A] + (L R : A → ℝ) (hL : Continuous L) (hR : Continuous R) : + Continuous (fun x => movingRealNodeCutoff value φ G T (L x) (R x)) := by + have hp (g : ℝ) : Continuous (fun x => (positiveLogCutoff φ g x : ℂ)) := by + have he (x : ℝ) := logCutoffPolynomialFactor_value Polynomial.X φ g B D hB hD hφ hlip hout x + simp only [Polynomial.eval_X] at he + exact ((logCutoffPolynomialFactor Polynomial.X φ g B D hB hD hφ hlip).continuous_value).congr he + induction T generalizing L R with + | leaf => exact continuous_const + | @node n s CL CR u left right ihL ihR => + have hc := (MovingSlotData.step s CL CR u left right false).continuous_realPivot value L R hL hR + exact (((hp (G (n + 1))).comp hc).mul (ihL _ L hc hL)).mul (ihR _ R hc hR) + +noncomputable def movingRealSmoothWeight {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) (L R : ℝ) : ℂ := + movingRealFourierWeight value T ψ X lo hi hlo hhi L R * movingRealNodeCutoff value φ G T L R + +theorem movingSmoothPolynomialFactors_real {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (hout : ∀ x, 1 ≤ |x| → φ x = 0) (z : ℝ) : + smoothPolynomialWeight (movingSmoothPolynomialFactors value T L R ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip) z = + movingRealSmoothWeight value T ψ X lo hi hlo hhi φ G (L.eval z) (R.eval z) := by + rw [movingSmoothPolynomialFactors_value value T L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout, + movingFourierPolynomialFactors_real] + rfl + +theorem continuous_movingRealSmoothWeight {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) + (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {A : Type*} [TopologicalSpace A] (L R : A → ℝ) (hL : Continuous L) (hR : Continuous R) : + Continuous (fun x => movingRealSmoothWeight value T ψ X lo hi hlo hhi φ G (L x) (R x)) := + (continuous_movingRealFourierWeight value T ψ X lo hi hlo hhi L R hL hR).mul + (continuous_movingRealNodeCutoff value φ G B D hB hD hφ hlip hout T L R hL hR) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..782d6051bbc645d4d6c47396910d98f02d3a0bbc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealWeight.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportWeight + +namespace OAI + +/-! # The actual recursive coefficient on real moving giants -/ + +namespace Ostmann +open scoped Classical + +/-- Real evaluation of the very same moving recursion, before arithmetic +indicators. The reciprocal compensation product remains in every pivot. -/ +noncomputable def movingRealWeight {σ : Type*} (value : σ → ℕ) + (F : ∀ {n}, MovingSlotData σ n → ℝ → ℝ → ℂ) + (E : ∀ {n}, MovingSlotData σ n → ℝ → ℝ → ℝ) : + {n : ℕ} → MovingSlotData σ n → ℝ → ℝ → ℂ + | _, .leaf s regular, L, R => F (.leaf s regular) L R + | _, .node s CL CR u left right, L, R => + let p := (MovingSlotData.step s CL CR u left right false).realPivot value L R + (E (.node s CL CR u left right) L R : ℂ) * + movingRealWeight value F E left p L * star (movingRealWeight value F E right p R) + +noncomputable def movingRealLeaf {σ : Type*} + (F : ∀ {n}, MovingSlotData σ n → ℝ → ℝ → ℂ) (x : MovingSlotState σ) (_s : ℤ) : ℂ := + F x.data x.leftGiant x.rightGiant + +noncomputable def movingRealExtra {σ : Type*} + (E : ∀ {n}, MovingSlotData σ n → ℝ → ℝ → ℝ) + (x : MovingSlotState σ) (_s _v _w : ℤ) : ℝ := + E x.data x.leftGiant x.rightGiant + +/-- Agreement uses the proved integer recursion, not a new realization +hypothesis for each of the polynomial leaves. -/ +theorem movingRealWeight_eq_unrestricted {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) + (F : ∀ {n}, MovingSlotData σ n → ℝ → ℝ → ℂ) + (E : ∀ {n}, MovingSlotData σ n → ℝ → ℝ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (XL XR : ℕ) (hI : T.Integral value XL XR) : + movingRealWeight value F E T XL XR = + movingUnrestrictedWeight value (movingRealLeaf F) (movingRealExtra E) T XL XR := by + induction T generalizing XL XR with + | leaf => rfl + | node s CL CR u left right ihL ihR => + let step := MovingSlotData.step s CL CR u left right false + have hp := step.realPivot_eq value XL XR hf.1 + (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) hI.1 + dsimp only [step] at hp + simp only [movingRealWeight, hp, movingUnrestrictedWeight, movingRealExtra] + rw [ihL hf.2.1 _ _ hI.2.1, ihR hf.2.2 _ _ hI.2.2] + +/-- Exact smooth/arithmetic separation for the original recursive weight. +All invalid integer reconstructions are retained as zero terms. -/ +theorem movingSlotWeight_real_factor {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : ∀ {n}, MovingSlotData σ n → ℝ → ℝ → ℂ) + (E : ∀ {n}, MovingSlotData σ n → ℝ → ℝ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hf : T.Frequencies (· ≠ 0)) (XL XR : ℕ) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) (movingRealLeaf F) + (movingSlotCutoff value childBound pivotBound (movingRealExtra E)) n ⟨n, T, XL, XR⟩ t = + movingArithmeticIndicator value childBound pivotBound T XL XR * + movingRealWeight value F E T XL XR := by + rw [movingSlotWeight_indicator_factor value hvalue childBound pivotBound _ _ T t hT hf] + by_cases hs : T.ArithmeticSupport value childBound pivotBound XL XR + · rw [movingRealWeight_eq_unrestricted value hvalue F E T hf XL XR + (hs.integral value hvalue childBound pivotBound T XL XR)] + · simp only [movingArithmeticIndicator, ite_eq_right hs, zero_mul] + +/-- Once the indicator is fixed on a residue/root cell, its contribution to +an oscillation is at most that of the explicit real weight. -/ +theorem movingSlotWeight_real_cell_difference {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : ∀ {n}, MovingSlotData σ n → ℝ → ℝ → ℂ) + (E : ∀ {n}, MovingSlotData σ n → ℝ → ℝ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hf : T.Frequencies (· ≠ 0)) (XL YL XR : ℕ) + (hres : (XL : ℤ) ≡ (YL : ℤ) [ZMOD movingTopPeriod value hvalue childBound pivotBound T hf]) + (hcell : rootCellCode (movingTopRootCuts value hvalue childBound pivotBound T hf XR) (XL : ℝ) = + rootCellCode (movingTopRootCuts value hvalue childBound pivotBound T hf XR) (YL : ℝ)) : + ‖recursiveTransferWeight (movingSlotSystem value childBound pivotBound) (movingRealLeaf F) + (movingSlotCutoff value childBound pivotBound (movingRealExtra E)) n ⟨n, T, XL, XR⟩ t - + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) (movingRealLeaf F) + (movingSlotCutoff value childBound pivotBound (movingRealExtra E)) n ⟨n, T, YL, XR⟩ t‖ ≤ + ‖movingRealWeight value F E T XL XR - movingRealWeight value F E T YL XR‖ := by + rw [movingSlotWeight_real_factor value hvalue childBound pivotBound F E T t hT hf, + movingSlotWeight_real_factor value hvalue childBound pivotBound F E T t hT hf, + movingArithmeticIndicator_cells value hvalue childBound pivotBound T hf XL YL XR hres hcell, + ← mul_sub, norm_mul] + by_cases hs : T.ArithmeticSupport value childBound pivotBound YL XR + · simp only [movingArithmeticIndicator, ite_eq_left hs, norm_one, one_mul, le_refl] + · simp only [movingArithmeticIndicator, ite_eq_right hs, norm_zero, zero_mul, norm_nonneg] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealWindows.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5d0c41ecd0c8a6e14a96c4431abf999e89ec7b6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRealWindows.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWindowedSpectators +import OAI.NumberTheory.Ostmann.Arithmetic.MovingResidueFactorization +import OAI.NumberTheory.Ostmann.Arithmetic.MovingLogLeaves + +namespace OAI + +/-! # The terminal-window factor on two real giant coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem MovingSlotData.leafPolynomials_real {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (L R : Polynomial ℝ) (z : ℝ) (i : TreeLeafIndex n) : + (T.leafPolynomials value L R i).eval z = T.realLeafModuli value (L.eval z) (R.eval z) i := by + induction T generalizing L R with + | leaf => simp only [leafPolynomials, realLeafModuli, Polynomial.eval_mul, Polynomial.eval_C] + | node s CL CR U left right ihL ihR => + cases i with + | inl i => + simpa only [leafPolynomials, realLeafModuli, MovingSlotReversal.pivotPolynomial_eval] using + ihL ((MovingSlotData.step s CL CR U left right false).pivotPolynomial value L R) L i + | inr i => + simpa only [leafPolynomials, realLeafModuli, MovingSlotReversal.pivotPolynomial_eval] using + ihR ((MovingSlotData.step s CL CR U left right false).pivotPolynomial value L R) R i + +theorem MovingSlotData.realLeafModuli_nat {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (XL XR : ℕ) (hI : T.Integral value XL XR) (i : TreeLeafIndex n) : + T.realLeafModuli value XL XR i = (T.leafModuli value XL XR i : ℝ) := by + have h := T.leafPolynomials_real value Polynomial.X (Polynomial.C XR) XL i + rw [T.leafPolynomials_eval value hvalue hf XL XR hI _ _ _ (by simp) (by simp) i] at h + simpa only [Polynomial.eval_X, Polynomial.eval_C] using h.symm + +noncomputable def movingRealWindowFlag {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (X lo hi XL XR : ℝ) : ℂ := + if ∀ i, T.realLeafModuli value XL XR i / X ∈ Set.Icc lo hi then 1 else 0 + +theorem movingWindowedData_real_factor {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (XL XR : ℕ) (hI : T.Integral value XL XR) : + movingUnrestrictedWeight value (movingWindowLeaf value X lo hi (movingDataLeaf F)) + (movingDataExtra E) T XL XR = + movingRealWindowFlag value T X lo hi XL XR * movingDataWeight F E T := by + rw [movingUnrestrictedWeight_data_window] + simp only [movingRealWindowFlag, T.realLeafModuli_nat value hvalue hf XL XR hI] + split_ifs <;> simp only [one_mul, zero_mul] + +/-- The original nonsmooth coefficient is exactly a fixed residue factor +times a function of the two real giant coordinates. This includes zero terms. -/ +theorem moving_original_nonsmooth_residue_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XL XR a b M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + movingArithmeticIndicator value childBound pivotBound T XL XR * + movingWindowedSpectatorWeight q value F E X lo hi g D S T XL XR = + (movingResidueFlag nodes (topGiantInput a b) * movingSpectatorResidue q value g D S T a b) * + (movingArchimedeanFlag nodes (topGiantReal XL XR) * + movingRealWindowFlag value T X lo hi XL XR * movingDataWeight F E T) := by + dsimp only + have he : movingArithmeticIndicator value childBound pivotBound T XL XR * + movingWindowedSpectatorWeight q value F E X lo hi g D S T XL XR = + (movingArithmeticIndicator value childBound pivotBound T XL XR * + ∏ i ∈ S, movingSlotSpectator value (g i) (D i) T XL XR) * + (movingRealWindowFlag value T X lo hi XL XR * movingDataWeight F E T) := by + by_cases hs : T.ArithmeticSupport value childBound pivotBound XL XR + · unfold movingWindowedSpectatorWeight + rw [movingWindowedData_real_factor value hvalue F E X lo hi T hf XL XR + (hs.integral value hvalue childBound pivotBound T XL XR)] + ring + · have hz : movingArithmeticIndicator value childBound pivotBound T XL XR = 0 := ite_eq_right hs + rw [hz, zero_mul, zero_mul, zero_mul] + rw [he, moving_arithmetic_spectator_residue_factor q value hvalue childBound pivotBound + g D S T hf XL XR a b M hM hMq hL hR] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveCompensation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveCompensation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b26a05578439982ec0720e2210e8b4fde11bf3a2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveCompensation.lean @@ -0,0 +1,118 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRecursiveSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePatternBudget + +namespace OAI + +/-! # Extracting compensation from the actual supported recursion -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingCompensatedExtra {σ : Type*} (value : σ → ℕ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (x : MovingSlotState σ) (s v w : ℤ) : ℝ := + (x.compensation value : ℝ) * E x s v w + +theorem movingSlotCutoff_compensated {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (x : MovingSlotState σ) (s v w : ℤ) : + movingSlotCutoff value childBound pivotBound (movingCompensatedExtra value E) x s v w = + (x.compensation value : ℝ) * movingSlotCutoff value childBound pivotBound E x s v w := by + unfold movingSlotCutoff movingCompensatedExtra + split_ifs <;> simp only [mul_zero] + +theorem MovingSlotState.compensation_rootData {σ : Type*} (value : σ → ℕ) + (x : MovingSlotState σ) : + (⟨x.depth, x.data.rootData, x.leftGiant, x.rightGiant⟩ : MovingSlotState σ).compensation value = + x.compensation value := by + rcases x with ⟨n, T, XL, XR⟩ + cases T <;> rfl + +theorem movingLocalExtra_compensated {σ : Type*} (value : σ → ℕ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) : + movingLocalExtra (movingCompensatedExtra value E) = + movingCompensatedExtra value (movingLocalExtra E) := by + funext x s v w + simp only [movingLocalExtra, movingCompensatedExtra, MovingSlotState.compensation_rootData] + +/-- Each node contributes its newly sampled compensation exactly once, +including off-support samples where both sides vanish. -/ +theorem movingRecursiveWeight_compensated {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (a : MovingSampleSlots σ n) (XL XR : ℕ) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingCompensatedExtra value E)) n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ t = + (movingSampleProduct value a : ℂ) * + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound E) n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ t := by + let sys := movingSlotSystem value childBound pivotBound + let cut := movingSlotCutoff value childBound pivotBound E + let cutc := movingSlotCutoff value childBound pivotBound (movingCompensatedExtra value E) + induction a generalizing XL XR with + | leaf => simp only [movingSampleProduct, Nat.cast_one, one_mul, recursiveTransferWeight] + | @node n a l r hl hr => + let x : MovingSlotState σ := + ⟨n + 1, buildMovingSlotData (n + 1) t small bulk (.node a l r), XL, XR⟩ + let P := historyPivot sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + by_cases hv : ValidTransferNode sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) P + · rw [recursiveTransferWeight_node sys F cutc n x t P hv, + recursiveTransferWeight_node sys F cut n x t P hv] + change (cutc x t.1 _ _ : ℂ) * + recursiveTransferWeight sys F cutc n ⟨n, _, _, _⟩ t.2.1 * + star (recursiveTransferWeight sys F cutc n ⟨n, _, _, _⟩ t.2.2) = _ + simp only [ite_true, Bool.false_eq_true, ite_false] + rw [hl, hr] + have hc : cutc x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) = + (x.compensation value : ℝ) * cut x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) := + movingSlotCutoff_compensated value childBound pivotBound E x _ _ _ + rw [hc] + simp only [movingSampleProduct, Complex.ofReal_mul, Complex.ofReal_natCast, + Nat.cast_mul, star_mul, star_natCast] + change _ = (x.compensation value : ℂ) * _ * _ * _ + simp only [sys, movingSlotSystem, MovingSlotState.child, x, buildMovingSlotData, + ite_true, Bool.false_eq_true, ite_false] + ring + · have hz₁ : recursiveTransferWeight sys F cutc (n + 1) x t = 0 := by + simp only [recursiveTransferWeight, P, hv, ite_false] + have hz₂ : recursiveTransferWeight sys F cut (n + 1) x t = 0 := by + simp only [recursiveTransferWeight, P, hv, ite_false] + rw [hz₁, hz₂, mul_zero] + +theorem movingSupportedWeight_mul {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) (c z : ℂ) : + movingSupportedWeight value outside T XL XR (c * z) = + c * movingSupportedWeight value outside T XL XR z := by + unfold movingSupportedWeight + split_ifs <;> simp only [mul_zero] + +/-- Exact compensated prior times the supported coefficient with node +compensations removed. This is the scalar used by the pattern comparison. -/ +theorem movingSampledWeight_compensated_supported {σ : Type*} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (XL XR : ℕ) : + movingSampledWeight value μ childBound pivotBound (movingGuardedLeaf value outside F) + (movingGuardedExtra value outside (movingLocalExtra (movingCompensatedExtra value E))) + n t small bulk XL XR = + ∑ a : MovingSampleSlots σ n, + (((movingSampleProduct value a : ℝ) * movingSamplesPrior μ a : ℝ) : ℂ) * + movingSupportedWeight value outside (buildMovingSlotData n t small bulk a) XL XR + (recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingLocalExtra E)) n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ t) := by + rw [movingSampledWeight_supported] + apply Finset.sum_congr rfl + intro a _ + rw [movingLocalExtra_compensated, movingRecursiveWeight_compensated, + movingSupportedWeight_mul, Complex.ofReal_mul, Complex.ofReal_natCast] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveProductBounds.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveProductBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b7a0a3cf7a9df7c99034da0eeefddd771e1a4b1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveProductBounds.lean @@ -0,0 +1,155 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingEarlyCellCaps +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularSlots + +namespace OAI + +/-! # Product windows inherited through every actual integer extension -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- The logarithmic product budget left after each common pivot is removed. -/ +noncomputable def movingProductExponent (T : ℕ → ℝ) (W : ℝ) : ℕ → ℝ + | 0 => W + | n + 1 => 2 * (movingProductExponent T W n - T n) + +private theorem remove_positive_product (A B : ℕ) (T E : ℝ) + (hA : Real.exp T ≤ (A : ℝ)) (hAB : ((A * B : ℕ) : ℝ) ≤ Real.exp E) : + (B : ℝ) ≤ Real.exp (E - T) := by + rw [Nat.cast_mul] at hAB + rw [Real.exp_sub] + apply (le_div_iff₀ (Real.exp_pos T)).mpr + have hh := (mul_le_mul_of_nonneg_right hA (Nat.cast_nonneg B)).trans hAB + simpa only [Nat.cast_mul, mul_comm] using hh + +theorem movingNaturalProduct_append_leaves {σ : Type*} (value : σ → ℕ) + (n : ℕ) (u small bulk : TreeLeafTuple (List σ) n) : + MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (appendMovingSlotLeaves n u small) ++ flattenMovingSlots n bulk) = + MovingSlotReversal.naturalProduct value (flattenMovingSlots n u) * + MovingSlotReversal.naturalProduct value + (flattenMovingSlots n small ++ flattenMovingSlots n bulk) := by + have hp := ((flattenMovingSlots_append_perm n u small).append_right + (flattenMovingSlots n bulk)).map value + change (List.map value _).prod = _ + rw [hp.prod_eq] + simp only [MovingSlotReversal.naturalProduct, List.map_append, List.prod_append] + ring + +/-- This bound is proved on the original sampled histories, before summing any +frequencies. The inserted giants may be arbitrary positive integers. -/ +theorem movingSupportedSampledWeight_product_bound {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (T : ℕ → ℝ) (W : ℝ) + (hF : ∀ s small XL XR, + F ⟨0, .leaf s small, XL, XR⟩ s ≠ 0 → + ((XL * XR * MovingSlotReversal.naturalProduct value small : ℕ) : ℝ) ≤ Real.exp W) + (hmin : ∀ n (a : TreeLeafTuple (Fin 4 → σ) n), + movingCompensationPrior (μ n) n a ≠ 0 → ∀ p : ℕ, 0 < p → + φ (Real.log p - G (n + 1)) ≠ 0 → + Real.exp (T n) ≤ (p * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingCompensationSlots n a)) : ℕ)) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (XL XR : ℕ) + (h : movingSupportedSampledWeight value outside μ childBound pivotBound F + (movingOriginalNode value childBound pivotBound φ G) n t small bulk XL XR ≠ 0) : + ((XL * XR * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n small ++ flattenMovingSlots n bulk) : ℕ) : ℝ) ≤ + Real.exp (movingProductExponent T W n) := by + induction n generalizing XL XR with + | zero => + change List σ at small bulk + change ℤ at t + have hh := movingFrequencyCoefficient_levelZero_support σ value outside μ childBound pivotBound + (fun _ => 0) F φ G t small bulk XL XR + (by rwa [movingFrequencyCoefficient_levelZero_sample]) + exact hF t (small ++ bulk) XL XR hh + | succ n ih => + rw [movingSupportedSampledWeight_direct_node] at h + obtain ⟨a, _, ha⟩ := Finset.exists_ne_zero_of_sum_ne_zero h + dsimp only at ha + have hm : movingCompensationPrior (μ n) n a ≠ 0 := by + intro hz + exact ha (by rw [hz, Complex.ofReal_zero, zero_mul]) + have hb := right_ne_zero_of_mul ha + split_ifs at hb with hg + · let u := movingCompensationSlots n a + let p := movingTopPivot value + (flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1) + (flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2) + (flattenMovingSlots n u) XL XR t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + have hp : 0 < p := Nat.pos_of_mul_pos_right hg.2.1.pivot_pos + have hphi : φ (Real.log p - G (n + 1)) ≠ 0 := by + intro hz + apply left_ne_zero_of_mul (left_ne_zero_of_mul hb) + change (((MovingSlotReversal.naturalProduct value (flattenMovingSlots n u) : ℝ) * + φ (Real.log p - G (n + 1)) : ℝ) : ℂ) = 0 + rw [hz, mul_zero, Complex.ofReal_zero] + have hl := ih t.2.1 (appendMovingSlotLeaves n u small.1) bulk.1 p XL + (right_ne_zero_of_mul (left_ne_zero_of_mul hb)) + have hr := ih t.2.2 (appendMovingSlotLeaves n u small.2) bulk.2 p XR + (star_ne_zero.mp (right_ne_zero_of_mul hb)) + rw [movingNaturalProduct_append_leaves] at hl hr + let U := MovingSlotReversal.naturalProduct value (flattenMovingSlots n u) + let L := XL * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1) + let R := XR * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2) + have hidL : p * XL * (U * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1)) = (p * U) * L := by + dsimp only [L]; ring + have hidR : p * XR * (U * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2)) = (p * U) * R := by + dsimp only [R]; ring + rw [hidL] at hl + rw [hidR] at hr + have hlow := hmin n a hm p hp hphi + have hl' := remove_positive_product (p * U) L (T n) _ hlow hl + have hr' := remove_positive_product (p * U) R (T n) _ hlow hr + have hprod := mul_le_mul hl' hr' (Nat.cast_nonneg R) (Real.exp_nonneg _) + have hid : XL * XR * MovingSlotReversal.naturalProduct value + (flattenMovingSlots (n + 1) small ++ flattenMovingSlots (n + 1) bulk) = L * R := by + simp only [flattenMovingSlots, movingNaturalProduct_append, L, R] + ring + rw [hid, Nat.cast_mul] + convert hprod using 1 + rw [movingProductExponent, ← Real.exp_add] + congr 1 + ring + · exact (hb rfl).elim + +/-- Summing descendants cannot create support outside the inherited product +window. This is the coefficient used by the original arithmetic comparison. -/ +theorem movingFrequencyCoefficient_recursive_product_bound {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi W : ℝ) (hX : 0 < X) (hwindow : X * hi ≤ Real.exp W) + (φ : ℝ → ℝ) (G T : ℕ → ℝ) + (hmin : ∀ n (a : TreeLeafTuple (Fin 4 → σ) n), + movingCompensationPrior (μ n) n a ≠ 0 → ∀ p : ℕ, 0 < p → + φ (Real.log p - G (n + 1)) ≠ 0 → + Real.exp (T n) ≤ (p * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingCompensationSlots n a)) : ℕ)) + (n : ℕ) (s : ℤ) (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s small bulk XL XR ≠ 0) : + ((XL * XR * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n small ++ flattenMovingSlots n bulk) : ℕ) : ℝ) ≤ + Real.exp (movingProductExponent T W n) := by + unfold movingFrequencyCoefficient at h + obtain ⟨t, _, ht⟩ := Finset.exists_ne_zero_of_sum_ne_zero h + apply movingSupportedSampledWeight_product_bound value outside μ childBound pivotBound + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G T W _ hmin n _ small bulk XL XR ht + intro s small XL XR hh + have hw := movingOriginalLeaf_window value q F g Dq S ψ X lo hi + ⟨0, .leaf s small, XL, XR⟩ s hh + have hu := (div_le_iff₀ hX).mp hw.2 + have hu' : ((XL * XR * MovingSlotReversal.naturalProduct value small : ℕ) : ℝ) ≤ X * hi := by + simpa only [movingSlotModulus, mul_comm] using hu + exact hu'.trans hwindow + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..e0f6e631c144e4ac88ef4c931b5491c4ae489cfe --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveSupport.lean @@ -0,0 +1,184 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampledRecursion +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedWeight + +namespace OAI + +/-! # Full original support as local guards in the sampled recursion + +All current-state coprimalities and all descendant-frequency unit tests are +retained. This puts the existing fully supported coefficient into the local +recursion form, without conditioning any internal sample prior. +-/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingLocalSupport {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + (x : MovingSlotState σ) : Prop := + (x.data.currentSlots value x.leftGiant x.rightGiant ++ outside).Pairwise Nat.Coprime ∧ + movingLocalGiantUnits value outside x.data x.leftGiant x.rightGiant + +noncomputable def movingGuardedLeaf {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (x : MovingSlotState σ) (s : ℤ) : ℂ := + if movingLocalSupport value outside x then F x s else 0 + +noncomputable def movingGuardedExtra {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (x : MovingSlotState σ) (s v w : ℤ) : ℝ := + if movingLocalSupport value outside x then E x s v w else 0 + +theorem movingFullSupport_node {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (s : ℤ) (CL CR u : List σ) (l r : MovingSlotData σ n) (XL XR : ℕ) : + let T := MovingSlotData.node s CL CR u l r + let p := (MovingSlotData.step s CL CR u l r false).naturalPivot value XL XR + movingFullSupport value outside T XL XR ↔ + movingLocalSupport value outside ⟨n + 1, T, XL, XR⟩ ∧ + movingFullSupport value outside l p XL ∧ movingFullSupport value outside r p XR := by + simp only [movingFullSupport, movingLocalSupport, movingFullOutsidePairwise, movingNaturalGiantUnits] + tauto + +theorem movingSlotCutoff_guarded {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (x : MovingSlotState σ) (s v w : ℤ) : + movingSlotCutoff value childBound pivotBound (movingGuardedExtra value outside E) x s v w = + if movingLocalSupport value outside x then + movingSlotCutoff value childBound pivotBound E x s v w else 0 := by + unfold movingSlotCutoff movingGuardedExtra + split_ifs <;> rfl + +/-- The fully supported original history coefficient equals the recursive +coefficient with the literal local support test at each node and leaf. -/ +theorem movingSupportedWeight_recursive {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (XL XR : ℕ) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (movingGuardedLeaf value outside F) + (movingSlotCutoff value childBound pivotBound (movingGuardedExtra value outside E)) + n ⟨n, T, XL, XR⟩ t = + movingSupportedWeight value outside T XL XR + (recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound E) n ⟨n, T, XL, XR⟩ t) := by + let sys := movingSlotSystem value childBound pivotBound + let cut := movingSlotCutoff value childBound pivotBound E + let cutg := movingSlotCutoff value childBound pivotBound (movingGuardedExtra value outside E) + induction T generalizing XL XR with + | leaf s regular => rfl + | @node n s CL CR u l r hl hr => + let x : MovingSlotState σ := ⟨n + 1, .node s CL CR u l r, XL, XR⟩ + let P := historyPivot sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + let p := (MovingSlotData.step s CL CR u l r false).naturalPivot value XL XR + have hp : P / MovingSlotReversal.naturalProduct value u = p := by + simp only [P, p, historyPivot, sys, movingSlotSystem, x, MovingSlotState.leftProduct, + MovingSlotState.rightProduct, MovingSlotReversal.naturalPivot, MovingSlotData.step, + movingGiantPivot, Nat.mul_one, ← hT.1, ← hT.2.1.root, ← hT.2.2.root] + by_cases hv : ValidTransferNode sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) P + · rw [recursiveTransferWeight_node sys _ cutg n x t P hv] + change (cutg x t.1 _ _ : ℂ) * + recursiveTransferWeight sys _ cutg n ⟨n, l, P / MovingSlotReversal.naturalProduct value u, XL⟩ t.2.1 * + star (recursiveTransferWeight sys _ cutg n ⟨n, r, P / MovingSlotReversal.naturalProduct value u, XR⟩ t.2.2) = _ + rw [hp, hl t.2.1 hT.2.1 p XL, hr t.2.2 hT.2.2 p XR] + have hg := movingSlotCutoff_guarded value outside childBound pivotBound E x + t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + change cutg x t.1 _ _ = if movingLocalSupport value outside x then cut x t.1 _ _ else 0 at hg + rw [hg] + unfold movingSupportedWeight + have hs := movingFullSupport_node value outside s CL CR u l r XL XR + dsimp only at hs + rw [hs] + rw [recursiveTransferWeight_node sys F cut n x t P hv] + have hleft : sys.leftState x P = + ⟨n, l, P / MovingSlotReversal.naturalProduct value u, XL⟩ := rfl + have hright : sys.rightState x P = + ⟨n, r, P / MovingSlotReversal.naturalProduct value u, XR⟩ := rfl + rw [hleft, hright, hp] + by_cases hA : movingLocalSupport value outside x <;> + by_cases hB : movingFullSupport value outside l p XL <;> + by_cases hC : movingFullSupport value outside r p XR + all_goals dsimp only [x, p] at hA hB hC ⊢ + all_goals simp only [hA, hB, hC, and_true, and_false, + ite_true, ite_false, Complex.ofReal_zero, zero_mul, mul_zero, star_zero] + rfl + · have hz₁ : recursiveTransferWeight sys (movingGuardedLeaf value outside F) cutg + (n + 1) x t = 0 := by simp only [recursiveTransferWeight, P, hv, ite_false] + have hz₂ : recursiveTransferWeight sys F cut (n + 1) x t = 0 := by + simp only [recursiveTransferWeight, P, hv, ite_false] + rw [hz₁, hz₂] + unfold movingSupportedWeight + split_ifs <;> rfl + +theorem movingFrequencySkeleton_frequencyTree (σ : Type*) (n : ℕ) + (t : FrequencyTree ℤ n) : + (movingFrequencySkeleton σ n t).frequencyTree = t := by + induction n with + | zero => rfl + | succ n ih => + simp only [movingFrequencySkeleton, MovingSlotData.frequencyTree, ih] + rfl + +theorem MovingSlotData.skeleton_frequencyProduct {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) : + (movingFrequencySkeleton σ n T.frequencyTree).frequencyProduct = T.frequencyProduct := by + induction T with + | leaf => rfl + | node s CL CR u l r hl hr => + simp only [MovingSlotData.frequencyTree, movingFrequencySkeleton, frequencyProduct, hl, hr] + +theorem MovingSlotData.rootData_regularSlots {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) : T.rootData.regularSlots = T.regularSlots := by + cases T <;> rfl + +theorem MovingSlotData.rootData_frequencyProduct {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) : T.rootData.frequencyProduct = T.frequencyProduct := by + cases T with + | leaf => rfl + | node s CL CR u l r => + simp only [rootData, frequencyProduct, skeleton_frequencyProduct] + +theorem MovingSlotData.rootData_idempotent {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) : T.rootData.rootData = T.rootData := by + cases T with + | leaf => rfl + | node s CL CR u l r => + simp only [rootData, movingFrequencySkeleton_frequencyTree] + +theorem movingLocalSupport_rootData {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + (x : MovingSlotState σ) : + movingLocalSupport value outside ⟨x.depth, x.data.rootData, x.leftGiant, x.rightGiant⟩ ↔ + movingLocalSupport value outside x := by + simp only [movingLocalSupport, MovingSlotData.currentSlots, movingLocalGiantUnits, + MovingSlotData.rootData_regularSlots, MovingSlotData.rootData_frequencyProduct] + +theorem movingLocalExtra_guarded {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) : + movingLocalExtra (movingGuardedExtra value outside (movingLocalExtra E)) = + movingGuardedExtra value outside (movingLocalExtra E) := by + funext x s v w + simp only [movingLocalExtra, movingGuardedExtra, movingLocalSupport_rootData, + MovingSlotData.rootData_idempotent] + +/-- The sample expansion of the fully supported original coefficient. Every +sample retains its original weight, including samples whose support fails. -/ +theorem movingSampledWeight_supported {σ : Type*} [Fintype σ] (value : σ → ℕ) + (outside : List ℕ) (μ : ℕ → σ → ℝ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (XL XR : ℕ) : + movingSampledWeight value μ childBound pivotBound (movingGuardedLeaf value outside F) + (movingGuardedExtra value outside (movingLocalExtra E)) n t small bulk XL XR = + ∑ a : MovingSampleSlots σ n, (movingSamplesPrior μ a : ℂ) * + movingSupportedWeight value outside (buildMovingSlotData n t small bulk a) XL XR + (recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingLocalExtra E)) n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ t) := by + unfold movingSampledWeight + rw [movingLocalExtra_guarded] + apply Finset.sum_congr rfl + intro a _ + rw [movingSupportedWeight_recursive value outside childBound pivotBound F (movingLocalExtra E) + _ t (buildMovingSlotData_follows n t small bulk a)] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveTemplateCaps.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveTemplateCaps.lean new file mode 100644 index 0000000000000000000000000000000000000000..c57e4b215bc3afe376f5719732f1027342669611 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRecursiveTemplateCaps.lean @@ -0,0 +1,96 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRecursiveProductBounds +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateIntegerNode + +namespace OAI + +/-! # Derived product caps for every restored moving template -/ +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingCellPivotExponent (G c : ℕ → ℝ) (n : ℕ) : ℝ := + G (n + 1) - 1 + ((2 ^ n * 4 : ℕ) : ℝ) * (c n - 1) + +/-- Every compensation prior is the original prior. Only its actual nonzero +support is used in the lower bound; no renormalization is performed. -/ +theorem movingFrequencyCoefficient_recursive_cell_cap {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi W : ℝ) (hX : 0 < X) + (hwindow : X * hi ≤ Real.exp W) + (φ : ℝ → ℝ) (G c : ℕ → ℝ) (hout : ∀ t, 1 ≤ |t| → φ t = 0) + (hμ : ∀ j x, μ j x ≠ 0 → Real.exp (c j - 1) ≤ (value x : ℝ)) + (n : ℕ) (a : TreeLeafTuple (Fin 4 → σ) n) + (ha : movingCompensationPrior (μ n) n a ≠ 0) + (s : ℤ) (small bulk : TreeLeafTuple (List σ) n) (p XR : ℕ) + (hpbound : Real.exp (G (n + 1) - 1) ≤ (p : ℝ)) + (h : movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n s + (appendMovingSlotLeaves n (movingCompensationSlots n a) small) bulk p XR ≠ 0) : + XR * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n small ++ flattenMovingSlots n bulk) ≤ + ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊ := by + let T := movingCellPivotExponent G c + have hmin (j : ℕ) (b : TreeLeafTuple (Fin 4 → σ) j) + (hb : movingCompensationPrior (μ j) j b ≠ 0) (p' : ℕ) (hp' : 0 < p') + (hφ' : φ (Real.log p' - G (j + 1)) ≠ 0) := + movingInsertedPivot_product_lower value (μ j) (c j) (G (j + 1)) φ + (hμ j) hout j b hb p' hp' hφ' + have hb := movingFrequencyCoefficient_recursive_product_bound value outside μ + childBound pivotBound V q F g Dq S ψ X lo hi W hX hwindow φ G T hmin n s + (appendMovingSlotLeaves n (movingCompensationSlots n a) small) bulk p XR h + rw [movingNaturalProduct_append_leaves] at hb + let U := MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingCompensationSlots n a)) + let R := XR * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n small ++ flattenMovingSlots n bulk) + have hid : p * XR * (U * MovingSlotReversal.naturalProduct value + (flattenMovingSlots n small ++ flattenMovingSlots n bulk)) = (p * U) * R := by + dsimp only [R]; ring + rw [hid, Nat.cast_mul] at hb + have hlow := movingCompensation_pivot_lower_of_bound value (μ n) (c n) (G (n + 1)) + (hμ n) n a ha p hpbound + have hreal : (R : ℝ) ≤ Real.exp (movingProductExponent T W n - T n) := by + rw [Real.exp_sub] + apply (le_div_iff₀ (Real.exp_pos _)).mpr + have hh := (mul_le_mul_of_nonneg_right hlow (Nat.cast_nonneg R)).trans hb + simpa only [T, movingCellPivotExponent, mul_comm] using hh + exact_mod_cast hreal.trans (Nat.le_ceil _) + +/-- The product bound required by the Cauchy--Schwarz transfer now follows at +any depth from the terminal cutoff and the selected compensation cells. -/ +theorem movingTemplateCoefficient_recursive_cell_cap {σ I : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi W : ℝ) (hX : 0 < X) + (hwindow : X * hi ≤ Real.exp W) + (φ : ℝ → ℝ) (G c : ℕ → ℝ) (hout : ∀ t, 1 ≤ |t| → φ t = 0) + (hμ : ∀ j x, μ j x ≠ 0 → Real.exp (c j - 1) ≤ (value x : ℝ)) + (n r m : ℕ) (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (s : ℤ) (y : MovingRegularSlot n r m → σ) (p XR : ℕ) + (hpbound : Real.exp (G (n + 1) - 1) ≤ (p : ℝ)) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q F g Dq S ψ X lo hi) φ G n (4 + r) m s + (movingRestoreSample n r m u y) p XR ≠ 0) : + XR * (∏ i, value (y i)) ≤ + ⌈Real.exp (movingProductExponent (movingCellPivotExponent G c) W n - + movingCellPivotExponent G c n)⌉₊ := by + let a := (movingTemplateCompensationEquiv σ n).symm u + have he : movingTemplateCompensationEquiv σ n a = u := Equiv.apply_symm_apply _ _ + have ha : movingCompensationPrior (μ n) n a ≠ 0 := by + rw [← movingTemplateCompensationEquiv_prior, he] + exact hu + rw [← he, movingTemplateCoefficient_restored] at h + have hc := movingFrequencyCoefficient_recursive_cell_cap value outside μ childBound pivotBound V + q F g Dq S ψ X lo hi W hX hwindow φ G c hout hμ n a ha s _ _ p XR hpbound h + rwa [movingTemplateMapped_product] at hc + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedCRT.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedCRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c044fde091a6cf65110e6f7a1de844f7516efec --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedCRT.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedOuterFactor +import OAI.NumberTheory.Ostmann.ZeroDensity.PageResidueReduction + +namespace OAI + +/-! # The original reduced arithmetic coefficient in the regular-prime CRT split -/ + +namespace Ostmann +open scoped BigOperators Classical ComplexConjugate + +theorem crtSplitExternalEquiv_snd (c r : ℕ) (hcop : c.Coprime r) + (z : ZMod (c * r) × (ZMod (c * r))ˣ) : + (crtSplitExternalEquiv c r hcop z).2 = externalResidueReduction (dvd_mul_left r c) z := by + have he (a : ZMod (c * r)) : (ZMod.chineseRemainder hcop a).2 = + ZMod.castHom (dvd_mul_left r c) (ZMod r) a := + RingHom.congr_fun (Subsingleton.elim + ((RingHom.snd (ZMod c) (ZMod r)).comp (ZMod.chineseRemainder hcop).toRingHom) + (ZMod.castHom (dvd_mul_left r c) (ZMod r))) a + apply Prod.ext + · exact he z.1 + · apply Units.ext + exact he (z.2 : ZMod (c * r)) + +theorem movingReducedPairResidueCoefficient_modEq {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (a b c d : ℕ) + (hL : (a : ℤ) ≡ (c : ℤ) [ZMOD movingReducedPairModulus value hvalue outside childBound pivotBound T hf q S]) + (hR : (b : ℤ) ≡ (d : ℤ) [ZMOD movingReducedPairModulus value hvalue outside childBound pivotBound T hf q S]) : + let nodes := fun b => (T b).formulaNodes value hvalue childBound pivotBound (hf b) (.prime false) (.prime true) + movingReducedPairResidueCoefficient q value outside F E g Dq S T nodes a b = + movingReducedPairResidueCoefficient q value outside F E g Dq S T nodes c d := by + dsimp only + have ht := movingReducedPairModulus_tests value hvalue outside childBound pivotBound T hf q S + have he (side : Bool) := movingReducedResidueWeight_modEq value hvalue outside (T side) (hf side) + a b c d _ _ _ (ht.2.2.1 side) (ht.2.2.2 side) hL hR + (movingResidueCoefficient_modEq q value hvalue childBound pivotBound (F side) (E side) + g (Dq side) S (T side) (hf side) a b c d _ (ht.1 side) (ht.2.1 side) hL hR) + exact congrArg₂ (fun x y : ℂ => x * conj y) (he false) (he true) + +/-- A periodic natural-coordinate coefficient descends to the second CRT +coordinate without changing its signed value. -/ +theorem periodic_coefficient_crt (C : ℕ → ℕ → ℂ) (c r : ℕ) [NeZero r] [NeZero (c * r)] + (hcop : c.Coprime r) + (hC : ∀ a b d e, Nat.ModEq r a d → Nat.ModEq r b e → C a b = C d e) + (z : ZMod (c * r) × (ZMod (c * r))ˣ) : + C z.1.val (z.2 : ZMod (c * r)).val = + C (crtSplitExternalEquiv c r hcop z).2.1.val + ((crtSplitExternalEquiv c r hcop z).2.2 : ZMod r).val := by + rw [crtSplitExternalEquiv_snd] + apply hC + · exact nat_modEq_castHom_val (dvd_mul_left r c) z.1 + · exact nat_modEq_castHom_val (dvd_mul_left r c) (z.2 : ZMod (c * r)) + +/-- Both factors are evaluated at their original natural residue representatives. +Only periodicity and the proved local transform energy are used in the split. -/ +theorem periodic_coefficient_regular_average {I : Type*} [Fintype I] [DecidableEq I] + (p : I → ℕ) [∀ i, Fact (p i).Prime] [∀ i, NeZero (p i)] [NeZero (∏ i, p i)] + (hc : Pairwise (fun i j => (p i).Coprime (p j))) + (r : ℕ) [NeZero r] [NeZero ((∏ i, p i) * r)] (hcop : (∏ i, p i).Coprime r) + (active : I → Bool) (s : ℤ) (other : ∀ i, ZMod (p i)) + (hs : ∀ i, (s : ZMod (p i)) ≠ 0) (ho : ∀ i, other i ≠ 0) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i, g i 0 = 0) + (henergy : ∀ i, (∑ x : ZMod (p i), ‖g i x‖ ^ 2) = p i) + (C : ℕ → ℕ → ℂ) + (hC : ∀ a b d e, Nat.ModEq r a d → Nat.ModEq r b e → C a b = C d e) : + (Fintype.card (ZMod ((∏ i, p i) * r) × (ZMod ((∏ i, p i) * r))ˣ) : ℂ)⁻¹ * + (∑ z : ZMod ((∏ i, p i) * r) × (ZMod ((∏ i, p i) * r))ˣ, (guardedRegularMultiplier p active s other g z.1.val + (z.2 : ZMod ((∏ i, p i) * r)).val : ℂ) * C z.1.val (z.2 : ZMod ((∏ i, p i) * r)).val) = + ((∏ i, if active i then (1 : ℝ) else 1 - (p i : ℝ)⁻¹ : ℝ) : ℂ) * + ((Fintype.card (ZMod r × (ZMod r)ˣ) : ℂ)⁻¹ * ∑ z : ZMod r × (ZMod r)ˣ, C z.1.val (z.2 : ZMod r).val) := by + simp_rw [periodic_coefficient_crt C (∏ i, p i) r hcop hC] + exact guardedRegularMultiplier_average p hc r hcop active s other hs ho g hg henergy + (fun z => C z.1.val (z.2 : ZMod r).val) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedCoefficient.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..258ae0bd0d393b09fb10ae16d47b1f510b6f7306 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedCoefficient.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedWeight + +namespace OAI + +/-! # Periodicity of the remaining arithmetic and spectator coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingResidueGate_modEq (nodes : List MovingFormulaNode) (x y : Bool → ℤ) (M : ℕ) + (hM : movingArithmeticPeriod nodes ∣ M) (hxy : ∀ i, x i ≡ y i [ZMOD M]) : + movingResidueGate nodes x ↔ movingResidueGate nodes y := by + apply forall₂_congr + intro f hf + apply and_congr_left + intro _ + exact f.residueTests_modEq x y (fun i => (hxy i).of_dvd + (by exact_mod_cast (movingArithmeticPeriod_dvd nodes f hf).trans hM)) + +theorem movingResidueCoefficient_modEq {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (a b c d M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hL : (a : ℤ) ≡ (c : ℤ) [ZMOD M]) (hR : (b : ℤ) ≡ (d : ℤ) [ZMOD M]) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + movingResidueCoefficient q value F E g D S T nodes a b = + movingResidueCoefficient q value F E g D S T nodes c d := by + dsimp only + have hgates := movingResidueGate_modEq _ (topGiantInput a b) (topGiantInput c d) M hM + (by intro i; cases i; exact hL; exact hR) + have hs : movingSpectatorResidue q value g D S T a b = movingSpectatorResidue q value g D S T c d := by + apply Finset.prod_congr rfl + intro i hi + exact movingSignedSpectator_modEq value hvalue (g i) (D i) T hf a b c d + (hL.of_dvd (hMq i hi)) (hR.of_dvd (hMq i hi)) + simp only [movingResidueCoefficient, movingResidueFlag, hgates, hs] + +theorem movingReducedResidueWeight_modEq {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (a b c d : ℤ) (M : ℤ) (z w : ℂ) + (hunit : movingAuxiliaryUnitPeriod value outside T ∣ M) + (hsquare : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hL : a ≡ c [ZMOD M]) (hR : b ≡ d [ZMOD M]) (hz : z = w) : + movingReducedResidueWeight value outside T a b z = movingReducedResidueWeight value outside T c d w := by + simp only [movingReducedResidueWeight, hz, + movingReducedResidueSupport_modEq value hvalue outside T hf a b c d M hunit hsquare hL hR] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedDiagonalComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedDiagonalComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..9685c1e71b84af5fe4520ba7e883595de78ad4e1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedDiagonalComparison.lean @@ -0,0 +1,114 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedOuterComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedPageAverage + +namespace OAI + +/-! # Original diagonal giant comparison after integrating the regular primes -/ + +namespace Ostmann +universe u v w +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_original_reduced_diagonal_haar_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (I : Type v) (J : Type w) [Fintype J] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + ∀ hqeq : q = (∏ i, reg i) * movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p S, + (∀ b, movingRegularOutsidePairwise value outside (T b)) → + Pairwise (fun i j => (reg i).Coprime (reg j)) → + (∀ i ∈ S, (∏ j, reg j).Coprime (p i)) → + pageAtModulus q (selectedPageZero P Q) = + pageAtModulus (movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p S) (selectedPageZero P Q) → + (∀ i, (sreg : ZMod (reg i)) ≠ 0) → (∀ i, other i ≠ 0) → + (∀ i, greg i 0 = 0) → (∀ i, (∑ x : ZMod (reg i), ‖greg i x‖ ^ 2) = reg i) → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c0 := movingReducedPairResidueCoefficient p value outside F E g Dq S T nodes + let c := fun a b => movingReducedPairResidueCoefficient p value outside F E g Dq S T nodes a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + letI : NeZero (movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p S) := ⟨by + intro hz + rw [hz, mul_zero] at hqeq + omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * (((∏ i, if active i then (1 : ℝ) else 1 - (reg i : ℝ)⁻¹ : ℝ) : ℂ) * + correctedMixedPairAverage P Q (movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p S) c0 y) / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_original_reduced_regular_mixed_haar_rate n C d] with L hL + intro σ I J _ p _ + have hL := hL σ I J p + intro tier value hprime hdisjoint outside childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod + F E g hg Dq S reg instReg hregular active sreg other greg ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q hQ hq hqQ hqeq houtside hreg hqs hpage hsreg hother hgreg henergy hlog + u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog + dsimp only + intro A hA0 hA hbudget + let hv := fun i => (hprime i).ne_zero + let R := movingReducedPairModulus value hv outside childBound pivotBound T hf p S + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c0 := movingReducedPairResidueCoefficient p value outside F E g Dq S T nodes + let c := fun a b => c0 a b * (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + have : NeZero q := ⟨by omega⟩ + have : NeZero R := ⟨by + intro hz + have hzq : q = 0 := by rw [hqeq, show movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p S = R from rfl, hz, mul_zero] + omega⟩ + have : ∀ i, NeZero (reg i) := fun i => ⟨(Fact.out : (reg i).Prime).ne_zero⟩ + have : NeZero (∏ i, reg i) := ⟨Finset.prod_ne_zero_iff.mpr (fun i _ => (Fact.out : (reg i).Prime).ne_zero)⟩ + have : NeZero ((∏ i, reg i) * R) := ⟨mul_ne_zero (NeZero.ne _) (NeZero.ne _)⟩ + have hbase := hL tier value hprime hdisjoint outside childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod + F E g hg Dq S reg hregular active sreg other greg ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD + hφ hlip hout diagonal V hV Q q hQ hq hqQ hqeq hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog A hA0 hA hbudget + have hcrt (y : ℝ) : correctedMixedPairAverage P Q q c y = + ((∏ i, if active i then (1 : ℝ) else 1 - (reg i : ℝ)⁻¹ : ℝ) : ℂ) * + correctedMixedPairAverage P Q R c0 y := by + have hqR : q = (∏ i, reg i) * R := hqeq + have hpR : pageAtModulus ((∏ i, reg i) * R) (selectedPageZero P Q) = + pageAtModulus R (selectedPageZero P Q) := by simpa only [hqR] using hpage + have hh := movingReducedPair_regular_page_average P Q p tier value hprime hdisjoint outside + childBound pivotBound F E g Dq S T hf hlevels hsmall houtside reg hreg hregular hqs R rfl + hpR active sreg other hsreg hother greg hgreg henergy y + simpa only [← hqR] using hh + change ‖_ - (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * correctedMixedPairAverage P Q q c y / (y : ℂ))‖ ≤ _ at hbase + simp_rw [hcrt] at hbase + exact hbase + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedDiagonalRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedDiagonalRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b9d62f3b47f43dd2464a4773070128c8c240be3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedDiagonalRate.lean @@ -0,0 +1,125 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedDiagonalComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterVariationScale +import OAI.NumberTheory.Ostmann.Construction.RegularMultiplierNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantBounds + +namespace OAI + +/-! # Numerical giant comparison for the original diagonal -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_original_reduced_diagonal_prime_rate (P : PublishedProgressionInput) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (Afreq Wwin B D : ℝ) + (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) (hB : 0 ≤ B) (hD : 0 ≤ D) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (σ J : Type) [Fintype J] (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + 0 ≤ V → V ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + ∀ q : ℕ, ∀ hq : 1 ≤ q, q ≤ giantProgressionCutoff L → + ∀ hqeq : q = (∏ i, reg i) * movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p Finset.univ, + (∀ b, movingRegularOutsidePairwise value outside (T b)) → + Pairwise (fun i j => (reg i).Coprime (reg j)) → + (∀ i, (∏ j, reg j).Coprime (p i)) → + pageAtModulus q (selectedPageZero P (giantProgressionCutoff L)) = + pageAtModulus (movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p Finset.univ) (selectedPageZero P (giantProgressionCutoff L)) → + (∀ i, (sreg : ZMod (reg i)) ≠ 0) → (∀ i, other i ≠ 0) → + (∀ i, greg i 0 = 0) → (∀ i, (∑ x : ZMod (reg i), ‖greg i x‖ ^ 2) = reg i) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + (∀ b, ‖movingDataWeight (F b) (E b) (T b)‖ ≤ 1) → + (∀ i z, ‖g i z‖ ≤ p i) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c0 := movingReducedPairResidueCoefficient p value outside F E g Dq Finset.univ T nodes + letI : NeZero q := ⟨by omega⟩ + letI : NeZero (movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p Finset.univ) := ⟨by + intro hz + rw [hz, mul_zero] at hqeq + omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq Finset.univ ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * (((∏ i, if active i then (1 : ℝ) else 1 - (reg i : ℝ)⁻¹ : ℝ) : ℂ) * + correctedMixedPairAverage P (giantProgressionCutoff L) (movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p Finset.univ) c0 y) / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + obtain ⟨C, hC, hbudget⟩ := moving_outer_variation_scale ψ n r₀ k Afreq Wwin B D 1 + hAfreq hWwin (by norm_num) + filter_upwards [P.moving_original_reduced_diagonal_haar_rate n C 2, + eventually_ge_atTop (200 : ℝ)] with L hrate hL + dsimp only + intro σ J _ p _ tier value hprime hdisjoint outside childBound pivotBound T hf t hT + hlevels hcoh hc hsmall hfmod F E g hg Dq reg _ hregular active sreg other greg + X lo hi hlo hhi φ G Jleft Jright hφ hlip hout diagonal V hV hV0 hVA hwindow hpupper + q hq hqQ hqeq houtside hreg hqs hpage hsreg hother hgreg henergy + u v r s H hH huv hshort hvH hr hrs hrshort hweight hgnorm + let R := movingReducedPairModulus value (fun i => (hprime i).ne_zero) + outside childBound pivotBound T hf p Finset.univ + have hR : 0 < R := by + apply Nat.pos_of_ne_zero + intro hz + change q = (∏ i, reg i) * R at hqeq + rw [hz, mul_zero] at hqeq + omega + have hregq : (∏ i, reg i) ≤ q := by + change q = (∏ i, reg i) * R at hqeq + rw [hqeq] + exact Nat.le_mul_of_pos_right _ hR + have hqlog := giantProgressionCutoff_log_le (by omega : 0 < q) hqQ + have hregbound : (∏ i, (reg i : ℝ)) ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + rw [← Nat.cast_prod] + apply (Nat.cast_le.mpr hregq).trans + exact (Real.log_le_iff_le_exp (by exact_mod_cast (show 0 < q by omega))).mp hqlog + let amp := (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 * ∏ j, (reg j : ℝ) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hamp : amp ≤ 4 * (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 * + Real.exp (1 * L + 1 * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + have hL1 : 1 ≤ L := by linarith only [hL] + have hcoef : Real.exp ((12 / 1000 : ℝ) * L) ≤ + 1 * L + 1 * L * Real.exp ((12 / 1000 : ℝ) * L) := by + have hh := le_mul_of_one_le_left (Real.exp_nonneg ((12 / 1000 : ℝ) * L)) hL1 + linarith only [hh, hL1] + have hh := hregbound.trans (Real.exp_le_exp.mpr hcoef) + apply (mul_le_mul_of_nonneg_left hh (sq_nonneg _)).trans + nlinarith only [mul_nonneg (sq_nonneg (∏ i, (p i : ℝ) ^ (2 ^ n))) + (Real.exp_nonneg (1 * L + 1 * L * Real.exp ((12 / 1000 : ℝ) * L)))] + have hb := hbudget L (by linarith only [hL]) p V lo hi amp diagonal + hV0 hVA hhi hwindow hpupper hamp0 hamp + have hQ := giantProgressionCutoff_bounds L hL + apply hrate σ (Fin (spectatorBulkCount k L)) J p tier value hprime hdisjoint outside + childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod F E g hg Dq Finset.univ + reg hregular active sreg other greg ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD + hφ hlip hout diagonal V hV (giantProgressionCutoff L) q hQ.1 hq hqQ hqeq houtside + hreg (fun i _ => hqs i) hpage hsreg hother hgreg henergy hQ.2 + u v r s H hH huv hshort hvH hr hrs hrshort hqlog amp hamp0 _ hb + intro a ha b hb + exact movingReducedPair_with_regular_norm p reg value outside F E g hgnorm Dq T _ + hweight active sreg other greg henergy a b + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedModulus.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..1467d5187a0d4de498fa991aa6070e368dd0f021 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedModulus.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCoprimePeriods +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullModulus + +namespace OAI + +/-! # The common residue modulus after extracting the regular primes -/ + +namespace Ostmann +open scoped BigOperators Classical + +noncomputable def movingReducedPairModulusBase {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) : ℕ := + ∏ b : Bool, movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S * + (movingAuxiliaryUnitPeriod value outside (T b)).natAbs + +noncomputable def movingReducedPairModulus {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) : ℕ := + (movingReducedPairModulusBase value hvalue outside childBound pivotBound T hf q S) ^ 2 + +theorem movingReducedPairModulus_components {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (b : Bool) : + movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S ∣ + movingReducedPairModulusBase value hvalue outside childBound pivotBound T hf q S ∧ + (movingAuxiliaryUnitPeriod value outside (T b)).natAbs ∣ + movingReducedPairModulusBase value hvalue outside childBound pivotBound T hf q S := by + have h := Finset.dvd_prod_of_mem + (fun b => movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S * + (movingAuxiliaryUnitPeriod value outside (T b)).natAbs) (Finset.mem_univ b) + exact ⟨(dvd_mul_right _ _).trans h, (dvd_mul_left _ _).trans h⟩ + +theorem movingReducedPairModulus_pos {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (hout : outside.prod ≠ 0) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (hq : ∀ i ∈ S, 0 < q i) : + 0 < movingReducedPairModulus value hvalue outside childBound pivotBound T hf q S := by + apply pow_pos + apply Finset.prod_pos + intro b _ + exact Nat.mul_pos (movingSpectatorModulus_pos value hvalue childBound pivotBound (T b) (hf b) q S hq) + (Int.natAbs_pos.mpr ((ne_zero_of_dvd_ne_zero (movingGiantUnitPeriod_ne_zero value hvalue outside hout (T b) (hf b)) (movingAuxiliaryUnitPeriod_dvd_full value outside (T b))))) + +/-- The one common modulus supplies all four divisibility conditions used in +exact two-history factorization, including every compensation-prime square. -/ +theorem movingReducedPairModulus_tests {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) : + let M := movingReducedPairModulus value hvalue outside childBound pivotBound T hf q S + (∀ b, movingTopPeriod value hvalue childBound pivotBound (T b) (hf b) ∣ M) ∧ + (∀ b, ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value (T b) ∣ (M : ℤ)) ∧ + (∀ b, movingAuxiliaryUnitPeriod value outside (T b) ∣ (M : ℤ)) ∧ + (∀ b, ∀ o ∈ (T b).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ (M : ℤ)) := by + let N := movingReducedPairModulusBase value hvalue outside childBound pivotBound T hf q S + have hN : N ∣ N ^ 2 := ⟨N, pow_two N⟩ + have hc := movingReducedPairModulus_components value hvalue outside childBound pivotBound T hf q S + have hs (b : Bool) : movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S ∣ N ^ 2 := + (hc b).1.trans hN + refine ⟨fun b => (movingTopPeriod_dvd_spectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S).trans (hs b), + fun b i hi => ?_, fun b => ?_, fun b o ho i hi => ?_⟩ + · exact (spectator_dvd_movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S i hi).trans + (by exact_mod_cast hs b) + · exact (Int.dvd_natAbs.mpr (dvd_refl (movingAuxiliaryUnitPeriod value outside (T b)))).trans + (by exact_mod_cast (hc b).2.trans hN) + · have hd : value i ∣ (movingSpectatorDenominator value (T b)).natAbs := by + exact_mod_cast Int.dvd_natAbs.mpr ((T b).compensation_dvd_spectatorDenominator value o ho i hi) + have hds : (movingSpectatorDenominator value (T b)).natAbs ∣ + movingSpectatorModulus value hvalue childBound pivotBound (T b) (hf b) q S := by + refine ⟨movingTopPeriod value hvalue childBound pivotBound (T b) (hf b) * ∏ j ∈ S, q j, ?_⟩ + simp only [movingSpectatorModulus] + ring + have hpow := pow_dvd_pow_of_dvd (hd.trans (hds.trans (hc b).1)) 2 + exact_mod_cast hpow + +/-- The reduced modulus introduces no new size cost. -/ +theorem movingReducedPairModulus_dvd_full {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) : + movingReducedPairModulus value hvalue outside childBound pivotBound T hf q S ∣ + movingFullPairModulus value hvalue outside childBound pivotBound T hf q S := by + apply pow_dvd_pow_of_dvd + apply Finset.prod_dvd_prod_of_dvd + intro b _ + exact Nat.mul_dvd_mul_left _ (Int.natAbs_dvd_natAbs.mpr + (movingAuxiliaryUnitPeriod_dvd_full value outside (T b))) + +/-- The auxiliary period and the node frequencies suffice to split off any +regular block coprime to the fixed spectator primes. -/ +theorem movingReducedPairModulus_coprime {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (r : ℕ) + (hfreq : ∀ b, (T b).Frequencies (fun s => r.Coprime s.natAbs)) + (haux : ∀ b, r.Coprime (movingAuxiliaryUnitPeriod value outside (T b)).natAbs) + (hq : ∀ i ∈ S, r.Coprime (q i)) : + r.Coprime (movingReducedPairModulus value hvalue outside childBound pivotBound T hf q S) := by + apply Nat.Coprime.pow_right + apply Nat.coprime_prod_right_iff.mpr + intro b _ + have ht := movingTopPeriod_coprime_of_auxiliary value hvalue outside childBound pivotBound + (T b) (hf b) r (hfreq b) (haux b) + have hd := (haux b).of_dvd_right (Int.natAbs_dvd_natAbs.mpr + (movingSpectatorDenominator_dvd_auxiliary value outside (T b))) + exact (((ht.mul_right hd).mul_right (Nat.coprime_prod_right_iff.mpr hq)).mul_right (haux b)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedModulusFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedModulusFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..afd484dc81f66d3a8c53d091bb862eac056f97fb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedModulusFactor.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedCRT + +namespace OAI + +/-! # The extracted original coefficient at any common regular/auxiliary modulus -/ + +namespace Ostmann +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +theorem movingOriginalSupportedReducedRegular_modulus_factor {σ I J : Type*} [Fintype J] (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (hT : ∀ b, (T b).Follows (t b)) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hlevels : ∀ b, (T b).Levels tier) (hcoh : ∀ b, (T b).RegularCoherent) + (hc : ∀ b, (T b).CompensationPrimeData value) + (hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (s : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (M : ℕ) + (hM : movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside + childBound pivotBound T hf q S ∣ M) + (hregM : ∀ i, reg i ∣ M) (XL XR : ℕ) : + let hv := fun i => (hprime i).ne_zero + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingReducedPairResidueCoefficient q value outside F E g Dq S T nodes a b * + (guardedRegularMultiplier reg active s other greg a b : ℂ) + movingOriginalSupportedOuterPair q value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t XL XR * + (naturalRegularMultiplier reg active s other greg XL XR : ℂ) = + if XL.Coprime XR then + c (XL % M) (XR % M) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal XL XR else 0 := by + dsimp only + let hv := fun i => (hprime i).ne_zero + let R := movingReducedPairModulus value hv outside childBound pivotBound T hf q S + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let C := movingReducedPairResidueCoefficient q value outside F E g Dq S T nodes + have he := movingOriginalSupportedReducedRegular_factor q tier value hprime hdisjoint outside + childBound pivotBound F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD + hφ hlip hout diagonal T t hT hf hlevels hcoh hc hsmall hfmod reg hregular active s other greg XL XR + dsimp only at he + have hcoef : C (XL % R) (XR % R) = C (XL % M) (XR % M) := by + apply movingReducedPairResidueCoefficient_modEq q value hv outside childBound pivotBound F E g Dq S T hf + · exact Int.natCast_modEq_iff.mpr ((Nat.mod_modEq XL R).trans + (((Nat.mod_modEq XL M).of_dvd hM).symm)) + · exact Int.natCast_modEq_iff.mpr ((Nat.mod_modEq XR R).trans + (((Nat.mod_modEq XR M).of_dvd hM).symm)) + have hgmod := guardedRegularMultiplier_modEq reg active s other greg XL XR (XL % M) (XR % M) M + hregM (Nat.mod_modEq XL M).symm (Nat.mod_modEq XR M).symm + change _ = if XL.Coprime XR then (C (XL % M) (XR % M) * + (guardedRegularMultiplier reg active s other greg (XL % M) (XR % M) : ℂ)) * _ else 0 + change _ = if XL.Coprime XR then (C (XL % R) (XR % R) * + (guardedRegularMultiplier reg active s other greg XL XR : ℂ)) * _ else 0 at he + rw [hcoef, hgmod] at he + exact he + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..6215b62a71eb418293e6004706e222095a820cde --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedNorm.lean @@ -0,0 +1,38 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedOuterFactor + +namespace OAI + +/-! # A concrete pointwise budget for the extracted original coefficient -/ + +namespace Ostmann +open scoped BigOperators Classical + +theorem movingReducedResidueWeight_norm {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (a b : ℤ) (z : ℂ) : + ‖movingReducedResidueWeight value outside T a b z‖ ≤ ‖z‖ := by + unfold movingReducedResidueWeight + split_ifs <;> simp + +theorem movingReducedPairResidueCoefficient_norm {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (B : I → ℝ) (hB : ∀ i ∈ S, 0 ≤ B i) (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) (a b : ℕ) : + ‖movingReducedPairResidueCoefficient q value outside F E g Dq S T nodes a b‖ ≤ + (‖movingDataWeight (F false) (E false) (T false)‖ * ∏ i ∈ S, B i ^ (2 ^ n)) * + (‖movingDataWeight (F true) (E true) (T true)‖ * ∏ i ∈ S, B i ^ (2 ^ n)) := by + unfold movingReducedPairResidueCoefficient + rw [norm_mul, Complex.norm_conj] + apply mul_le_mul + · exact (movingReducedResidueWeight_norm value outside _ a b _).trans + (movingResidueCoefficient_norm q value _ _ g _ S B hB hg _ _ a b) + · exact (movingReducedResidueWeight_norm value outside _ a b _).trans + (movingResidueCoefficient_norm q value _ _ g _ S B hB hg _ _ a b) + · exact norm_nonneg _ + · exact mul_nonneg (norm_nonneg _) (Finset.prod_nonneg (fun i hi => pow_nonneg (hB i hi) _)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedOuterComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedOuterComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..38578adf3d089d3e4420ae74a5c55e9cf2546561 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedOuterComparison.lean @@ -0,0 +1,167 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedModulusFactor +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterCoprimeComparison + +namespace OAI + +/-! # The original-prior Haar comparison at the split regular/auxiliary modulus -/ + +namespace Ostmann +universe u v w +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_original_reduced_regular_prime_haar_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (I : Type v) (J : Type w) [Fintype J] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + q = (∏ i, reg i) * movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p S → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingReducedPairResidueCoefficient p value outside F E g Dq S T nodes a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_outer_coprime_prime_haar_rate n C d] with L hL + intro σ I J _ p _ + have hL := hL σ + intro tier value hprime hdisjoint outside childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod + F E g hg Dq S reg instReg hregular active sreg other greg ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q hQ hq hqQ hqeq hlog u v r s hu huv hshort hr hrs hrshort hqlog + dsimp only + intro A hA0 hA hbudget + let hv := fun i => (hprime i).ne_zero + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingReducedPairResidueCoefficient p value outside F E g Dq S T nodes a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + have h := hL value hv childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c A hA0 hA hbudget + dsimp only at h + have hfactor (x y : ℕ) : + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t x y * + (naturalRegularMultiplier reg active sreg other greg x y : ℂ) = + if x.Coprime y then c (x % q) (y % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal x y else 0 := by + have hregM : ∀ i, reg i ∣ q := by + intro i + rw [hqeq] + exact dvd_mul_of_dvd_left (Finset.dvd_prod_of_mem reg (Finset.mem_univ i)) _ + exact movingOriginalSupportedReducedRegular_modulus_factor p tier value hprime hdisjoint outside + childBound pivotBound F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD + hφ hlip hout diagonal T t hT hf hlevels hcoh hc hsmall hfmod reg hregular active sreg other greg + q (by rw [hqeq]; exact dvd_mul_left _ _) hregM x y + simpa only [hfactor] using h + +theorem PublishedProgressionInput.moving_original_reduced_regular_mixed_haar_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (I : Type v) (J : Type w) [Fintype J] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + q = (∏ i, reg i) * movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p S → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingReducedPairResidueCoefficient p value outside F E g Dq S T nodes a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * correctedMixedPairAverage P Q q c y / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_outer_coprime_mixed_haar_rate n C d] with L hL + intro σ I J _ p _ + have hL := hL σ + intro tier value hprime hdisjoint outside childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod + F E g hg Dq S reg instReg hregular active sreg other greg ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q hQ hq hqQ hqeq hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog + dsimp only + intro A hA0 hA hbudget + let hv := fun i => (hprime i).ne_zero + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingReducedPairResidueCoefficient p value outside F E g Dq S T nodes a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + have h := hL value hv childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog c A hA0 hA hbudget + dsimp only at h + have hfactor (x y : ℕ) : + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t x y * + (naturalRegularMultiplier reg active sreg other greg x y : ℂ) = + if x.Coprime y then c (x % q) (y % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal x y else 0 := by + have hregM : ∀ i, reg i ∣ q := by + intro i + rw [hqeq] + exact dvd_mul_of_dvd_left (Finset.dvd_prod_of_mem reg (Finset.mem_univ i)) _ + exact movingOriginalSupportedReducedRegular_modulus_factor p tier value hprime hdisjoint outside + childBound pivotBound F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD + hφ hlip hout diagonal T t hT hf hlevels hcoh hc hsmall hfmod reg hregular active sreg other greg + q (by rw [hqeq]; exact dvd_mul_left _ _) hregM x y + simpa only [hfactor] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedOuterFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedOuterFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..d75c4d44cf90d3c35ba0b5ccb9dda18584cad92e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedOuterFactor.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedPair +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedModulus +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedOuterFactor +import OAI.NumberTheory.Ostmann.Arithmetic.GuardedRegularCRT + +namespace OAI + +/-! # Original outer priors with the regular block removed from the residue coefficient -/ + +namespace Ostmann +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +noncomputable def movingReducedPairResidueCoefficient {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (a b : ℕ) : ℂ := + movingReducedResidueWeight value outside (T false) a b + (movingResidueCoefficient q value (F false) (E false) g (Dq false) S (T false) (nodes false) a b) * + conj (movingReducedResidueWeight value outside (T true) a b + (movingResidueCoefficient q value (F true) (E true) g (Dq true) S (T true) (nodes true) a b)) + +theorem movingOriginalSupportedOuterPair_reduced_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (hT : ∀ b, (T b).Follows (t b)) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hlevels : ∀ b, (T b).Levels tier) (hcoh : ∀ b, (T b).RegularCoherent) + (hc : ∀ b, (T b).CompensationPrimeData value) + (hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (R : ℕ) (hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = R) + (XL XR : ℕ) : + let hv := fun i => (hprime i).ne_zero + let M := movingReducedPairModulus value hv outside childBound pivotBound T hf q S + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := movingReducedPairResidueCoefficient q value outside F E g Dq S T nodes + movingOriginalSupportedOuterPair q value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t XL XR = + if XL.Coprime XR ∧ XL.Coprime R ∧ XR.Coprime R then c (XL % M) (XR % M) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal XL XR else 0 := by + dsimp only + let hv := fun i => (hprime i).ne_zero + let M := movingReducedPairModulus value hv outside childBound pivotBound T hf q S + have ht := movingReducedPairModulus_tests value hv outside childBound pivotBound T hf q S + have h := movingOriginalGiantWeight_reduced_pair_factor q tier value hprime hdisjoint outside childBound pivotBound + F E g hg Dq S ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout T t hT hf hlevels hcoh hc hsmall hfmod + R hregular XL XR (XL % M) (XR % M) M ht.1 ht.2.1 ht.2.2.1 ht.2.2.2 + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XL M).symm) + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XR M).symm) + dsimp only [movingOriginalSupportedOuterPair] + rw [h] + by_cases hp : XL.Coprime XR ∧ XL.Coprime R ∧ XR.Coprime R + · rw [ite_eq_left hp, ite_eq_left hp] + exact mul_assoc _ _ _ + · rw [ite_eq_right hp, ite_eq_right hp, zero_mul] + +theorem movingOriginalSupportedReducedRegular_factor {σ I J : Type*} [Fintype J] (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (hT : ∀ b, (T b).Follows (t b)) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hlevels : ∀ b, (T b).Levels tier) (hcoh : ∀ b, (T b).RegularCoherent) + (hc : ∀ b, (T b).CompensationPrimeData value) + (hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (s : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (XL XR : ℕ) : + let hv := fun i => (hprime i).ne_zero + let M := movingReducedPairModulus value hv outside childBound pivotBound T hf q S + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := movingReducedPairResidueCoefficient q value outside F E g Dq S T nodes + movingOriginalSupportedOuterPair q value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t XL XR * + (naturalRegularMultiplier reg active s other greg XL XR : ℂ) = + if XL.Coprime XR then + (c (XL % M) (XR % M) * (guardedRegularMultiplier reg active s other greg XL XR : ℂ)) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal XL XR else 0 := by + dsimp only + apply multiply_regular_after_support reg active s other greg XL XR + exact movingOriginalSupportedOuterPair_reduced_factor q tier value hprime hdisjoint outside childBound pivotBound + F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal + T t hT hf hlevels hcoh hc hsmall hfmod (∏ i, reg i) hregular XL XR + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedPageAverage.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedPageAverage.lean new file mode 100644 index 0000000000000000000000000000000000000000..d6b3f31c5d8540bc89396d4ff8c3aca944f57c74 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedPageAverage.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.Ostmann.ZeroDensity.PageRegularAverage +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularCoprime + +namespace OAI + +/-! # The Page-weighted regular average of the actual two-history coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- All non-Page hypotheses here are the actual small-slot and tree data. The +periodicity and regular-block coprimality are derived from those data. -/ +theorem movingReducedPair_regular_page_average {σ I J : Type*} [Fintype J] [DecidableEq J] + (P : PublishedProgressionInput) (N : ℕ) (q : I → ℕ) [∀ i, Fact (q i).Prime] + (tier : σ → ℕ) (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hlevels : ∀ b, (T b).Levels tier) + (hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hout : ∀ b, movingRegularOutsidePairwise value outside (T b)) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] [∀ i, NeZero (reg i)] [NeZero (∏ i, reg i)] + (hreg : Pairwise (fun i j => (reg i).Coprime (reg j))) + (hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (hq : ∀ i ∈ S, (∏ j, reg j).Coprime (q i)) + (r : ℕ) [NeZero r] [NeZero ((∏ i, reg i) * r)] + (hr : r = movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside + childBound pivotBound T hf q S) + (hpage : pageAtModulus ((∏ i, reg i) * r) (selectedPageZero P N) = + pageAtModulus r (selectedPageZero P N)) + (active : J → Bool) (s : ℤ) (other : ∀ i, ZMod (reg i)) + (hs : ∀ i, (s : ZMod (reg i)) ≠ 0) (ho : ∀ i, other i ≠ 0) + (greg : ∀ i, ZMod (reg i) → ℂ) (hg : ∀ i, greg i 0 = 0) + (henergy : ∀ i, (∑ x : ZMod (reg i), ‖greg i x‖ ^ 2) = reg i) (y : ℝ) : + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) + childBound pivotBound (hf b) (.prime false) (.prime true) + let C := movingReducedPairResidueCoefficient q value outside F E g Dq S T nodes + correctedMixedPairAverage P N ((∏ i, reg i) * r) + (fun a b => C a b * (guardedRegularMultiplier reg active s other greg a b : ℂ)) y = + ((∏ i, if active i then (1 : ℝ) else 1 - (reg i : ℝ)⁻¹ : ℝ) : ℂ) * + correctedMixedPairAverage P N r C y := by + dsimp only + have hcop : (∏ i, reg i).Coprime r := by + rw [hr] + exact movingOriginalRegular_coprime_reduced tier value hprime hdisjoint outside childBound + pivotBound T hf hlevels hsmall hout (∏ i, reg i) hregular q S hq + apply periodic_coefficient_regular_page_average P N reg hreg r hcop hpage + active s other hs ho greg hg henergy + intro a b c d hab hcd + apply movingReducedPairResidueCoefficient_modEq q value (fun i => (hprime i).ne_zero) + outside childBound pivotBound F E g Dq S T hf a b c d + · rw [← hr] + exact Int.natCast_modEq_iff.mpr hab + · rw [← hr] + exact Int.natCast_modEq_iff.mpr hcd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedPair.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..2a77e54a12c8009c409df836faa4d57c6bf9299f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedPair.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPair + +namespace OAI + +/-! # The two original histories with a common regular-prime block extracted -/ + +namespace Ostmann +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +theorem movingOriginalGiantWeight_reduced_pair_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (hT : ∀ b, (T b).Follows (t b)) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hlevels : ∀ b, (T b).Levels tier) (hcoh : ∀ b, (T b).RegularCoherent) + (hc : ∀ b, (T b).CompensationPrimeData value) + (hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (R : ℕ) (hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = R) + (XL XR a b M : ℕ) + (hM : ∀ b, movingTopPeriod value (fun i => (hprime i).ne_zero) childBound pivotBound (T b) (hf b) ∣ M) + (hMq : ∀ b, ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value (T b) ∣ (M : ℤ)) + (hunit : ∀ b, movingAuxiliaryUnitPeriod value outside (T b) ∣ (M : ℤ)) + (hsquare : ∀ b, ∀ o ∈ (T b).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ (M : ℤ)) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun side => movingReducedResidueWeight value outside (T side) a b + (movingResidueCoefficient q value (F side) (E side) g (Dq side) S (T side) (nodes side) a b) + movingSupportedWeight value outside (T false) XL XR + (movingOriginalGiantWeight q value childBound pivotBound (F false) (E false) g (Dq false) S + ψ X lo hi φ G (T false) (t false) XL XR) * + conj (movingSupportedWeight value outside (T true) XL XR + (movingOriginalGiantWeight q value childBound pivotBound (F true) (E true) g (Dq true) S + ψ X lo hi φ G (T true) (t true) XL XR)) = + if XL.Coprime XR ∧ XL.Coprime R ∧ XR.Coprime R then (c false * conj (c true)) * + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G XL XR else 0 := by + dsimp only + rw [movingOriginalGiantWeight_reduced_factor q tier value hprime hdisjoint outside childBound pivotBound + (F false) (E false) g hg (Dq false) S ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + (T false) (t false) (hT false) (hlevels false) (hcoh false) (hc false) (hf false) + (hsmall false) (hfmod false) XL XR a b M (hM false) (hMq false) (hunit false) (hsquare false) hL hR, + movingOriginalGiantWeight_reduced_factor q tier value hprime hdisjoint outside childBound pivotBound + (F true) (E true) g hg (Dq true) S ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + (T true) (t true) (hT true) (hlevels true) (hcoh true) (hc true) (hf true) + (hsmall true) (hfmod true) XL XR a b M (hM true) (hMq true) (hunit true) (hsquare true) hL hR] + simp only [hregular] + by_cases hp : XL.Coprime XR ∧ XL.Coprime R ∧ XR.Coprime R + · rw [ite_eq_left hp, ite_eq_left hp, ite_eq_left hp, map_mul, movingRealKernelPair] + ring + · rw [ite_eq_right hp, ite_eq_right hp, ite_eq_right hp, map_zero, mul_zero] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..c238a01f90147243edc168be9f697fa15529ab6f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedSupport.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAuxiliaryCoprime + +namespace OAI + +/-! # The recursive residue support after extracting the regular-prime units -/ + +namespace Ostmann +open scoped Classical + +noncomputable def movingReducedResidueSupport {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℤ) : Prop := + movingRegularOutsidePairwise value outside T ∧ movingSquareLineSupport value T XL XR ∧ + movingSignedAuxiliaryUnits value outside T XL XR + +theorem movingReducedResidueSupport_modEq {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (XL XR YL YR M : ℤ) + (hunit : movingAuxiliaryUnitPeriod value outside T ∣ M) + (hsquare : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hL : XL ≡ YL [ZMOD M]) (hR : XR ≡ YR [ZMOD M]) : + movingReducedResidueSupport value outside T XL XR ↔ + movingReducedResidueSupport value outside T YL YR := by + unfold movingReducedResidueSupport + rw [movingSquareLineSupport_modEq value T XL XR YL YR M hsquare hL hR, + movingSignedAuxiliaryUnits_modEq value hvalue outside T hf XL XR YL YR + (hL.of_dvd hunit) (hR.of_dvd hunit)] + +theorem movingFullSupport_reduced_iff {σ : Type*} (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hlevels : T.Levels tier) (hcoh : T.RegularCoherent) (hc : T.CompensationPrimeData value) + (hf : T.Frequencies (· ≠ 0)) + (hsmall : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (XL XR : ℕ) (hI : T.Integral value XL XR) : + movingFullSupport value outside T XL XR ↔ + XL.Coprime XR ∧ + XL.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) ∧ + XR.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) ∧ + movingReducedResidueSupport value outside T XL XR := by + rw [movingFullSupport_auxiliary_square_iff value outside T hcoh hc hsmall XL XR hI, + T.currentPairwise_iff value XL XR, + T.squareTests_iff_lines tier value hprime hdisjoint hlevels hfmod XL XR hI, + ← movingSignedAuxiliaryUnits_nat value (fun i => (hprime i).ne_zero) outside T hf XL XR hI] + have hstatic : movingRegularOutsidePairwise value outside T → + (T.regularSlots.map value).Pairwise Nat.Coprime := by + intro h + have hr : (T.regularSlots.map value ++ outside).Pairwise Nat.Coprime := by + cases T with + | leaf => exact h + | node => exact h.1 + exact (List.pairwise_append.mp hr).1 + simp only [movingReducedResidueSupport, movingSquareLineSupport, Int.cast_natCast] + tauto + +noncomputable def movingReducedResidueWeight {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (a b : ℤ) (z : ℂ) : ℂ := + if movingReducedResidueSupport value outside T a b then z else 0 + +theorem movingSupportedWeight_reduced_residue {σ : Type*} (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hlevels : T.Levels tier) (hcoh : T.RegularCoherent) (hc : T.CompensationPrimeData value) + (hf : T.Frequencies (· ≠ 0)) + (hsmall : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (XL XR a b : ℕ) (M : ℤ) (z : ℂ) (hI : z ≠ 0 → T.Integral value XL XR) + (hunit : movingAuxiliaryUnitPeriod value outside T ∣ M) + (hsquare : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + movingSupportedWeight value outside T XL XR z = + if XL.Coprime XR ∧ + XL.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) ∧ + XR.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) then + movingReducedResidueWeight value outside T a b z else 0 := by + by_cases hz : z = 0 + · simp [movingSupportedWeight, movingReducedResidueWeight, hz] + · have hs := movingFullSupport_reduced_iff tier value hprime hdisjoint outside T hlevels hcoh hc + hf hsmall hfmod XL XR (hI hz) + rw [movingReducedResidueSupport_modEq value (fun i => (hprime i).ne_zero) outside T hf + XL XR a b M hunit hsquare hL hR] at hs + unfold movingSupportedWeight movingReducedResidueWeight + rw [hs] + split_ifs <;> simp_all + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..829346b80434b592aae4e7a190f73648c2bab840 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingReducedWeight.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedSupport + +namespace OAI + +/-! # Exact original-weight factorization with the regular units extracted -/ + +namespace Ostmann +open scoped Classical SchwartzMap + +theorem movingOriginalGiantWeight_reduced_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hlevels : T.Levels tier) (hcoh : T.RegularCoherent) (hc : T.CompensationPrimeData value) + (hf : T.Frequencies (· ≠ 0)) + (hsmall : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (XL XR a b M : ℕ) + (hM : movingTopPeriod value (fun i => (hprime i).ne_zero) childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hunit : movingAuxiliaryUnitPeriod value outside T ∣ (M : ℤ)) + (hsquare : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ (M : ℤ)) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := T.formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound hf (.prime false) (.prime true) + movingSupportedWeight value outside T XL XR + (movingOriginalGiantWeight q value childBound pivotBound F E g Dq S ψ X lo hi φ G T t XL XR) = + if XL.Coprime XR ∧ + XL.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) ∧ + XR.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) then + movingReducedResidueWeight value outside T a b + (movingResidueCoefficient q value F E g Dq S T nodes a b) * + movingRealKernel value T nodes ψ X lo hi hlo hhi φ G XL XR else 0 := by + dsimp only + have hvalue : ∀ i, value i ≠ 0 := fun i => (hprime i).ne_zero + rw [movingSupportedWeight_reduced_residue tier value hprime hdisjoint outside T hlevels hcoh hc hf + hsmall hfmod XL XR a b M _ + (movingOriginalGiantWeight_integral q value hvalue childBound pivotBound F E g Dq S + ψ X lo hi φ G T t hT hf XL XR) hunit hsquare hL hR, + movingOriginalGiantWeight_factor q value hvalue childBound pivotBound F E g hg Dq S + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout T t hT hf XL XR a b M hM hMq hL hR] + split_ifs + · unfold movingReducedResidueWeight + split_ifs <;> simp + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularCollisionSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularCollisionSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ce988ac723c1baf8f9b791db7296049540b8532 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularCollisionSupport.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenFrequencyAverage +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedOuterFactor +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeObservable + +namespace OAI + +/-! # Invalid regular-prime configurations vanish before either average -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingSupportedWeight_zero_of_not_regular {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hbad : ¬ movingRegularOutsidePairwise value outside T) + (XL XR : ℕ) (z : ℂ) : movingSupportedWeight value outside T XL XR z = 0 := by + apply ite_eq_right + intro h + exact hbad (movingFullOutsidePairwise_regular value outside T XL XR h.1) + +theorem movingOriginalSupportedOuterPair_zero_of_not_regular {σ I : Type*} + (p : I → ℕ) [∀ i, Fact (p i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) {n : ℕ} (T : Bool → MovingSlotData σ n) + (t : Bool → FrequencyTree ℤ n) (hbad : ¬ ∀ b, movingRegularOutsidePairwise value outside (T b)) + (XL XR : ℕ) : + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi + φ G Jleft Jright diagonal T t XL XR = 0 := by + obtain ⟨b, hb⟩ := not_forall.mp hbad + have hz := movingSupportedWeight_zero_of_not_regular value outside (T b) hb XL XR + cases b <;> simp only [movingOriginalSupportedOuterPair, hz, map_zero, zero_mul, mul_zero] + +theorem movingFrequencyPageAverage_zero_of_not_regular {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (hbad : ¬ ∀ b, movingRegularOutsidePairwise value outside (T b)) : + movingFrequencyPageAverage value outside F E T nodes R r input Q y = 0 := by + rw [movingFrequencyPageAverage_core] + have hn : ¬ ∀ b, movingRegularOutsidePairwise value outside (T b) ∧ + (∀ f ∈ nodes b, f.guard.frequencyBounds) := fun h => hbad (fun b => (h b).1) + rw [ite_eq_right hn, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularCoprime.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularCoprime.lean new file mode 100644 index 0000000000000000000000000000000000000000..285e9e3a0d2f9d30b6656763cfe80678270886ca --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularCoprime.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedModulus + +namespace OAI + +/-! # The CRT split for the actual common regular slots -/ + +namespace Ostmann +open scoped Classical + +private theorem product_coprime_frequency {σ : Type*} (value : σ → ℕ) (L : List σ) (s : ℤ) + (h : ∀ i, IsCoprime s (value i : ℤ)) : + (MovingSlotReversal.naturalProduct value L).Coprime s.natAbs := by + apply Nat.coprime_list_prod_left_iff.mpr + intro a ha + obtain ⟨i, _, rfl⟩ := List.mem_map.mp ha + simpa only [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast] using (h i).symm + +theorem MovingSlotData.smallProduct_frequency_coprime {σ : Type*} (value : σ → ℕ) + (L : List σ) {n : ℕ} (T : MovingSlotData σ n) + (hf : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) : + T.Frequencies (fun s => (MovingSlotReversal.naturalProduct value L).Coprime s.natAbs) := by + induction T with + | leaf s regular => exact product_coprime_frequency value L s hf + | node s CL CR U left right ihL ihR => + exact ⟨product_coprime_frequency value L s (fun i => (hf i).1), + ihL (fun i => (hf i).2.1), ihR (fun i => (hf i).2.2)⟩ + +/-- For the two original histories, the computed reduced modulus is coprime +to their common regular-prime product. No extra coprimality of moduli is assumed. -/ +theorem movingOriginalRegular_coprime_reduced {σ I : Type*} (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hlevels : ∀ b, (T b).Levels tier) + (hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hout : ∀ b, movingRegularOutsidePairwise value outside (T b)) + (R : ℕ) (hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = R) + (q : I → ℕ) (S : Finset I) (hq : ∀ i ∈ S, R.Coprime (q i)) : + R.Coprime (movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside + childBound pivotBound T hf q S) := by + apply movingReducedPairModulus_coprime value (fun i => (hprime i).ne_zero) + outside childBound pivotBound T hf q S R _ _ hq + · intro b + have h := (T b).smallProduct_frequency_coprime value (T false).regularSlots (hsmall b) + simpa only [hregular false] using h + · intro b + have h := movingRegularProduct_coprime_auxiliary tier value hprime hdisjoint outside + (T b) (hlevels b) (hsmall b) (hout b) + simpa only [hregular b, Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..517140a2ccc70592362f47d420de8b2a2d77e3eb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularDiagonal.lean @@ -0,0 +1,101 @@ +import Mathlib.Data.Nat.PrimeFin +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularTransfer +import OAI.NumberTheory.Ostmann.Construction.PrimeProductMatching + +namespace OAI + +/-! # The common Fourier multiplier on equal-product diagonal fibres -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- The cofactor formula written in terms of the integer product, so that +the order of the current prime list is absent. -/ +noncomputable def primeProductTransform (g : ∀ p : ℕ, ZMod p → ℂ) + (D H : ℕ) (s : ℤ) : ℂ := + ∏ p ∈ H.primeFactors, g p ((s : ZMod p) * ((D * (H / p) : ℕ) : ZMod p)⁻¹) + +theorem primeTuple_image_factors {J : Type*} [Fintype J] + (p : J → ℕ) (hp : ∀ j, (p j).Prime) : + Finset.univ.image p = (∏ j, p j).primeFactors := by + ext q + rw [Nat.mem_primeFactors] + constructor + · intro hq + obtain ⟨j, _, rfl⟩ := Finset.mem_image.mp hq + exact ⟨hp j, Finset.dvd_prod_of_mem p (Finset.mem_univ j), + (Finset.prod_pos (fun j _ => (hp j).pos)).ne'⟩ + · rintro ⟨hq, hd, _⟩ + obtain ⟨j, rfl⟩ := prime_dvd_prime_product p hp q hq hd + exact Finset.mem_image.mpr ⟨j, Finset.mem_univ j, rfl⟩ + +/-- Every distinct-prime arrangement has exactly the same transform on a +fixed product/frequency fibre. This justifies extracting it before taking +the squared modulus of the sum over arrangements. -/ +theorem movingRegularTransform_eq_primeProduct {J : Type*} [Fintype J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] (hinj : Function.Injective p) + (g : ∀ q : ℕ, ZMod q → ℂ) (D : ℕ) (s : ℤ) : + movingRegularTransform p (fun j => g (p j)) D s = + primeProductTransform g D (∏ j, p j) s := by + have hc (j : J) : tupleCofactor p j = (∏ i, p i) / p j := by + rw [← tupleCofactor_mul p j] + exact (Nat.mul_div_cancel_left _ (Fact.out : (p j).Prime).pos).symm + unfold movingRegularTransform primeProductTransform + rw [← primeTuple_image_factors p (fun j => Fact.out), Finset.prod_image] + · exact Finset.prod_congr rfl (fun j _ => by rw [hc j]) + · intro i _ j _ hij + exact hinj hij + +theorem movingRegularTransform_order_independent {J K : Type*} [Fintype J] [Fintype K] + (p : J → ℕ) (q : K → ℕ) [∀ j, Fact (p j).Prime] [∀ k, Fact (q k).Prime] + (hp : Function.Injective p) (hq : Function.Injective q) + (hprod : (∏ j, p j) = ∏ k, q k) + (g : ∀ r : ℕ, ZMod r → ℂ) (D : ℕ) (s : ℤ) : + movingRegularTransform p (fun j => g (p j)) D s = + movingRegularTransform q (fun k => g (q k)) D s := by + rw [movingRegularTransform_eq_primeProduct p hp, + movingRegularTransform_eq_primeProduct q hq, hprod] + +/-- Grouping precedes the absolute value. The transform is constant on +each fibre, so its squared modulus is a nonnegative common multiplier. -/ +theorem diagonal_common_transform {A K : Type*} [Fintype A] [Fintype K] + (key : A → K) (W : A → ℂ) (G : K → ℂ) : + (∑ a, ∑ b, if key a = key b then + (W a * G (key a)) * conj (W b * G (key b)) else 0).re = + ∑ k, ‖G k‖ ^ 2 * ‖groupedCoefficient key W k‖ ^ 2 := by + rw [← diagonal_real_eq_sum_sq key W (fun k => ‖G k‖ ^ 2)] + congr 1 + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + by_cases h : key a = key b + · rw [ite_eq_left h, ite_eq_left h, ← h, map_mul] + have hn : G (key a) * conj (G (key a)) = (‖G (key a)‖ ^ 2 : ℝ) := by + rw [Complex.mul_conj'] + norm_cast + calc + _ = (G (key a) * conj (G (key a))) * W a * conj (W b) := by ring + _ = _ := by rw [hn]; rfl + · rw [ite_eq_right h, ite_eq_right h] + +/-- The giant factor can be discarded after fibre grouping. The remaining +regular multiplier is retained exactly as required in the diagonal norm. -/ +theorem diagonal_common_transform_drop_giant {A K : Type*} [Fintype A] [Fintype K] + (key : A → K) (W : A → ℂ) (giant regular : K → ℂ) + (hgiant : ∀ k, ‖giant k‖ ≤ 1) : + (∑ a, ∑ b, if key a = key b then + (W a * (giant (key a) * regular (key a))) * + conj (W b * (giant (key b) * regular (key b))) else 0).re ≤ + ∑ k, ‖regular k‖ ^ 2 * ‖groupedCoefficient key W k‖ ^ 2 := by + rw [diagonal_common_transform key W (fun k => giant k * regular k)] + apply Finset.sum_le_sum + intro k _ + apply mul_le_mul_of_nonneg_right _ (sq_nonneg _) + rw [norm_mul, mul_pow] + exact mul_le_of_le_one_left (sq_nonneg _) + (pow_le_one₀ (norm_nonneg _) (hgiant k)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularLiveOffDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularLiveOffDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..55fde4f6528cedff9973a0d455e24313a583645a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularLiveOffDiagonal.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularOffDiagonal + +namespace OAI + +/-! # The transfer only tests live retained primes -/ +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance liveCopiedSum_neZero {H K : Type*} (L : H → ℕ) (R : K → ℕ) + [∀ i, NeZero (L i)] [∀ i, NeZero (R i)] (i : H ⊕ K) : + NeZero (Sum.elim L R i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +/-- The original coefficient and all its prior factors remain in `W`. +Only the local Fourier arguments are rewritten; no absolute values are +taken and no integer-pivot transform is introduced. -/ +theorem movingGiantOffDiagonal_regular_on_live {A H : Type*} [Fintype A] [Fintype H] + (L : A → H → ℕ) [∀ a i, Fact (L a i).Prime] + (g : ∀ a i, ZMod (L a i) → ℂ) + (hg : ∀ a i x, g a i (-x) = conj (g a i x)) + (I : Finset ℕ) (V U D : ℕ) (v : A → ℤ) (w : ℕ → ℝ) (W : ℕ → A → ℂ) + (hsupport : ∀ p ∈ I, ∀ a, W p a ≠ 0 → + Pairwise (fun i j => (L a i).Coprime (L a j)) ∧ + (∏ i, L a i).Coprime (p * U) ∧ ∀ i, D.Coprime (L a i)) + (hlarge : ∀ p ∈ I, ∀ a, W p a ≠ 0 → + ∀ q, q.Prime → q ∣ ∏ i, L a i → V < q) : + movingGiantOffDiagonal I V U (fun a => ∏ i, L a i) v w + (movingRegularCoefficient L g D U v W) = + ∑ s ∈ transferFrequencyRange V, ∑ a, ∑ b, + if validTransferredPivot I (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U) then + let p := reconstructedPivot (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U) + (w p : ℂ) * W p a * conj (W p b) * + movingRegularTransform (Sum.elim (L a) (L b)) + (fun i => match i with | .inl j => g a j | .inr j => g b j) D s + else 0 := by + unfold movingGiantOffDiagonal + apply Finset.sum_congr rfl + intro s hsV + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + split_ifs with hvalid + · let p := reconstructedPivot (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U) + change (w p : ℂ) * movingRegularCoefficient L g D U v W p a * + conj (movingRegularCoefficient L g D U v W p b) = + (w p : ℂ) * W p a * conj (W p b) * _ + by_cases ha : W p a = 0 + · simp only [movingRegularCoefficient, ha, zero_mul, mul_zero] + by_cases hb : W p b = 0 + · simp only [movingRegularCoefficient, hb, zero_mul, map_zero, mul_zero] + have hp : p ∈ I := hvalid.2.2.2 + obtain ⟨hpa, hMa, hDa⟩ := hsupport p hp a ha + obtain ⟨hpb, hMb, hDb⟩ := hsupport p hp b hb + have hs : s ≠ 0 := left_ne_zero_of_mul hvalid.1 + have hrel : v a * (∏ i, L b i) - v b * (∏ i, L a i) = + s * ((p * U : ℕ) : ℤ) := by + have he := validTransferredPivot_equation I _ _ hvalid + calc + _ = (s * (U : ℤ)) * (p : ℤ) := he + _ = _ := by push_cast; ring + have hAB := transferred_products_coprime (∏ i, L a i) (∏ i, L b i) + (v a) (v b) s (p * U) hs hrel + (fun q hq hqa _ => ((mem_transferFrequencyRange V s).mp hsV).trans_lt + (hlarge p hp a ha q hq hqa)) + (common_prime_pivot_unit (p * U) _ _ hMa) + have hcross (i j : H) : (L a i).Coprime (L b j) := + (hAB.coprime_dvd_left (Finset.dvd_prod_of_mem (L a) (Finset.mem_univ i))).coprime_dvd_right + (Finset.dvd_prod_of_mem (L b) (Finset.mem_univ j)) + have hcop : Pairwise (fun i j => + (Sum.elim (L a) (L b) i).Coprime (Sum.elim (L a) (L b) j)) := by + intro i j hij + cases i with + | inl i => + cases j with + | inl j => exact hpa (fun he => hij (congrArg Sum.inl he)) + | inr j => exact hcross i j + | inr i => + cases j with + | inl j => exact (hcross j i).symm + | inr j => exact hpb (fun he => hij (congrArg Sum.inr he)) + have hM : ∀ i, (p * U).Coprime (Sum.elim (L a) (L b) i) := by + intro i + cases i with + | inl i => exact hMa.symm.coprime_dvd_right (Finset.dvd_prod_of_mem (L a) (Finset.mem_univ i)) + | inr i => exact hMb.symm.coprime_dvd_right (Finset.dvd_prod_of_mem (L b) (Finset.mem_univ i)) + have hD : ∀ i, D.Coprime (Sum.elim (L a) (L b) i) := by + intro i + cases i with + | inl i => exact hDa i + | inr i => exact hDb i + have he := moving_regular_transform_transfer (L a) (L b) (g a) (g b) (hg b) + (p * U) D (v a) (v b) s hcop hM hD hrel + simp only [movingRegularCoefficient, map_mul (starRingEnd ℂ)] + calc + _ = ((w p : ℂ) * W p a * conj (W p b)) * + (movingRegularTransform (L a) (g a) (p * U * D) (v a) * + conj (movingRegularTransform (L b) (g b) (p * U * D) (v b))) := by ring + _ = _ := by + rw [he] + congr 1 + unfold movingRegularTransform + apply Finset.prod_congr rfl + intro i _ + cases i <;> rfl + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularMultiplierIdentity.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularMultiplierIdentity.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d1eef5a94215ccea46543358dc3f2991b015ec7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularMultiplierIdentity.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternRegularUnits +import OAI.NumberTheory.Ostmann.Construction.RegularGiantMultiplier + +namespace OAI + +/-! # The literal diagonal multiplier is the squared regular Fourier product -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingRegularOther_eq_cofactor {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (slots : List σ) (j : Fin slots.length) : + movingRegularOther value outside slots j = + ((outside.prod * tupleCofactor (fun i => value (slots.get i)) j : ℕ) : ℤ) := by + unfold movingRegularOther tupleCofactor + congr 2 + apply Finset.prod_congr + · ext i + simp only [Finset.mem_erase, Finset.mem_univ] + · intro i _ + rfl + +theorem naturalRegularMultiplier_eq_transform_norm {I : Type*} [Fintype I] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (active : I → Bool) (s : ℤ) + (D : ℕ) (g : ∀ i, ZMod (p i) → ℂ) (XL XR : ℕ) : + naturalRegularMultiplier p active s + (fun i => ((D * tupleCofactor p i : ℕ) : ZMod (p i))) g XL XR = + ‖movingRegularTransform p (fun i x => if active i then g i x else 1) + (D * XL * XR) s‖ ^ 2 := by + rw [movingRegularTransform, norm_prod, ← Finset.prod_pow] + unfold naturalRegularMultiplier + apply Finset.prod_congr rfl + intro i _ + cases ha : active i + · simp only [Bool.false_eq_true, ite_false, norm_one, one_pow] + · simp only [ite_true] + congr 2 + simp only [div_eq_mul_inv, Nat.cast_mul] + congr 2 + ring + +theorem movingPattern_regular_multiplier_eq_transform {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (small : TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) (value : Fin (N + 1) → ℕ) + (hprime : ∀ i, (value i).Prime) (outside : List ℕ) + (active : Fin (movingPatternRegularSlots e n m small slot).length → Bool) + (g : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) (XL XR : ℕ) : + let slots := movingPatternRegularSlots e n m small slot + let p := fun i : Fin slots.length => value (slots.get i) + let : ∀ i, Fact (p i).Prime := fun _ => ⟨hprime _⟩ + naturalRegularMultiplier p active s + (fun i => (movingRegularOther value outside slots i : ZMod (p i))) + (fun i => g (p i)) XL XR = + ‖movingRegularTransform p (fun i x => if active i then g (p i) x else 1) + (outside.prod * XL * XR) s‖ ^ 2 := by + dsimp only + let : ∀ i : Fin (movingPatternRegularSlots e n m small slot).length, + Fact (value ((movingPatternRegularSlots e n m small slot).get i)).Prime := fun _ => ⟨hprime _⟩ + simp only [movingRegularOther_eq_cofactor, Int.cast_natCast] + exact naturalRegularMultiplier_eq_transform_norm _ active s outside.prod _ XL XR + +/-- On the original support, the squared regular factor depends only on the +prime product, frequency, outside product, and the two current giants. -/ +theorem movingPattern_regular_multiplier_eq_primeProduct {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) (value : Fin (N + 1) → ℕ) + (hprime : ∀ i, (value i).Prime) (outside : List ℕ) + (g : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) (XL XR : ℕ) + (h : movingRegularOutsidePairwise value outside + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern false)) : + let slots := movingPatternRegularSlots e n m small slot + let p := fun i : Fin slots.length => value (slots.get i) + let : ∀ i, Fact (p i).Prime := fun _ => ⟨hprime _⟩ + naturalRegularMultiplier p (fun _ => true) s + (fun i => (movingRegularOther value outside slots i : ZMod (p i))) + (fun i => g (p i)) XL XR = + ‖primeProductTransform g (outside.prod * XL * XR) + (MovingSlotReversal.naturalProduct value slots) s‖ ^ 2 := by + dsimp only + let slots := movingPatternRegularSlots e n m small slot + let p := fun i : Fin slots.length => value (slots.get i) + let : ∀ i, Fact (p i).Prime := fun _ => ⟨hprime _⟩ + have hp := movingPattern_regular_pairwise e t small slot pattern value outside false h + have hinj : Function.Injective p := by + intro i j he + by_contra hne + have hc := hp hne + change (p i).Coprime (p j) at hc + rw [he, Nat.coprime_self] at hc + exact (hprime _).ne_one hc + rw [movingPattern_regular_multiplier_eq_transform e small slot value hprime outside + (fun _ => true) g s XL XR] + simp only [ite_true] + change ‖movingRegularTransform p (fun i => g (p i)) (outside.prod * XL * XR) s‖ ^ 2 = + ‖primeProductTransform g (outside.prod * XL * XR) + (MovingSlotReversal.naturalProduct value slots) s‖ ^ 2 + rw [movingRegularTransform_eq_primeProduct p hinj, naturalProduct_eq_finprod] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularOffDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularOffDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..91d5be57457b21b629212ab34201e063e0fbfb14 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularOffDiagonal.lean @@ -0,0 +1,118 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeArithmeticTransfer +import OAI.NumberTheory.Ostmann.Construction.TransferOutputSupport + +namespace OAI + +/-! # The weighted off-diagonal with its actual surviving Fourier transform -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance copiedSum_neZero {H K : Type*} (L : H → ℕ) (R : K → ℕ) + [∀ i, NeZero (L i)] [∀ i, NeZero (R i)] (i : H ⊕ K) : + NeZero (Sum.elim L R i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +noncomputable def movingRegularCoefficient {A H : Type*} [Fintype H] + (L : A → H → ℕ) [∀ a i, NeZero (L a i)] + (g : ∀ a i, ZMod (L a i) → ℂ) (D U : ℕ) (v : A → ℤ) + (W : ℕ → A → ℂ) (p : ℕ) (a : A) : ℂ := + W p a * movingRegularTransform (L a) (g a) (p * U * D) (v a) + +/-- The original coefficient and all its prior factors remain in `W`. +Only the local Fourier arguments are rewritten; no absolute values are +taken and no integer-pivot transform is introduced. -/ +theorem movingGiantOffDiagonal_regular {A H : Type*} [Fintype A] [Fintype H] + (L : A → H → ℕ) [∀ a i, Fact (L a i).Prime] + (g : ∀ a i, ZMod (L a i) → ℂ) + (hg : ∀ a i x, g a i (-x) = conj (g a i x)) + (I : Finset ℕ) (V U D : ℕ) (v : A → ℤ) (w : ℕ → ℝ) (W : ℕ → A → ℂ) + (hsupport : ∀ p ∈ I, ∀ a, W p a ≠ 0 → + Pairwise (fun i j => (L a i).Coprime (L a j)) ∧ + (∏ i, L a i).Coprime (p * U) ∧ ∀ i, D.Coprime (L a i)) + (hlarge : ∀ a q, q.Prime → q ∣ ∏ i, L a i → V < q) : + movingGiantOffDiagonal I V U (fun a => ∏ i, L a i) v w + (movingRegularCoefficient L g D U v W) = + ∑ s ∈ transferFrequencyRange V, ∑ a, ∑ b, + if validTransferredPivot I (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U) then + let p := reconstructedPivot (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U) + (w p : ℂ) * W p a * conj (W p b) * + movingRegularTransform (Sum.elim (L a) (L b)) + (fun i => match i with | .inl j => g a j | .inr j => g b j) D s + else 0 := by + unfold movingGiantOffDiagonal + apply Finset.sum_congr rfl + intro s hsV + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + split_ifs with hvalid + · let p := reconstructedPivot (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U) + change (w p : ℂ) * movingRegularCoefficient L g D U v W p a * + conj (movingRegularCoefficient L g D U v W p b) = + (w p : ℂ) * W p a * conj (W p b) * _ + by_cases ha : W p a = 0 + · simp only [movingRegularCoefficient, ha, zero_mul, mul_zero] + by_cases hb : W p b = 0 + · simp only [movingRegularCoefficient, hb, zero_mul, map_zero, mul_zero] + have hp : p ∈ I := hvalid.2.2.2 + obtain ⟨hpa, hMa, hDa⟩ := hsupport p hp a ha + obtain ⟨hpb, hMb, hDb⟩ := hsupport p hp b hb + have hs : s ≠ 0 := left_ne_zero_of_mul hvalid.1 + have hrel : v a * (∏ i, L b i) - v b * (∏ i, L a i) = + s * ((p * U : ℕ) : ℤ) := by + have he := validTransferredPivot_equation I _ _ hvalid + calc + _ = (s * (U : ℤ)) * (p : ℤ) := he + _ = _ := by push_cast; ring + have hAB := transferred_products_coprime (∏ i, L a i) (∏ i, L b i) + (v a) (v b) s (p * U) hs hrel + (fun q hq hqa _ => ((mem_transferFrequencyRange V s).mp hsV).trans_lt + (hlarge a q hq hqa)) + (common_prime_pivot_unit (p * U) _ _ hMa) + have hcross (i j : H) : (L a i).Coprime (L b j) := + (hAB.coprime_dvd_left (Finset.dvd_prod_of_mem (L a) (Finset.mem_univ i))).coprime_dvd_right + (Finset.dvd_prod_of_mem (L b) (Finset.mem_univ j)) + have hcop : Pairwise (fun i j => + (Sum.elim (L a) (L b) i).Coprime (Sum.elim (L a) (L b) j)) := by + intro i j hij + cases i with + | inl i => + cases j with + | inl j => exact hpa (fun he => hij (congrArg Sum.inl he)) + | inr j => exact hcross i j + | inr i => + cases j with + | inl j => exact (hcross j i).symm + | inr j => exact hpb (fun he => hij (congrArg Sum.inr he)) + have hM : ∀ i, (p * U).Coprime (Sum.elim (L a) (L b) i) := by + intro i + cases i with + | inl i => exact hMa.symm.coprime_dvd_right (Finset.dvd_prod_of_mem (L a) (Finset.mem_univ i)) + | inr i => exact hMb.symm.coprime_dvd_right (Finset.dvd_prod_of_mem (L b) (Finset.mem_univ i)) + have hD : ∀ i, D.Coprime (Sum.elim (L a) (L b) i) := by + intro i + cases i with + | inl i => exact hDa i + | inr i => exact hDb i + have he := moving_regular_transform_transfer (L a) (L b) (g a) (g b) (hg b) + (p * U) D (v a) (v b) s hcop hM hD hrel + simp only [movingRegularCoefficient, map_mul (starRingEnd ℂ)] + calc + _ = ((w p : ℂ) * W p a * conj (W p b)) * + (movingRegularTransform (L a) (g a) (p * U * D) (v a) * + conj (movingRegularTransform (L b) (g b) (p * U * D) (v b))) := by ring + _ = _ := by + rw [he] + congr 1 + unfold movingRegularTransform + apply Finset.prod_congr rfl + intro i _ + cases i <;> rfl + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularOuterComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularOuterComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..8949abfba36a6460dc2d2348ce892fc58b8e930f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularOuterComparison.lean @@ -0,0 +1,152 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularOuterFactor +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterCoprimeComparison + +namespace OAI + +/-! # The displayed regular G retained in the original-prior Haar comparison -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_original_regular_prime_haar_rate (P : PublishedProgressionInput) + {σ I J : Type*} [Fintype J] (p : I → ℕ) [∀ i, Fact (p i).Prime] (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] (label : J → σ) + (_hlabel : ∀ i, value (label i) = reg i) (_hmem : ∀ i, label i ∈ (T false).regularSlots) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + q = movingFullPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p S → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingFullPairResidueCoefficient p value outside F E g Dq S T nodes a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [(P.moving_outer_coprime_prime_haar_rate n C d).mono (fun _ h => h σ)] with L hL + intro tier value hprime hdisjoint outside childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod + F E g hg Dq S reg instReg label hlabel hmem active sreg other greg ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q hQ hq hqQ hqeq hlog u v r s hu huv hshort hr hrs hrshort hqlog + dsimp only + intro A hA0 hA hbudget + let hv := fun i => (hprime i).ne_zero + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingFullPairResidueCoefficient p value outside F E g Dq S T nodes a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + have h := hL value hv childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c A hA0 hA hbudget + dsimp only at h + have hfactor (x y : ℕ) : + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t x y * + (naturalRegularMultiplier reg active sreg other greg x y : ℂ) = + if x.Coprime y then c (x % q) (y % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal x y else 0 := by + rw [hqeq] + exact movingOriginalSupportedRegular_factor p tier value hprime hdisjoint outside childBound pivotBound + F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal + T t hT hf hlevels hcoh hc hsmall hfmod reg label hlabel hmem active sreg other greg x y + simpa only [hfactor] using h + +theorem PublishedProgressionInput.moving_original_regular_mixed_haar_rate (P : PublishedProgressionInput) + {σ I J : Type*} [Fintype J] (p : I → ℕ) [∀ i, Fact (p i).Prime] (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] (label : J → σ) + (_hlabel : ∀ i, value (label i) = reg i) (_hmem : ∀ i, label i ∈ (T false).regularSlots) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + q = movingFullPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p S → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingFullPairResidueCoefficient p value outside F E g Dq S T nodes a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * correctedMixedPairAverage P Q q c y / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [(P.moving_outer_coprime_mixed_haar_rate n C d).mono (fun _ h => h σ)] with L hL + intro tier value hprime hdisjoint outside childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod + F E g hg Dq S reg instReg label hlabel hmem active sreg other greg ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q hQ hq hqQ hqeq hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog + dsimp only + intro A hA0 hA hbudget + let hv := fun i => (hprime i).ne_zero + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingFullPairResidueCoefficient p value outside F E g Dq S T nodes a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + have h := hL value hv childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog c A hA0 hA hbudget + dsimp only at h + have hfactor (x y : ℕ) : + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t x y * + (naturalRegularMultiplier reg active sreg other greg x y : ℂ) = + if x.Coprime y then c (x % q) (y % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal x y else 0 := by + rw [hqeq] + exact movingOriginalSupportedRegular_factor p tier value hprime hdisjoint outside childBound pivotBound + F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal + T t hT hf hlevels hcoh hc hsmall hfmod reg label hlabel hmem active sreg other greg x y + simpa only [hfactor] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularOuterFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularOuterFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..2fa440d956b95f212a78a05351a057a0131d16a5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularOuterFactor.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedOuterFactor +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularResidues + +namespace OAI + +/-! # The original supported pair with the displayed regular-prime multiplier -/ + +namespace Ostmann +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +theorem movingOriginalSupportedRegular_factor {σ I J : Type*} [Fintype J] (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (hT : ∀ b, (T b).Follows (t b)) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hlevels : ∀ b, (T b).Levels tier) (hcoh : ∀ b, (T b).RegularCoherent) + (hc : ∀ b, (T b).CompensationPrimeData value) + (hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] (label : J → σ) + (hlabel : ∀ i, value (label i) = reg i) (hmem : ∀ i, label i ∈ (T false).regularSlots) + (active : J → Bool) (s : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (XL XR : ℕ) : + let hv := fun i => (hprime i).ne_zero + let M := movingFullPairModulus value hv outside childBound pivotBound T hf q S + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingFullPairResidueCoefficient q value outside F E g Dq S T nodes a b * + (guardedRegularMultiplier reg active s other greg a b : ℂ) + movingOriginalSupportedOuterPair q value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t XL XR * + (naturalRegularMultiplier reg active s other greg XL XR : ℂ) = + if XL.Coprime XR then c (XL % M) (XR % M) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal XL XR else 0 := by + dsimp only + let hv := fun i => (hprime i).ne_zero + let M := movingFullPairModulus value hv outside childBound pivotBound T hf q S + have hr := movingSupportedWeight_regular_multiplier value outside (T false) reg label hlabel hmem + active s other greg XL XR + (movingOriginalGiantWeight q value childBound pivotBound (F false) (E false) g (Dq false) S + ψ X lo hi φ G (T false) (t false) XL XR) + have hrpair : movingOriginalSupportedOuterPair q value outside childBound pivotBound F E g Dq S + ψ X lo hi φ G Jleft Jright diagonal T t XL XR * + (naturalRegularMultiplier reg active s other greg XL XR : ℂ) = + movingOriginalSupportedOuterPair q value outside childBound pivotBound F E g Dq S + ψ X lo hi φ G Jleft Jright diagonal T t XL XR * + (guardedRegularMultiplier reg active s other greg XL XR : ℂ) := by + unfold movingOriginalSupportedOuterPair + convert congrArg (fun z : ℂ => z * + conj (movingSupportedWeight value outside (T true) XL XR + (movingOriginalGiantWeight q value childBound pivotBound (F true) (E true) g (Dq true) S + ψ X lo hi φ G (T true) (t true) XL XR)) * giantOuterWeight φ Jleft Jright diagonal XL XR) hr using 1 <;> ring + have hk := movingOriginalSupportedOuterPair_factor q tier value hprime hdisjoint outside childBound pivotBound + F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal + T t hT hf hlevels hcoh hc hsmall hfmod XL XR + dsimp only at hk + have hm := guardedRegularMultiplier_full_modulus value hv outside childBound pivotBound T hf q S + reg label hlabel hmem active s other greg XL XR + dsimp only at hm + rw [hrpair, hk] + by_cases hp : XL.Coprime XR + · rw [ite_eq_left hp, ite_eq_left hp, hm] + ring + · rw [ite_eq_right hp, ite_eq_right hp, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularResidues.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2247df59b8e9a9a1d896b8a2a84f4a7a7bcd998 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularResidues.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.Ostmann.Construction.RegularGiantMultiplier +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullModulus + +namespace OAI + +/-! # Regular-prime multiplier coordinates in the actual full modulus -/ + +namespace Ostmann +open scoped BigOperators Classical + +theorem movingRegularProduct_dvd_unitPeriod {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) : + (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) ∣ movingGiantUnitPeriod value outside T := by + cases T with + | leaf s regular => + exact dvd_mul_of_dvd_left (dvd_mul_left _ _) _ + | node s CL CR U left right => + exact dvd_mul_of_dvd_left (dvd_mul_of_dvd_left (dvd_mul_of_dvd_left + (dvd_mul_of_dvd_left (dvd_mul_left _ _) _) _) _) _ + +theorem movingFullPairModulus_regular_dvd {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (b : Bool) (i : σ) (hi : i ∈ (T b).regularSlots) : + value i ∣ movingFullPairModulus value hvalue outside childBound pivotBound T hf q S := by + have hd : value i ∣ MovingSlotReversal.naturalProduct value (T b).regularSlots := + List.dvd_prod (List.mem_map.mpr ⟨i, hi, rfl⟩) + have hdZ : (value i : ℤ) ∣ (MovingSlotReversal.naturalProduct value (T b).regularSlots : ℤ) := by exact_mod_cast hd + have hu := (movingFullPairModulus_tests value hvalue outside childBound pivotBound T hf q S).2.2.1 b + exact_mod_cast hdZ.trans ((movingRegularProduct_dvd_unitPeriod value outside (T b)).trans hu) + +theorem guardedRegularMultiplier_full_modulus {σ I J : Type*} [Fintype J] + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (p : J → ℕ) [∀ i, Fact (p i).Prime] + (label : J → σ) (hp : ∀ i, value (label i) = p i) + (hmem : ∀ i, label i ∈ (T false).regularSlots) + (active : J → Bool) (s : ℤ) (other : ∀ i, ZMod (p i)) (g : ∀ i, ZMod (p i) → ℂ) + (XL XR : ℕ) : + let M := movingFullPairModulus value hvalue outside childBound pivotBound T hf q S + guardedRegularMultiplier p active s other g XL XR = + guardedRegularMultiplier p active s other g (XL % M) (XR % M) := by + dsimp only + apply guardedRegularMultiplier_modEq + · intro i + rw [← hp i] + exact movingFullPairModulus_regular_dvd value hvalue outside childBound pivotBound T hf q S false (label i) (hmem i) + · exact (Nat.mod_modEq _ _).symm + · exact (Nat.mod_modEq _ _).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularSlots.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularSlots.lean new file mode 100644 index 0000000000000000000000000000000000000000..70bd01a90372012413690caf5d70088b8b290f52 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularSlots.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCoprimeDescent + +namespace OAI + +/-! # The original regular slot lists in every moving child -/ + +namespace Ostmann +open scoped Classical + +/-- Current regular slots, before sampling at this node. -/ +def MovingSlotData.regularSlots {σ : Type*} : {n : ℕ} → MovingSlotData σ n → List σ + | _, .leaf _ regular => regular + | _, .node _ CL CR _ _ _ => CL ++ CR + +/-- The child regular slots contain the same compensation vector and the +corresponding parent's regular slots, with their actual per-leaf allocation. -/ +def MovingSlotData.RegularCoherent {σ : Type*} : {n : ℕ} → MovingSlotData σ n → Prop + | _, .leaf _ _ => True + | _, .node _ CL CR U left right => + left.regularSlots.Perm (U ++ CL) ∧ right.regularSlots.Perm (U ++ CR) ∧ + left.RegularCoherent ∧ right.RegularCoherent + +theorem flattenMovingSlots_append_perm {σ : Type*} (n : ℕ) + (x y : TreeLeafTuple (List σ) n) : + (flattenMovingSlots n (appendMovingSlotLeaves n x y)).Perm + (flattenMovingSlots n x ++ flattenMovingSlots n y) := by + apply List.perm_iff_count.mpr + intro a + induction n with + | zero => simp [flattenMovingSlots, appendMovingSlotLeaves] + | succ n ih => + have hx := ih x.1 y.1 + have hy := ih x.2 y.2 + simpa only [flattenMovingSlots, appendMovingSlotLeaves, List.count_append, + Nat.add_assoc, Nat.add_comm, Nat.add_left_comm] using congrArg₂ (· + ·) hx hy + +theorem buildMovingSlotData_regular_perm {σ : Type*} (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (samples : MovingSampleSlots σ n) : + (buildMovingSlotData n t small bulk samples).regularSlots.Perm + (flattenMovingSlots n small ++ flattenMovingSlots n bulk) := by + cases samples with + | leaf => exact List.Perm.refl _ + | @node n samples left right => + apply List.perm_iff_count.mpr + intro a + simp only [buildMovingSlotData, MovingSlotData.regularSlots, flattenMovingSlots, + List.count_append] + omega + +/-- Coherence is proved for the actual sampler, not supplied as a new +assumption about the original history. -/ +theorem buildMovingSlotData_regular_coherent {σ : Type*} (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (samples : MovingSampleSlots σ n) : + (buildMovingSlotData n t small bulk samples).RegularCoherent := by + induction samples with + | leaf => trivial + | @node n samples left right ihL ihR => + let U := movingCompensationSlots n samples + have hL := (buildMovingSlotData_regular_perm n t.2.1 + (appendMovingSlotLeaves n U small.1) bulk.1 left).trans + ((flattenMovingSlots_append_perm n U small.1).append_right (flattenMovingSlots n bulk.1)) + have hR := (buildMovingSlotData_regular_perm n t.2.2 + (appendMovingSlotLeaves n U small.2) bulk.2 right).trans + ((flattenMovingSlots_append_perm n U small.2).append_right (flattenMovingSlots n bulk.2)) + refine ⟨?_, ?_, ihL _ _ _, ihR _ _ _⟩ + · simpa only [List.append_assoc] using hL + · simpa only [List.append_assoc] using hR + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularTemplate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularTemplate.lean new file mode 100644 index 0000000000000000000000000000000000000000..407732acfb3ffcb55e7a5efddb4f54bebf6f507b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularTemplate.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkBudgets +import OAI.NumberTheory.Ostmann.Arithmetic.BulkSlotNodup + +namespace OAI + +/-! # The actual small and bulk slots at a moving-giant level -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Each surviving leaf has its remaining small slots and its original bulk. -/ +abbrev MovingRegularSlot (n r m : ℕ) := TreeLeafIndex n × (Fin r ⊕ Fin m) + +def movingTemplateBulk (n r m : ℕ) : (TreeLeafIndex n × Fin m) ↪ MovingRegularSlot n r m where + toFun j := (j.1, .inr j.2) + inj' := by intro i j h; cases i; cases j; cases h; rfl + +noncomputable def movingTemplateSmall (n r m : ℕ) : TreeLeafTuple (List (MovingRegularSlot n r m)) n := + bulkSlotLeaves n r (fun j => (j.1, .inl j.2)) + +theorem movingTemplateSmall_length (n r m : ℕ) : + MovingLeafLengthLE n (movingTemplateSmall n r m) r := bulkSlotLeaves_length n r _ + +theorem movingTemplateSmall_not_bulk (n r m : ℕ) : + ∀ i ∈ flattenMovingSlots n (movingTemplateSmall n r m), i ∉ Set.range (movingTemplateBulk n r m) := by + intro i hi hbulk + obtain ⟨j, rfl⟩ := (mem_flatten_bulkSlotLeaves n r _ i).mp hi + obtain ⟨k, hk⟩ := hbulk + have hs : (Sum.inr k.2 : Fin r ⊕ Fin m) = .inl j.2 := + congrArg (fun z : MovingRegularSlot n r m => z.2) hk + cases hs + +theorem movingRegularSlot_card (n r m : ℕ) : + Fintype.card (MovingRegularSlot n r m) = 2 ^ n * (r + m) := by + simp only [MovingRegularSlot, Fintype.card_prod, card_treeLeafIndex, Fintype.card_sum, + Fintype.card_fin] + +/-- Restoring a removed type puts its four sampled compensation primes back +before the surviving small slots. Bulk labels retain their identity. -/ +def movingReverseTemplate (n r m : ℕ) : + ((TreeLeafIndex n × Fin 4) ⊕ MovingRegularSlot n r m) ≃ MovingRegularSlot n (4 + r) m where + toFun + | .inl (j, i) => (j, .inl (Fin.castAdd r i)) + | .inr (j, .inl i) => (j, .inl (Fin.natAdd 4 i)) + | .inr (j, .inr i) => (j, .inr i) + invFun + | (j, .inl i) => Fin.addCases (fun a => .inl (j, a)) (fun b => .inr (j, .inl b)) i + | (j, .inr i) => .inr (j, .inr i) + left_inv := by + intro x + rcases x with (⟨j, i⟩ | ⟨j, i | i⟩) <;> simp + right_inv := by + rintro ⟨j, i | i⟩ + · refine Fin.addCases (fun a => ?_) (fun b => ?_) i <;> simp + · rfl + +@[simp] theorem movingReverseTemplate_bulk (n r m : ℕ) (j : TreeLeafIndex n × Fin m) : + movingReverseTemplate n r m (.inr (movingTemplateBulk n r m j)) = + movingTemplateBulk n (4 + r) m j := rfl + +@[simp] theorem movingReverseTemplate_compensation (n r m : ℕ) (j : TreeLeafIndex n × Fin 4) : + movingReverseTemplate n r m (.inl j) = (j.1, .inl (Fin.castAdd r j.2)) := rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..173ff04a4b1a04a3673647b1f3832ad3d177f31f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularTransfer.lean @@ -0,0 +1,181 @@ +import OAI.NumberTheory.Ostmann.Construction.TransferTupleCoordinates +import OAI.NumberTheory.Ostmann.Characters.NormalizedResidueIndicator +import OAI.NumberTheory.Ostmann.Characters.PivotKeyReduction + +namespace OAI + +/-! # The surviving regular Fourier transform in the giant-only transfer -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +private theorem transfer_quotient {K : Type*} [Field K] + (P R D v s : K) (hP : P ≠ 0) (hR : R ≠ 0) (hD : D ≠ 0) + (h : v * R = s * P) : v / (P * D) = s / (R * D) := by + apply (div_eq_div_iff (mul_ne_zero hP hD) (mul_ne_zero hR hD)).mpr + calc + v * (R * D) = (v * R) * D := by ring + _ = (s * P) * D := by rw [h] + _ = s * (P * D) := by ring + +/-- The local left transform keeps its function; only the denominator changes. -/ +theorem moving_regular_left_transfer {p : ℕ} [Fact p.Prime] + (g : ZMod p → ℂ) (L R M D : ℕ) (v w s : ℤ) + (hpL : p ∣ L) (hM : M.Coprime p) (hR : R.Coprime p) (hD : D.Coprime p) + (hrel : v * R - w * L = s * M) : + g ((v : ZMod p) / ((M * D : ℕ) : ZMod p)) = + g ((s : ZMod p) / ((R * D : ℕ) : ZMod p)) := by + congr 1 + simp only [Nat.cast_mul] + exact transfer_quotient _ _ _ _ _ + (zmod_natCast_ne_zero_of_coprime M hM) + (zmod_natCast_ne_zero_of_coprime R hR) + (zmod_natCast_ne_zero_of_coprime D hD) + (transfer_equation_mod_left p L R M v w s hpL hrel) + +/-- The conjugated right transform has the same new argument, because the +underlying physical residue function is real. -/ +theorem moving_regular_right_transfer {p : ℕ} [Fact p.Prime] + (g : ZMod p → ℂ) (hg : ∀ x, g (-x) = conj (g x)) + (L R M D : ℕ) (v w s : ℤ) + (hpR : p ∣ R) (hM : M.Coprime p) (hL : L.Coprime p) (hD : D.Coprime p) + (hrel : v * R - w * L = s * M) : + conj (g ((w : ZMod p) / ((M * D : ℕ) : ZMod p))) = + g ((s : ZMod p) / ((L * D : ℕ) : ZMod p)) := by + rw [← hg] + congr 1 + simp only [Nat.cast_mul, ← neg_div] + exact transfer_quotient _ _ _ _ _ + (zmod_natCast_ne_zero_of_coprime M hM) + (zmod_natCast_ne_zero_of_coprime L hL) + (zmod_natCast_ne_zero_of_coprime D hD) + (transfer_equation_mod_right p L R M v w s hpR hrel) + +/-- Product of the actual local transforms, with their CRT cofactors. -/ +noncomputable def movingRegularTransform {I : Type*} [Fintype I] + (p : I → ℕ) [∀ i, NeZero (p i)] + (g : ∀ i, ZMod (p i) → ℂ) (D : ℕ) (s : ℤ) : ℂ := + ∏ i, g i ((s : ZMod (p i)) * ((D * tupleCofactor p i : ℕ) : ZMod (p i))⁻¹) + +local instance sumElim_neZero {H K : Type*} (L : H → ℕ) (R : K → ℕ) + [∀ i, NeZero (L i)] [∀ i, NeZero (R i)] (i : H ⊕ K) : + NeZero (Sum.elim L R i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +/-- Splitting the actual prime list extracts exactly the pivot row and +retains the old regular transform at the composite pivot denominator. -/ +theorem moving_regular_transform_split {H K : Type*} [Fintype H] [Fintype K] + (L : H → ℕ) (R : K → ℕ) [∀ i, NeZero (L i)] [∀ i, NeZero (R i)] + (gL : ∀ i, ZMod (L i) → ℂ) (gR : ∀ i, ZMod (R i) → ℂ) + (D : ℕ) (s : ℤ) : + movingRegularTransform (Sum.elim L R) + (fun i => match i with | .inl j => gL j | .inr j => gR j) D s = + movingRegularTransform L gL (D * ∏ i, R i) s * + movingRegularTransform R gR (D * ∏ i, L i) s := by + unfold movingRegularTransform + rw [Fintype.prod_sum_type] + congr 1 + · apply Finset.prod_congr rfl + intro i _ + rw [tupleCofactor_sum_left L R i (NeZero.ne (L i))] + simp only [mul_assoc, mul_comm] + rfl + · apply Finset.prod_congr rfl + intro i _ + rw [tupleCofactor_sum_right L R i (NeZero.ne (R i))] + simp only [mul_assoc] + rfl + +/-- The extracted row depends only on the grouped key `v/H mod P`, with +the original outside denominator and every local cofactor unchanged. -/ +theorem moving_regular_transform_grouped_key {J : Type*} [Fintype J] + (p : J → ℕ) [∀ j, Fact (p j).Prime] + (g : ∀ j, ZMod (p j) → ℂ) (H D : ℕ) (v : ℤ) + (hH : H.Coprime (∏ j, p j)) : + movingRegularTransform p g D + ((positiveIntegerPivotKey (∏ j, p j) + (Finset.prod_pos (fun j _ => (Fact.out : (p j).Prime).pos)) H v).val : ℤ) = + movingRegularTransform p g (D * H) v := by + unfold movingRegularTransform + apply Finset.prod_congr rfl + intro j _ + have hd := Finset.dvd_prod_of_mem p (Finset.mem_univ j) + have hHj := zmod_natCast_ne_zero_of_coprime H (hH.of_dvd_right hd) + have he := positiveIntegerPivotKey_mul_at_divisor (∏ j, p j) + (Finset.prod_pos (fun j _ => (Fact.out : (p j).Prime).pos)) H v hd hH + have heq := (eq_div_iff hHj).mpr he + simp only [Int.cast_natCast, heq, div_eq_mul_inv, Nat.cast_mul, mul_inv_rev] + congr 1 + ring + +/-- The full current transform factors through the precise grouped row +used by the Cauchy step, before the giant is extended to integers. -/ +theorem moving_full_transform_grouped {J K : Type*} [Fintype J] [Fintype K] + (p : J → ℕ) (q : K → ℕ) + [∀ j, Fact (p j).Prime] [∀ k, Fact (q k).Prime] + (g : ∀ j, ZMod (p j) → ℂ) (h : ∀ k, ZMod (q k) → ℂ) + (D : ℕ) (v : ℤ) (hqp : (∏ k, q k).Coprime (∏ j, p j)) : + movingRegularTransform (Sum.elim p q) + (fun i => match i with | .inl j => g j | .inr k => h k) D v = + movingRegularTransform p g D + ((positiveIntegerPivotKey (∏ j, p j) + (Finset.prod_pos (fun j _ => (Fact.out : (p j).Prime).pos)) (∏ k, q k) v).val : ℤ) * + movingRegularTransform q h (D * ∏ j, p j) v := by + rw [moving_regular_transform_grouped_key p g (∏ k, q k) D v hqp] + exact moving_regular_transform_split p q g h D v + +/-- No averaging or approximation occurs when the two surviving transforms +combine. The extracted pivot and compensation product disappear together. -/ +theorem moving_regular_transform_transfer {H K : Type*} [Fintype H] [Fintype K] + (L : H → ℕ) (R : K → ℕ) + [∀ i, Fact (L i).Prime] [∀ i, Fact (R i).Prime] + (gL : ∀ i, ZMod (L i) → ℂ) (gR : ∀ i, ZMod (R i) → ℂ) + (hgR : ∀ i x, gR i (-x) = conj (gR i x)) + (M D : ℕ) (v w s : ℤ) + (hc : Pairwise (fun i j => (Sum.elim L R i).Coprime (Sum.elim L R j))) + (hM : ∀ i, M.Coprime (Sum.elim L R i)) + (hD : ∀ i, D.Coprime (Sum.elim L R i)) + (hrel : v * (∏ i, R i) - w * (∏ i, L i) = s * M) : + movingRegularTransform L gL (M * D) v * + conj (movingRegularTransform R gR (M * D) w) = + movingRegularTransform (Sum.elim L R) + (fun i => match i with | .inl j => gL j | .inr j => gR j) D s := by + have hLc : Pairwise (fun i j => (L i).Coprime (L j)) := by + intro i j hij + exact hc (by simpa using hij : Sum.inl i ≠ Sum.inl j) + have hRc : Pairwise (fun i j => (R i).Coprime (R j)) := by + intro i j hij + exact hc (by simpa using hij : Sum.inr i ≠ Sum.inr j) + have hleft (i : H) : + gL i ((v : ZMod (L i)) / ((M * D * tupleCofactor L i : ℕ) : ZMod (L i))) = + gL i ((s : ZMod (L i)) / + ((D * tupleCofactor (Sum.elim L R) (.inl i) : ℕ) : ZMod (L i))) := by + have hRi : (∏ j, R j).Coprime (L i) := Nat.coprime_prod_left_iff.mpr (by + intro j _ + exact hc (by simp : Sum.inr j ≠ Sum.inl i)) + have hh := moving_regular_left_transfer (gL i) (∏ j, L j) (∏ j, R j) M + (D * tupleCofactor L i) v w s (Finset.dvd_prod_of_mem L (Finset.mem_univ i)) + (hM (.inl i)) hRi ((hD (.inl i)).mul_left (tupleCofactor_coprime L hLc i)) hrel + simpa only [tupleCofactor_sum_left L R i (Fact.out : (L i).Prime).ne_zero, + mul_assoc, mul_left_comm, mul_comm] using hh + have hright (i : K) : + conj (gR i ((w : ZMod (R i)) / ((M * D * tupleCofactor R i : ℕ) : ZMod (R i)))) = + gR i ((s : ZMod (R i)) / + ((D * tupleCofactor (Sum.elim L R) (.inr i) : ℕ) : ZMod (R i))) := by + have hLi : (∏ j, L j).Coprime (R i) := Nat.coprime_prod_left_iff.mpr (by + intro j _ + exact hc (by simp : Sum.inl j ≠ Sum.inr i)) + have hh := moving_regular_right_transfer (gR i) (hgR i) (∏ j, L j) (∏ j, R j) M + (D * tupleCofactor R i) v w s (Finset.dvd_prod_of_mem R (Finset.mem_univ i)) + (hM (.inr i)) hLi ((hD (.inr i)).mul_left (tupleCofactor_coprime R hRc i)) hrel + simpa only [tupleCofactor_sum_right L R i (Fact.out : (R i).Prime).ne_zero, + mul_assoc, mul_left_comm, mul_comm] using hh + unfold movingRegularTransform + rw [map_prod, Fintype.prod_sum_type] + simp only [div_eq_mul_inv] at hleft hright + exact congrArg₂ (· * ·) (Finset.prod_congr rfl (fun i _ => hleft i)) + (Finset.prod_congr rfl (fun i _ => hright i)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularTransformCongruence.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularTransformCongruence.lean new file mode 100644 index 0000000000000000000000000000000000000000..d96c92d1e30eb3b1d3b52de9c4f96aa86bd00214 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRegularTransformCongruence.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeTerms +import OAI.NumberTheory.Ostmann.Construction.PrimeMaskExtension + +namespace OAI + +/-! # Changing regular tests away from the sampled alphabet changes no statistic -/ +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTaggedTransform_regular_congr {I J : Type*} [Fintype I] [Fintype J] + (p : I → ℕ) (q : J → ℕ) (greg hreg ggiant : ∀ r : ℕ, ZMod r → ℂ) + (favorable : ℕ → Bool) (D : ℕ) (s : ℤ) (hregEq : ∀ j, greg (q j) = hreg (q j)) : + movingTaggedTransform (Sum.elim p q) (Sum.elim (fun _ => true) (fun _ => false)) + greg ggiant favorable D s = + movingTaggedTransform (Sum.elim p q) (Sum.elim (fun _ => true) (fun _ => false)) + hreg ggiant favorable D s := by + unfold movingTaggedTransform + apply Finset.prod_congr rfl + intro i _ + cases i with + | inl i => rfl + | inr j => simp only [Sum.elim_inr, Bool.false_eq_true, ↓reduceIte, hregEq j] + +theorem movingTemplatePrimeAmplitude_regular_congr {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (Pg : Finset ℕ) (ρ : Pg → ℝ) + (ν : MovingRegularSlot n r m → σ → ℝ) + (greg hreg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hregEq : ∀ a, greg (value a) = hreg (value a)) : + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n r m + Pg ρ ν greg ggiant favorable = + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n r m + Pg ρ ν hreg ggiant favorable := by + unfold movingTemplatePrimeAmplitude + have ht (p : Bool → ℕ) (y : MovingRegularSlot n r m → σ) (D : ℕ) (s : ℤ) : + movingTaggedTransform (Sum.elim p (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable D s = + movingTaggedTransform (Sum.elim p (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) hreg ggiant favorable D s := + movingTaggedTransform_regular_congr p (value ∘ y) greg hreg ggiant favorable D s + (fun i => hregEq _) + simp_rw [ht] + +theorem movingAmplitudeDiagonal_regular_congr {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (Pg I : Finset ℕ) (ρ : Pg → ℝ) + (ν : MovingRegularSlot n r m → σ → ℝ) + (greg hreg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hregEq : ∀ a, greg (value a) = hreg (value a)) : + movingAmplitudeDiagonal value outside μ childBound pivotBound V F φ G n r m + Pg I ρ ν greg ggiant favorable = + movingAmplitudeDiagonal value outside μ childBound pivotBound V F φ G n r m + Pg I ρ ν hreg ggiant favorable := by + unfold movingAmplitudeDiagonal + dsimp only + simp_rw [show ∀ X (y : MovingRegularSlot n r m → σ) D s, + movingTaggedTransform (movingOneGiantModuli X (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable D s = + movingTaggedTransform (movingOneGiantModuli X (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) hreg ggiant favorable D s from + fun X y D s => movingTaggedTransform_regular_congr (fun _ : Unit => X) + (value ∘ y) greg hreg ggiant favorable D s (fun i => hregEq _)] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRepresentativeLineSystem.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRepresentativeLineSystem.lean new file mode 100644 index 0000000000000000000000000000000000000000..9924199dd59edc0a9f284bf0a00688599d2accfd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRepresentativeLineSystem.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalBaseAverage + +namespace OAI + +/-! # Fixed occurrence systems for a representative sampled prime -/ + +namespace Ostmann +open scoped Classical BigOperators + +abbrev MovingPairRepresentativeOccurrences {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (rep : σ) := + Σ side : Bool, MovingRepresentativeOccurrences (T side) rep + +noncomputable def movingRepresentativeLine {σ : Type*} {n : ℕ} + (T : Bool → MovingSlotData σ n) (rep : σ) + (j : MovingPairRepresentativeOccurrences T rep) : PolynomialGiantLine σ := + let o := (T j.1).occurrences.get j.2.val + movingSlotLine o.path o.current + +/-- On samples with distinct prime values, all occurrences of the selected +prime are precisely the fixed occurrences of its representative slot. -/ +theorem movingPrimeLineSystem_representative_iff {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (rep : σ) + (hunique : ∀ i, value i = value rep → i = rep) + (x y : ZMod (value rep)) : + (∀ j : MovingPrimeOccurrences value T (value rep), + let φ := MovingSlotReversal.naturalReduction (value rep) value + let L := movingPrimeOccurrenceLine value T (value rep) j + φ L.a * x + φ L.b * y = 0) ↔ + (∀ j : MovingPairRepresentativeOccurrences T rep, + let φ := MovingSlotReversal.naturalReduction (value rep) value + let L := movingRepresentativeLine T rep j + φ L.a * x + φ L.b * y = 0) := by + constructor + · intro h j + let k : MovingPrimeOccurrences value T (value rep) := + ⟨j.1, ⟨j.2.val, ⟨rep, j.2.property, rfl⟩⟩⟩ + exact h k + · intro h j + obtain ⟨i, hi, hv⟩ := j.2.property + have he : i = rep := hunique i hv + subst i + let k : MovingPairRepresentativeOccurrences T rep := ⟨j.1, ⟨j.2.val, hi⟩⟩ + exact h k + +/-- This reindexing fixes the polynomial family before the prime values are +sampled, as required by the joint small-prime coincidence theorem. -/ +theorem movingInternalBaseProbability_representative {σ : Type*} {n : ℕ} + (value : σ → ℕ) (T : Bool → MovingSlotData σ n) (rep : σ) + [Fact (value rep).Prime] (hunique : ∀ i, value i = value rep → i = rep) : + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).a) + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingPrimeOccurrenceLine value T (value rep) j).b) = + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingRepresentativeLine T rep j).a) + (fun j => MovingSlotReversal.naturalReduction (value rep) value + (movingRepresentativeLine T rep j).b) := by + unfold internalLineProbability + simp only [ite_true, ← Nat.card_eq_fintype_card] + apply congrArg (fun k : ℕ => (k : ℝ) / Nat.card (ZMod (value rep) × (ZMod (value rep))ˣ)) + exact Nat.card_congr (Equiv.subtypeEquivRight + (fun z : ZMod (value rep) × (ZMod (value rep))ˣ => + movingPrimeLineSystem_representative_iff value T rep hunique z.1 z.2)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRepresentativeSquares.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRepresentativeSquares.lean new file mode 100644 index 0000000000000000000000000000000000000000..7fff48703030d9162af1dd9d8338bc952c032087 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRepresentativeSquares.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOccurrenceSquares + +namespace OAI + +/-! # Uniform square-exclusion loss for each sampled representative prime -/ + +namespace Ostmann +open scoped Classical BigOperators + +abbrev MovingRepresentativeOccurrences {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) (rep : σ) := + {j : Fin T.occurrences.length // rep ∈ (T.occurrences.get j).current.compensationSlots} + +/-- Repetition across nodes costs only the actual number of occurrences. -/ +theorem movingRepresentativeOccurrences_card {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) (rep : σ) : + Fintype.card (MovingRepresentativeOccurrences T rep) ≤ 2 ^ n - 1 := by + classical + calc + _ ≤ Fintype.card (Fin T.occurrences.length) := + Fintype.card_le_of_injective Subtype.val Subtype.val_injective + _ = _ := by rw [Fintype.card_fin, T.occurrences_length] + +/-- All unit and nonzero-row requirements for a representative's lift count +follow from the sampled prime types, not from an assumed line system. -/ +theorem moving_representative_square_loss {σ : Type*} (tier : σ → ℕ) + (value : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + {n : ℕ} (T : MovingSlotData σ n) (hlevels : T.Levels tier) (rep : σ) + (hfreq : T.Frequencies (fun s => (s : ZMod (value rep)) ≠ 0)) + (x₀ y₀ : ZMod (value rep)) (hy : y₀ ≠ 0) + (hbase : ∀ j : MovingRepresentativeOccurrences T rep, + let o := T.occurrences.get j.val + let φ := MovingSlotReversal.naturalReduction (value rep) value + φ (movingSlotLine o.path o.current).a * x₀ + + φ (movingSlotLine o.path o.current).b * y₀ = 0) + (F : SquareLiftPairs (value rep) x₀ y₀ → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hF : ∀ v, ‖F v‖ ≤ B) : + let _ : Fact (value rep).Prime := ⟨hprime rep⟩ + let φ := MovingSlotReversal.naturalReduction (value rep ^ 2) value + ‖∑ v ∈ Finset.univ.filter (fun v : SquareLiftPairs (value rep) x₀ y₀ => + ∃ j : MovingRepresentativeOccurrences T rep, + let o := T.occurrences.get j.val + φ (movingSlotLine o.path o.current).a * v.1.1 + + φ (movingSlotLine o.path o.current).b * v.2.1 = 0), F v‖ / (value rep : ℝ) ^ 2 ≤ + B * (2 ^ n - 1 : ℕ) / value rep := by + classical + let : Fact (value rep).Prime := ⟨hprime rep⟩ + let path := fun j : MovingRepresentativeOccurrences T rep => (T.occurrences.get j.val).path + let current := fun j : MovingRepresentativeOccurrences T rep => (T.occurrences.get j.val).current + have hu (j : MovingRepresentativeOccurrences T rep) := + T.occurrence_units_of_prime_types tier value hprime hdisjoint hlevels + (T.occurrences.get j.val) (List.get_mem _ _ ) rep + (T.occurrence_compensation_level tier hlevels _ (List.get_mem _ _) rep j.property) hfreq + have hb := movingSlotLines_square_loss value path current + (fun j s hs => (hu j).1 s hs) (fun j => (hu j).2) x₀ y₀ hy hbase F B hB hF + refine hb.trans ?_ + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + apply mul_le_mul_of_nonneg_left _ hB + exact_mod_cast movingRepresentativeOccurrences_card T rep + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingResidueFactorization.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingResidueFactorization.lean new file mode 100644 index 0000000000000000000000000000000000000000..8698a11e04a85ad5bdfd2a0ef61d36f1010de645 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingResidueFactorization.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRealResidues +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSignedSpectator +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportWeight + +namespace OAI + +/-! # Fixed residue factors separated from the real moving support -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingResidueFlag (nodes : List MovingFormulaNode) (a : Bool → ℤ) : ℂ := + if movingResidueGate nodes a then 1 else 0 + +noncomputable def movingArchimedeanFlag (nodes : List MovingFormulaNode) (x : Bool → ℝ) : ℂ := + if movingArchimedeanGate nodes x then 1 else 0 + +noncomputable def movingSpectatorResidue {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (g : ∀ i, ZMod (q i) → ℂ) + (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) {n : ℕ} (T : MovingSlotData σ n) + (a b : ℤ) : ℂ := ∏ i ∈ S, movingSignedSpectator value (g i) (D i) T a b + +theorem movingArithmeticIndicator_residue_real {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XL XR a b M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + movingArithmeticIndicator value childBound pivotBound T XL XR = + movingResidueFlag nodes (topGiantInput a b) * movingArchimedeanFlag nodes (topGiantReal XL XR) := by + dsimp only + have h := movingArithmeticSupport_residue_real value hvalue childBound pivotBound T hf XL XR a b M hM hL hR + unfold movingArithmeticIndicator movingResidueFlag movingArchimedeanFlag + by_cases hr : movingResidueGate + (T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true)) (topGiantInput a b) <;> + by_cases ha : movingArchimedeanGate + (T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true)) (topGiantReal XL XR) <;> + simp only [h, hr, ha, and_self, and_false, false_and, ite_true, ite_false, mul_one, mul_zero] + +/-- On a fixed top residue pair the original spectator coefficient is a +fixed signed-residue value. The only remaining variable gate is real. -/ +theorem moving_arithmetic_spectator_residue_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (g : ∀ i, ZMod (q i) → ℂ) + (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (XL XR a b M : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + movingArithmeticIndicator value childBound pivotBound T XL XR * + (∏ i ∈ S, movingSlotSpectator value (g i) (D i) T XL XR) = + (movingResidueFlag nodes (topGiantInput a b) * movingArchimedeanFlag nodes (topGiantReal XL XR)) * + movingSpectatorResidue q value g D S T a b := by + dsimp only + have hflag := movingArithmeticIndicator_residue_real value hvalue childBound pivotBound T hf XL XR a b M hM hL hR + by_cases hs : T.ArithmeticSupport value childBound pivotBound XL XR + · have hI := hs.integral value hvalue childBound pivotBound T XL XR + have hspec : (∏ i ∈ S, movingSlotSpectator value (g i) (D i) T XL XR) = + movingSpectatorResidue q value g D S T a b := by + apply Finset.prod_congr rfl + intro i hi + exact movingSlotSpectator_eq_residue value hvalue (g i) (D i) T hf XL XR a b M hI (hMq i hi) hL hR + rw [hspec, hflag] + · have hz : movingArithmeticIndicator value childBound pivotBound T XL XR = 0 := + ite_eq_right hs + rw [hz, zero_mul, ← hflag, hz, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingResidueTests.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingResidueTests.lean new file mode 100644 index 0000000000000000000000000000000000000000..b79a76a272c9852a884658d2e5a07aa209961501 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingResidueTests.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticSupport + +namespace OAI + +/-! # Three explicit residue tests at each original moving node -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def MovingFormulaNode.testFormulas (f : MovingFormulaNode) : Fin 3 → HistoryFormula Bool := + ![f.guard.pivot, f.guard.rightProduct, f.newGiant] + +def MovingFormulaNode.testModuli (f : MovingFormulaNode) : Fin 3 → ℕ := + ![f.guard.right.natAbs, f.guard.root.natAbs, 1] + +noncomputable def MovingFormulaNode.residueTests (f : MovingFormulaNode) (a : Bool → ℤ) : Prop := + ∀ j, smallDivisionTest + (MvPolynomial.eval₂Hom (RingHom.id ℤ) a (f.testFormulas j).cleared.numerator) + (f.testFormulas j).cleared.denominator (f.testModuli j) + +theorem formula_integral_small_test (F : HistoryFormula Bool) (a : Bool → ℤ) : + F.IntegralAt a ↔ smallDivisionTest + (MvPolynomial.eval₂Hom (RingHom.id ℤ) a F.cleared.numerator) F.cleared.denominator 1 := by + rw [F.integralAt_iff] + have hu (z : ℤ) : IsUnit (z : ZMod 1) := by + rw [Subsingleton.elim (z : ZMod 1) 1] + exact isUnit_one + simp only [smallDivisionTest, hu, and_true] + +theorem MovingFormulaNode.residueTests_iff (f : MovingFormulaNode) (a : Bool → ℤ) : + f.residueTests a ↔ f.guard.residueAt a ∧ f.newGiant.IntegralAt a := by + simp only [residueTests, testFormulas, testModuli, Fin.forall_fin_succ, + Matrix.cons_val_zero, Matrix.cons_val_succ, Matrix.cons_val_fin_one, + Fin.forall_fin_zero, and_true, WordTransferGuard.residueAt, ← formula_integral_small_test, + and_assoc] + +/-- The actual common period is built from the cleared formula denominators +and the two retained frequency moduli. -/ +noncomputable def MovingFormulaNode.residuePeriod (f : MovingFormulaNode) : ℕ := + ∏ j : Fin 3, (f.testFormulas j).cleared.denominator.natAbs * f.testModuli j + +theorem MovingFormulaNode.residuePeriod_pos (f : MovingFormulaNode) + (hw : f.guard.right ≠ 0) (hs : f.guard.root ≠ 0) : 0 < f.residuePeriod := by + apply Finset.prod_pos + intro j _ + apply Nat.mul_pos (Int.natAbs_pos.mpr (f.testFormulas j).cleared.denominator_ne_zero) + fin_cases j + · exact Int.natAbs_pos.mpr hw + · exact Int.natAbs_pos.mpr hs + · exact Nat.zero_lt_one + +theorem MovingFormulaNode.test_period_dvd (f : MovingFormulaNode) (j : Fin 3) : + (f.testFormulas j).cleared.denominator * (f.testModuli j : ℤ) ∣ (f.residuePeriod : ℤ) := by + apply Int.dvd_natCast.mpr + simp only [Int.natAbs_mul, Int.natAbs_natCast] + exact Finset.dvd_prod_of_mem (fun j : Fin 3 => + (f.testFormulas j).cleared.denominator.natAbs * f.testModuli j) (Finset.mem_univ j) + +/-- All three tests are constant on the constructed residue classes. -/ +theorem MovingFormulaNode.residueTests_modEq (f : MovingFormulaNode) + (a b : Bool → ℤ) (h : ∀ i, a i ≡ b i [ZMOD f.residuePeriod]) : + f.residueTests a ↔ f.residueTests b := by + apply forall_congr' + intro j + exact cleared_history_test_residue_invariant (f.testFormulas j).cleared.numerator + a b f.residuePeriod (f.testFormulas j).cleared.denominator (f.testModuli j) + (f.testFormulas j).cleared.denominator_ne_zero (f.test_period_dvd j) h + +noncomputable def movingGiantUpdate (a : Bool → ℤ) (coord : Bool) (z : ℤ) : Bool → ℤ := + @Function.update Bool (fun _ => ℤ) (fun x y => Classical.propDecidable (x = y)) a coord z + +/-- At a fixed residue class, the remaining arithmetic support uses only +three explicit polynomial inequalities and fixed frequency bounds. -/ +theorem MovingFormulaNode.holds_polynomials (f : MovingFormulaNode) + (a : Bool → ℤ) (coord : Bool) (z : ℤ) : + (f.guard.ValidAt (movingGiantUpdate a coord z) ∧ f.newGiant.IntegralAt (movingGiantUpdate a coord z)) ↔ + f.residueTests (movingGiantUpdate a coord z) ∧ f.guard.frequencyBounds ∧ + ∀ j, 0 ≤ (f.guard.polynomials a coord j).eval (z : ℝ) := by + rw [residueTests_iff] + have hg := f.guard.validAt_polynomials a coord z + change (f.guard.ValidAt _ ∧ _) ↔ _ + rw [show f.guard.ValidAt (movingGiantUpdate a coord z) ↔ + f.guard.residueAt (movingGiantUpdate a coord z) ∧ f.guard.frequencyBounds ∧ + ∀ j, 0 ≤ (f.guard.polynomials a coord j).eval (z : ℝ) from hg] + tauto + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..6d86fa9bb5d4be2c645c9c07984b08108699322d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredEnergy.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredMultiplier +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateAmplitudeRestore +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateSupport + +namespace OAI + +/-! # The unchanged restored prior and the masked one-branch energy -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Real-valued finite Fubini in exactly the restored template coordinates. -/ +theorem movingReverseTemplate_average_real {A : Type*} [Fintype A] (n r m : ℕ) + (ν : MovingRegularSlot n (4 + r) m → A → ℝ) + (F : (MovingRegularSlot n (4 + r) m → A) → ℝ) : + (∑ x, (∏ i, ν i (x i)) * F x) = + ∑ u : TreeLeafIndex n × Fin 4 → A, + (∏ i, ν (movingReverseTemplate n r m (.inl i)) (u i)) * + ∑ y : MovingRegularSlot n r m → A, + (∏ i, ν (movingReverseTemplate n r m (.inr i)) (y i)) * + F (movingRestoreSample n r m u y) := by + have h := movingReverseTemplate_average n r m ν (fun x => (F x : ℂ)) + exact_mod_cast h + +/-- Restoring slots changes neither the compensation law nor the surviving law. -/ +theorem movingTemplateRestoredPrior_average_real {A : Type} [Fintype A] (n r m : ℕ) + (μ : A → ℝ) (ν : MovingRegularSlot n r m → A → ℝ) + (F : (MovingRegularSlot n (4 + r) m → A) → ℝ) : + (∑ x, (∏ i, movingTemplateRestoredPrior n r m μ ν i (x i)) * F x) = + ∑ u : TreeLeafIndex n × Fin 4 → A, (∏ i, μ (u i)) * + ∑ y : MovingRegularSlot n r m → A, (∏ i, ν i (y i)) * + F (movingRestoreSample n r m u y) := by + simpa only [movingTemplateRestoredPrior, Equiv.symm_apply_apply, + Sum.elim_inl, Sum.elim_inr] using + movingReverseTemplate_average_real n r m (movingTemplateRestoredPrior n r m μ ν) F + +/-- The actual coefficient supplies the distinctness needed to replace its +masked arithmetic multiplier by the surviving prime-product transform. -/ +theorem movingTemplateCoefficient_restored_multiplier {A : Type} [Fintype A] + (value : A → ℕ) (hprime : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → A → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState A → ℤ → ℂ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n r m : ℕ) (s : ℤ) (u : TreeLeafIndex n × Fin 4 → A) + (y : MovingRegularSlot n r m → A) (XL XR : ℕ) (g : ∀ q : ℕ, ZMod q → ℂ) : + let x := movingRestoreSample n r m u y + let _ : ∀ i, Fact ((value ∘ x) i).Prime := fun i => ⟨hprime (x i)⟩ + let C := movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m s x XL XR + ‖C‖ ^ 2 * naturalRegularMultiplier (value ∘ x) (movingRestoredActive n r m) s + (fun i => ((outside.prod * tupleCofactor (value ∘ x) i : ℕ) : ZMod ((value ∘ x) i))) + (fun i => g (value (x i))) XL XR = + ‖C * primeProductTransform g (outside.prod * XL * XR * ∏ i, value (u i)) + (∏ i, value (y i)) s‖ ^ 2 := by + intro x inst C + by_cases hC : C = 0 + · simp only [hC, norm_zero, zero_pow (by norm_num : 2 ≠ 0), zero_mul] + have hi := movingTemplateCoefficient_nonzero_injective value outside μ childBound + pivotBound V F φ G n (4 + r) m s x XL XR (fun i => hprime (x i)) hC + have hx (i : MovingRegularSlot n r m) : + x (movingReverseTemplate n r m (.inr i)) = y i := by + simp only [x, movingRestoreSample, Function.comp_apply, Equiv.symm_apply_apply, + Sum.elim_inr] + have hy : Function.Injective (value ∘ y) := by + intro i j hij + apply Sum.inr.inj + apply (movingReverseTemplate n r m).injective + apply hi + simpa only [Function.comp_apply, hx] using hij + have he := naturalRegularMultiplier_restored_primeProduct value hprime n r m u y hy + g outside.prod XL XR s + change naturalRegularMultiplier (value ∘ x) (movingRestoredActive n r m) s _ _ XL XR = _ at he + rw [he, norm_mul, mul_pow] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredHarmonicCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredHarmonicCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..440702e2a8a57ac55f79a243b467bd0f0ecfc249 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredHarmonicCost.lean @@ -0,0 +1,37 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredLogProduct +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicCounterpart + +namespace OAI + +/-! # The harmonic counterpart cost on the original restored support -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTemplate_restored_harmonic_cost_le {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (hvalue : ∀ a, 0 < value a) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (y : MovingRegularSlot n r m → σ) (hn : n < k) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (XL XR : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) (cg Gmin : ℝ) + (hX : Real.exp Gmin ≤ (XR : ℝ)) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n (4 + r) m s (movingRestoreSample n r m u y) XL XR ≠ 0) : + (Real.exp cg / XR) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, value (y i) : ℕ) : ℝ)⁻¹ ≤ + Real.exp (cg - Gmin - (2 ^ n : ℕ) * (cb - 1)) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) := by + exact moving_harmonic_counterpart_le n r m Q cg Gmin cb XR (value ∘ y) hX + (movingTemplateCoefficient_restored_log_product_lower value tier hvalue k outside cb cd μ hμ + childBound pivotBound V F φ G n r m s u hu y hn hsmall hbulk XL XR h) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredLogProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredLogProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea347e2f80e68ff29915a3f193ac0f4d0590c80f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredLogProduct.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogProduct + +namespace OAI + +/-! # The bulk lower cutoff survives restoration of compensation coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Restoring the independent compensation draw does not charge its product +to the lower bound for the surviving regular modulus. -/ +theorem movingTemplateCoefficient_restored_log_product_lower {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (hvalue : ∀ a, 0 < value a) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (y : MovingRegularSlot n r m → σ) (hn : n < k) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (XL XR : ℕ) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n (4 + r) m s (movingRestoreSample n r m u y) XL XR ≠ 0) : + Real.exp ((2 ^ n : ℕ) * (cb - 1)) ≤ ((∏ i, value (y i) : ℕ) : ℝ) := by + have hut i : tier (u i) = n := + hμ n (u i) ((Finset.prod_ne_zero_iff.mp hu) i (Finset.mem_univ i)) + have hs : ∀ j : TreeLeafIndex n × Fin (4 + r), + tier (movingRestoreSample n r m u y (j.1, .inl j.2)) ≠ k := by + rintro ⟨j, i⟩ + refine Fin.addCases (fun i => ?_) (fun i => ?_) i + · dsimp only + rw [movingRestoreSample_compensation n r m u y (j, i), hut] + exact hn.ne + · dsimp only + rw [movingRestoreSample_small] + exact hsmall (j, i) + have hb : ∀ j : TreeLeafIndex n × Fin m, + tier (movingRestoreSample n r m u y (j.1, .inr j.2)) = k := by + intro j + change tier (movingRestoreSample n r m u y (movingTemplateBulk n (4 + r) m j)) = k + rw [movingRestoreSample_bulk] + exact hbulk j + have hlow := movingTemplateCoefficient_bulk_log_product_lower value tier hvalue k outside cb cd + μ hμ childBound pivotBound V F φ G n (4 + r) m s (movingRestoreSample n r m u y) + hn.le hs hb XL XR h + have heq : (∏ j : TreeLeafIndex n × Fin m, + value (movingRestoreSample n r m u y (j.1, .inr j.2))) = + ∏ j : TreeLeafIndex n × Fin m, value (y (j.1, .inr j.2)) := by + apply Finset.prod_congr rfl + intro j _ + change value (movingRestoreSample n r m u y (movingTemplateBulk n (4 + r) m j)) = _ + rw [movingRestoreSample_bulk] + rfl + rw [heq] at hlow + apply hlow.trans + have hsmallprod : 1 ≤ ∏ j : TreeLeafIndex n × Fin r, value (y (j.1, .inl j.2)) := + Finset.one_le_prod (fun j _ => hvalue _) + have he : (∏ i, value (y i)) = + (∏ j : TreeLeafIndex n × Fin r, value (y (j.1, .inl j.2))) * + (∏ j : TreeLeafIndex n × Fin m, value (y (j.1, .inr j.2))) := by + simp only [MovingRegularSlot, Fintype.prod_prod_type, Fintype.prod_sum_type, + Finset.prod_mul_distrib] + rw [he] + exact_mod_cast le_mul_of_one_le_left (Nat.zero_le _) hsmallprod + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredMultiplier.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredMultiplier.lean new file mode 100644 index 0000000000000000000000000000000000000000..8b6b6730ff892af188b8d14be3d465f96253fc51 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredMultiplier.lean @@ -0,0 +1,140 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularMultiplierIdentity +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTransferSlots + +namespace OAI + +/-! # The surviving Fourier factors in the restored compensation coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The extracted compensation primes retain their places in every cofactor, +but the Cauchy step leaves no Fourier factor at those places. -/ +def movingRestoredActive (n r m : ℕ) : MovingRegularSlot n (4 + r) m → Bool := + Sum.elim (fun _ => false) (fun _ => true) ∘ (movingReverseTemplate n r m).symm + +@[simp] theorem movingRestoredActive_compensation (n r m : ℕ) + (i : TreeLeafIndex n × Fin 4) : + movingRestoredActive n r m (movingReverseTemplate n r m (.inl i)) = false := by + simp only [movingRestoredActive, Function.comp_apply, Equiv.symm_apply_apply, Sum.elim_inl] + +@[simp] theorem movingRestoredActive_surviving (n r m : ℕ) + (i : MovingRegularSlot n r m) : + movingRestoredActive n r m (movingReverseTemplate n r m (.inr i)) = true := by + simp only [movingRestoredActive, Function.comp_apply, Equiv.symm_apply_apply, Sum.elim_inr] + +/-- In particular every protected bulk coordinate remains active. -/ +@[simp] theorem movingRestoredActive_bulk (n r m : ℕ) (i : TreeLeafIndex n × Fin m) : + movingRestoredActive n r m (movingTemplateBulk n (4 + r) m i) = true := by + rw [← movingReverseTemplate_bulk, movingRestoredActive_surviving] + +theorem movingRestoredActive_inactive_not_bulk (n r m : ℕ) + (i : MovingRegularSlot n (4 + r) m) (hi : movingRestoredActive n r m i = false) : + i ∉ Set.range (movingTemplateBulk n (4 + r) m) := by + rintro ⟨j, rfl⟩ + simp only [movingRestoredActive_bulk, Bool.true_eq_false] at hi + +/-- The restored masked transform is exactly the surviving transform, with +the same sampled compensation product in its outside denominator. -/ +theorem movingRegularTransform_restored_active {A : Type*} (value : A → ℕ) + (hprime : ∀ a, (value a).Prime) (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) + (g : ∀ q : ℕ, ZMod q → ℂ) (D : ℕ) (s : ℤ) : + let x := movingRestoreSample n r m u y + let _ : ∀ i, NeZero ((value ∘ x) i) := fun i => ⟨(hprime (x i)).ne_zero⟩ + let _ : ∀ i, NeZero ((value ∘ y) i) := fun i => ⟨(hprime (y i)).ne_zero⟩ + movingRegularTransform (value ∘ x) + (fun i z => if movingRestoredActive n r m i then g (value (x i)) z else 1) D s = + movingRegularTransform (value ∘ y) (fun i => g (value (y i))) + (D * ∏ i, value (u i)) s := by + dsimp only + let x := movingRestoreSample n r m u y + let p := value ∘ x + let _ : ∀ i, NeZero (p i) := fun i => ⟨(hprime (x i)).ne_zero⟩ + let _ : ∀ i, Fact (value (u i)).Prime := fun _ => ⟨hprime _⟩ + let _ : ∀ i, Fact (value (y i)).Prime := fun _ => ⟨hprime _⟩ + have he := movingRegularTransform_equiv (movingReverseTemplate n r m) p + (fun i z => if movingRestoredActive n r m i then g (p i) z else 1) D s + dsimp only at he + apply he.symm.trans + have hp : (fun i => p (movingReverseTemplate n r m i)) = + Sum.elim (value ∘ u) (value ∘ y) := by + funext i + simp only [p, x, Function.comp_apply, movingRestoreSample, Equiv.symm_apply_apply] + cases i <;> rfl + -- Reindexing the cofactor product directly avoids transporting dependent functions. + unfold movingRegularTransform + rw [Fintype.prod_sum_type] + have hu : (∏ i : TreeLeafIndex n × Fin 4, + (if movingRestoredActive n r m (movingReverseTemplate n r m (.inl i)) then + g (p (movingReverseTemplate n r m (.inl i))) + ((s : ZMod (p (movingReverseTemplate n r m (.inl i)))) * + ((D * tupleCofactor (fun j => p (movingReverseTemplate n r m j)) (.inl i) : ℕ) : + ZMod (p (movingReverseTemplate n r m (.inl i))))⁻¹) + else 1)) = 1 := by simp only [movingRestoredActive_compensation, Bool.false_eq_true, + ite_false, Finset.prod_const_one] + rw [hu, one_mul] + apply Finset.prod_congr rfl + intro i _ + simp only [movingRestoredActive_surviving, ite_true] + have hc : tupleCofactor (fun j => p (movingReverseTemplate n r m j)) (.inr i) = + (∏ j, value (u j)) * tupleCofactor (value ∘ y) i := by + rw [hp, tupleCofactor_sum_right (value ∘ u) (value ∘ y) i (hprime (y i)).ne_zero] + rfl + rw [hc] + let T (a : A) (M : ℕ) : ℂ := + g (value a) ((s : ZMod (value a)) * (M : ZMod (value a))⁻¹) + change T (Sum.elim u y ((movingReverseTemplate n r m).symm + (movingReverseTemplate n r m (.inr i)))) + (D * ((∏ j, value (u j)) * tupleCofactor (value ∘ y) i)) = + T (y i) ((D * ∏ j, value (u j)) * tupleCofactor (value ∘ y) i) + rw [Equiv.symm_apply_apply] + congr 1 + ac_rfl + +/-- The arithmetic multiplier with inactive compensation slots gives the +same surviving transform, retaining every compensation prime in its denominator. -/ +theorem naturalRegularMultiplier_restored_active {A : Type*} (value : A → ℕ) + (hprime : ∀ a, (value a).Prime) (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) + (g : ∀ q : ℕ, ZMod q → ℂ) (D XL XR : ℕ) (s : ℤ) : + let x := movingRestoreSample n r m u y + let _ : ∀ i, Fact ((value ∘ x) i).Prime := fun i => ⟨hprime (x i)⟩ + let _ : ∀ i, Fact ((value ∘ y) i).Prime := fun i => ⟨hprime (y i)⟩ + naturalRegularMultiplier (value ∘ x) (movingRestoredActive n r m) s + (fun i => ((D * tupleCofactor (value ∘ x) i : ℕ) : ZMod ((value ∘ x) i))) + (fun i => g (value (x i))) XL XR = + ‖movingRegularTransform (value ∘ y) (fun i => g (value (y i))) + (D * XL * XR * ∏ i, value (u i)) s‖ ^ 2 := by + dsimp only + let _ : ∀ i, Fact ((value ∘ movingRestoreSample n r m u y) i).Prime := + fun i => ⟨hprime _⟩ + let _ : ∀ i, Fact ((value ∘ y) i).Prime := fun i => ⟨hprime _⟩ + rw [naturalRegularMultiplier_eq_transform_norm] + exact congrArg (fun z : ℂ => ‖z‖ ^ 2) + (movingRegularTransform_restored_active value hprime n r m u y g (D * XL * XR) s) + +/-- Distinct surviving primes put the same identity in product coordinates. -/ +theorem naturalRegularMultiplier_restored_primeProduct {A : Type*} (value : A → ℕ) + (hprime : ∀ a, (value a).Prime) (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) + (hy : Function.Injective (value ∘ y)) + (g : ∀ q : ℕ, ZMod q → ℂ) (D XL XR : ℕ) (s : ℤ) : + let x := movingRestoreSample n r m u y + let _ : ∀ i, Fact ((value ∘ x) i).Prime := fun i => ⟨hprime (x i)⟩ + naturalRegularMultiplier (value ∘ x) (movingRestoredActive n r m) s + (fun i => ((D * tupleCofactor (value ∘ x) i : ℕ) : ZMod ((value ∘ x) i))) + (fun i => g (value (x i))) XL XR = + ‖primeProductTransform g (D * XL * XR * ∏ i, value (u i)) (∏ i, value (y i)) s‖ ^ 2 := by + dsimp only + let _ : ∀ i, Fact ((value ∘ movingRestoreSample n r m u y) i).Prime := + fun i => ⟨hprime _⟩ + let _ : ∀ i, Fact ((value ∘ y) i).Prime := fun i => ⟨hprime _⟩ + rw [naturalRegularMultiplier_restored_active value hprime] + simpa only [Function.comp_def] using congrArg (fun z : ℂ => ‖z‖ ^ 2) + (movingRegularTransform_eq_primeProduct (value ∘ y) hy g + (D * XL * XR * ∏ i, value (u i)) s) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredPrimeLaws.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredPrimeLaws.lean new file mode 100644 index 0000000000000000000000000000000000000000..9c82c4810a85259e5613f2a1a3d2d46f6d135dc0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredPrimeLaws.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateAmplitudeRestore +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredMultiplier + +namespace OAI + +/-! # The original prime sets and tiers in restored coordinates -/ + +namespace Ostmann +open scoped Classical + +noncomputable def movingRestoredPrimeSets (n r m : ℕ) (Qμ : Finset ℕ) + (Qν : MovingRegularSlot n r m → Finset ℕ) : MovingRegularSlot n (4 + r) m → Finset ℕ := + fun i => Sum.elim (fun _ => Qμ) Qν ((movingReverseTemplate n r m).symm i) + +noncomputable def movingRestoredTiers (n r m : ℕ) + (tier : MovingRegularSlot n r m → ℕ) : MovingRegularSlot n (4 + r) m → ℕ := + fun i => Sum.elim (fun _ => n) tier ((movingReverseTemplate n r m).symm i) + +@[simp] theorem movingRestoredPrimeSets_compensation (n r m : ℕ) (Qμ : Finset ℕ) + (Qν : MovingRegularSlot n r m → Finset ℕ) (i : TreeLeafIndex n × Fin 4) : + movingRestoredPrimeSets n r m Qμ Qν (movingReverseTemplate n r m (.inl i)) = Qμ := by + simp only [movingRestoredPrimeSets, Equiv.symm_apply_apply, Sum.elim_inl] + +@[simp] theorem movingRestoredPrimeSets_surviving (n r m : ℕ) (Qμ : Finset ℕ) + (Qν : MovingRegularSlot n r m → Finset ℕ) (i : MovingRegularSlot n r m) : + movingRestoredPrimeSets n r m Qμ Qν (movingReverseTemplate n r m (.inr i)) = Qν i := by + simp only [movingRestoredPrimeSets, Equiv.symm_apply_apply, Sum.elim_inr] + +@[simp] theorem movingRestoredPrimeSets_bulk (n r m : ℕ) (Qμ : Finset ℕ) + (Qν : MovingRegularSlot n r m → Finset ℕ) (i : TreeLeafIndex n × Fin m) : + movingRestoredPrimeSets n r m Qμ Qν (movingTemplateBulk n (4 + r) m i) = + Qν (movingTemplateBulk n r m i) := by + rw [← movingReverseTemplate_bulk, movingRestoredPrimeSets_surviving] + +theorem movingRestoredPrimeSets_prior (P : Finset ℕ) (n r m : ℕ) (Qμ : Finset ℕ) + (Qν : MovingRegularSlot n r m → Finset ℕ) : + (fun i => primeSubsetPrior P (movingRestoredPrimeSets n r m Qμ Qν i)) = + movingTemplateRestoredPrior n r m (primeSubsetPrior P Qμ) (fun i => primeSubsetPrior P (Qν i)) := by + funext i a + unfold movingTemplateRestoredPrior movingRestoredPrimeSets + cases (movingReverseTemplate n r m).symm i <;> rfl + +theorem movingRestoredTiers_lower (n r m : ℕ) (tier : MovingRegularSlot n r m → ℕ) + (h : ∀ i, n ≤ tier i) : ∀ i, n ≤ movingRestoredTiers n r m tier i := by + intro i + unfold movingRestoredTiers + cases (movingReverseTemplate n r m).symm i with + | inl _ => exact le_rfl + | inr j => exact h j + +theorem movingRestoredPrimeSets_tier (P : Finset ℕ) (n r m : ℕ) (Qμ : Finset ℕ) + (Qν : MovingRegularSlot n r m → Finset ℕ) + (tier : MovingRegularSlot n r m → ℕ) (t : P → ℕ) + (hμ : ∀ q : P, (q : ℕ) ∈ Qμ → t q = n) + (hν : ∀ i (q : P), (q : ℕ) ∈ Qν i → t q = tier i) : + ∀ i (q : P), (q : ℕ) ∈ movingRestoredPrimeSets n r m Qμ Qν i → + t q = movingRestoredTiers n r m tier i := by + intro i q + unfold movingRestoredPrimeSets movingRestoredTiers + cases (movingReverseTemplate n r m).symm i with + | inl _ => exact hμ q + | inr j => exact hν j q + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredTierSeparation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredTierSeparation.lean new file mode 100644 index 0000000000000000000000000000000000000000..22394acf66069d0cc6305afdeab2c6ba7718e5b8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRestoredTierSeparation.lean @@ -0,0 +1,44 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredPrimeLaws + +namespace OAI + +/-! # Restoration preserves the terminal-tier separation -/ + +namespace Ostmann +open scoped Classical + +@[simp] theorem movingRestoredTiers_compensation (n r m : ℕ) + (tier : MovingRegularSlot n r m → ℕ) (i : TreeLeafIndex n × Fin 4) : + movingRestoredTiers n r m tier (movingReverseTemplate n r m (.inl i)) = n := by + simp only [movingRestoredTiers, Equiv.symm_apply_apply, Sum.elim_inl] + +@[simp] theorem movingRestoredTiers_surviving (n r m : ℕ) + (tier : MovingRegularSlot n r m → ℕ) (i : MovingRegularSlot n r m) : + movingRestoredTiers n r m tier (movingReverseTemplate n r m (.inr i)) = tier i := by + simp only [movingRestoredTiers, Equiv.symm_apply_apply, Sum.elim_inr] + +theorem movingRestoredTiers_small (n r m k : ℕ) (hn : n ≠ k) + (tier : MovingRegularSlot n r m → ℕ) + (h : ∀ j : TreeLeafIndex n × Fin r, tier (j.1, .inl j.2) ≠ k) : + ∀ j : TreeLeafIndex n × Fin (4 + r), + movingRestoredTiers n r m tier (j.1, .inl j.2) ≠ k := by + rintro ⟨j, i⟩ + refine Fin.addCases (fun a => ?_) (fun b => ?_) i + · change movingRestoredTiers n r m tier + (movingReverseTemplate n r m (.inl (j, a))) ≠ k + simpa only [movingRestoredTiers_compensation] using hn + · change movingRestoredTiers n r m tier + (movingReverseTemplate n r m (.inr (j, .inl b))) ≠ k + simpa only [movingRestoredTiers_surviving] using h (j, b) + +theorem movingRestoredTiers_bulk (n r m k : ℕ) + (tier : MovingRegularSlot n r m → ℕ) + (h : ∀ j, tier (movingTemplateBulk n r m j) = k) : + ∀ j, movingRestoredTiers n r m tier (movingTemplateBulk n (4 + r) m j) = k := by + intro j + rw [← movingReverseTemplate_bulk, movingRestoredTiers_surviving] + exact h j + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRootBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRootBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..4759dbf062d21ca26fe0ca65f46ce12c840b95c6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRootBudget.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTopCells + +namespace OAI + +/-! # Finite root budgets for the exact moving arithmetic support -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingNodeGuard_cost (CL CR : ℕ) (s v w : ℤ) (hs : s ≠ 0) + (childBound pivotBound : ℕ) (L R : HistoryFormula Bool) : + (movingNodeGuard CL CR s v w hs childBound pivotBound L R).pivot.cost = L.cost + R.cost + 6 ∧ + (movingNodeGuard CL CR s v w hs childBound pivotBound L R).rightProduct.cost = R.cost + 2 := by + simp [movingNodeGuard, wordTransferGuard, wordTransferStep, movingNodeWord, + HistoryPivotStep.formula, HistoryFormula.bind, HistoryFormula.listProduct, HistoryFormula.cost] + omega + +theorem MovingSlotData.formulaNodes_cost {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (L R : HistoryFormula Bool) + (D : ℕ) (hL : L.cost ≤ D) (hR : R.cost ≤ D) : + ∀ f ∈ T.formulaNodes value hvalue childBound pivotBound hf L R, + max f.guard.pivot.cost f.guard.rightProduct.cost ≤ 2 ^ n * (D + 6) := by + induction T generalizing L R D with + | leaf => simp [formulaNodes] + | @node n s CL CR u left right ihL ihR => + let step := MovingSlotData.step s CL CR u left right false + let G := step.giantFormula value hf.1 (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) L R + have hG : G.cost ≤ 2 * D + 4 := by + dsimp [G, MovingSlotReversal.giantFormula, HistoryFormula.cost] + omega + have hd : D ≤ 2 * D + 4 := by omega + have hl := ihL hf.2.1 G L (2 * D + 4) hG (hL.trans hd) + have hr := ihR hf.2.2 G R (2 * D + 4) hG (hR.trans hd) + have hp : 1 ≤ 2 ^ n := Nat.one_le_two_pow + have he : 2 ^ n * (2 * D + 4 + 6) ≤ 2 ^ (n + 1) * (D + 6) := by + rw [pow_succ]; nlinarith + intro f hmem + rcases List.mem_cons.mp hmem with h | h + · subst f + have hc := movingNodeGuard_cost (MovingSlotReversal.naturalProduct value CL) + (MovingSlotReversal.naturalProduct value CR) s left.frequency right.frequency hf.1 + (childBound (n + 1)) (pivotBound (n + 1)) L R + apply max_le + · rw [hc.1] + rw [pow_succ] + nlinarith + · rw [hc.2] + rw [pow_succ] + nlinarith + · rcases List.mem_append.mp h with h | h + · exact (hl f h).trans he + · exact (hr f h).trans he + +/-- A uniform explicit bound for the number of real arithmetic cut points. +It is independent of the values of both top giants and of the prime cutoffs. -/ +theorem movingTopRootCuts_card {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR : ℕ) : + (movingTopRootCuts value hvalue childBound pivotBound T hf XR).card ≤ + (2 ^ n - 1) * (3 * (7 * 2 ^ n)) := by + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + have hcost := T.formulaNodes_cost value hvalue childBound pivotBound hf + (.prime false) (.prime true) 1 (by rfl) (by rfl) + have hdegree (f : MovingFormulaNode) (hf : f ∈ nodes) (j : Fin 3) : + (f.guard.polynomials (topGiantInput 0 XR) false j).natDegree ≤ 7 * 2 ^ n := by + apply (f.guard.polynomials_degree _ _ j).trans + simpa only [Nat.reduceAdd, mul_comm] using hcost f hf + apply (movingArithmeticRootCuts_card nodes (topGiantInput 0 XR) false).trans + calc + _ ≤ ∑ _f ∈ nodes.toFinset, 3 * (7 * 2 ^ n) := by + apply Finset.sum_le_sum + intro f hf + calc + _ ≤ ∑ _j : Fin 3, 7 * 2 ^ n := Finset.sum_le_sum (fun j _ => hdegree f (List.mem_toFinset.mp hf) j) + _ = _ := by simp + _ = nodes.toFinset.card * (3 * (7 * 2 ^ n)) := by simp + _ ≤ nodes.length * (3 * (7 * 2 ^ n)) := Nat.mul_le_mul_right _ (List.toFinset_card_le nodes) + _ = _ := by rw [MovingSlotData.formulaNodes_length] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRootReconstruction.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRootReconstruction.lean new file mode 100644 index 0000000000000000000000000000000000000000..49c12841edca173827d774d9341b72c530bffcea --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRootReconstruction.lean @@ -0,0 +1,167 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalSampleExpansion +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeArithmeticTransfer + +namespace OAI + +/-! # The integer substitution is the giant in the original node coefficient -/ + +namespace Ostmann +open scoped Classical + +/-- The composite pivot reconstructed by the history system is the +compensation product times the reconstructed giant. -/ +theorem reconstructedPivot_compensation (I : Finset ℕ) (N s : ℤ) (U : ℕ) + (h : validTransferredPivot I N (s * U)) : + reconstructedPivot N s = reconstructedPivot N (s * U) * U := by + have hs : s ≠ 0 := left_ne_zero_of_mul h.1 + have he := validTransferredPivot_equation I N (s * U) h + apply reconstructedPivot_of_eq N s hs + push_cast + calc + N = (s * U) * reconstructedPivot N (s * U) := he + _ = _ := by ring + +theorem reconstructedGiant_eq_div (I : Finset ℕ) (N s : ℤ) (U : ℕ) + (hU : 0 < U) (h : validTransferredPivot I N (s * U)) : + reconstructedPivot N s / U = reconstructedPivot N (s * U) := by + rw [reconstructedPivot_compensation I N s U h, Nat.mul_div_left _ hU] + +/-- Conversely the original composite-pivot integrality test gives exactly +one positive giant in the retained integer range. -/ +theorem validTransferredGiant_of_composite (I : Finset ℕ) + (N s : ℤ) (P U : ℕ) (hs : s ≠ 0) (hP : 0 < P) (hU : 0 < U) + (hdiv : U ∣ P) (hI : P / U ∈ I) (hrel : N = s * P) : + validTransferredPivot I N (s * U) := by + have he : P / U * U = P := Nat.div_mul_cancel hdiv + have hp : 0 < P / U := by + by_contra hn + have hz : P / U = 0 := Nat.eq_zero_of_not_pos hn + rw [hz, zero_mul] at he + omega + apply validTransferredPivot_of_eq I N (s * U) + (mul_ne_zero hs (by exact_mod_cast hU.ne')) (P / U) hp hI + calc + N = s * (P : ℤ) := hrel + _ = s * (((P / U) * U : ℕ) : ℤ) := by rw [he] + _ = (s * (U : ℤ)) * ((P / U : ℕ) : ℤ) := by rw [Nat.cast_mul]; ring + +/-- The node's original factor is exactly `U φ(log p - G)`, where `p` is +reconstructed from the same signed quotient as the integer off-diagonal. -/ +theorem movingOriginalNode_reconstructed {σ : Type*} + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (x : MovingSlotState σ) (s v w : ℤ) + (hU : 0 < x.compensation value) + (h : validTransferredPivot I + (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) + (s * x.compensation value)) : + movingSlotCutoff value childBound pivotBound + (movingCompensatedExtra value (movingOriginalNode value childBound pivotBound φ G)) + x s v w = + (x.compensation value : ℝ) * φ + (Real.log (reconstructedPivot + (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) + (s * x.compensation value)) - G x.depth) := by + let N := v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ) + let U := x.compensation value + let p := reconstructedPivot N (s * U) + have hP : historyPivot (movingSlotSystem value childBound pivotBound) x s v w = p * U := + reconstructedPivot_compensation I N s U h + have hdiv : U ∣ historyPivot (movingSlotSystem value childBound pivotBound) x s v w := by + rw [hP] + exact dvd_mul_left U p + have hquot : historyPivot (movingSlotSystem value childBound pivotBound) x s v w / U = p := by + rw [hP, Nat.mul_div_left _ hU] + have hp : 0 < (p : ℝ) := by exact_mod_cast hI p h.2.2.2 + unfold movingSlotCutoff + rw [ite_eq_left ⟨hU, hdiv⟩] + change (U : ℝ) * (1 * positiveLogCutoff φ (G x.depth) + (historyPivot (movingSlotSystem value childBound pivotBound) x s v w / U : ℕ)) = _ + rw [hquot, one_mul, positiveLogCutoff, ite_eq_left hp] + +/-- An unconditional node formula in terms of the reconstructed giant. +All original frequency, range, and coprimality tests remain in the guard. -/ +theorem movingSampleRootFactor_reconstructed {σ : Type*} + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) + (t : FrequencyTree ℤ (n + 1)) (CL CR u : List σ) (XL XR : ℕ) : + let x := movingRootState n t CL CR u XL XR + let sys := movingSlotSystem value childBound pivotBound + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let U := x.compensation value + let p := reconstructedPivot (v * (x.rightProduct value : ℤ) - + w * (x.leftProduct value : ℤ)) (t.1 * U) + movingSampleRootFactor value childBound pivotBound + (movingCompensatedExtra value (movingOriginalNode value childBound pivotBound φ G)) + n t CL CR u XL XR = + if ValidTransferNode sys x t.1 v w (p * U) ∧ 0 < U then + ((U : ℝ) * φ (Real.log p - G (n + 1)) : ℂ) else 0 := by + dsimp only + let x := movingRootState n t CL CR u XL XR + let sys := movingSlotSystem value childBound pivotBound + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let U := x.compensation value + let N := v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ) + let p := reconstructedPivot N (t.1 * U) + let P := historyPivot sys x t.1 v w + change (if ValidTransferNode sys x t.1 v w P then + (movingSlotCutoff value childBound pivotBound + (movingCompensatedExtra value (movingOriginalNode value childBound pivotBound φ G)) + x t.1 v w : ℂ) else 0) = + if ValidTransferNode sys x t.1 v w (p * U) ∧ 0 < U then + ((U : ℝ) * φ (Real.log p - G (n + 1)) : ℂ) else 0 + by_cases h : ValidTransferNode sys x t.1 v w (p * U) ∧ 0 < U + · have hP : P = p * U := h.1.historyPivot_eq + have hp : 0 < p := Nat.pos_of_mul_pos_right h.1.pivot_pos + have he : N = (t.1 * (U : ℤ)) * p := by + have hh := h.1.relation + change N = t.1 * ((p * U : ℕ) : ℤ) at hh + rw [Nat.cast_mul] at hh + calc + N = t.1 * ((p : ℤ) * U) := hh + _ = _ := by ring + have hvalid : validTransferredPivot {p} N (t.1 * U) := + validTransferredPivot_of_eq {p} N (t.1 * U) + (mul_ne_zero h.1.root_ne_zero (by exact_mod_cast h.2.ne')) p hp (by simp) he + have hcut := movingOriginalNode_reconstructed value childBound pivotBound φ G + {p} (fun q hq => by simpa only [Finset.mem_singleton.mp hq] using hp) + x t.1 v w h.2 hvalid + rw [ite_eq_left h, hP, ite_eq_left h.1, hcut] + simp only [Complex.ofReal_mul] + rfl + + · rw [ite_eq_right h] + by_cases hv : ValidTransferNode sys x t.1 v w P + · rw [ite_eq_left hv] + have hdiv : ¬(0 < U ∧ U ∣ P) := by + rintro ⟨hU, hd⟩ + have hh := validTransferredGiant_of_composite {P / U} N t.1 P U + hv.root_ne_zero hv.pivot_pos hU hd (by simp) hv.relation + have he : P / U = p := (reconstructedGiant_eq_div {P / U} N t.1 U hU hh) + have hPU : P = p * U := by rw [← he]; exact (Nat.div_mul_cancel hd).symm + exact h ⟨hPU ▸ hv, hU⟩ + change ((if 0 < U ∧ U ∣ P then _ else 0 : ℝ) : ℂ) = 0 + rw [ite_eq_right hdiv, Complex.ofReal_zero] + · rw [ite_eq_right hv] + +/-- The full current-state support guard commutes with root extraction. +Its subtree-frequency unit tests are not discarded by the integer change +of variables. -/ +theorem movingSampleRootFactor_guarded {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) (n : ℕ) + (t : FrequencyTree ℤ (n + 1)) (CL CR u : List σ) (XL XR : ℕ) : + movingSampleRootFactor value childBound pivotBound (movingGuardedExtra value outside E) + n t CL CR u XL XR = + if movingLocalSupport value outside (movingRootState n t CL CR u XL XR) then + movingSampleRootFactor value childBound pivotBound E n t CL CR u XL XR else 0 := by + unfold movingSampleRootFactor + dsimp only + rw [movingSlotCutoff_guarded] + split_ifs <;> rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRootedSum.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRootedSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea3d81918a5505396e587e726e35423af3b7add9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRootedSum.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyCoefficient + +namespace OAI + +/-! # Exact grouping of the two independent child frequency sums -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingRootedFrequencyTree_root (V : ℕ → ℕ) (n : ℕ) (s : ℤ) + (a : MovingDescendantFrequencyIndex V n) : + frequencyRoot n (movingRootedFrequencyTree V n s a) = s := by + cases n <;> rfl + +theorem scheduledFrequencyIndex_sum_split (V : ℕ → ℕ) (n : ℕ) + (f : ScheduledFrequencyIndex V n → ℂ) : + (∑ a, f a) = ∑ s : transferFrequencyRange (V n), + ∑ b : MovingDescendantFrequencyIndex V n, + f ((scheduledFrequencyRootEquiv V n).symm (s, b)) := by + simpa only [Fintype.sum_prod_type] using + ((scheduledFrequencyRootEquiv V n).symm.sum_comp f).symm + +theorem scheduledFrequencyHistory_from_root (V : ℕ → ℕ) (n : ℕ) + (s : transferFrequencyRange (V n)) (a : MovingDescendantFrequencyIndex V n) : + scheduledFrequencyHistory V n ((scheduledFrequencyRootEquiv V n).symm (s, a)) = + movingRootedFrequencyTree V n s.val a := by + rw [scheduledFrequencyRootEquiv_history, Equiv.apply_symm_apply] + +/-- The two histories are independent after their roots are fixed. No number +of histories occurs in this exact distributive identity. The child functions +may depend on both roots through the reconstructed pivot. -/ +theorem scheduledFrequency_bilinear_sum (V : ℕ → ℕ) (n : ℕ) + (W : ℤ → ℤ → ℂ) + (L R : ℤ → ℤ → FrequencyTree ℤ n → ℂ) : + (∑ l : ScheduledFrequencyIndex V n, ∑ r : ScheduledFrequencyIndex V n, + W (frequencyRoot n (scheduledFrequencyHistory V n l)) + (frequencyRoot n (scheduledFrequencyHistory V n r)) * + L (frequencyRoot n (scheduledFrequencyHistory V n l)) + (frequencyRoot n (scheduledFrequencyHistory V n r)) (scheduledFrequencyHistory V n l) * + star (R (frequencyRoot n (scheduledFrequencyHistory V n l)) + (frequencyRoot n (scheduledFrequencyHistory V n r)) (scheduledFrequencyHistory V n r))) = + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + W v.val w.val * + (∑ a : MovingDescendantFrequencyIndex V n, + L v.val w.val (movingRootedFrequencyTree V n v.val a)) * + star (∑ b : MovingDescendantFrequencyIndex V n, + R v.val w.val (movingRootedFrequencyTree V n w.val b)) := by + rw [scheduledFrequencyIndex_sum_split V n] + simp_rw [scheduledFrequencyIndex_sum_split V n, + scheduledFrequencyHistory_from_root, movingRootedFrequencyTree_root] + simp only [star_sum, Finset.mul_sum, Finset.sum_mul] + apply Finset.sum_congr rfl + intro v _ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro w _ + rw [Finset.sum_comm] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRoundedCellSums.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRoundedCellSums.lean new file mode 100644 index 0000000000000000000000000000000000000000..db7c6211b0303efd2a9075bace99fa3ac91aed3a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingRoundedCellSums.lean @@ -0,0 +1,119 @@ +import Mathlib.Data.List.Forall2 +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationTargets + +namespace OAI + +/-! # The endpoint loss of rounded top and compensation cells -/ + +namespace Ostmann + +/-- A compensation type occurs four times in the full initial list. -/ +noncomputable def movingSmallCellCenters (top compensation : List ℝ) : List ℝ := + top ++ compensation.flatMap (List.replicate 4) + +theorem movingSmallCellCenters_length (top compensation : List ℝ) : + (movingSmallCellCenters top compensation).length = top.length + 4 * compensation.length := by + induction compensation with + | nil => simp [movingSmallCellCenters] + | cons c cs ih => + simp only [movingSmallCellCenters, List.flatMap_cons, List.length_append, + List.length_replicate, List.length_cons] at * + omega + +theorem movingSmallCellCenters_sum (top compensation : List ℝ) : + (movingSmallCellCenters top compensation).sum = top.sum + 4 * compensation.sum := by + induction compensation with + | nil => simp [movingSmallCellCenters] + | cons c cs ih => + simp only [movingSmallCellCenters, List.flatMap_cons, List.sum_append, + List.sum_replicate, List.sum_cons, nsmul_eq_mul] at * + norm_num at * + linarith + +theorem movingCompensationCenters_error (E : ℝ) (centers targets : List ℝ) + (h : List.Forall₂ (fun c w => |4 * c - w| ≤ 4 * E) centers targets) : + |4 * centers.sum - targets.sum| ≤ 4 * E * centers.length := by + induction h with + | nil => simp + | @cons c w cs ws hcw hrest ih => + simp only [List.sum_cons, List.length_cons, Nat.cast_add, Nat.cast_one] + calc + |4 * (c + cs.sum) - (w + ws.sum)| = + |(4 * c - w) + (4 * cs.sum - ws.sum)| := by congr 1; ring + _ ≤ |4 * c - w| + |4 * cs.sum - ws.sum| := abs_add_le _ _ + _ ≤ 4 * E * ((cs.length : ℝ) + 1) := by linarith + +/-- Replacing each center by the bottom of its width-two cell loses exactly +one per slot, in addition to the top and compensation rounding errors. -/ +theorem movingSmallCellCenters_lower (J cb E et : ℝ) + (top centers targets : List ℝ) + (htop : J - et ≤ top.sum + cb) + (hcomp : List.Forall₂ (fun c w => |4 * c - w| ≤ 4 * E) centers targets) : + J + targets.sum - (et + 4 * E * centers.length + + (top.length + 4 * centers.length : ℕ) + 1) ≤ + ((movingSmallCellCenters top centers).map (fun c => c - 1)).sum + (cb - 1) := by + have hc := (abs_le.mp (movingCompensationCenters_error E centers targets hcomp)).1 + have hmap (l : List ℝ) : (l.map (fun c => c - 1)).sum = l.sum - l.length := by + induction l with + | nil => simp + | cons c cs ih => simp only [List.map_cons, List.sum_cons, List.length_cons, + Nat.cast_add, Nat.cast_one, ih]; ring + rw [hmap, movingSmallCellCenters_sum, movingSmallCellCenters_length] + linarith + +/-- One-sided rounding has no accumulated center error in the lower bound. -/ +theorem movingSmallCellCenters_lower_of_le (J cb : ℝ) + (top centers targets : List ℝ) + (htop : J ≤ top.sum + cb) + (hcomp : List.Forall₂ (fun c w => w ≤ 4 * c) centers targets) : + J + targets.sum - ((top.length + 4 * centers.length : ℕ) + 1) ≤ + ((movingSmallCellCenters top centers).map (fun c => c - 1)).sum + (cb - 1) := by + have hs : targets.sum ≤ 4 * centers.sum := by + induction hcomp with + | nil => simp + | cons hcw hrest ih => simp only [List.sum_cons]; linarith + have hmap (l : List ℝ) : (l.map (fun c => c - 1)).sum = l.sum - l.length := by + induction l with + | nil => simp + | cons c cs ih => simp only [List.map_cons, List.sum_cons, List.length_cons, + Nat.cast_add, Nat.cast_one, ih]; ring + rw [hmap, movingSmallCellCenters_sum, movingSmallCellCenters_length] + linarith + +/-- The actual repeated cell endpoints satisfy the diagonal gap after paying +for excluded integer centers and one unit per cell endpoint. -/ +theorem moving_rounded_cell_diagonal_gap (k n : ℕ) + (BD Bz C L J cb w b cg : ℝ) (top centers targets : List ℝ) + (D : Finset ℤ) + (hC : 0 ≤ C) (hk : 16 * C + 20 ≤ (k : ℝ) ^ 4) + (hL : (top.length + 4 * centers.length : ℕ) + 9 ≤ L) + (hD : (D.card : ℝ) ≤ C * L) + (hcg : cg ≤ (91 / 100 : ℝ) * L) + (htop : J ≤ top.sum + cb) + (hcomp : List.Forall₂ (fun c t => t ≤ 4 * c) centers targets) + (hupper : 4 * b ≤ w + 4 * (D.card + 2)) + (hbalance : (2 ^ n : ℕ) * w = (2 ^ n : ℕ) * (J + targets.sum) - + spectatorStepGap BD Bz ((k : ℝ) ^ 4) (2 ^ n : ℕ) (spectatorBulkCount k L)) : + 2 * cg + 1 + ((2 ^ n : ℕ) * 4) * b - + ((2 ^ n : ℕ) * ((movingSmallCellCenters top centers).map (fun c => c - 1)).sum + + (2 ^ n : ℕ) * (cb - 1)) ≤ + -spectatorStepGap (BD - 1) Bz ((k : ℝ) ^ 4) (2 ^ n : ℕ) + (spectatorBulkCount k L) := by + have hL1 : 1 ≤ L := by have h := Nat.cast_nonneg (α := ℝ) (top.length + 4 * centers.length); linarith + have hr : (0 : ℝ) ≤ (2 ^ n : ℕ) := Nat.cast_nonneg _ + apply moving_cell_diagonal_gap BD Bz ((k : ℝ) ^ 4) (2 ^ n : ℕ) + (spectatorBulkCount k L) J targets.sum w b cb + ((2 ^ n : ℕ) * ((movingSmallCellCenters top centers).map (fun c => c - 1)).sum) + cg (4 * (D.card + 2)) ((top.length + 4 * centers.length : ℕ) + 1) + hr hbalance hupper + · have h := mul_le_mul_of_nonneg_left + (movingSmallCellCenters_lower_of_le J cb top centers targets htop hcomp) hr + nlinarith only [h] + · apply moving_linear_cell_error_budget k n (4 * C + 1) L cg + (4 * (D.card + 2)) ((top.length + 4 * centers.length : ℕ) + 1) + (by linarith) (by linarith) hL1 hcg + nlinarith only [hL, hD] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleCoordinateLevels.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleCoordinateLevels.lean new file mode 100644 index 0000000000000000000000000000000000000000..3935e1ef16feb91e123d60e33348910704502c15 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleCoordinateLevels.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleCoordinates + +namespace OAI + +/-! # Tier separation for the original indexed sample tree -/ + +namespace Ostmann +open scoped Classical + +theorem movingCompensationSlots_forall {A : Type*} (n : ℕ) + (a : TreeLeafTuple (Fin 4 → A) n) (P : A → Prop) + (h : ∀ t j, P (treeLeafTupleEquiv (Fin 4 → A) n a t j)) : + ∀ i ∈ flattenMovingSlots n (movingCompensationSlots n a), P i := by + induction n with + | zero => + intro i hi + obtain ⟨j, rfl⟩ := List.mem_ofFn.mp hi + exact h () j + | succ n ih => + intro i hi + rcases List.mem_append.mp hi with hi | hi + · exact ih a.1 (fun t j => h (.inl t) j) i hi + · exact ih a.2 (fun t j => h (.inr t) j) i hi + +/-- The sample constructor itself enforces the required tier of every +compensation occurrence. No assumption about an independently chosen tree +is needed when the labels are the actual sample coordinates. -/ +theorem movingSampleCoordinates_levels {A : Type*} (tier : A → ℕ) + (n : ℕ) (x : MovingSampleIndex n → A) + (hx : ∀ i, tier (x i) = movingSampleTier i) : + ((movingSampleCoordinates A n).symm x).Levels tier := by + induction n with + | zero => trivial + | succ n ih => + let u := (treeLeafTupleEquiv (Fin 4 → A) n).symm (fun t j => x (.inl (t, j))) + change (∀ i ∈ flattenMovingSlots n (movingCompensationSlots n u), tier i = n) ∧ _ ∧ _ + refine ⟨movingCompensationSlots_forall n u _ ?_, ?_, ?_⟩ + · intro t j + have hu := congrFun (congrFun + ((treeLeafTupleEquiv (Fin 4 → A) n).apply_symm_apply + (fun t j => x (.inl (t, j)))) t) j + change tier (treeLeafTupleEquiv (Fin 4 → A) n u t j) = n + rw [hu] + exact hx (.inl (t, j)) + · exact ih (fun i => x (.inr (true, i))) (fun i => hx (.inr (true, i))) + · exact ih (fun i => x (.inr (false, i))) (fun i => hx (.inr (false, i))) + +def canonicalMovingSamples (n : ℕ) : MovingSampleSlots (MovingSampleIndex n) n := + (movingSampleCoordinates (MovingSampleIndex n) n).symm id + +theorem canonicalMovingSamples_levels (n : ℕ) : + (canonicalMovingSamples n).Levels movingSampleTier := + movingSampleCoordinates_levels movingSampleTier n id (fun _ => rfl) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleCoordinates.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleCoordinates.lean new file mode 100644 index 0000000000000000000000000000000000000000..1bb7c67ddc34e9b7993f1cae554536d7b5ded668 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleCoordinates.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePrior +import OAI.NumberTheory.Ostmann.Characters.TreeLeafIndex + +namespace OAI + +/-! # Fixed coordinates for the actual internal prime samples + +The coordinates count each sample when it is made, not its later occurrences +in descendant lists. Their number is independent of the number of bulk slots. +-/ + +namespace Ostmann +open scoped Classical BigOperators + +def MovingSampleIndex : ℕ → Type + | 0 => Empty + | n + 1 => (TreeLeafIndex n × Fin 4) ⊕ (Bool × MovingSampleIndex n) + +instance movingSampleIndexFintype : (n : ℕ) → Fintype (MovingSampleIndex n) + | 0 => inferInstanceAs (Fintype Empty) + | n + 1 => @instFintypeSum _ _ inferInstance + (@instFintypeProd _ _ inferInstance (movingSampleIndexFintype n)) + +def movingSampleTier : {n : ℕ} → MovingSampleIndex n → ℕ + | n + 1, .inl _ => n + | _ + 1, .inr (_, i) => movingSampleTier i + +theorem movingSampleTier_lt {n : ℕ} (i : MovingSampleIndex n) : movingSampleTier i < n := by + induction n with + | zero => exact Empty.elim i + | succ n ih => + rcases i with i | ⟨b, i⟩ + · exact Nat.lt_succ_self n + · exact (ih i).trans (Nat.lt_succ_self n) + +theorem card_movingSampleIndex (n : ℕ) : Fintype.card (MovingSampleIndex n) = 2 * n * 2 ^ n := by + induction n with + | zero => rfl + | succ n ih => + change Fintype.card ((TreeLeafIndex n × Fin 4) ⊕ (Bool × MovingSampleIndex n)) = _ + rw [Fintype.card_sum, Fintype.card_prod, Fintype.card_prod, Fintype.card_bool, + Fintype.card_fin, card_treeLeafIndex, ih, pow_succ] + ring + +def movingSampleCoordinates (A : Type*) : (n : ℕ) → + MovingSampleSlots A n ≃ (MovingSampleIndex n → A) + | 0 => + { toFun := fun _ i => Empty.elim i + invFun := fun _ => .leaf + left_inv := fun a => by cases a; rfl + right_inv := fun a => by funext i; exact Empty.elim i } + | n + 1 => + { toFun := fun a => match a with + | .node u l r => fun i => match i with + | .inl (t, j) => treeLeafTupleEquiv (Fin 4 → A) n u t j + | .inr (true, i) => movingSampleCoordinates A n l i + | .inr (false, i) => movingSampleCoordinates A n r i + invFun := fun a => .node + ((treeLeafTupleEquiv (Fin 4 → A) n).symm (fun t j => a (.inl (t, j)))) + ((movingSampleCoordinates A n).symm (fun i => a (.inr (true, i)))) + ((movingSampleCoordinates A n).symm (fun i => a (.inr (false, i)))) + left_inv := by + intro a + cases a with + | node u l r => + simp only [Equiv.symm_apply_apply] + right_inv := by + intro a + funext i + rcases i with ⟨t, j⟩ | ⟨b, i⟩ + · exact congrFun (congrFun ((treeLeafTupleEquiv (Fin 4 → A) n).apply_symm_apply + (fun t j => a (.inl (t, j)))) t) j + · cases b <;> exact congrFun ((movingSampleCoordinates A n).apply_symm_apply _) i } + +theorem movingCompensationPrior_indexed {A : Type*} (μ : A → ℝ) (n : ℕ) + (a : TreeLeafTuple (Fin 4 → A) n) : + movingCompensationPrior μ n a = + ∏ t : TreeLeafIndex n, ∏ j : Fin 4, μ (treeLeafTupleEquiv (Fin 4 → A) n a t j) := by + induction n with + | zero => + change (∏ j : Fin 4, μ (a j)) = ∏ _t : Unit, ∏ j : Fin 4, μ (a j) + simp only [Fintype.prod_unique] + | succ n ih => + change movingCompensationPrior μ n a.1 * movingCompensationPrior μ n a.2 = + ∏ t : TreeLeafIndex n ⊕ TreeLeafIndex n, + ∏ j : Fin 4, μ (treeLeafTupleEquiv (Fin 4 → A) (n + 1) a t j) + rw [Fintype.prod_sum_type, ih, ih] + rfl + +/-- The tree law is precisely the product of the original coordinate priors. +This identity permits the proved equality-pattern comparison to be applied +without replacing the law by a conditioned or uniform distribution. -/ +theorem movingSamplesPrior_coordinates {A : Type*} (μ : ℕ → A → ℝ) (n : ℕ) + (a : MovingSampleSlots A n) : + movingSamplesPrior μ a = + ∏ i : MovingSampleIndex n, μ (movingSampleTier i) (movingSampleCoordinates A n a i) := by + induction a with + | leaf => rfl + | @node n u l r hl hr => + change movingCompensationPrior (μ n) n u * movingSamplesPrior μ l * movingSamplesPrior μ r = + ∏ i : (TreeLeafIndex n × Fin 4) ⊕ (Bool × MovingSampleIndex n), _ + rw [Fintype.prod_sum_type, Fintype.prod_prod_type, Fintype.prod_prod_type, Fintype.prod_bool, + movingCompensationPrior_indexed, hl, hr] + simp only [movingSampleTier, movingSampleCoordinates, Equiv.coe_fn_mk] + ring + +theorem movingSamplesPrior_reindex {A : Type*} [Fintype A] (μ : ℕ → A → ℝ) + (n : ℕ) (F : MovingSampleSlots A n → ℂ) : + (∑ a : MovingSampleSlots A n, (movingSamplesPrior μ a : ℂ) * F a) = + ∑ x : MovingSampleIndex n → A, + ((∏ i, μ (movingSampleTier i) (x i) : ℝ) : ℂ) * + F ((movingSampleCoordinates A n).symm x) := by + have h := (movingSampleCoordinates A n).symm.sum_comp + (fun a => (movingSamplesPrior μ a : ℂ) * F a) + rw [← h] + apply Finset.sum_congr rfl + intro x _ + rw [movingSamplesPrior_coordinates, Equiv.apply_symm_apply] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleDiagonalExpansion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleDiagonalExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..f671abd741e8ff9515af4e98f78e394367a48c32 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleDiagonalExpansion.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPrimeExpansion +import OAI.NumberTheory.Ostmann.Arithmetic.IntegerIntervalVariation + +namespace OAI + +/-! # Exact sample expansion in the mixed prime/integer diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem complexIntegerInterval_sum {I : Type*} (q a : ℕ) (u v G : ℝ) + (S : Finset I) (F : I → ℝ → ℂ) : + complexIntegerInterval q a u v G (fun x => ∑ i ∈ S, F i x) = + ∑ i ∈ S, complexIntegerInterval q a u v G (F i) := by + unfold complexIntegerInterval + simp only [Finset.sum_mul] + rw [Finset.sum_comm] + +theorem complexIntegerInterval_const_mul (q a : ℕ) (u v G : ℝ) + (c : ℂ) (F : ℝ → ℂ) : + complexIntegerInterval q a u v G (fun x => c * F x) = + c * complexIntegerInterval q a u v G F := by + unfold complexIntegerInterval + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro p _ + exact mul_assoc _ _ _ + +/-- The outer factor may contain the full cutoff weight and the common +regular transform. It depends on the external draws, not the internal pair. -/ +theorem movingCompensatedAverage_diagonal_patterns {A : Type*} [Fintype A] + (μ : ℕ → A → ℝ) (value : A → ℕ) (n : ℕ) + (H K : ℝ → ℝ → MovingSampleSlots A n → ℂ) + (W : ℝ → ℝ → ℂ) (u v r s center : ℝ) : + letI := sampleSetoidFintype (Bool × MovingSampleIndex n) + complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v center (fun x => + (movingCompensatedAverage μ value n (H x y) * + star (movingCompensatedAverage μ value n (K x y))) * W x y)) = + ∑ eqp : Setoid (Bool × MovingSampleIndex n), + ∑ z : {z : Quotient eqp → A // Function.Injective z}, + let a := (movingSamplePairCoordinates A n).symm (fun i => z.val (Quotient.mk'' i)) + (internalPatternWeight (fun i => Quotient.mk'' i) + (fun i => μ (movingSampleTier i.2)) value z.val : ℂ) * + complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v center + (fun x => (H x y a.1 * star (K x y a.2)) * W x y)) := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + simp_rw [movingCompensatedAverage_pair_patterns, Finset.sum_mul, + complexIntegerInterval_sum, complexPrimeInterval_sum] + apply Finset.sum_congr rfl + intro eqp _ + apply Finset.sum_congr rfl + intro z _ + simp_rw [mul_assoc, complexIntegerInterval_const_mul, complexPrimeInterval_const_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleDiagonalRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleDiagonalRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..f07f02667ad83b7f5868f8431c665dd27a9c30be --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleDiagonalRate.lean @@ -0,0 +1,142 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedDiagonalRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleModulusRange +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullPageDeletion + +namespace OAI + +/-! # The mixed giant comparison for actual sampled histories -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_original_sampled_diagonal_prime_rate (P : PublishedProgressionInput) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (Afreq Wwin B D : ℝ) + (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) (hB : 0 ≤ B) (hD : 0 ≤ D) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (σ J : Type) [Fintype J] (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V Pmax cutoff : ℕ) + (small bulk : Bool → TreeLeafTuple (List σ) n) (samples : Bool → MovingSampleSlots σ n), + (∀ b, T b = buildMovingSlotData n (t b) (small b) (bulk b) (samples b)) → + (∀ b, MovingLeafLengthLE n (small b) r₀) → (∀ b, MovingLeafLengthLE n (bulk b) m) → + (∀ b, (T b).Frequencies (fun s => s.natAbs ≤ V)) → + 1 ≤ V → 1 ≤ Pmax → (∀ i, value i ≤ Pmax) → + (Pmax : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) → + (V : ℝ) ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + outside.length ≤ m → (∀ q ∈ outside, q.Prime) → + (∀ q ∈ outside, ∃ i, p i = q) → V < cutoff → (∀ i, cutoff ≤ value i) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, value i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + ∀ q : ℕ, ∀ hq : 1 ≤ q, + ∀ hqeq : q = (∏ i, reg i) * movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p Finset.univ, + (∀ b, movingRegularOutsidePairwise value outside (T b)) → + Pairwise (fun i j => (reg i).Coprime (reg j)) → + (∀ i, (∏ j, reg j).Coprime (p i)) → + (∀ i, (sreg : ZMod (reg i)) ≠ 0) → (∀ i, other i ≠ 0) → + (∀ i, greg i 0 = 0) → (∀ i, (∑ x : ZMod (reg i), ‖greg i x‖ ^ 2) = reg i) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + (∀ b, ‖movingDataWeight (F b) (E b) (T b)‖ ≤ 1) → + (∀ i z, ‖g i z‖ ≤ p i) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c0 := movingReducedPairResidueCoefficient p value outside F E g Dq Finset.univ T nodes + letI : NeZero q := ⟨by omega⟩ + letI : NeZero (movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p Finset.univ) := ⟨by + intro hz + rw [hz, mul_zero] at hqeq + omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq Finset.univ ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * (((∏ i, if active i then (1 : ℝ) else 1 - (reg i : ℝ)⁻¹ : ℝ) : ℂ) * + correctedMixedPairAverage P (giantProgressionCutoff L) (movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p Finset.univ) c0 y) / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_original_reduced_diagonal_prime_rate ψ n r₀ k Afreq Wwin B D + hAfreq hWwin hB hD, movingSample_pair_modulus_giant_range n r₀ k Afreq hAfreq] + with L hrate hmod + dsimp only + intro σ J _ p _ tier value hprime hdisjoint outside childBound pivotBound T hf t hT + hlevels hcoh hc hsmall hfmod F E g hg Dq reg _ hregular active sreg other greg + X lo hi hlo hhi φ G Jleft Jright hφ hlip hout diagonal V Pmax cutoff small bulk samples + hbuild hsmallLen hbulkLen hV hVpos hPpos hvalueP hPexp hVA hwindow hpupper + houtLen houtPrime houtCover hVcut hlarge hdeleteValue hdeleteSpect + q hq hqeq houtside hreg hqs hsreg hother hgreg henergy + u v r s H hH huv hshort hvH hr hrs hrshort hweight hgnorm + have hout0 : outside.prod ≠ 0 := by + apply List.prod_ne_zero + intro hz + exact (houtPrime 0 hz).ne_zero rfl + have hout1 : 1 ≤ outside.prod := Nat.one_le_iff_ne_zero.mpr hout0 + have hbuild' : T = fun b => buildMovingSlotData n (t b) (small b) (bulk b) (samples b) := + funext hbuild + have hfull : movingFullPairModulus value (fun i => (hprime i).ne_zero) outside + childBound pivotBound T hf p Finset.univ ≤ giantProgressionCutoff L := by + subst T + exact hmod σ value (fun i => (hprime i).ne_zero) outside Pmax V hout1 houtLen + (fun a ha => by obtain ⟨i, rfl⟩ := houtCover a ha; exact hpupper i) + hPpos hVpos hvalueP hPexp hVA childBound pivotBound t small bulk samples hf + hsmallLen hbulkLen hV p hpupper + have hcop := movingOriginalRegular_coprime_reduced tier value hprime hdisjoint outside + childBound pivotBound T hf hlevels hsmall houtside (∏ i, reg i) hregular p Finset.univ + (fun i _ => hqs i) + have hqQ : q ≤ giantProgressionCutoff L := by + rw [hqeq] + exact (Nat.le_of_dvd (movingFullPairModulus_pos value (fun i => (hprime i).ne_zero) + outside hout0 childBound pivotBound T hf p Finset.univ + (fun i _ => (Fact.out : (p i).Prime).pos)) + (movingSplitModulus_dvd_full value (fun i => (hprime i).ne_zero) outside + childBound pivotBound T hf p Finset.univ (∏ i, reg i) (hregular false) hcop)).trans hfull + have hpage : pageAtModulus q (selectedPageZero P (giantProgressionCutoff L)) = + pageAtModulus (movingReducedPairModulus value (fun i => (hprime i).ne_zero) + outside childBound pivotBound T hf p Finset.univ) (selectedPageZero P (giantProgressionCutoff L)) := by + rw [hqeq] + have hc' : (MovingSlotReversal.naturalProduct value (T false).regularSlots).Coprime + (movingReducedPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p Finset.univ) := by + simpa only [hregular false] using hcop + have hh := movingSplitModulus_page_projection value hprime outside childBound pivotBound T hf + p Finset.univ (fun i _ => (Fact.out : (p i).Prime)) houtPrime V cutoff hVcut hV + (selectedPageZero P (giantProgressionCutoff L)) hdeleteValue + (fun z hz q hq i _ => hdeleteSpect z hz q hq i) + (by + intro z hz q hq hmem + obtain ⟨i, hi⟩ := houtCover q hmem + exact hdeleteSpect z hz q hq i hi) hlarge hc' + simpa only [hregular false] using hh + have hVreal : ∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ (V : ℝ)) := by + intro b + exact (hV b).mono (fun s hs => by + simpa only [Nat.cast_natAbs, Int.cast_abs] using (Nat.cast_le (α := ℝ).mpr hs)) + exact hrate σ J p tier value hprime hdisjoint outside childBound pivotBound T hf t hT + hlevels hcoh hc hsmall hfmod F E g hg Dq reg hregular active sreg other greg + X lo hi hlo hhi φ G Jleft Jright hφ hlip hout diagonal V hVreal + (Nat.cast_nonneg _) hVA hwindow hpupper q hq hqQ hqeq houtside hreg hqs hpage + hsreg hother hgreg henergy u v r s H hH huv hshort hvH hr hrs hrshort hweight hgnorm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleIntegrality.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleIntegrality.lean new file mode 100644 index 0000000000000000000000000000000000000000..82451d502a3faf996cb96033e97e71080fa6df00 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleIntegrality.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleValues + +namespace OAI + +/-! # Full integer support for the labelled moving-giant sampler -/ + +namespace Ostmann +open scoped Classical + +@[simp] theorem MovingGiantTree.castConstant_integral {n C D : ℕ} (h : C = D) + (T : MovingGiantTree n C) (XL XR : ℕ) (bulk : TreeLeafTuple ℕ n) : + (T.castConstant h).Integral XL XR bulk ↔ T.Integral XL XR bulk := by + subst D + rfl + +/-- The labelled history is interpreted by the same positive integer pivots +as the original sampler. No primality is imposed on a reconstructed giant. -/ +def MovingSlotData.Integral {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → Prop + | _, .leaf _ _, _, _ => True + | _, .node s CL CR u left right, XL, XR => + let step := MovingSlotData.step s CL CR u left right false + let p := step.naturalPivot value XL XR + step.IntegralAt value (XL, XR) ∧ left.Integral value p XL ∧ right.Integral value p XR + +theorem buildMovingSlotData_integral {σ : Type*} (value : σ → ℕ) (n : ℕ) + (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) (XL XR : ℕ) : + (buildMovingSlotData n t small bulk samples).Integral value XL XR ↔ + (buildMovingGiantTree n t (movingSlotValues value n small) (samples.values value)).Integral + XL XR (movingSlotValues value n bulk) := by + induction samples generalizing XL XR with + | leaf => rfl + | @node n samples left right ihL ihR => + let u := movingCompensationSlots n samples + let comp := treeLeafProduct n (movingSlotValues value n u) + let CL := treeLeafProduct n (movingSlotValues value n small.1) + let CR := treeLeafProduct n (movingSlotValues value n small.2) + let ML := treeLeafProduct n (movingSlotValues value n bulk.1) + let MR := treeLeafProduct n (movingSlotValues value n bulk.2) + let step := MovingSlotData.step t.1 + (flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1) + (flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2) + (flattenMovingSlots n u) + (buildMovingSlotData n t.2.1 (appendMovingSlotLeaves n u small.1) bulk.1 left) + (buildMovingSlotData n t.2.2 (appendMovingSlotLeaves n u small.2) bulk.2 right) false + have hp : step.naturalPivot value XL XR = + movingGiantPivot t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + CL CR comp XL XR ML MR := by + simp only [MovingSlotReversal.naturalPivot, step, MovingSlotData.step, + buildMovingSlotData_frequency, movingNaturalProduct_append, movingSlotValues_flatten] + simp only [movingGiantPivot, CL, CR, ML, MR, comp, Nat.mul_one, Nat.mul_assoc] + have hL := ihL t.2.1 (appendMovingSlotLeaves n u small.1) bulk.1 + (step.naturalPivot value XL XR) XL + have hR := ihR t.2.2 (appendMovingSlotLeaves n u small.2) bulk.2 + (step.naturalPivot value XL XR) XR + change (step.IntegralAt value (XL, XR) ∧ _ ∧ _) ↔ _ + rw [hL, hR] + simp only [buildMovingGiantTree, MovingSampleSlots.values, movingSlotValues, + MovingGiantTree.Integral, MovingGiantTree.castConstant_frequency, + buildMovingGiantTree_frequency, MovingGiantTree.castConstant_integral] + simp only [← movingCompensationValues_product, hp] + have hstep : step.IntegralAt value (XL, XR) ↔ + 0 < step.naturalPivot value XL XR ∧ + frequencyRoot n t.2.1 * ((XR * CR * MR : ℕ) : ℤ) - + frequencyRoot n t.2.2 * ((XL * CL * ML : ℕ) : ℤ) = + t.1 * ((comp * step.naturalPivot value XL XR : ℕ) : ℤ) := by + simp only [MovingSlotReversal.IntegralAt, step, MovingSlotData.step, + buildMovingSlotData_frequency, movingNaturalProduct_append, movingSlotValues_flatten] + dsimp only [CL, CR, ML, MR, comp] + simp only [Nat.mul_assoc] + rw [hstep] + simp only [hp] + simp only [CL, CR, ML, MR, comp, u, and_assoc] + rw [movingSlotValues_append, movingSlotValues_append, movingCompensationValues_product] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleMap.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleMap.lean new file mode 100644 index 0000000000000000000000000000000000000000..d966d17a8c4fa00c012d452f8b90ba9a920daa14 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleMap.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleCoordinateLevels +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotRelabel +import OAI.NumberTheory.Ostmann.Characters.TreeTupleProfiles + +namespace OAI + +/-! # Evaluating the fixed indexed sample tree + +This identifies the original sampled prime tree with evaluation of fixed +slot data. Thus equality-pattern and polynomial arguments use the same +literal constructor as the sampled coefficient. +-/ + +namespace Ostmann +open scoped Classical + +def MovingSampleSlots.map {A B : Type*} (f : A → B) : + {n : ℕ} → MovingSampleSlots A n → MovingSampleSlots B n + | _, .leaf => .leaf + | n + 1, .node u l r => + .node (treeLeafMap (fun a : Fin 4 → A => f ∘ a) n u) (l.map f) (r.map f) + +theorem flattenMovingSlots_map {A B : Type*} (f : A → B) (n : ℕ) + (a : TreeLeafTuple (List A) n) : + flattenMovingSlots n (treeLeafMap (List.map f) n a) = (flattenMovingSlots n a).map f := by + induction n with + | zero => rfl + | succ n ih => + simp only [treeLeafMap, flattenMovingSlots, List.map_append, ih] + +theorem appendMovingSlotLeaves_map {A B : Type*} (f : A → B) (n : ℕ) + (a b : TreeLeafTuple (List A) n) : + treeLeafMap (List.map f) n (appendMovingSlotLeaves n a b) = + appendMovingSlotLeaves n (treeLeafMap (List.map f) n a) (treeLeafMap (List.map f) n b) := by + induction n with + | zero => exact List.map_append + | succ n ih => exact Prod.ext (ih a.1 b.1) (ih a.2 b.2) + +theorem movingCompensationSlots_map {A B : Type*} (f : A → B) (n : ℕ) + (a : TreeLeafTuple (Fin 4 → A) n) : + movingCompensationSlots n (treeLeafMap (fun a : Fin 4 → A => f ∘ a) n a) = + treeLeafMap (List.map f) n (movingCompensationSlots n a) := by + induction n with + | zero => exact List.map_ofFn.symm + | succ n ih => exact Prod.ext (ih a.1) (ih a.2) + +theorem buildMovingSlotData_map {A B : Type*} (f : A → B) (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List A) n) (a : MovingSampleSlots A n) : + (buildMovingSlotData n t small bulk a).map f = + buildMovingSlotData n t (treeLeafMap (List.map f) n small) + (treeLeafMap (List.map f) n bulk) (a.map f) := by + induction a with + | leaf => exact congrArg (MovingSlotData.leaf t) List.map_append + | node u l r hl hr => + simp only [buildMovingSlotData, MovingSlotData.map, MovingSampleSlots.map, + treeLeafMap, movingCompensationSlots_map, flattenMovingSlots_map, + List.map_append, hl, hr, appendMovingSlotLeaves_map] + +theorem movingSampleCoordinates_map {A B : Type*} (f : A → B) {n : ℕ} + (a : MovingSampleSlots A n) (i : MovingSampleIndex n) : + movingSampleCoordinates B n (a.map f) i = f (movingSampleCoordinates A n a i) := by + induction a with + | leaf => exact Empty.elim i + | @node n u l r hl hr => + rcases i with ⟨t, j⟩ | ⟨b, i⟩ + · exact congrFun (treeLeafTupleEquiv_map (fun a : Fin 4 → A => f ∘ a) n u t) j + · cases b + · exact hr i + · exact hl i + +/-- All sampled values are the evaluation of one fixed indexed tree. -/ +theorem canonicalMovingSamples_map {A : Type*} (n : ℕ) (x : MovingSampleIndex n → A) : + (canonicalMovingSamples n).map x = (movingSampleCoordinates A n).symm x := by + apply (movingSampleCoordinates A n).injective + funext i + rw [movingSampleCoordinates_map, canonicalMovingSamples, Equiv.apply_symm_apply, + Equiv.apply_symm_apply] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleModulusRange.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleModulusRange.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce7cc59258a570795cf9acd72f3e38b6289df9ac --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleModulusRange.lean @@ -0,0 +1,199 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSplitModulusBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantBounds + +namespace OAI + +/-! # The full modulus of the actual sampled histories at the giant scale -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +private theorem list_nat_prod_exp_bound (s : List ℕ) (U : ℝ) + (h : ∀ q ∈ s, (q : ℝ) ≤ Real.exp U) : + (s.prod : ℝ) ≤ Real.exp (s.length * U) := by + induction s with + | nil => simp + | cons q s ih => + simp only [List.prod_cons, List.length_cons, Nat.cast_mul, Nat.cast_add, Nat.cast_one] + calc + _ ≤ Real.exp U * Real.exp (s.length * U) := + mul_le_mul (h q (by simp)) (ih (fun q hq => h q (by simp [hq]))) + (Nat.cast_nonneg _) (Real.exp_nonneg _) + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +theorem movingSample_pair_modulus_bound {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (hout : 1 ≤ outside.prod) + (childBound pivotBound : ℕ → ℕ) (n r₀ m P V : ℕ) + (hP : 1 ≤ P) (hV : 1 ≤ V) (hvalueP : ∀ i, value i ≤ P) + (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List σ) n) + (samples : Bool → MovingSampleSlots σ n) + (hsmall : ∀ b, MovingLeafLengthLE n (small b) r₀) + (hbulk : ∀ b, MovingLeafLengthLE n (bulk b) m) + (hf : ∀ b, (buildMovingSlotData n (t b) (small b) (bulk b) (samples b)).Frequencies (· ≠ 0)) + (hfreq : ∀ b, (buildMovingSlotData n (t b) (small b) (bulk b) (samples b)).Frequencies + (fun s => s.natAbs ≤ V)) (q : I → ℕ) (S : Finset I) : + movingFullPairModulus value hvalue outside childBound pivotBound + (fun b => buildMovingSlotData n (t b) (small b) (bulk b) (samples b)) hf q S ≤ + ((V * P ^ (2 ^ n * (r₀ + m + 4 * n) + 4 * 2 ^ n) * outside.prod) ^ + movingFullModulusExponent n * ∏ i ∈ S, q i) ^ 4 := by + let D := 2 ^ n * (r₀ + m + 4 * n) + let K := V * P ^ (D + 4 * 2 ^ n) * outside.prod + have hpow : 1 ≤ P ^ (D + 4 * 2 ^ n) := Nat.one_le_pow _ _ hP + have hVK : V ≤ K := by + change V ≤ V * P ^ (D + 4 * 2 ^ n) * outside.prod + calc + V = V * 1 * 1 := by simp + _ ≤ _ := Nat.mul_le_mul (Nat.mul_le_mul_left V hpow) hout + have hPK : P ^ (D + 4 * 2 ^ n) ≤ K := by + change P ^ (D + 4 * 2 ^ n) ≤ V * P ^ (D + 4 * 2 ^ n) * outside.prod + calc + _ = 1 * P ^ (D + 4 * 2 ^ n) * 1 := by simp + _ ≤ _ := Nat.mul_le_mul (Nat.mul_le_mul_right _ hV) hout + have hOK : outside.prod ≤ K := by + change outside.prod ≤ V * P ^ (D + 4 * 2 ^ n) * outside.prod + simpa only [one_mul] using Nat.mul_le_mul_right outside.prod (Nat.mul_le_mul hV hpow) + apply movingFullPairModulus_bound value hvalue outside childBound pivotBound _ hf q S K + (hV.trans hVK) (fun b => (hfreq b).mono (fun _ hs => hs.trans hVK)) + · intro b + exact (buildMovingSlotData_compensation_bound value P hP hvalueP n (t b) + (small b) (bulk b) (samples b)).mono value + ((Nat.pow_le_pow_right hP (Nat.le_add_left _ _)).trans hPK) + · intro b + exact MovingSlotData.RegularBound.mono _ value + (MovingSlotData.RegularLengthLE.product_bound _ + (buildMovingSlotData_regular_length n (t b) (small b) (bulk b) (samples b) + r₀ m (hsmall b) (hbulk b)) value P hP hvalueP) + ((Nat.pow_le_pow_right hP (Nat.le_add_right _ _)).trans hPK) + · exact hOK + +private theorem sampled_modulus_exponent_bound (n r₀ k : ℕ) (A L : ℝ) + (hA : 0 ≤ A) (hL : 1 ≤ L) : + let m := spectatorBulkCount k L + let D : ℝ := (2 ^ n * (r₀ + m + 4 * n) + 4 * 2 ^ n : ℕ) + let K : ℝ := (k : ℝ) ^ 4 + let D₀ : ℝ := (2 ^ n : ℕ) * (r₀ + K + 4 * n) + 4 * (2 ^ n : ℕ) + 4 * ((movingFullModulusExponent n : ℝ) * + (A * m + D * Real.exp ((11 / 1000 : ℝ) * L) + + m * Real.exp ((1 / 1000 : ℝ) * L)) + m * Real.exp ((1 / 1000 : ℝ) * L)) ≤ + (4 * ((movingFullModulusExponent n : ℝ) * (A * K + D₀ + K) + K)) * + L * Real.exp ((11 / 1000 : ℝ) * L) := by + dsimp only + let K : ℝ := (k : ℝ) ^ 4 + let D₀ : ℝ := (2 ^ n : ℕ) * (r₀ + K + 4 * n) + 4 * (2 ^ n : ℕ) + have hL0 : 0 ≤ L := le_trans zero_le_one hL + have hm := spectatorBulkCount_upper k L hL0 + have hsmall : Real.exp ((1 / 1000 : ℝ) * L) ≤ Real.exp ((11 / 1000 : ℝ) * L) := + Real.exp_le_exp.mpr (by linarith only [hL0]) + have hone : 1 ≤ Real.exp ((11 / 1000 : ℝ) * L) := + Real.one_le_exp_iff.mpr (by positivity) + have hD : ((2 ^ n * (r₀ + spectatorBulkCount k L + 4 * n) + 4 * 2 ^ n : ℕ) : ℝ) ≤ D₀ * L := by + have hr := mul_le_mul_of_nonneg_left hL (Nat.cast_nonneg r₀ : (0 : ℝ) ≤ r₀) + have hn := mul_le_mul_of_nonneg_left hL (show (0 : ℝ) ≤ 4 * n by positivity) + have hfour := mul_le_mul_of_nonneg_left hL (show (0 : ℝ) ≤ 4 * (2 ^ n : ℕ) by positivity) + have hadd : (r₀ : ℝ) + spectatorBulkCount k L + 4 * n ≤ ((r₀ : ℝ) + K + 4 * n) * L := by + dsimp only [K] + linarith only [hr, hn, hm] + have hh := mul_le_mul_of_nonneg_left hadd (show (0 : ℝ) ≤ (2 ^ n : ℕ) by positivity) + push_cast + dsimp only [D₀] + push_cast + push_cast at hh hfour + nlinarith only [hh, hfour] + have hfreq : A * (spectatorBulkCount k L : ℝ) ≤ A * K * L * Real.exp ((11 / 1000 : ℝ) * L) := by + apply (mul_le_mul_of_nonneg_left hm hA).trans + simpa only [mul_assoc, K] using le_mul_of_one_le_right + (show 0 ≤ A * ((k : ℝ) ^ 4 * L) by positivity) hone + have hcomp := mul_le_mul_of_nonneg_right hD (Real.exp_nonneg ((11 / 1000 : ℝ) * L)) + have hspec : (spectatorBulkCount k L : ℝ) * Real.exp ((1 / 1000 : ℝ) * L) ≤ + K * L * Real.exp ((11 / 1000 : ℝ) * L) := + mul_le_mul hm hsmall (Real.exp_nonneg _) (by positivity) + have hE : (0 : ℝ) ≤ movingFullModulusExponent n := Nat.cast_nonneg _ + dsimp only [D₀, K] at hcomp hfreq hspec ⊢ + nlinarith only [mul_le_mul_of_nonneg_left (add_le_add (add_le_add hfreq hcomp) hspec) hE, hspec] + +/-- The cutoff is uniform in the actual histories and all sampled prime +values. It permits the full `.011` internal range and the original bulk size. -/ +theorem movingSample_pair_modulus_giant_range (n r₀ k : ℕ) (A : ℝ) (hA : 0 ≤ A) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (σ : Type) (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (outside : List ℕ) (P V : ℕ), + 1 ≤ outside.prod → outside.length ≤ m → + (∀ q ∈ outside, (q : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 1 ≤ P → 1 ≤ V → (∀ i, value i ≤ P) → + (P : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) → + (V : ℝ) ≤ Real.exp (A * m) → + ∀ (childBound pivotBound : ℕ → ℕ) (t : Bool → FrequencyTree ℤ n) + (small bulk : Bool → TreeLeafTuple (List σ) n) (samples : Bool → MovingSampleSlots σ n) + (hf : ∀ b, (buildMovingSlotData n (t b) (small b) (bulk b) (samples b)).Frequencies (· ≠ 0)), + (∀ b, MovingLeafLengthLE n (small b) r₀) → + (∀ b, MovingLeafLengthLE n (bulk b) m) → + (∀ b, (buildMovingSlotData n (t b) (small b) (bulk b) (samples b)).Frequencies + (fun s => s.natAbs ≤ V)) → + ∀ p : Fin m → ℕ, + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + movingFullPairModulus value hvalue outside childBound pivotBound + (fun b => buildMovingSlotData n (t b) (small b) (bulk b) (samples b)) hf p Finset.univ ≤ + giantProgressionCutoff L := by + let K : ℝ := (k : ℝ) ^ 4 + let D₀ : ℝ := (2 ^ n : ℕ) * (r₀ + K + 4 * n) + 4 * (2 ^ n : ℕ) + let C : ℝ := 4 * ((movingFullModulusExponent n : ℝ) * (A * K + D₀ + K) + K) + have hC : 0 ≤ C := by dsimp only [C, D₀, K]; positivity + filter_upwards [arithmetic_exponent_absorption (11 / 1000) (12 / 1000) 0 C 1 1 + (by norm_num) (by norm_num) (by norm_num) (by norm_num), + eventually_ge_atTop (1 : ℝ)] with L hrate hL + dsimp only + intro σ value hvalue outside P V hout hlen houtP hP hV hvalueP hPexp hVexp + childBound pivotBound t small bulk samples hf hsmall hbulk hfreq p hp + let m := spectatorBulkCount k L + let D := 2 ^ n * (r₀ + m + 4 * n) + 4 * 2 ^ n + have houtExp : (outside.prod : ℝ) ≤ Real.exp (m * Real.exp ((1 / 1000 : ℝ) * L)) := by + calc + _ ≤ Real.exp (outside.length * Real.exp ((1 / 1000 : ℝ) * L)) := by + exact list_nat_prod_exp_bound outside _ houtP + _ ≤ _ := Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right + (Nat.cast_le.mpr hlen) (Real.exp_nonneg _)) + have hpExp : ((∏ i, p i : ℕ) : ℝ) ≤ Real.exp (m * Real.exp ((1 / 1000 : ℝ) * L)) := by + rw [Nat.cast_prod] + calc + _ ≤ ∏ _i : Fin m, Real.exp (Real.exp ((1 / 1000 : ℝ) * L)) := + Finset.prod_le_prod₀ (fun _ _ => Nat.cast_nonneg _) (fun i _ => hp i) + _ = _ := by simp only [Finset.prod_const, Finset.card_univ, Fintype.card_fin, ← Real.exp_nat_mul] + have hB : ((V * P ^ D * outside.prod : ℕ) : ℝ) ≤ + Real.exp (A * m + D * Real.exp ((11 / 1000 : ℝ) * L) + + m * Real.exp ((1 / 1000 : ℝ) * L)) := by + simp only [Nat.cast_mul, Nat.cast_pow] + calc + _ ≤ (Real.exp (A * m) * Real.exp (Real.exp ((11 / 1000 : ℝ) * L)) ^ D) * + Real.exp (m * Real.exp ((1 / 1000 : ℝ) * L)) := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add] + apply Nat.le_floor + have hb := movingSample_pair_modulus_bound value hvalue outside hout childBound pivotBound + n r₀ m P V hP hV hvalueP t small bulk samples hsmall hbulk hf hfreq p Finset.univ + have hb' : ((movingFullPairModulus value hvalue outside childBound pivotBound + (fun b => buildMovingSlotData n (t b) (small b) (bulk b) (samples b)) hf p Finset.univ : ℕ) : ℝ) ≤ + (((V * P ^ D * outside.prod : ℕ) : ℝ) ^ movingFullModulusExponent n * + ((∏ i, p i : ℕ) : ℝ)) ^ 4 := by exact_mod_cast hb + apply hb'.trans + calc + _ ≤ (Real.exp (A * m + D * Real.exp ((11 / 1000 : ℝ) * L) + + m * Real.exp ((1 / 1000 : ℝ) * L)) ^ movingFullModulusExponent n * + Real.exp (m * Real.exp ((1 / 1000 : ℝ) * L))) ^ 4 := by gcongr + _ = Real.exp (4 * ((movingFullModulusExponent n : ℝ) * + (A * m + D * Real.exp ((11 / 1000 : ℝ) * L) + + m * Real.exp ((1 / 1000 : ℝ) * L)) + m * Real.exp ((1 / 1000 : ℝ) * L))) := by + rw [← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_nat_mul] + norm_num only [Nat.cast_ofNat] + _ ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + apply Real.exp_le_exp.mpr + have hh := sampled_modulus_exponent_bound n r₀ k A L hA hL + dsimp only at hh + simp only [pow_one, zero_mul, Real.exp_zero, one_mul] at hrate + have hCL : 0 ≤ C * L := mul_nonneg hC (le_trans zero_le_one hL) + exact hh.trans (by dsimp only [C, D₀, K] at hrate hCL ⊢; linarith only [hrate, hCL]) + _ = _ := by congr 2; ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleOccurrence.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleOccurrence.lean new file mode 100644 index 0000000000000000000000000000000000000000..2059ada0b35d16ad1ec59745c1fbed8b09d1ad03 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleOccurrence.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTree +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRepresentativeLineSystem + +namespace OAI + +/-! # An actual occurrence for every internal sample class -/ + +namespace Ostmann +open scoped Classical + +theorem movingCompensationSlots_mem {A : Type*} (n : ℕ) + (a : TreeLeafTuple (Fin 4 → A) n) (t : TreeLeafIndex n) (j : Fin 4) : + treeLeafTupleEquiv (Fin 4 → A) n a t j ∈ + flattenMovingSlots n (movingCompensationSlots n a) := by + induction n with + | zero => exact List.mem_ofFn.mpr ⟨j, rfl⟩ + | succ n ih => + cases t with + | inl t => exact List.mem_append_left _ (ih a.1 t) + | inr t => exact List.mem_append_right _ (ih a.2 t) + +/-- Each independent draw has a genuine node occurrence in the constructed +history; subsequent copies in regular lists are irrelevant to this witness. -/ +theorem movingSample_occurs {A : Type*} (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List A) n) (a : MovingSampleSlots A n) + (i : MovingSampleIndex n) : + ∃ o ∈ (buildMovingSlotData n t small bulk a).occurrences, + movingSampleCoordinates A n a i ∈ o.current.compensationSlots := by + induction a with + | leaf => exact Empty.elim i + | @node n a l r hl hr => + let U := flattenMovingSlots n (movingCompensationSlots n a) + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let L := buildMovingSlotData n t.2.1 + (appendMovingSlotLeaves n (movingCompensationSlots n a) small.1) bulk.1 l + let R := buildMovingSlotData n t.2.2 + (appendMovingSlotLeaves n (movingCompensationSlots n a) small.2) bulk.2 r + change ∃ o ∈ (MovingSlotData.node t.1 CL CR U L R).occurrences, + movingSampleCoordinates A (n + 1) (.node a l r) i ∈ o.current.compensationSlots + rcases i with ⟨ti, j⟩ | ⟨b, i⟩ + · refine ⟨⟨n + 1, MovingSlotData.step t.1 CL CR U L R false, []⟩, List.mem_cons_self, ?_⟩ + exact movingCompensationSlots_mem n a ti j + · cases b with + | false => + obtain ⟨o, ho, hi⟩ := hr t.2.2 + (appendMovingSlotLeaves n (movingCompensationSlots n a) small.2) bulk.2 i + refine ⟨o.extend (MovingSlotData.step t.1 CL CR U L R false), ?_, hi⟩ + exact List.mem_cons_of_mem _ (List.mem_append_right _ (List.mem_map.mpr ⟨o, ho, rfl⟩)) + | true => + obtain ⟨o, ho, hi⟩ := hl t.2.1 + (appendMovingSlotLeaves n (movingCompensationSlots n a) small.1) bulk.1 i + refine ⟨o.extend (MovingSlotData.step t.1 CL CR U L R true), ?_, hi⟩ + exact List.mem_cons_of_mem _ (List.mem_append_left _ (List.mem_map.mpr ⟨o, ho, rfl⟩)) + +/-- A representative occurrence exists for every nonempty internal class of +the actual paired pattern, without an extra arithmetic assumption. -/ +theorem movingPattern_representative_nonempty {B C : Type*} + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (c : C) : + Nonempty (MovingPairRepresentativeOccurrences + (fun side => movingPatternSlotData n (t side) (small side) (bulk side) pattern side) (.inr c)) := by + let i := rep c + have h := movingSample_occurs n (t i.val.1) + (treeLeafMap (List.map Sum.inl) n (small i.val.1)) (treeLeafMap (List.map Sum.inl) n (bulk i.val.1)) + (movingPatternSamples (B ⊕ C) n (Sum.inr ∘ pattern) i.val.1) i.val.2 + simp only [movingPatternSamples, Equiv.apply_symm_apply, Function.comp_apply, i.property] at h + obtain ⟨o, ho, hi⟩ := h + change o ∈ (movingPatternSlotData n (t i.val.1) (small i.val.1) (bulk i.val.1) pattern i.val.1).occurrences at ho + obtain ⟨k, hk, hko⟩ := List.mem_iff_getElem.mp ho + refine ⟨⟨i.val.1, ⟨⟨k, hk⟩, ?_⟩⟩⟩ + simpa only [List.get_eq_getElem, hko] using hi + +noncomputable def movingPatternRepresentative {B C : Type*} + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : Bool → TreeLeafTuple (List B) n) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (c : C) : + MovingPairRepresentativeOccurrences + (fun side => movingPatternSlotData n (t side) (small side) (bulk side) pattern side) (.inr c) := + Classical.choice (movingPattern_representative_nonempty n t small bulk pattern rep c) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePairExpansion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePairExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a8443eb672eb04f74e6e2c285ffdd6245dfddf7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePairExpansion.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRecursiveCompensation + +namespace OAI + +/-! # Exact paired expansion of the fully supported sampled coefficient + +The equality-pattern scalar is the literal original prior times all node +compensations. The remaining coefficient retains every support test. +-/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingCompensatedAverage {A : Type*} [Fintype A] + (μ : ℕ → A → ℝ) (value : A → ℕ) (n : ℕ) (H : MovingSampleSlots A n → ℂ) : ℂ := + ∑ a, (((movingSampleProduct value a : ℝ) * movingSamplesPrior μ a : ℝ) : ℂ) * H a + +theorem movingCompensatedAverage_pair {A : Type*} [Fintype A] + (μ : ℕ → A → ℝ) (value : A → ℕ) (n : ℕ) (H K : MovingSampleSlots A n → ℂ) : + movingCompensatedAverage μ value n H * star (movingCompensatedAverage μ value n K) = + ∑ a, ∑ b, (movingPairCompensatedMass μ value (a, b) : ℂ) * H a * star (K b) := by + unfold movingCompensatedAverage + rw [star_sum, Finset.sum_mul] + simp_rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro b _ + simp only [movingPairCompensatedMass, Complex.ofReal_mul, star_mul, + Complex.star_def, Complex.conj_ofReal] + ring + +/-- The class assignments are injective, so coincidences are recorded exactly +once; no independence is ascribed to their induced law. -/ +theorem movingCompensatedAverage_pair_patterns {A : Type*} [Fintype A] + (μ : ℕ → A → ℝ) (value : A → ℕ) (n : ℕ) (H K : MovingSampleSlots A n → ℂ) : + letI := sampleSetoidFintype (Bool × MovingSampleIndex n) + movingCompensatedAverage μ value n H * star (movingCompensatedAverage μ value n K) = + ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ x : {x : Quotient s → A // Function.Injective x}, + let a := (movingSamplePairCoordinates A n).symm (fun i => x.val (Quotient.mk'' i)) + (internalPatternWeight (fun i => Quotient.mk'' i) + (fun i => μ (movingSampleTier i.2)) value x.val : ℂ) * H a.1 * star (K a.2) := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + rw [movingCompensatedAverage_pair, sum_movingSamplePair_patterns] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro x _ + dsimp only + have h := movingPairCompensatedMass_pattern μ value n + (fun i : Bool × MovingSampleIndex n => (Quotient.mk'' i : Quotient s)) x.val + dsimp only [Function.comp_def] at h + rw [h] + +noncomputable def movingSupportedSampleTerm {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (XL XR : ℕ) (a : MovingSampleSlots σ n) : ℂ := + movingSupportedWeight value outside (buildMovingSlotData n t small bulk a) XL XR + (recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingLocalExtra E)) n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ t) + +noncomputable def movingSupportedSampledWeight {σ : Type*} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (XL XR : ℕ) : ℂ := + movingSampledWeight value μ childBound pivotBound (movingGuardedLeaf value outside F) + (movingGuardedExtra value outside (movingLocalExtra (movingCompensatedExtra value E))) + n t small bulk XL XR + +theorem movingSupportedSampledWeight_eq {σ : Type*} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (XL XR : ℕ) : + movingSupportedSampledWeight value outside μ childBound pivotBound F E n t small bulk XL XR = + movingCompensatedAverage μ value n + (movingSupportedSampleTerm value outside childBound pivotBound F E n t small bulk XL XR) := + movingSampledWeight_compensated_supported value outside μ childBound pivotBound F E n t small bulk XL XR + +/-- The original supported coefficient squared, in the coordinates used by +Section 8's arithmetic comparison. Neither support nor the original weights +are discarded in passing to equality patterns. -/ +theorem movingSupportedSampledWeight_pair_patterns {σ : Type*} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (XL XR : ℕ) : + letI := sampleSetoidFintype (Bool × MovingSampleIndex n) + let W := movingSupportedSampledWeight value outside μ childBound pivotBound F E n t small bulk XL XR + let H := movingSupportedSampleTerm value outside childBound pivotBound F E n t small bulk XL XR + W * star W = ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ x : {x : Quotient s → σ // Function.Injective x}, + let a := (movingSamplePairCoordinates σ n).symm (fun i => x.val (Quotient.mk'' i)) + (internalPatternWeight (fun i => Quotient.mk'' i) + (fun i => μ (movingSampleTier i.2)) value x.val : ℂ) * H a.1 * star (H a.2) := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + rw [movingSupportedSampledWeight_eq] + exact movingCompensatedAverage_pair_patterns μ value n _ _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePairPatterns.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePairPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..e79d8a9c108bdff973e7b78d678397acadef50a3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePairPatterns.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationWeight +import OAI.NumberTheory.Ostmann.Tree.SampleEqualityPatterns + +namespace OAI + +/-! # Equality patterns of the two actual internal sample trees -/ + +namespace Ostmann +open scoped Classical BigOperators + +def movingSamplePairCoordinates (A : Type*) (n : ℕ) : + (MovingSampleSlots A n × MovingSampleSlots A n) ≃ (Bool × MovingSampleIndex n → A) where + toFun a i := if i.1 then movingSampleCoordinates A n a.2 i.2 + else movingSampleCoordinates A n a.1 i.2 + invFun x := ((movingSampleCoordinates A n).symm (fun i => x (false, i)), + (movingSampleCoordinates A n).symm (fun i => x (true, i))) + left_inv a := by + rcases a with ⟨l, r⟩ + simp only [Bool.false_eq_true, ite_false, ite_true, Equiv.symm_apply_apply] + right_inv x := by + funext i + rcases i with ⟨b, i⟩ + cases b <;> simp only [Bool.false_eq_true, ite_false, ite_true, Equiv.apply_symm_apply] + +@[simp] theorem movingSamplePairCoordinates_left {A : Type*} (n : ℕ) + (x : Bool × MovingSampleIndex n → A) (i : MovingSampleIndex n) : + movingSampleCoordinates A n ((movingSamplePairCoordinates A n).symm x).1 i = x (false, i) := by + exact congrFun ((movingSampleCoordinates A n).apply_symm_apply (fun i => x (false, i))) i + +@[simp] theorem movingSamplePairCoordinates_right {A : Type*} (n : ℕ) + (x : Bool × MovingSampleIndex n → A) (i : MovingSampleIndex n) : + movingSampleCoordinates A n ((movingSamplePairCoordinates A n).symm x).2 i = x (true, i) := by + exact congrFun ((movingSampleCoordinates A n).apply_symm_apply (fun i => x (true, i))) i + +theorem sum_movingSamplePair {A M : Type*} [Fintype A] [AddCommMonoid M] + (n : ℕ) (F : MovingSampleSlots A n → MovingSampleSlots A n → M) : + (∑ l, ∑ r, F l r) = ∑ x : Bool × MovingSampleIndex n → A, + F ((movingSamplePairCoordinates A n).symm x).1 ((movingSamplePairCoordinates A n).symm x).2 := by + have hs := Fintype.sum_prod_type (fun a : MovingSampleSlots A n × MovingSampleSlots A n => F a.1 a.2) + have he := (movingSamplePairCoordinates A n).symm.sum_comp + (fun a : MovingSampleSlots A n × MovingSampleSlots A n => F a.1 a.2) + simp only [finite_univ_canonical] at hs he ⊢ + exact hs.symm.trans he.symm + +/-- The two histories have exactly `4*n*2^n` independent internal draws, +irrespective of the number of protected bulk positions. -/ +theorem card_movingSamplePairIndex (n : ℕ) : + Fintype.card (Bool × MovingSampleIndex n) = 4 * n * 2 ^ n := by + rw [Fintype.card_prod, Fintype.card_bool, card_movingSampleIndex] + ring + +theorem movingSamplePair_compensated_prior {A : Type*} (μ : ℕ → A → ℝ) + (value : A → ℕ) (n : ℕ) (x : Bool × MovingSampleIndex n → A) : + let a := (movingSamplePairCoordinates A n).symm x + ((movingSampleProduct value a.1 : ℝ) * movingSamplesPrior μ a.1) * + ((movingSampleProduct value a.2 : ℝ) * movingSamplesPrior μ a.2) = + ∏ i : Bool × MovingSampleIndex n, (value (x i) : ℝ) * μ (movingSampleTier i.2) (x i) := by + dsimp only + rw [movingSamples_compensated_prior, movingSamples_compensated_prior, + Fintype.prod_prod_type, Fintype.prod_bool] + simp only [movingSamplePairCoordinates_left, movingSamplePairCoordinates_right] + ring + +/-- Exact decomposition of the original pair of sample trees by its +equality pattern. No restriction on coincidences between descendants is +inserted, and no factor depending on the bulk length appears. -/ +theorem sum_movingSamplePair_patterns {A M : Type*} [Fintype A] [AddCommMonoid M] + (n : ℕ) (F : MovingSampleSlots A n → MovingSampleSlots A n → M) : + letI := sampleSetoidFintype (Bool × MovingSampleIndex n) + (∑ l, ∑ r, F l r) = + ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ x : {x : Quotient s → A // Function.Injective x}, + let a := (movingSamplePairCoordinates A n).symm (fun i => x.val (Quotient.mk'' i)) + F a.1 a.2 := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + have h₁ := sum_movingSamplePair n F + have h₂ := sum_sample_equality_patterns (I := Bool × MovingSampleIndex n) (A := A) (M := M) + (fun x => F ((movingSamplePairCoordinates A n).symm x).1 + ((movingSamplePairCoordinates A n).symm x).2) + simp only [finite_univ_canonical] at h₁ h₂ ⊢ + exact h₁.trans h₂ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePatternBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePatternBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..371eed5fbc1882041f98977e54ca80c3c7518841 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePatternBudget.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePairPatterns + +namespace OAI + +/-! # Applying representative-prior domination to the literal sampled pair -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingPairCompensatedMass {A : Type*} (μ : ℕ → A → ℝ) + (prime : A → ℕ) {n : ℕ} (a : MovingSampleSlots A n × MovingSampleSlots A n) : ℝ := + ((movingSampleProduct prime a.1 : ℝ) * movingSamplesPrior μ a.1) * + ((movingSampleProduct prime a.2 : ℝ) * movingSamplesPrior μ a.2) + +theorem movingPairCompensatedMass_pattern {A C : Type*} (μ : ℕ → A → ℝ) + (prime : A → ℕ) (n : ℕ) (pattern : Bool × MovingSampleIndex n → C) (x : C → A) : + movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm (x ∘ pattern)) = + internalPatternWeight pattern (fun i => μ (movingSampleTier i.2)) prime x := by + rw [movingPairCompensatedMass, movingSamplePair_compensated_prior] + rfl + +/-- The weight bound needed by the proved symbolic-line comparison now +applies to the original two sample trees, including each node's `u` factor. -/ +theorem movingPairCompensatedMass_pattern_bound {A C : Type*} [Fintype C] + (μ : ℕ → A → ℝ) (prime : A → ℕ) (n : ℕ) + (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (C → A) → ℂ) (B : ℝ) (hB : 0 ≤ B) (hG : ∀ x, ‖G x‖ ≤ B) (x : C → A) : + ‖(movingPairCompensatedMass μ prime + ((movingSamplePairCoordinates A n).symm (x ∘ pattern)) : ℂ) * G x‖ * + (∏ c, (prime (x c) : ℝ)⁻¹) ≤ + (B * ((2 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + ∏ c, μ (movingSampleTier (rep c).val.2) (x c) := by + rw [movingPairCompensatedMass_pattern] + have h := internalPatternWeight_complex_bound pattern rep + (fun i => μ (movingSampleTier i.2)) prime E hprime + (fun i a => hμ _ a) (fun i a => hbound _ a) G B hB hG x + simpa only [card_movingSamplePairIndex] using h + +theorem sampleEqualityPattern_count_le (I : Type*) [Fintype I] : + let _ := sampleSetoidFintype I + Fintype.card (Setoid I) ≤ 2 ^ (Fintype.card I) ^ 2 := by + let _ := sampleSetoidFintype I + have hi : Function.Injective (fun s : Setoid I => {p : I × I | s p.1 p.2}) := by + intro s t h + ext i j + exact Set.ext_iff.mp h (i, j) + have h := Fintype.card_le_of_injective _ hi + simpa only [Fintype.card_set, Fintype.card_prod, pow_two] using h + +/-- A coarse sufficient bound for all patterns at a fixed transfer depth. +In particular no bulk-length variable enters the exponent. -/ +theorem movingSamplePair_pattern_count (n : ℕ) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + Fintype.card (Setoid (Bool × MovingSampleIndex n)) ≤ 2 ^ (4 * n * 2 ^ n) ^ 2 := by + simpa only [card_movingSamplePairIndex] using + sampleEqualityPattern_count_le (Bool × MovingSampleIndex n) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePeriod.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePeriod.lean new file mode 100644 index 0000000000000000000000000000000000000000..aab3e8074688e742aa00b88ca0f0e79b0c579356 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePeriod.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPeriodBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleSizes + +namespace OAI + +/-! # The residue period for actual four-slot samples -/ + +namespace Ostmann +open scoped Classical + +theorem movingNaturalProduct_le_pow {σ : Type*} (value : σ → ℕ) (P : ℕ) + (hvalue : ∀ i, value i ≤ P) (slots : List σ) : + MovingSlotReversal.naturalProduct value slots ≤ P ^ slots.length := by + induction slots with + | nil => simp [MovingSlotReversal.naturalProduct] + | cons i slots ih => + simpa only [MovingSlotReversal.naturalProduct, List.map_cons, List.prod_cons, + List.length_cons, pow_succ, mul_comm] using Nat.mul_le_mul (hvalue i) ih + +theorem MovingSlotData.CompensationBound.mono {σ : Type*} {n B C : ℕ} + {T : MovingSlotData σ n} (value : σ → ℕ) (h : T.CompensationBound value B) + (hBC : B ≤ C) : T.CompensationBound value C := by + induction T with + | leaf => trivial + | node s CL CR u left right ihL ihR => + exact ⟨h.1.trans hBC, ihL h.2.1, ihR h.2.2⟩ + +/-- Only the four compensation samples at each leaf enter the denominator. +The lengths of the bulk and initial small-prime lists do not enter this bound. -/ +theorem buildMovingSlotData_compensation_bound {σ : Type*} (value : σ → ℕ) + (P : ℕ) (hP : 1 ≤ P) (hvalue : ∀ i, value i ≤ P) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) : + (buildMovingSlotData n t small bulk samples).CompensationBound value (P ^ (4 * 2 ^ n)) := by + induction samples with + | leaf => trivial + | @node n samples left right ihL ihR => + have he : 4 * 2 ^ n ≤ 4 * 2 ^ (n + 1) := by rw [pow_succ]; omega + have hp := Nat.pow_le_pow_right hP he + refine ⟨?_, (ihL _ _ _).mono value hp, (ihR _ _ _).mono value hp⟩ + apply (movingNaturalProduct_le_pow value P hvalue _).trans + apply Nat.pow_le_pow_right hP + have hl := moving_flatten_length_le n (movingCompensationSlots n samples) 4 + (moving_compensation_length n samples) + exact hl.trans (by rw [pow_succ]; omega) + +/-- The concrete common modulus is controlled by the frequency cutoff and +compensation-prime cutoff alone, uniformly in both top giants. -/ +theorem movingSample_topPeriod_bound {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (P V : ℕ) (hP : 1 ≤ P) (hV : 1 ≤ V) + (hvalueP : ∀ i, value i ≤ P) (childBound pivotBound : ℕ → ℕ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) + (hf : (buildMovingSlotData n t small bulk samples).Frequencies (· ≠ 0)) + (hfreq : (buildMovingSlotData n t small bulk samples).Frequencies (fun s => s.natAbs ≤ V)) : + movingTopPeriod value hvalue childBound pivotBound + (buildMovingSlotData n t small bulk samples) hf ≤ + (V * P ^ (4 * 2 ^ n)) ^ (4 * (4 ^ n - 1)) := by + have hp : 1 ≤ P ^ (4 * 2 ^ n) := Nat.one_le_pow _ _ hP + have hVB : V ≤ V * P ^ (4 * 2 ^ n) := by nlinarith + have hPB : P ^ (4 * 2 ^ n) ≤ V * P ^ (4 * 2 ^ n) := by nlinarith + apply movingTopPeriod_bound value hvalue childBound pivotBound _ hf _ (hV.trans hVB) + · have hmap {r : ℕ} (T : MovingSlotData σ r) + (h : T.Frequencies (fun s => s.natAbs ≤ V)) : + T.Frequencies (fun s => s.natAbs ≤ V * P ^ (4 * 2 ^ n)) := by + induction T with + | leaf => exact h.trans hVB + | node s CL CR u left right ihL ihR => exact ⟨h.1.trans hVB, ihL h.2.1, ihR h.2.2⟩ + exact hmap _ hfreq + · exact (buildMovingSlotData_compensation_bound value P hP hvalueP n t small bulk samples).mono value hPB + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePrimeExpansion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePrimeExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..85bdc1f735fd3e5dcab6dd8007d46abecc25175e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePrimeExpansion.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalSampleExpansion +import OAI.NumberTheory.Ostmann.ZeroDensity.ComplexPrimeWeights + +namespace OAI + +/-! # The exact sample expansion inside the actual giant-prime averages -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem complexPrimeInterval_sum {I : Type*} (q a : ℕ) (u v : ℝ) + (S : Finset I) (F : I → ℝ → ℂ) : + complexPrimeInterval q a u v (fun x => ∑ i ∈ S, F i x) = + ∑ i ∈ S, complexPrimeInterval q a u v (F i) := by + unfold complexPrimeInterval + simp only [Finset.sum_mul] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro p _ + by_cases h : p.Prime ∧ Nat.ModEq q p a + · simp [h] + · simp [h] + +theorem complexPrimeInterval_const_mul (q a : ℕ) (u v : ℝ) (c : ℂ) (F : ℝ → ℂ) : + complexPrimeInterval q a u v (fun x => c * F x) = + c * complexPrimeInterval q a u v F := by + unfold complexPrimeInterval + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro p _ + split_ifs <;> simp only [mul_assoc, mul_zero] + +theorem complexPrimePair_sum {I : Type*} (u v r s : ℝ) + (S : Finset I) (F : I → ℝ → ℝ → ℂ) : + complexPrimeInterval 1 0 r s (fun y => + complexPrimeInterval 1 0 u v (fun x => ∑ i ∈ S, F i x y)) = + ∑ i ∈ S, complexPrimeInterval 1 0 r s (fun y => + complexPrimeInterval 1 0 u v (fun x => F i x y)) := by + simp_rw [complexPrimeInterval_sum] + +theorem complexPrimePair_const_mul (u v r s : ℝ) (c : ℂ) (F : ℝ → ℝ → ℂ) : + complexPrimeInterval 1 0 r s (fun y => + complexPrimeInterval 1 0 u v (fun x => c * F x y)) = + c * complexPrimeInterval 1 0 r s (fun y => + complexPrimeInterval 1 0 u v (fun x => F x y)) := by + simp_rw [complexPrimeInterval_const_mul] + +/-- No prime asymptotic or independence approximation enters this exchange: +these are finite sums over the original two giant-prime intervals. -/ +theorem movingCompensatedAverage_prime_pair_patterns {A : Type*} [Fintype A] + (μ : ℕ → A → ℝ) (value : A → ℕ) (n : ℕ) + (H K : ℝ → ℝ → MovingSampleSlots A n → ℂ) (u v r s : ℝ) : + letI := sampleSetoidFintype (Bool × MovingSampleIndex n) + complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + movingCompensatedAverage μ value n (H x y) * + star (movingCompensatedAverage μ value n (K x y)))) = + ∑ eqp : Setoid (Bool × MovingSampleIndex n), + ∑ z : {z : Quotient eqp → A // Function.Injective z}, + let a := (movingSamplePairCoordinates A n).symm (fun i => z.val (Quotient.mk'' i)) + (internalPatternWeight (fun i => Quotient.mk'' i) + (fun i => μ (movingSampleTier i.2)) value z.val : ℂ) * + complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + H x y a.1 * star (K x y a.2))) := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + simp_rw [movingCompensatedAverage_pair_patterns, complexPrimeInterval_sum] + apply Finset.sum_congr rfl + intro eqp _ + apply Finset.sum_congr rfl + intro z _ + simp_rw [mul_assoc, complexPrimeInterval_const_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePrior.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePrior.lean new file mode 100644 index 0000000000000000000000000000000000000000..10f3c881919d98b2749359de570eea89bb3ad57d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSamplePrior.lean @@ -0,0 +1,137 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleValues +import OAI.NumberTheory.Ostmann.Construction.FiniteEnumeration + +namespace OAI + +/-! # The original independent compensation samples + +Section 7.4, equations (7.10)--(7.11), samples one compensation vector at +each node. That vector is shared by its two children; samples subsequently +made in the children are independent. These are the literal finite priors, +before any distinctness or equality-pattern restriction. +-/ + +namespace Ostmann +open scoped Classical BigOperators + +def movingSampleNodeEquiv (A : Type*) (n : ℕ) : + TreeLeafTuple (Fin 4 → A) n × MovingSampleSlots A n × MovingSampleSlots A n ≃ + MovingSampleSlots A (n + 1) where + toFun x := .node x.1 x.2.1 x.2.2 + invFun x := match x with | .node a l r => (a, l, r) + left_inv _ := rfl + right_inv x := by cases x; rfl + +def movingSampleZeroEquiv (A : Type*) : Unit ≃ MovingSampleSlots A 0 where + toFun _ := .leaf + invFun _ := () + left_inv _ := rfl + right_inv x := by cases x; rfl + +noncomputable instance movingSampleSlotsFintype (A : Type*) [Fintype A] : + (n : ℕ) → Fintype (MovingSampleSlots A n) + | 0 => Fintype.ofEquiv Unit (movingSampleZeroEquiv A) + | n + 1 => @Fintype.ofEquiv _ _ + (@instFintypeProd _ _ (treeLeafTupleFintype (Fin 4 → A) n) + (@instFintypeProd _ _ (movingSampleSlotsFintype A n) (movingSampleSlotsFintype A n))) + (movingSampleNodeEquiv A n) + +noncomputable def movingCompensationPrior {A : Type*} (μ : A → ℝ) : + (n : ℕ) → TreeLeafTuple (Fin 4 → A) n → ℝ + | 0, a => ∏ i : Fin 4, μ (a i) + | n + 1, a => movingCompensationPrior μ n a.1 * movingCompensationPrior μ n a.2 + +noncomputable def movingSamplesPrior {A : Type*} (μ : ℕ → A → ℝ) : + {n : ℕ} → MovingSampleSlots A n → ℝ + | _, .leaf => 1 + | n + 1, .node a l r => + movingCompensationPrior (μ n) n a * movingSamplesPrior μ l * movingSamplesPrior μ r + +theorem movingCompensationPrior_nonneg {A : Type*} (μ : A → ℝ) + (hμ : ∀ a, 0 ≤ μ a) (n : ℕ) (a : TreeLeafTuple (Fin 4 → A) n) : + 0 ≤ movingCompensationPrior μ n a := by + induction n with + | zero => exact Finset.prod_nonneg (fun i _ => hμ (a i)) + | succ n ih => exact mul_nonneg (ih a.1) (ih a.2) + +theorem movingSamplesPrior_nonneg {A : Type*} (μ : ℕ → A → ℝ) + (hμ : ∀ n a, 0 ≤ μ n a) {n : ℕ} (a : MovingSampleSlots A n) : + 0 ≤ movingSamplesPrior μ a := by + induction a with + | leaf => exact zero_le_one + | node a l r hl hr => + exact mul_nonneg (mul_nonneg (movingCompensationPrior_nonneg _ (hμ _) _ a) hl) hr + +theorem movingCompensationPrior_mass {A : Type*} [Fintype A] (μ : A → ℝ) + (hμ : ∑ a, μ a = 1) (n : ℕ) : + ∑ a : TreeLeafTuple (Fin 4 → A) n, movingCompensationPrior μ n a = 1 := by + induction n with + | zero => + change (∑ a : Fin 4 → A, ∏ i : Fin 4, μ (a i)) = 1 + rw [← Fintype.prod_sum] + simp only [hμ, Finset.prod_const_one] + | succ n ih => + change (∑ a : TreeLeafTuple (Fin 4 → A) n × TreeLeafTuple (Fin 4 → A) n, + movingCompensationPrior μ n a.1 * movingCompensationPrior μ n a.2) = 1 + rw [Fintype.sum_prod_type, ← Finset.sum_mul_sum, ih, one_mul] + +theorem sum_movingSample_node {A M : Type*} [Fintype A] [AddCommMonoid M] + (n : ℕ) (f : MovingSampleSlots A (n + 1) → M) : + (∑ a, f a) = ∑ u : TreeLeafTuple (Fin 4 → A) n, + ∑ l : MovingSampleSlots A n, ∑ r : MovingSampleSlots A n, f (.node u l r) := by + have h := (movingSampleNodeEquiv A n).sum_comp f + simp only [finite_univ_canonical] at h ⊢ + rw [← h] + have h₁ := Fintype.sum_prod_type (fun x : TreeLeafTuple (Fin 4 → A) n × + MovingSampleSlots A n × MovingSampleSlots A n => f ((movingSampleNodeEquiv A n) x)) + simp only [finite_univ_canonical] at h₁ + rw [h₁] + apply Finset.sum_congr rfl + intro u _ + have h₂ := Fintype.sum_prod_type (fun x : MovingSampleSlots A n × MovingSampleSlots A n => + f (.node u x.1 x.2)) + simp only [finite_univ_canonical] at h₂ + refine Eq.trans ?_ h₂ + apply Finset.sum_congr rfl + intro x _ + rfl + +theorem movingSamplesPrior_mass {A : Type*} [Fintype A] (μ : ℕ → A → ℝ) + (hμ : ∀ n, ∑ a, μ n a = 1) (n : ℕ) : + ∑ a : MovingSampleSlots A n, movingSamplesPrior μ a = 1 := by + induction n with + | zero => + have h := (movingSampleZeroEquiv A).sum_comp (movingSamplesPrior μ) + simpa only [movingSampleZeroEquiv, Equiv.coe_fn_mk, movingSamplesPrior, + Finset.univ_unique, Finset.sum_singleton] using h.symm + | succ n ih => + rw [sum_movingSample_node] + simp only [movingSamplesPrior, ← Finset.mul_sum, ih, mul_one, + movingCompensationPrior_mass _ (hμ n)] + +/-- Independent descendants factor, while the single root vector is retained +outside both child expectations. No prime-distinctness event is conditioned on. -/ +theorem movingSamplesPrior_node_product {A : Type*} [Fintype A] + (μ : ℕ → A → ℝ) (n : ℕ) + (c : TreeLeafTuple (Fin 4 → A) n → ℂ) + (L R : TreeLeafTuple (Fin 4 → A) n → MovingSampleSlots A n → ℂ) : + (∑ a : MovingSampleSlots A (n + 1), (movingSamplesPrior μ a : ℂ) * + (match a with | .node u l r => c u * L u l * star (R u r))) = + ∑ u : TreeLeafTuple (Fin 4 → A) n, (movingCompensationPrior (μ n) n u : ℂ) * c u * + (∑ l : MovingSampleSlots A n, (movingSamplesPrior μ l : ℂ) * L u l) * + star (∑ r : MovingSampleSlots A n, (movingSamplesPrior μ r : ℂ) * R u r) := by + rw [sum_movingSample_node] + apply Finset.sum_congr rfl + intro u _ + simp only [movingSamplesPrior, Complex.ofReal_mul, star_sum, star_mul, + Complex.star_def, Complex.conj_ofReal, Finset.mul_sum, Finset.sum_mul] + conv_rhs => rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro l _ + apply Finset.sum_congr rfl + intro r _ + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleSizes.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleSizes.lean new file mode 100644 index 0000000000000000000000000000000000000000..b67504e0b52d69e6a7f086528a2cfbed205d8819 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleSizes.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleSlots + +namespace OAI + +/-! # Concrete degree budgets for the sampled moving-giant paths -/ + +namespace Ostmann + +def MovingLeafLengthLE {σ : Type*} : (n : ℕ) → TreeLeafTuple (List σ) n → ℕ → Prop + | 0, x, A => (show List σ from x).length ≤ A + | n + 1, x, A => MovingLeafLengthLE n x.1 A ∧ MovingLeafLengthLE n x.2 A + +theorem moving_flatten_length_le {σ : Type*} (n : ℕ) (x : TreeLeafTuple (List σ) n) + (A : ℕ) (hx : MovingLeafLengthLE n x A) : + (flattenMovingSlots n x).length ≤ 2 ^ n * A := by + induction n with + | zero => simpa only [MovingLeafLengthLE, flattenMovingSlots, pow_zero, one_mul] using hx + | succ n ih => + simp only [flattenMovingSlots, List.length_append] + have h := Nat.add_le_add (ih x.1 hx.1) (ih x.2 hx.2) + convert h using 1 + rw [pow_succ] + ring + +theorem moving_append_length_le {σ : Type*} (n : ℕ) + (x y : TreeLeafTuple (List σ) n) (A B : ℕ) + (hx : MovingLeafLengthLE n x A) (hy : MovingLeafLengthLE n y B) : + MovingLeafLengthLE n (appendMovingSlotLeaves n x y) (A + B) := by + induction n with + | zero => + change ((show List σ from x) ++ (show List σ from y)).length ≤ A + B + rw [List.length_append] + exact Nat.add_le_add hx hy + | succ n ih => exact ⟨ih x.1 y.1 hx.1 hy.1, ih x.2 y.2 hx.2 hy.2⟩ + +theorem moving_compensation_length {σ : Type*} (n : ℕ) + (samples : TreeLeafTuple (Fin 4 → σ) n) : + MovingLeafLengthLE n (movingCompensationSlots n samples) 4 := by + induction n with + | zero => simp [MovingLeafLengthLE, movingCompensationSlots] + | succ n ih => exact ⟨ih samples.1, ih samples.2⟩ + +def MovingSlotData.SizeLE {σ : Type*} (D : ℕ) : {n : ℕ} → MovingSlotData σ n → Prop + | _, .leaf _ _ => True + | _, .node _ CL CR u left right => + CL.length ≤ D ∧ CR.length ≤ D ∧ u.length ≤ D ∧ left.SizeLE D ∧ right.SizeLE D + +theorem MovingSlotData.SizeLE.mono {σ : Type*} {n D E : ℕ} {T : MovingSlotData σ n} + (h : T.SizeLE D) (hDE : D ≤ E) : T.SizeLE E := by + induction T with + | leaf => trivial + | node s CL CR u left right ihL ihR => + exact ⟨h.1.trans hDE, h.2.1.trans hDE, h.2.2.1.trans hDE, ihL h.2.2.2.1, ihR h.2.2.2.2⟩ + +/-- Compensation adds exactly four labels per bottom leaf per level. -/ +theorem buildMovingSlotData_size {σ : Type*} (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (samples : MovingSampleSlots σ n) + (A B : ℕ) (hsmall : MovingLeafLengthLE n small A) (hbulk : MovingLeafLengthLE n bulk B) : + (buildMovingSlotData n t small bulk samples).SizeLE (2 ^ n * (A + B + 4 * n + 4)) := by + induction samples generalizing A B with + | leaf => trivial + | @node n samples left right ihL ihR => + have hp : 0 < 2 ^ n := by positivity + have hleft := ihL t.2.1 (appendMovingSlotLeaves n (movingCompensationSlots n samples) small.1) + bulk.1 (4 + A) B (moving_append_length_le n _ _ 4 A + (moving_compensation_length n samples) hsmall.1) hbulk.1 + have hright := ihR t.2.2 (appendMovingSlotLeaves n (movingCompensationSlots n samples) small.2) + bulk.2 (4 + A) B (moving_append_length_le n _ _ 4 A + (moving_compensation_length n samples) hsmall.2) hbulk.2 + have hD : 2 ^ n * (4 + A + B + 4 * n + 4) ≤ 2 ^ (n + 1) * (A + B + 4 * (n + 1) + 4) := by + rw [pow_succ] + nlinarith + have hbase : 2 ^ n * A + 2 ^ n * B ≤ 2 ^ (n + 1) * (A + B + 4 * (n + 1) + 4) := by + rw [pow_succ] + nlinarith + have hcomp : 2 ^ n * 4 ≤ 2 ^ (n + 1) * (A + B + 4 * (n + 1) + 4) := by + rw [pow_succ] + nlinarith + refine ⟨?_, ?_, ?_, hleft.mono hD, hright.mono hD⟩ + · rw [List.length_append] + exact (Nat.add_le_add (moving_flatten_length_le n _ A hsmall.1) + (moving_flatten_length_le n _ B hbulk.1)).trans hbase + · rw [List.length_append] + exact (Nat.add_le_add (moving_flatten_length_le n _ A hsmall.2) + (moving_flatten_length_le n _ B hbulk.2)).trans hbase + · exact (moving_flatten_length_le n _ 4 (moving_compensation_length n samples)).trans hcomp + +theorem MovingSlotData.occurrence_size {σ : Type*} {n D : ℕ} + (T : MovingSlotData σ n) (hT : T.SizeLE D) : + ∀ o ∈ T.occurrences, + o.current.lengthLE D ∧ ∀ s ∈ o.path, s.lengthLE D := by + induction T with + | leaf => simp [occurrences] + | @node n s CL CR u left right ihL ihR => + intro o ho + have hb (b : Bool) : (step s CL CR u left right b).lengthLE D := + ⟨hT.2.1, hT.1, hT.2.2.1⟩ + rcases List.mem_cons.mp ho with ho | ho + · subst o + exact ⟨hb false, by simp⟩ + · rcases List.mem_append.mp ho with ho | ho + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + have h := ihL hT.2.2.2.1 o' ho' + refine ⟨h.1, ?_⟩ + intro t ht + rcases List.mem_append.mp ht with ht | ht + · exact h.2 t ht + · simpa only [List.mem_singleton.mp ht] using hb true + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + have h := ihR hT.2.2.2.2 o' ho' + refine ⟨h.1, ?_⟩ + intro t ht + rcases List.mem_append.mp ht with ht | ht + · exact h.2 t ht + · simpa only [List.mem_singleton.mp ht] using hb false + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleSlots.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleSlots.lean new file mode 100644 index 0000000000000000000000000000000000000000..751f5e9c77bf2c5ad2e08ffb9e4d748e189b5849 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleSlots.lean @@ -0,0 +1,129 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotOccurrences +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantSamples + +namespace OAI + +/-! # Labelled four-slot samples and the concrete occurrence paths -/ + +namespace Ostmann +open scoped Classical + +/-- The same sampler as `MovingGiantSamples`, before the prime labels have +been evaluated. Four actual positions are used at each child leaf. -/ +inductive MovingSampleSlots (σ : Type*) : ℕ → Type _ + | leaf : MovingSampleSlots σ 0 + | node {n : ℕ} (samples : TreeLeafTuple (Fin 4 → σ) n) + (left right : MovingSampleSlots σ n) : MovingSampleSlots σ (n + 1) + +def movingCompensationSlots {σ : Type*} : (n : ℕ) → + TreeLeafTuple (Fin 4 → σ) n → TreeLeafTuple (List σ) n + | 0, x => List.ofFn (show Fin 4 → σ from x) + | n + 1, x => (movingCompensationSlots n x.1, movingCompensationSlots n x.2) + +def flattenMovingSlots {σ : Type*} : (n : ℕ) → TreeLeafTuple (List σ) n → List σ + | 0, x => (show List σ from x) + | n + 1, x => flattenMovingSlots n x.1 ++ flattenMovingSlots n x.2 + +def appendMovingSlotLeaves {σ : Type*} : (n : ℕ) → + TreeLeafTuple (List σ) n → TreeLeafTuple (List σ) n → TreeLeafTuple (List σ) n + | 0, x, y => (show List σ from x) ++ (show List σ from y) + | n + 1, x, y => (appendMovingSlotLeaves n x.1 y.1, appendMovingSlotLeaves n x.2 y.2) + +theorem flattenMovingSlots_append_bound {σ : Type*} (tier : σ → ℕ) (r n : ℕ) + (x y : TreeLeafTuple (List σ) n) + (hx : ∀ i ∈ flattenMovingSlots n x, r ≤ tier i) + (hy : ∀ i ∈ flattenMovingSlots n y, r ≤ tier i) : + ∀ i ∈ flattenMovingSlots n (appendMovingSlotLeaves n x y), r ≤ tier i := by + induction n with + | zero => + intro i hi + exact (List.mem_append.mp hi).elim (hx i) (hy i) + | succ n ih => + intro i hi + rcases List.mem_append.mp hi with hi | hi + · exact ih x.1 y.1 (fun i h => hx i (List.mem_append_left _ h)) + (fun i h => hy i (List.mem_append_left _ h)) i hi + · exact ih x.2 y.2 (fun i h => hx i (List.mem_append_right _ h)) + (fun i h => hy i (List.mem_append_right _ h)) i hi + +def MovingSampleSlots.Levels {σ : Type*} (tier : σ → ℕ) : + {n : ℕ} → MovingSampleSlots σ n → Prop + | _, .leaf => True + | n + 1, .node samples left right => + (∀ i ∈ flattenMovingSlots n (movingCompensationSlots n samples), tier i = n) ∧ + left.Levels tier ∧ right.Levels tier + +/-- This carries the source's compensation product into both child regular +lists while retaining the per-leaf distribution of the four samples. -/ +def buildMovingSlotData {σ : Type*} : (n : ℕ) → FrequencyTree ℤ n → + TreeLeafTuple (List σ) n → TreeLeafTuple (List σ) n → + MovingSampleSlots σ n → MovingSlotData σ n + | 0, t, small, bulk, .leaf => + .leaf (frequencyRoot 0 t) (flattenMovingSlots 0 small ++ flattenMovingSlots 0 bulk) + | n + 1, t, small, bulk, .node samples left right => + let u := movingCompensationSlots n samples + .node t.1 + (flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1) + (flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2) + (flattenMovingSlots n u) + (buildMovingSlotData n t.2.1 (appendMovingSlotLeaves n u small.1) bulk.1 left) + (buildMovingSlotData n t.2.2 (appendMovingSlotLeaves n u small.2) bulk.2 right) + +theorem buildMovingSlotData_levels {σ : Type*} (tier : σ → ℕ) (n : ℕ) + (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) + (hsmall : ∀ i ∈ flattenMovingSlots n small, n ≤ tier i) + (hbulk : ∀ i ∈ flattenMovingSlots n bulk, n ≤ tier i) + (hsamples : samples.Levels tier) : + (buildMovingSlotData n t small bulk samples).Levels tier := by + induction samples with + | leaf => trivial + | @node n samples left right ihL ihR => + have hsmallL : ∀ i ∈ flattenMovingSlots n small.1, n + 1 ≤ tier i := + fun i hi => hsmall i (List.mem_append_left _ hi) + have hsmallR : ∀ i ∈ flattenMovingSlots n small.2, n + 1 ≤ tier i := + fun i hi => hsmall i (List.mem_append_right _ hi) + have hbulkL : ∀ i ∈ flattenMovingSlots n bulk.1, n + 1 ≤ tier i := + fun i hi => hbulk i (List.mem_append_left _ hi) + have hbulkR : ∀ i ∈ flattenMovingSlots n bulk.2, n + 1 ≤ tier i := + fun i hi => hbulk i (List.mem_append_right _ hi) + refine ⟨?_, ?_, hsamples.1, ?_, ?_⟩ + · intro i hi + exact (List.mem_append.mp hi).elim (hsmallL i) (hbulkL i) + · intro i hi + exact (List.mem_append.mp hi).elim (hsmallR i) (hbulkR i) + · apply ihL _ _ _ _ _ hsamples.2.1 + · apply flattenMovingSlots_append_bound + · intro i hi + exact le_of_eq (hsamples.1 i hi).symm + · intro i hi + exact (Nat.le_succ n).trans (hsmallL i hi) + · intro i hi + exact (Nat.le_succ n).trans (hbulkL i hi) + · apply ihR _ _ _ _ _ hsamples.2.2 + · apply flattenMovingSlots_append_bound + · intro i hi + exact le_of_eq (hsamples.1 i hi).symm + · intro i hi + exact (Nat.le_succ n).trans (hsmallR i hi) + · intro i hi + exact (Nat.le_succ n).trans (hbulkR i hi) + +/-- Omission is now a proved fact of the actual sample constructor. -/ +theorem buildMovingSlotData_occurrence_absent {σ : Type*} (tier : σ → ℕ) (n : ℕ) + (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) + (hsmall : ∀ i ∈ flattenMovingSlots n small, n ≤ tier i) + (hbulk : ∀ i ∈ flattenMovingSlots n bulk, n ≤ tier i) + (hsamples : samples.Levels tier) (o : MovingSlotOccurrence σ) + (ho : o ∈ (buildMovingSlotData n t small bulk samples).occurrences) + (i : σ) (hi : tier i < o.level) : + (∀ s ∈ o.path, i ∉ s.leftSlots ∧ i ∉ s.rightSlots ∧ i ∉ s.compensationSlots) ∧ + i ∉ o.current.leftSlots ∧ i ∉ o.current.rightSlots := by + have h := MovingSlotData.occurrence_bounds tier _ + (buildMovingSlotData_levels tier n t small bulk samples hsmall hbulk hsamples) o ho + exact o.absent_of_level tier h.2.2 i hi + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleSpectator.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleSpectator.lean new file mode 100644 index 0000000000000000000000000000000000000000..e504ff3e18c74bca2cfea73e7d264a528791ef81 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleSpectator.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotSpectator + +namespace OAI + +/-! # The full recursive coefficient has the constructed spectator diagram -/ + +namespace Ostmann +open scoped Classical + +@[simp] theorem MovingGiantTree.castConstant_amplitude {q : ℕ} [Fact q.Prime] + (g : ZMod q → ℂ) (D : (ZMod q)ˣ) {n C E : ℕ} (h : C = E) + (T : MovingGiantTree n C) (XL XR : ℕ) (bulk : TreeLeafTuple ℕ n) : + movingGiantAmplitude g D (T.castConstant h) XL XR bulk = + movingGiantAmplitude g D T XL XR bulk := by + subst E + rfl + +theorem buildMovingSlotData_spectator {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (g : ZMod q → ℂ) (D : (ZMod q)ˣ) (n : ℕ) + (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) (XL XR : ℕ) : + movingSlotSpectator value g D (buildMovingSlotData n t small bulk samples) XL XR = + movingGiantAmplitude g D + (buildMovingGiantTree n t (movingSlotValues value n small) (samples.values value)) + XL XR (movingSlotValues value n bulk) := by + induction samples generalizing XL XR with + | leaf => + simp only [buildMovingSlotData, movingSlotSpectator, MovingSampleSlots.values, + buildMovingGiantTree, movingGiantAmplitude, movingSlotValues, treeLeafProduct, + flattenMovingSlots, movingNaturalProduct_append, Nat.mul_assoc] + | @node n samples left right ihL ihR => + let u := movingCompensationSlots n samples + let L := buildMovingSlotData n t.2.1 (appendMovingSlotLeaves n u small.1) bulk.1 left + let R := buildMovingSlotData n t.2.2 (appendMovingSlotLeaves n u small.2) bulk.2 right + let p := (MovingSlotData.step t.1 + (flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1) + (flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2) + (flattenMovingSlots n u) L R false).naturalPivot value XL XR + have hp : p = movingGiantPivot t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + (treeLeafProduct n (movingSlotValues value n small.1)) + (treeLeafProduct n (movingSlotValues value n small.2)) + (treeLeafProduct n (compensationLeafProducts n (movingCompensationValues value n samples))) + XL XR (treeLeafProduct n (movingSlotValues value n bulk.1)) + (treeLeafProduct n (movingSlotValues value n bulk.2)) := by + simp only [p, L, R, MovingSlotReversal.naturalPivot, MovingSlotData.step, + buildMovingSlotData_frequency, movingNaturalProduct_append, movingSlotValues_flatten, + movingGiantPivot, Nat.mul_one, Nat.mul_assoc] + rw [← movingCompensationValues_product] + have hL := ihL t.2.1 (appendMovingSlotLeaves n u small.1) bulk.1 p XL + have hR := ihR t.2.2 (appendMovingSlotLeaves n u small.2) bulk.2 p XR + change (if (p : ZMod q) = 0 then 0 else + movingSlotSpectator value g D L p XL * star (movingSlotSpectator value g D R p XR)) = _ + rw [hL, hR] + simp only [buildMovingGiantTree, MovingSampleSlots.values, movingSlotValues, + movingGiantAmplitude, MovingGiantTree.castConstant_frequency, + buildMovingGiantTree_frequency, MovingGiantTree.castConstant_amplitude] + rw [← hp] + dsimp only [u] + rw [movingSlotValues_append, movingSlotValues_append, movingCompensationValues_product] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleValues.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleValues.lean new file mode 100644 index 0000000000000000000000000000000000000000..f9250d0d13bf2dd8e8d4545be256526f176da336 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampleValues.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleSlots +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotRealization + +namespace OAI + +/-! # The labelled sampler evaluates to the actual natural prime sampler -/ + +namespace Ostmann +open scoped BigOperators + +def movingSlotValues {σ : Type*} (value : σ → ℕ) : (n : ℕ) → + TreeLeafTuple (List σ) n → TreeLeafTuple ℕ n + | 0, x => MovingSlotReversal.naturalProduct value (show List σ from x) + | n + 1, x => (movingSlotValues value n x.1, movingSlotValues value n x.2) + +def movingCompensationValues {σ : Type*} (value : σ → ℕ) : (n : ℕ) → + TreeLeafTuple (Fin 4 → σ) n → TreeLeafTuple (Fin 4 → ℕ) n + | 0, x => fun i => value ((show Fin 4 → σ from x) i) + | n + 1, x => (movingCompensationValues value n x.1, movingCompensationValues value n x.2) + +def MovingSampleSlots.values {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSampleSlots σ n → MovingGiantSamples n + | _, .leaf => .leaf + | n + 1, .node samples left right => + .node (movingCompensationValues value n samples) (left.values value) (right.values value) + +theorem movingNaturalProduct_append {σ : Type*} (value : σ → ℕ) (x y : List σ) : + MovingSlotReversal.naturalProduct value (x ++ y) = + MovingSlotReversal.naturalProduct value x * MovingSlotReversal.naturalProduct value y := by + simp only [MovingSlotReversal.naturalProduct, List.map_append, List.prod_append] + +theorem movingSlotValues_flatten {σ : Type*} (value : σ → ℕ) (n : ℕ) + (x : TreeLeafTuple (List σ) n) : + MovingSlotReversal.naturalProduct value (flattenMovingSlots n x) = + treeLeafProduct n (movingSlotValues value n x) := by + induction n with + | zero => rfl + | succ n ih => + simp only [flattenMovingSlots, MovingSlotReversal.naturalProduct, List.map_append, + List.prod_append, movingSlotValues, treeLeafProduct] + exact congrArg₂ (· * ·) (ih x.1) (ih x.2) + +theorem movingSlotValues_append {σ : Type*} (value : σ → ℕ) (n : ℕ) + (x y : TreeLeafTuple (List σ) n) : + movingSlotValues value n (appendMovingSlotLeaves n x y) = + multiplySmallLeaves n (movingSlotValues value n x) (movingSlotValues value n y) := by + induction n with + | zero => + simp only [movingSlotValues, appendMovingSlotLeaves, multiplySmallLeaves, + MovingSlotReversal.naturalProduct, List.map_append, List.prod_append] + | succ n ih => exact Prod.ext (ih x.1 y.1) (ih x.2 y.2) + +theorem movingCompensationValues_product {σ : Type*} (value : σ → ℕ) (n : ℕ) + (x : TreeLeafTuple (Fin 4 → σ) n) : + movingSlotValues value n (movingCompensationSlots n x) = + compensationLeafProducts n (movingCompensationValues value n x) := by + induction n with + | zero => + change ((List.ofFn (show Fin 4 → σ from x)).map value).prod = ∏ i : Fin 4, value (x i) + rw [List.map_ofFn, List.prod_ofFn] + rfl + | succ n ih => exact Prod.ext (ih x.1) (ih x.2) + +theorem buildMovingSlotData_frequency {σ : Type*} (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (samples : MovingSampleSlots σ n) : + (buildMovingSlotData n t small bulk samples).frequency = frequencyRoot n t := by + cases samples <;> rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampledIndexedProbability.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampledIndexedProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3240fad32ae35f1c9062a1fe70248ee325f7e47 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampledIndexedProbability.lean @@ -0,0 +1,46 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingIndexedProbability +import OAI.NumberTheory.Ostmann.Arithmetic.MovingLineIntegration + +namespace OAI + +/-! # Actual prime samples in the fixed line-probability coordinates -/ + +namespace Ostmann +open scoped Classical + +noncomputable def movingSampledInternalProbability {A : Type*} {N n : ℕ} + (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) + (T : Bool → MovingSlotData (Fin N) n) (x : Fin N → A) (rep : Fin N) : ℝ := + letI : Fact (prime (x rep)).Prime := ⟨hprime (x rep)⟩ + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction (prime (x rep)) (fun i => prime (x i)) + (movingPrimeOccurrenceLine (fun i => prime (x i)) T (prime (x rep)) j).a) + (fun j => MovingSlotReversal.naturalReduction (prime (x rep)) (fun i => prime (x i)) + (movingPrimeOccurrenceLine (fun i => prime (x i)) T (prime (x rep)) j).b) + +theorem movingSampledIndexedProbability {A : Type*} {N n : ℕ} + (prime : A → ℕ) (hprime : ∀ a, (prime a).Prime) (x : Fin N → A) + (T : Bool → MovingSlotData (Fin N) n) (tier : Fin N → ℕ) + (hdisjoint : ∀ i j, tier i ≠ tier j → prime (x i) ≠ prime (x j)) + (hlevels : ∀ side, (T side).Levels tier) + (rep : Fin N) (base : MovingPairRepresentativeOccurrences T rep) + (hunique : ∀ i, prime (x i) = prime (x rep) → i = rep) + (hf : ∀ side, (T side).Frequencies (fun s => (s : ZMod (prime (x rep))) ≠ 0)) : + letI : Fact (prime (x rep)).Prime := ⟨hprime (x rep)⟩ + internalLineProbability true + (fun j => MovingSlotReversal.naturalReduction (prime (x rep)) (fun i => prime (x i)) + (movingPrimeOccurrenceLine (fun i => prime (x i)) T (prime (x rep)) j).a) + (fun j => MovingSlotReversal.naturalReduction (prime (x rep)) (fun i => prime (x i)) + (movingPrimeOccurrenceLine (fun i => prime (x i)) T (prime (x rep)) j).b) = + movingSlotLineProbability (fun a => (prime a : ℤ)) prime hprime + (fun o => (movingIndexedOccurrence T rep base o).path) + (fun o => (movingIndexedOccurrence T rep base o).current) true x (x rep) := by + let : Fact (prime (x rep)).Prime := ⟨hprime (x rep)⟩ + have h := movingInternalBaseProbability_indexed_normalized T tier (fun i => prime (x i)) + (fun i => hprime (x i)) hdisjoint hlevels rep base hunique hf + simpa only [movingSlotLineProbability, integerLineReduction, + MovingSlotReversal.naturalReduction, Int.cast_natCast, movingIndexedLine] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampledRecursion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampledRecursion.lean new file mode 100644 index 0000000000000000000000000000000000000000..11203fb4ce142192e7d36ce9617e0a76ea382765 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSampledRecursion.lean @@ -0,0 +1,175 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotSystem + +namespace OAI + +/-! # Expanding the sampled giant recursion into its literal histories + +This is the recursion of Section 7.4 (7.10)--(7.11), rather than the +whole-atom recursion of Section 4. Each root sample is used by both children. +The child sample trees are independent under the original finite law. +-/ + +namespace Ostmann +open scoped Classical BigOperators + +def MovingSlotData.frequencyTree {σ : Type*} : {n : ℕ} → + MovingSlotData σ n → FrequencyTree ℤ n + | _, .leaf s _ => s + | _, .node s _ _ _ l r => (s, l.frequencyTree, r.frequencyTree) + +theorem buildMovingSlotData_frequencyTree {σ : Type*} (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (a : MovingSampleSlots σ n) : + (buildMovingSlotData n t small bulk a).frequencyTree = t := by + induction a with + | leaf => rfl + | node a l r hl hr => + exact Prod.ext rfl (Prod.ext (hl _ _ _) (hr _ _ _)) + +/-- Discard descendant prime data, keeping all their frequencies. Root +cutoffs may still impose the cross-branch frequency tests of Section 7.4. -/ +def movingFrequencySkeleton (σ : Type*) : (n : ℕ) → FrequencyTree ℤ n → MovingSlotData σ n + | 0, t => .leaf t [] + | n + 1, t => .node t.1 [] [] [] + (movingFrequencySkeleton σ n t.2.1) (movingFrequencySkeleton σ n t.2.2) + +def MovingSlotData.rootData {σ : Type*} : {n : ℕ} → MovingSlotData σ n → MovingSlotData σ n + | _, .leaf s regular => .leaf s regular + | n + 1, .node s CL CR u l r => .node s CL CR u + (movingFrequencySkeleton σ n l.frequencyTree) (movingFrequencySkeleton σ n r.frequencyTree) + +def movingRootState {σ : Type*} (n : ℕ) (t : FrequencyTree ℤ (n + 1)) + (CL CR u : List σ) (XL XR : ℕ) : MovingSlotState σ := + ⟨n + 1, .node t.1 CL CR u + (movingFrequencySkeleton σ n t.2.1) (movingFrequencySkeleton σ n t.2.2), XL, XR⟩ + +/-- Original node factors depend on the current prime lists, two giants and +complete frequency tree, not on prime samples which will be made later. -/ +noncomputable def movingLocalExtra {σ : Type*} + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (x : MovingSlotState σ) (s v w : ℤ) : ℝ := + E ⟨x.depth, x.data.rootData, x.leftGiant, x.rightGiant⟩ s v w + +noncomputable def movingSampleRootFactor {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ (n + 1)) (CL CR u : List σ) (XL XR : ℕ) : ℂ := + let x := movingRootState n t CL CR u XL XR + let sys := movingSlotSystem value childBound pivotBound + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let P := historyPivot sys x t.1 v w + if ValidTransferNode sys x t.1 v w P then + (movingSlotCutoff value childBound pivotBound E x t.1 v w : ℂ) else 0 + +/-- The actual termwise node identity, including failed integer and +divisibility tests. The new giant is the quotient of the composite pivot. -/ +theorem movingSample_weight_node {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ (n + 1)) + (small bulk : TreeLeafTuple (List σ) (n + 1)) + (a : TreeLeafTuple (Fin 4 → σ) n) (l r : MovingSampleSlots σ n) (XL XR : ℕ) : + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let p := historyPivot (movingSlotSystem value childBound pivotBound) + (movingRootState n t CL CR (flattenMovingSlots n u) XL XR) t.1 + (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) / + MovingSlotReversal.naturalProduct value (flattenMovingSlots n u) + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingLocalExtra E)) (n + 1) + ⟨n + 1, buildMovingSlotData (n + 1) t small bulk (.node a l r), XL, XR⟩ t = + movingSampleRootFactor value childBound pivotBound E n t CL CR (flattenMovingSlots n u) XL XR * + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingLocalExtra E)) n + ⟨n, buildMovingSlotData n t.2.1 (appendMovingSlotLeaves n u small.1) bulk.1 l, p, XL⟩ t.2.1 * + star (recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingLocalExtra E)) n + ⟨n, buildMovingSlotData n t.2.2 (appendMovingSlotLeaves n u small.2) bulk.2 r, p, XR⟩ t.2.2) := by + dsimp only + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let x : MovingSlotState σ := + ⟨n + 1, buildMovingSlotData (n + 1) t small bulk (.node a l r), XL, XR⟩ + let y := movingRootState n t CL CR (flattenMovingSlots n u) XL XR + let sys := movingSlotSystem value childBound pivotBound + let P := historyPivot sys y t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + have hp : historyPivot sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) = P := rfl + have hv : ValidTransferNode sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) P ↔ + ValidTransferNode sys y t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) P := by + constructor <;> intro h <;> + exact ⟨h.root_ne_zero, h.root_unit, h.relation, h.pivot_pos, h.pivot_bound, + h.left_bound, h.right_bound, h.range_gap, h.pivot_unit⟩ + have hc : movingSlotCutoff value childBound pivotBound (movingLocalExtra E) x t.1 + (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) = + movingSlotCutoff value childBound pivotBound E y t.1 + (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) := by + unfold movingSlotCutoff + have he : movingLocalExtra E x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) = + E y t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) := by + simp only [movingLocalExtra, x, buildMovingSlotData, MovingSlotData.rootData, + buildMovingSlotData_frequencyTree] + rfl + rw [he] + rfl + change recursiveTransferWeight sys F _ (n + 1) x t = _ + rw [recursiveTransferWeight] + simp only [hp] + rw [hv, hc] + by_cases h : ValidTransferNode sys y t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) P + · simp only [h, ite_true] + change _ = (if ValidTransferNode sys y t.1 _ _ P then _ else 0) * _ * _ + rw [ite_eq_left h] + rfl + · simp only [h, ite_false] + change 0 = (if ValidTransferNode sys y t.1 _ _ P then _ else 0) * _ * _ + rw [ite_eq_right h, zero_mul, zero_mul] + +/-- The finite expansion keeps every internal sample's original prior. -/ +noncomputable def movingSampledWeight {σ : Type*} [Fintype σ] (value : σ → ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) (XL XR : ℕ) : ℂ := + ∑ a : MovingSampleSlots σ n, (movingSamplesPrior μ a : ℂ) * + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound (movingLocalExtra E)) n + ⟨n, buildMovingSlotData n t small bulk a, XL, XR⟩ t + +theorem movingSampledWeight_node {σ : Type*} [Fintype σ] (value : σ → ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (E : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (t : FrequencyTree ℤ (n + 1)) + (small bulk : TreeLeafTuple (List σ) (n + 1)) (XL XR : ℕ) : + movingSampledWeight value μ childBound pivotBound F E (n + 1) t small bulk XL XR = + ∑ a : TreeLeafTuple (Fin 4 → σ) n, + let u := movingCompensationSlots n a + let CL := flattenMovingSlots n small.1 ++ flattenMovingSlots n bulk.1 + let CR := flattenMovingSlots n small.2 ++ flattenMovingSlots n bulk.2 + let p := historyPivot (movingSlotSystem value childBound pivotBound) + (movingRootState n t CL CR (flattenMovingSlots n u) XL XR) t.1 + (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) / + MovingSlotReversal.naturalProduct value (flattenMovingSlots n u) + (movingCompensationPrior (μ n) n a : ℂ) * + movingSampleRootFactor value childBound pivotBound E n t CL CR (flattenMovingSlots n u) XL XR * + movingSampledWeight value μ childBound pivotBound F E n t.2.1 + (appendMovingSlotLeaves n u small.1) bulk.1 p XL * + star (movingSampledWeight value μ childBound pivotBound F E n t.2.2 + (appendMovingSlotLeaves n u small.2) bulk.2 p XR) := by + unfold movingSampledWeight + rw [sum_movingSample_node] + simp_rw [movingSample_weight_node] + simp only [movingSamplesPrior, Complex.ofReal_mul, star_sum, star_mul, + Complex.star_def, Complex.conj_ofReal, Finset.mul_sum, Finset.sum_mul] + apply Finset.sum_congr rfl + intro a _ + conv_rhs => rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro l _ + apply Finset.sum_congr rfl + intro r _ + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingScalarWindows.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingScalarWindows.lean new file mode 100644 index 0000000000000000000000000000000000000000..e590091ffe24a055240ce1fa15172b445cbf0a8d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingScalarWindows.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFourierSupported + +namespace OAI + +/-! # The remaining original scalar and its literal terminal windows -/ + +namespace Ostmann +open scoped Classical + +noncomputable def movingDataLeaf {σ : Type*} + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) (x : MovingSlotState σ) (s : ℤ) : ℂ := + F x.data s + +noncomputable def movingDataExtra {σ : Type*} + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (x : MovingSlotState σ) (s v w : ℤ) : ℝ := E x.data s v w + +noncomputable def movingDataWeight {σ : Type*} + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) : + {n : ℕ} → MovingSlotData σ n → ℂ + | _, T@(.leaf s _) => F T s + | _, T@(.node s _ _ _ left right) => + (E T s left.frequency right.frequency : ℂ) * movingDataWeight F E left * + star (movingDataWeight F E right) + +theorem movingUnrestrictedWeight_data {σ : Type*} (value : σ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : + movingUnrestrictedWeight value (movingDataLeaf F) (movingDataExtra E) T XL XR = + movingDataWeight F E T := by + induction T generalizing XL XR with + | leaf => rfl + | node s CL CR U left right ihL ihR => + simp only [movingUnrestrictedWeight, movingDataExtra, ihL, ihR, movingDataWeight] + +/-- Sharp terminal windows leave one fixed scalar coefficient. The test is +on the actual terminal moduli obtained by the integer moving recursion. -/ +theorem movingUnrestrictedWeight_data_window {σ : Type*} (value : σ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : + movingUnrestrictedWeight value (movingWindowLeaf value X lo hi (movingDataLeaf F)) + (movingDataExtra E) T XL XR = + if ∀ i, (T.leafModuli value XL XR i : ℝ) / X ∈ Set.Icc lo hi + then movingDataWeight F E T else 0 := by + induction T generalizing XL XR with + | leaf s regular => + simp only [movingUnrestrictedWeight, movingWindowLeaf, movingSlotModulus, + movingDataLeaf, movingDataWeight, MovingSlotData.leafModuli, forall_const] + rfl + | @node n s CL CR U left right ihL ihR => + let p := (MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR + have hforall : (∀ i, ((MovingSlotData.node s CL CR U left right).leafModuli value XL XR i : ℝ) / X ∈ Set.Icc lo hi) ↔ + (∀ i, (left.leafModuli value p XL i : ℝ) / X ∈ Set.Icc lo hi) ∧ + (∀ i, (right.leafModuli value p XR i : ℝ) / X ∈ Set.Icc lo hi) := by + constructor + · intro h + exact ⟨fun i => h (.inl i), fun i => h (.inr i)⟩ + · rintro ⟨hL, hR⟩ i + cases i with + | inl i => exact hL i + | inr i => exact hR i + rw [movingUnrestrictedWeight, ihL, ihR] + simp only [movingDataExtra, movingDataWeight, hforall] + by_cases hL : ∀ i, (left.leafModuli value p XL i : ℝ) / X ∈ Set.Icc lo hi <;> + by_cases hR : ∀ i, (right.leafModuli value p XR i : ℝ) / X ∈ Set.Icc lo hi <;> + simp only [p, hL, hR, forall_const, and_self, and_false, false_and, ite_true, ite_false, + star_zero, zero_mul, mul_zero] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingScheduledLeafCongruence.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingScheduledLeafCongruence.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ef899395b175497b5091daac4b5a265b7f84057 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingScheduledLeafCongruence.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFrequencyCoefficient + +namespace OAI + +/-! # Only the scheduled bottom frequencies evaluate a leaf multiplier -/ +namespace Ostmann +open scoped Classical BigOperators + +theorem recursiveTransferWeight_scheduled_leaf_congr {State : Type*} + (sys : TransferHistorySystem State) (F H : State → ℤ → ℂ) + (cutoff : State → ℤ → ℤ → ℤ → ℝ) (V : ℕ → ℕ) + (hF : ∀ x s, s.natAbs ≤ V 0 → F x s = H x s) + (n : ℕ) (x : State) (t : ScheduledFrequencyIndex V n) : + recursiveTransferWeight sys F cutoff n x (scheduledFrequencyHistory V n t) = + recursiveTransferWeight sys H cutoff n x (scheduledFrequencyHistory V n t) := by + induction n generalizing x with + | zero => exact hF x t.val ((mem_transferFrequencyRange _ _).mp t.property) + | succ n ih => + simp only [scheduledFrequencyHistory, recursiveTransferWeight] + rw [ih _ t.2.1, ih _ t.2.2] + +theorem recursiveTransferWeight_rooted_leaf_congr {State : Type*} + (sys : TransferHistorySystem State) (F H : State → ℤ → ℂ) + (cutoff : State → ℤ → ℤ → ℤ → ℝ) (V : ℕ → ℕ) + (hF : ∀ x s, s.natAbs ≤ V 0 → F x s = H x s) + (n : ℕ) (s : ℤ) (hs : s.natAbs ≤ V n) (x : State) + (t : MovingDescendantFrequencyIndex V n) : + recursiveTransferWeight sys F cutoff n x (movingRootedFrequencyTree V n s t) = + recursiveTransferWeight sys H cutoff n x (movingRootedFrequencyTree V n s t) := by + let root : transferFrequencyRange (V n) := ⟨s, (mem_transferFrequencyRange _ _).mpr hs⟩ + let d := (scheduledFrequencyRootEquiv V n).symm (root, t) + have he : scheduledFrequencyHistory V n d = movingRootedFrequencyTree V n s t := by + rw [scheduledFrequencyRootEquiv_history] + simp only [d, Equiv.apply_symm_apply, root] + rw [← he] + exact recursiveTransferWeight_scheduled_leaf_congr sys F H cutoff V hF n x d + +theorem movingFrequencyCoefficient_leaf_congr {P : Type} [Fintype P] + (value : P → ℕ) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F H : MovingSlotState P → ℤ → ℂ) + (hF : ∀ x s, s.natAbs ≤ V 0 → F x s = H x s) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n : ℕ) (s : ℤ) (hs : s.natAbs ≤ V n) + (small bulk : TreeLeafTuple (List P) n) (XL XR : ℕ) : + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n s small bulk XL XR = + movingFrequencyCoefficient value outside μ childBound pivotBound V H φ G n s small bulk XL XR := by + unfold movingFrequencyCoefficient + apply Finset.sum_congr rfl + intro t _ + rw [movingSupportedSampledWeight_eq, movingSupportedSampledWeight_eq] + unfold movingCompensatedAverage + apply Finset.sum_congr rfl + intro a _ + congr 1 + unfold movingSupportedSampleTerm + rw [recursiveTransferWeight_rooted_leaf_congr _ F H _ V hF n s hs] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedAmplitudeEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedAmplitudeEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..802dd96b5640c122e3f8e52dce174ebb6245f7dd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedAmplitudeEnergy.lean @@ -0,0 +1,132 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedFullEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeOriginalEnergyNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredPrimeLaws + +namespace OAI + +/-! # The published arithmetic estimate for the actual one-branch energy -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_amplitude_regular_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n ≤ k) + (A Wwin Bφ Dφ c K ε : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hε : 0 < ε) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot n r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi b : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot n r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)), + let H := G (n + 1) + let slot := movingTemplateBulk n r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V n : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, n ≤ tierB i) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot n (4 + r) m) + 4 * n * 2 ^ n) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j ≤ n → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V n ≤ primeLo → V n < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ n, (q : ℝ) ≤ Real.exp b) → + movingAmplitudeRegularEnergy primes (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p (fun _ => f) (fun i => normalizedResidueTransform (sets i)) + Dq Finset.univ ψ X (Real.exp Δ) hi) φ G n r m Qν (normalizedResidueFamily setsReg) ≤ + Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * b + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + H) * + (4 * (Real.exp ((2 ^ n : ℕ) * Δ + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + ε * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)))) := by + filter_upwards [P.moving_selected_template_full_diagonal_energy C hM ψ n (4 + r) k hk hn + A Wwin Bφ Dφ c K ε hA hWwin hBφ hDφ hc hK hε hdepth, + eventually_ge_atTop (0 : ℝ)] with L henergy hL + dsimp only + dsimp only at henergy + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets + primeLo cutoff tier X Δ hi b φ G global Qμ Qν setsReg + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hφ0 hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp hHbig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg hb + let m := spectatorBulkCount k L + let Qfull := movingRestoredPrimeSets n r m (Qμ n) Qν + have hall (R : Finset ℕ → Prop) (h0 : R (Qμ n)) (h1 : ∀ j, R (Qν j)) : ∀ j, R (Qfull j) := by + intro j + dsimp only [Qfull, movingRestoredPrimeSets] + cases (movingReverseTemplate n r m).symm j with + | inl _ => exact h0 + | inr j => exact h1 j + have hlow : Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ + Real.exp (Real.exp ((1 / 100 : ℝ) * L)) := by + apply Real.exp_le_exp.mpr + apply Real.exp_le_exp.mpr + linarith + have he := henergy (movingRestoredTiers n r m tierB) primes hprimes + childBound pivotBound V f outside p Dq sets primeLo cutoff tier X Δ hi φ G + (movingRestoredActive n r m) global Qμ Qfull setsReg (G (n + 1)) + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH (movingRestoredTiers_lower n r m tierB hB) + hm hp hsets hsetsp hpupper hφ hlip hφout hShell hdel hout + (fun j => by simpa only [Qfull, m, movingRestoredPrimeSets_bulk] using hν j) + hμP (hall (fun Q => Q ⊆ primes) (hμP n) hνP) hμmass + (hall (fun Q => c / Real.exp (K * L) ≤ ∑ q ∈ Q, (q : ℝ)⁻¹) (hμmass n) hνmass) + hμrange + (hall (fun Q => ∀ q ∈ Q, Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) + (fun q hq => hlow.trans (hμrange n q hq)) hνrange) + (movingRestoredActive_bulk n r m) houtcover hinjp hHbig + (fun j hj => hμtier j hj.le) + (movingRestoredPrimeSets_tier primes n r m (Qμ n) Qν tierB tier (hμtier n le_rfl) hνtier) + hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep + (fun z hz q hq => hall (fun Q => q ∉ Q) (hdeleteμ z hz q hq n) (hdeleteν z hz q hq)) hsetsReg + have hnrm := movingAmplitudeRegularEnergy_original_norm_le primes hprimes p outside + (fun j => primeSubsetPrior primes (Qμ j)) (fun j a => primeSubsetPrior_nonneg _ _ a) n r m + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ hφ0 hφout G Qν (normalizedResidueFamily setsReg) (G (n + 1)) b + (fun a ha => hb a (primeSubsetPrior_support _ _ a ha)) + dsimp only at hnrm + rw [← movingRestoredPrimeSets_prior primes n r m (Qμ n) Qν] at hnrm + exact hnrm.trans (mul_le_mul_of_nonneg_left he (Real.exp_nonneg _)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedDiagonalDecay.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedDiagonalDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..550c0273289c89f6a193bb3bd6f22e66fb1145d0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedDiagonalDecay.lean @@ -0,0 +1,160 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedLogDiagonal +import OAI.NumberTheory.Ostmann.Construction.SelectedDiagonalBudget + +namespace OAI + +/-! # Decay of the original selected diagonal from its explicit cell-gap inequality -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_log_diagonal_decay + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n + 2 < k) + (A Wwin Bφ Dφ c K εdiag Bs BD Bz B : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (hBs : 0 ≤ Bs) (hBD0 : 0 ≤ BD) (hBz : 9 ≤ Bz) + (hmassBudget : 4 * (K + 1) * r ≤ (k : ℝ) ^ 4) + (hBD : Bs + 2 * B + + (Real.log 2 - Real.log (1 / 16000 : ℝ) + 5 / 4 + 1 + Real.log 12 + 1 + εdiag) + 6 ≤ BD) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd b : ℝ) (lower : TreeLeafIndex (n + 2) × Fin r → ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let Δ := spectatorBaseGap Bs ((k : ℝ) ^ 4) m + let H := G ((n + 2) + 1) + let slot := movingTemplateBulk (n + 2) r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) (4 + r) m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j : TreeLeafIndex (n + 2) × Fin r, tierB (j.1, .inl j.2) ≠ k) → + (∀ j, tierB (slot j) = k) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j (q : primes), (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ (n + 2), (q : ℝ) ≤ Real.exp b) → + (∀ x, φ x ≤ 1) → + (∀ j : TreeLeafIndex (n + 2) × Fin r, ∀ q : primes, + (q : ℕ) ∈ Qν (j.1, .inl j.2) → Real.exp (lower j) ≤ (q : ℝ)) → + (∀ q : primes, V (n + 2) < (q : ℕ)) → + (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + 1 + + ((2 ^ (n + 2) * 4 : ℕ) : ℝ) * b - + ((∑ j, lower j) + (2 ^ (n + 2) : ℕ) * (cb - 1)) ≤ + -spectatorStepGap BD Bz ((k : ℝ) ^ 4) (2 ^ (n + 2) : ℕ) m) → + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r m (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + (smoothGiantPrior (smoothGiantPrimeRange H) φ H) + (fun i => primeSubsetPrior primes (Qν i)) (normalizedResidueFamily setsReg) ggiant favorable ≤ + Real.exp (-(2 * B + 3) * (2 ^ (n + 2) : ℕ) * m) := by + let gain := max 0 ((Real.log 2 + Real.log ((k : ℝ) ^ 4 / (1 / 16000 : ℝ)) + + Real.log (2 ^ (n + 2) : ℕ) + 1 + 2 * B + 6) * (2 ^ (n + 2) : ℕ)) + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hdiag⟩ := + P.moving_selected_log_amplitude_diagonal C hM ψ n r k hk hn + A Wwin Bφ Dφ c K εdiag gain hA hWwin hBφ hDφ hc hK hεdiag hdepth Dlog hDlog hloglip + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + have hnumeric := selected_diagonal_budget hM (n + 2) r k hk c K Bs BD Bz B 1 εdiag + hc hK hBs hBD0 (by norm_num) hεdiag.le (by simpa only [one_mul] using hmassBudget) hBz hBD + filter_upwards [hdiag, hnumeric] with L hdiag hnumeric + dsimp only at hdiag hnumeric ⊢ + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X hi φ G global Qμ Qν setsReg cb cd b lower ggiant favorable + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange hsmalltier hbulktier houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb hφ1 hlower hvr hgap + have he := hdiag tierB primes hprimes childBound pivotBound V f outside p Dq sets β + primeLo cutoff tier X (spectatorBaseGap Bs ((k : ℝ) ^ 4) (spectatorBulkCount k L)) hi φ G global Qμ Qν setsReg cb cd b lower ggiant favorable + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange hsmalltier hbulktier houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb hφ1 hlower hvr + let m := spectatorBulkCount k L + let H := G ((n + 2) + 1) + let arch := Real.exp (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + 1 + + ((2 ^ (n + 2) * 4 : ℕ) : ℝ) * b - + ((∑ j, lower j) + (2 ^ (n + 2) : ℕ) * (cb - 1))) + have hglobal : (global.card : ℝ) ≤ Real.exp ((K + 1) * L) := by + apply le_trans _ hdel + exact_mod_cast (show global.card ≤ global.card + + (Fintype.card (MovingRegularSlot (n + 2) (4 + r) m) + 4 * (n + 2) * 2 ^ (n + 2)) + + outside.length by omega) + have hnumer := hnumeric global Qν hglobal hν hνmass arch (Real.exp_nonneg _) + (Real.exp_le_exp.mpr hgap) + apply he.trans + have hexp : + Real.exp (smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H - (H - 1) - + ((∑ j, lower j) + (2 ^ (n + 2) : ℕ) * (cb - 1))) * + Real.exp (((2 ^ (n + 2) * 4 : ℕ) : ℝ) * b + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + H) = arch := by + rw [← Real.exp_add] + congr 1 + ring + have hreassoc (a b c d e : ℝ) : (a * b * c) * (d * e) = (a * d) * (b * c) * e := by ring + rw [hreassoc, hexp] + simpa only [gain, Nat.cast_pow, Nat.cast_ofNat] using hnumer + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedDiagonalEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedDiagonalEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ffc70a2950fe3ed987c445eddf8b662e01acf4e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedDiagonalEnergy.lean @@ -0,0 +1,169 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalSelectedPriors +import OAI.NumberTheory.Ostmann.Arithmetic.MovingDiagonalEnergyRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternEnumeration + +namespace OAI + +/-! # The actual mixed diagonal energy under selected harmonic prime laws -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The mixed diagonal energy estimate with its original arithmetic premise +fully supplied by the published progression estimate and the concrete cells. -/ +theorem PublishedProgressionInput.moving_selected_diagonal_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n ≤ k) + (A Wwin Bφ Dφ c K ε : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hε : 0 < ε) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (B : Type) [Fintype B] (tierB : B → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : B → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V n : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → MovingLeafLengthLE n small r₀ → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card B + 4 * n * 2 ^ n) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j, j < n → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V n ≤ primeLo → V n < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingOriginalDiagonalEnergy p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ G n small (bulkSlotLeaves n m slot) + (normalizedResidueFamily setsReg) Jleft Jright diagonal uG vG rG sG center‖ ≤ + Real.exp ((2 ^ n : ℕ) * Δ + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + ε * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + have hCprior : 1 ≤ K + 1 := (selected_harmonic_family_bounds c K hc hK).1 + filter_upwards [P.movingPattern_diagonal_selected_priors_rate C hM ψ n r₀ k + A Wwin Bφ Dφ c K hA hWwin hc hK hBφ hDφ, + movingOriginalDiagonalEnergy_pattern_rate ψ n k hk hn Bφ A (K + 1) ε + hA hCprior hε hdepth] with L hprime henergy + dsimp only + dsimp only at henergy + obtain ⟨D, hD, hdiv, henergy⟩ := henergy + intro B _ tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets + primeLo cutoff tier X Δ hi φ G small slot global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen + hm hp hsets hsetsp hpupper hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let j₀ : TreeLeafIndex n × Fin (spectatorBulkCount k L) := + ⟨Classical.choice inferInstance, ⟨0, hm⟩⟩ + obtain ⟨N, e, hNcard⟩ := movingPattern_enumeration B (slot j₀) n + have hdel' (s) : ((global.card + (N s + 1) + outside.length : ℕ) : ℝ) ≤ + Real.exp ((K + 1) * L) := by + exact (Nat.cast_le.mpr (Nat.add_le_add_right + (Nat.add_le_add_left (hNcard s) global.card) outside.length)).trans hdel + apply henergy B primes hprimes p + (fun j => primeSubsetPrior primes (Qμ j)) (fun j => primeSubsetPrior primes (Qν j)) + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq + X Δ hi φ G small slot (normalizedResidueFamily setsReg) outside Jleft Jright diagonal + uG vG rG sG center N e hV hf0 hcard hVn hV0 + intro s t + let rep : ∀ c : Quotient s, {i : Bool × MovingSampleIndex n // Quotient.mk'' i = c} := + fun c => ⟨c.out, Quotient.out_eq' c⟩ + have hS : ∀ a ∈ Sfreq, a ≠ 0 := fun a ha => (Finset.mem_erase.mp ha).1 + have hN : ∀ a ∈ Sfreq, a.natAbs ≤ V n := by + intro a ha + exact (mem_transferFrequencyRange _ _).mp (Finset.mem_erase.mp ha).2 + have hdiv' (q : ℕ) (hq : q ≠ 0) (hsize : q ≤ (V n) ^ 2) : (q.divisors.card : ℝ) ≤ D := by + apply hdiv q hq + calc + (q : ℝ) ≤ ((V n : ℕ) : ℝ) ^ 2 := by exact_mod_cast hsize + _ ≤ (Real.exp (A * spectatorBulkCount k L)) ^ 2 := pow_le_pow_left₀ (Nat.cast_nonneg _) hVn 2 + _ = Real.exp (2 * A * spectatorBulkCount k L) := by + rw [← Real.exp_nat_mul] + congr 1 + ring + have hh := hprime (Real.exp Δ) hi (Real.one_le_exp_iff.mpr hΔ) hhi hwindow + B (Quotient s) (N s) (e s) tierB + (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b t)) + Sfreq t (V n) (V 0) D small slot (fun i => Quotient.mk'' i) rep primes hprimes + childBound pivotBound f outside p Dq sets primeLo cutoff tier X j₀ φ G global Qμ Qν + (frequencyRoot n (frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n false t))) + setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter (fun _ => hsmall) hB (fun _ => hsmallLen) + rfl hS hN (fun _ a _ => hf a) hD hdiv' hm hp hsets hsetsp hpupper + hφ hlip hφout hShell (hdel' s) hout hν hμP hνP hμmass hνmass hμrange hνrange + houtcover hinjp huBig hrBig hVn hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband + hdeleteμ hdeletep hdeleteν + (hS _ (allFrequencyList_subtype_mem Sfreq n (frequencyPairProjection Sfreq n false t) _ + (frequencyRoot_mem_allFrequencyList n _))) + (hN _ (allFrequencyList_subtype_mem Sfreq n (frequencyPairProjection Sfreq n false t) _ + (frequencyRoot_mem_allFrequencyList n _))) hsetsReg + calc + _ ≤ _ := hh + _ ≤ _ := by + rw [Fintype.card_prod, card_treeLeafIndex, Fintype.card_fin] + have hw : 0 ≤ frequencyLeafWeight (pairedFrequencyLeaf Sfreq (V 0)) n t * + ((frequencySplitList Sfreq n t).map (pairFrequencySupportBound D)).prod := by + apply mul_nonneg + · exact frequencyLeafWeight_nonneg _ (fun _ => by + unfold pairedFrequencyLeaf + split_ifs <;> norm_num) n t + · apply List.prod_nonneg + intro a ha + obtain ⟨a, _, rfl⟩ := List.mem_map.mp ha + exact pairFrequencySupportBound_nonneg D a + have hκ : 0 ≤ (2 : ℝ) ^ Fintype.card (Quotient s) * + (Real.exp ((K + 1) * L)) ^ (4 * n * 2 ^ n - Fintype.card (Quotient s)) := by positivity + have hreserve : 0 ≤ + (((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt (Real.exp Δ)) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * + ((2 : ℝ) ^ (2 ^ n * spectatorBulkCount k L) * 3 ^ (2 ^ n * spectatorBulkCount k L)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq (V 0)) n t * + ((frequencySplitList Sfreq n t).map (pairFrequencySupportBound D)).prod) * + 2 ^ (2 ^ n * spectatorBulkCount k L) := by positivity + nlinarith only [mul_nonneg hκ hreserve] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedEarlyDiagonalDecay.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedEarlyDiagonalDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..170dac1d71ded2a1d86849d3737fb039fdb8ed2a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedEarlyDiagonalDecay.lean @@ -0,0 +1,151 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedEarlyLogDiagonal +import OAI.NumberTheory.Ostmann.Construction.EarlyDiagonalBudget + +namespace OAI + +/-! # The actual first two diagonals satisfy the iteration reserve -/ +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_early_log_diagonal_decay + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n < k) (hearly : n ≤ 1) + (A Wwin Bφ Dφ c K εdiag Bs BD Bz B : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (hBs : 0 ≤ Bs) (hBD0 : 0 ≤ BD) (hBz : 9 ≤ Bz) + (hmassBudget : 4 * (K + 1) * r ≤ (k : ℝ) ^ 4) + (hBD : Bs + 2 * B + + (Real.log 2 - Real.log (1 / 16000 : ℝ) + 5 / 4 + 1 + Real.log 12 + 1 + εdiag) + 6 ≤ BD) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot n r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X hi b : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot n r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd : ℝ) (lower : TreeLeafIndex n × Fin r → ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let Δ := spectatorBaseGap Bs ((k : ℝ) ^ 4) m + let H := G (n + 1) + let slot := movingTemplateBulk n r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V n : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, n ≤ tierB i) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot n (4 + r) m) + 4 * n * 2 ^ n) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j (q : primes), (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V n ≤ primeLo → V n < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ n, (q : ℝ) ≤ Real.exp b) → + (∀ j : TreeLeafIndex n × Fin r, tierB (j.1, .inl j.2) ≠ k) → + (∀ j, tierB (slot j) = k) → + (∀ x, φ x ≤ 1) → + (∀ j : TreeLeafIndex n × Fin r, ∀ q : primes, + (q : ℕ) ∈ Qν (j.1, .inl j.2) → Real.exp (lower j) ≤ (q : ℝ)) → + (∀ q : primes, V n < (q : ℕ)) → + (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + 1 + + ((2 ^ n * 4 : ℕ) : ℝ) * b - + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1)) ≤ + -spectatorStepGap BD Bz ((k : ℝ) ^ 4) (2 ^ n : ℕ) m) → + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G n r m (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + (smoothGiantPrior (smoothGiantPrimeRange H) φ H) + (fun i => primeSubsetPrior primes (Qν i)) (normalizedResidueFamily setsReg) ggiant favorable ≤ + Real.exp (-(2 * B + 3) * (2 ^ n : ℕ) * m) := by + let gain := max 0 ((Real.log 2 + Real.log ((k : ℝ) ^ 4 / (1 / 16000 : ℝ)) + + Real.log (2 ^ n : ℕ) + 1 + 2 * B + 6) * (2 ^ n : ℕ)) + have hdiag := P.moving_selected_early_log_diagonal C hM ψ n r k hk hn + A Wwin Bφ Dφ c K εdiag hA hWwin hBφ hDφ hc hK hεdiag hdepth + have hnumeric := selected_diagonal_budget hM n r k hk c K Bs BD Bz B 1 εdiag + hc hK hBs hBD0 (by norm_num) hεdiag.le (by simpa only [one_mul] using hmassBudget) hBz hBD + filter_upwards [hdiag, hnumeric] with L hdiag hnumeric + dsimp only at hdiag hnumeric ⊢ + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets + primeLo cutoff tier X hi b φ G global Qμ Qν setsReg cb cd lower ggiant favorable + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hφ0 hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp hHbig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg hb hsmalltier hbulktier hφ1 hlower hvr hgap + have he := hdiag tierB primes hprimes childBound pivotBound V f outside p Dq sets + primeLo cutoff tier X (spectatorBaseGap Bs ((k : ℝ) ^ 4) (spectatorBulkCount k L)) hi b + φ G global Qμ Qν setsReg cb cd lower ggiant favorable + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hφ0 hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp hHbig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg hb hsmalltier hbulktier hφ1 hlower hvr + let m := spectatorBulkCount k L + let H := G (n + 1) + let arch := Real.exp (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + 1 + + ((2 ^ n * 4 : ℕ) : ℝ) * b - + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1))) + have hglobal : (global.card : ℝ) ≤ Real.exp ((K + 1) * L) := by + apply le_trans _ hdel + exact_mod_cast (show global.card ≤ global.card + + (Fintype.card (MovingRegularSlot n (4 + r) m) + 4 * n * 2 ^ n) + + outside.length by omega) + have hnumer := hnumeric global Qν hglobal hν hνmass arch (Real.exp_nonneg _) + (Real.exp_le_exp.mpr hgap) + apply he.trans + have hexp : + Real.exp (smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H - (H - 1) - + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1))) * + Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * b + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + H) = arch := by + rw [← Real.exp_add] + congr 1 + ring + have hreassoc (a b c d e : ℝ) : (a * b * c) * (d * e) = (a * d) * (b * c) * e := by ring + rw [hreassoc, hexp] + have henergy := early_diagonal_energy_le n hearly (m : ℝ) + (Real.exp ((2 ^ n : ℕ) * spectatorBaseGap Bs ((k : ℝ) ^ 4) m + + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + εdiag * m)) + (Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) (Real.exp (-gain * m)) + (Nat.cast_nonneg _) (Real.exp_nonneg _) (Real.exp_nonneg _) (Real.exp_nonneg _) + apply (mul_le_mul_of_nonneg_left henergy (by positivity)).trans + simpa only [gain, Nat.cast_pow, Nat.cast_ofNat] using hnumer + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedEarlyLogDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedEarlyLogDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..994c86d02441aba194419f4def750e1bb7f6b2ec --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedEarlyLogDiagonal.lean @@ -0,0 +1,167 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedAmplitudeEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSupportedFullCost +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalLeafMultiplier +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantActiveSupport + +namespace OAI + +/-! # Original first-step diagonals from the single-assignment arithmetic bound -/ +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_early_log_diagonal + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n < k) + (A Wwin Bφ Dφ c K ε : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hε : 0 < ε) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot n r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi b : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot n r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd : ℝ) (lower : TreeLeafIndex n × Fin r → ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let H := G (n + 1) + let slot := movingTemplateBulk n r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V n : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, n ≤ tierB i) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot n (4 + r) m) + 4 * n * 2 ^ n) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j (q : primes), (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V n ≤ primeLo → V n < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ n, (q : ℝ) ≤ Real.exp b) → + (∀ j : TreeLeafIndex n × Fin r, tierB (j.1, .inl j.2) ≠ k) → + (∀ j, tierB (slot j) = k) → + (∀ x, φ x ≤ 1) → + (∀ j : TreeLeafIndex n × Fin r, ∀ q : primes, + (q : ℕ) ∈ Qν (j.1, .inl j.2) → Real.exp (lower j) ≤ (q : ℝ)) → + (∀ q : primes, V n < (q : ℕ)) → + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G n r m (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + (smoothGiantPrior (smoothGiantPrimeRange H) φ H) + (fun i => primeSubsetPrior primes (Qν i)) (normalizedResidueFamily setsReg) ggiant favorable ≤ + (Real.exp (smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H - (H - 1) - + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1))) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Qν i, (q : ℝ)⁻¹)⁻¹)) * + (Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * b + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + H) * + (4 * (Real.exp ((2 ^ n : ℕ) * Δ + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + ε * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))))) := by + filter_upwards [P.moving_selected_amplitude_regular_energy C hM ψ n r k hk hn.le + A Wwin Bφ Dφ c K ε hA hWwin hBφ hDφ hc hK hε hdepth, + eventually_ge_atTop (0 : ℝ)] with L henergy hL + dsimp only at henergy ⊢ + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets + primeLo cutoff tier X Δ hi b φ G global Qμ Qν setsReg cb cd lower ggiant favorable + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hφ0 hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp hHbig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg hb hsmalltier hbulktier hφ1 hlower hvr + have he := henergy tierB primes hprimes childBound pivotBound V f outside p Dq sets + primeLo cutoff tier X Δ hi b φ G global Qμ Qν setsReg + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hφ0 hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp hHbig (fun j _ => hμtier j) hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg hb + let m := spectatorBulkCount k L + let H := G (n + 1) + have hexp : Real.exp ((11 / 1000 : ℝ) * L) ≤ H - 1 := by + apply le_trans (Real.exp_le_exp.mpr _) hHbig + nlinarith only [hL] + have hPbound (a : primes) : (a : ℝ) ≤ Real.exp (H - 1) := + (hupper a).trans (Real.exp_le_exp.mpr hexp) + have hVbound : (V n : ℝ) ≤ Real.exp (H - 1) := by + apply (Nat.cast_le.mpr hNlo).trans + apply hloReal.le.trans + apply Real.exp_le_exp.mpr + apply le_trans (Real.exp_le_exp.mpr _) hHbig + nlinarith only [hL] + obtain ⟨hvg, hsep⟩ := smoothGiantPrior_active_separation (smoothGiantPrimeRange H) primes + (smoothGiantPrimeRange_prime H) φ H hφout (V n) hVbound hPbound + have hX (q : smoothGiantPrimeRange H) + (hq : smoothGiantPrior (smoothGiantPrimeRange H) φ H q ≠ 0) : + Real.exp (H - 1) ≤ (q : ℝ) := + (smoothGiantPrior_active_bounds _ (smoothGiantPrimeRange_prime H) φ H hφout q hq).1.le + let F : MovingSlotState primes → ℤ → ℂ := movingOriginalLeaf Subtype.val p (fun _ => f) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi + have hF (x) : F x 0 = 0 := movingOriginalLeaf_zero Subtype.val p (fun _ => f) + (fun _ => hf0) (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi x + have hcost := movingAmplitude_full_harmonic_unweighted_cost_supported primes + (smoothGiantPrimeRange H) (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + hprimes (smoothGiantPrimeRange_prime H) + tier k outside cb cd (fun j => primeSubsetPrior primes (Qμ j)) + (fun j a => primeSubsetPrior_nonneg _ _ a) + (fun j a ha => hμtier j a (primeSubsetPrior_support _ _ a ha)) + childBound pivotBound V F hF φ hφ0 hφ1 G n r m hn Qν + (fun j q hq => by rw [hνtier _ q (primeSubsetPrior_support _ _ q hq)]; exact hsmalltier j) + (fun j q hq => (hνtier _ q (primeSubsetPrior_support _ _ q hq)).trans (hbulktier j)) + lower (fun j q hq => hlower j q (primeSubsetPrior_support _ _ q hq)) + hvg hvr hsep (H - 1) hX (normalizedResidueFamily setsReg) ggiant favorable + have hFw : (fun x s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s) = + movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi := by + funext x s + exact (movingOriginalLeaf_mul Subtype.val p + (fun T => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ)) + (fun _ => f) (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi x s).symm + dsimp only at hcost + rw [hFw] at hcost + apply hcost.trans + apply mul_le_mul_of_nonneg_left he + apply mul_nonneg + · exact mul_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + · exact Finset.prod_nonneg (fun i _ => inv_nonneg.mpr + (Finset.sum_nonneg (fun q _ => inv_nonneg.mpr (Nat.cast_nonneg q)))) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedFullEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedFullEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..06c93e2c41afede829112158b37a0f60527caaf8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedFullEnergy.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedTemplateEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedEnergyPartition + +namespace OAI + +/-! # The selected-prior estimate on the entire smooth giant cell -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_template_full_diagonal_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n ≤ k) + (A Wwin Bφ Dφ c K ε : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hε : 0 < ε) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot n r₀ m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot n r₀ m → Bool) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot n r₀ m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (H : ℝ), + let small := movingTemplateSmall n r₀ m + let slot := movingTemplateBulk n r₀ m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V n : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, n ≤ tierB i) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot n r₀ m) + 4 * n * 2 ^ n) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active (slot j) = true) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j < n → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V n ≤ primeLo → V n < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingWeightedDiagonalEnergy p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ G n small (bulkSlotLeaves n m slot) + (fun s => movingTemplateExternalMultiplier primes _hprimes n r₀ m active outside + (normalizedResidueFamily setsReg) s φ H H false) (H - 1) (H + 1) (H - 1) (H + 1) H‖ ≤ + 4 * (Real.exp ((2 ^ n : ℕ) * Δ + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + ε * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) := by + filter_upwards [P.moving_selected_template_diagonal_energy C hM ψ n r₀ k hk hn + A Wwin Bφ Dφ c K ε hA hWwin hBφ hDφ hc hK hε hdepth] with L henergy + dsimp only + dsimp only at henergy + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets + primeLo cutoff tier X Δ hi φ G active global Qμ Qν setsReg H + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive houtcover hinjp hHbig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg + apply movingWeightedDiagonalEnergy_full_cell_bound p Subtype.val outside + (fun j => primeSubsetPrior primes (Qμ j)) (fun j => primeSubsetPrior primes (Qν j)) + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ G n (movingTemplateSmall n r₀ (spectatorBulkCount k L)) + (bulkSlotLeaves n (spectatorBulkCount k L) (movingTemplateBulk n r₀ (spectatorBulkCount k L))) + (fun s => movingTemplateExternalMultiplier primes hprimes n r₀ (spectatorBulkCount k L) + active outside (normalizedResidueFamily setsReg) s φ H H false) H H H + intro i j + have hu : H - 1 ≤ (if i then H else H - 1) := by split <;> linarith + have hr : H - 1 ≤ (if j then H else H - 1) := by split <;> linarith + have hv : (if i then H else H - 1) ≤ H := by split <;> linarith + exact henergy tierB primes hprimes childBound pivotBound V f outside p Dq sets + primeLo cutoff tier X Δ hi φ G active global Qμ Qν setsReg H H false + (if i then H else H - 1) ((if i then H else H - 1) + 1) + (if j then H else H - 1) ((if j then H else H - 1) + 1) H + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow (hH.trans hu) (hH.trans hr) + (by linarith) (by linarith) le_rfl le_rfl (by linarith) hB hm hp hsets hsetsp hpupper + hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass hμrange hνrange hactive + houtcover hinjp (hHbig.trans (by linarith)) (hHbig.trans hr) hμtier hνtier hNlo hNcut + hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedGoodCorrelation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedGoodCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..7d63d0a1c5952ed4a7794b8d66b4821d47cc3a66 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedGoodCorrelation.lean @@ -0,0 +1,144 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGoodSelectedPriors +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMatchedCorrelationRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternEnumeration + +namespace OAI + +/-! # The complete good-matching correlation under original selected harmonic priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_good_correlation + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) + (A Wwin Bφ Dφ c K gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (B : Type) [Fintype B] (tierB : B → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) (n + 2)) (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : B → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ 1) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → MovingLeafLengthLE (n + 2) small r₀ → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card B + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j, j < (n + 2) → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingOriginalMatchedCorrelation p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ G (n + 2) small (movingPatternBulkLeaves (n + 2) m slot perm) + (normalizedResidueFamily setsReg) Jleft Jright diagonal uG vG rG sG center‖ ≤ + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + have hCprior : 1 ≤ K + 1 := (selected_harmonic_family_bounds c K hc hK).1 + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hprime⟩ := + P.movingPattern_good_selected_priors_rate C hM ψ n r₀ k A Wwin Bφ Dφ c K + (goodPatternGain (n + 2) (K + 1) A gain) hA hWwin hc hK hBφ hDφ + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hprime, movingOriginalMatchedCorrelation_pattern_rate ψ (n + 2) k hk + A (K + 1) gain hA hCprior] with L hprime hcorr + dsimp only at hcorr ⊢ + intro B _ tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G small slot perm global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen + hm hp hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + let _ := sampleSetoidFintype (Bool × MovingSampleIndex (n + 2)) + let j₀ : TreeLeafIndex (n + 2) × Fin (spectatorBulkCount k L) := + ⟨Classical.choice inferInstance, ⟨0, by omega⟩⟩ + obtain ⟨N, e, hNcard⟩ := movingPattern_enumeration B (slot j₀) (n + 2) + have hdel' (s) : ((global.card + (N s + 1) + outside.length : ℕ) : ℝ) ≤ + Real.exp ((K + 1) * L) := by + exact (Nat.cast_le.mpr (Nat.add_le_add_right + (Nat.add_le_add_left (hNcard s) global.card) outside.length)).trans hdel + apply hcorr B primes hprimes p + (fun j => primeSubsetPrior primes (Qμ j)) (fun j => primeSubsetPrior primes (Qν j)) + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq + X Δ hi φ G small slot perm (normalizedResidueFamily setsReg) outside Jleft Jright diagonal + uG vG rG sG center N e hV hf0 hcard + intro s t + let rep : ∀ c : Quotient s, {i : Bool × MovingSampleIndex (n + 2) // Quotient.mk'' i = c} := + fun c => ⟨c.out, Quotient.out_eq' c⟩ + have hS : ∀ a ∈ Sfreq, a ≠ 0 := fun a ha => (Finset.mem_erase.mp ha).1 + have hN : ∀ a ∈ Sfreq, a.natAbs ≤ V (n + 2) := by + intro a ha + exact (mem_transferFrequencyRange _ _).mp (Finset.mem_erase.mp ha).2 + have hh := hprime (Real.exp Δ) hi (Real.one_le_exp_iff.mpr hΔ) hhi hwindow + B (Quotient s) (N s) (e s) tierB + (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b t)) + Sfreq t (V (n + 2)) small slot perm (fun i => Quotient.mk'' i) rep primes hprimes + childBound pivotBound f outside p Dq sets β primeLo cutoff tier X j₀ φ G global Qμ Qν + (frequencyRoot (n + 2) (frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) false t))) + setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter (fun _ => hsmall) hB (fun _ => hsmallLen) + rfl hS hN hf hm hp hsets hsetsp hpupper hgood hdlo hdhi hβ hbias + hφ hlip hφout hShell (hdel' s) hout hν hμP hνP hμmass hνmass hμrange hνrange + houtcover hinjp huBig hrBig hVn hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband + hdeleteμ hdeletep hdeleteν hdeletebulk + (hS _ (allFrequencyList_subtype_mem Sfreq (n + 2) (frequencyPairProjection Sfreq (n + 2) false t) _ + (frequencyRoot_mem_allFrequencyList (n + 2) _))) + (hN _ (allFrequencyList_subtype_mem Sfreq (n + 2) (frequencyPairProjection Sfreq (n + 2) false t) _ + (frequencyRoot_mem_allFrequencyList (n + 2) _))) hsetsReg + simpa only [add_assoc] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialAmplitudeEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialAmplitudeEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..b09240ce685bf9f1195780f0124d63e2742739cb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialAmplitudeEnergy.lean @@ -0,0 +1,162 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedInitialFullEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSymmetrizedNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredTierSeparation + +namespace OAI + +/-! # The retained-log symmetrized amplitude with its original compensation law -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_initial_amplitude_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n + 2 < k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, ∀ b : ℕ, spectatorBulkCount k L = b + b → + let m := b + b + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (d rinit : ℕ) (sl sr : Fin d → primes) (fallback : primes) + (childBound pivotBound V : ℕ → ℕ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd btop : ℝ), + let H := G ((n + 2) + 1) + let slot := movingTemplateBulk (n + 2) r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + 4 + r + 4 * (n + 2) = rinit + rinit → + Monotone V → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) (4 + r) m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j ≤ n + 2 → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ (n + 2), (q : ℝ) ≤ Real.exp btop) → + movingAmplitudeSymmetrizedRegularEnergy primes (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d rinit cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r m Qν (normalizedResidueFamily setsReg) ≤ + Real.exp (((2 ^ (n + 2) * 4 : ℕ) : ℝ) * btop + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + H) * + (4 * ((((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, henergy⟩ := + P.moving_selected_initial_full_energy C hM ψ n (4 + r) k hk hn.le + A Wwin Bφ Dφ c K εdiag gain hA hWwin hBφ hDφ hc hK hεdiag hdepth Dlog hDlog hloglip + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [henergy, eventually_ge_atTop (0 : ℝ)] with L henergy hL + intro b hsize + have henergy := henergy b hsize + dsimp only at henergy ⊢ + intro tierB primes hprimes _ d rinit sl sr fallback childBound pivotBound V outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg cb cd btop + hlen hV hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb + let m := b + b + let depth := n + 2 + let Qfull := movingRestoredPrimeSets depth r m (Qμ depth) Qν + have hall (R : Finset ℕ → Prop) (h0 : R (Qμ depth)) (h1 : ∀ j, R (Qν j)) : ∀ j, R (Qfull j) := by + intro j + dsimp only [Qfull, movingRestoredPrimeSets] + cases (movingReverseTemplate depth r m).symm j with + | inl _ => exact h0 + | inr j => exact h1 j + have hlow : Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ + Real.exp (Real.exp ((1 / 100 : ℝ) * L)) := by + apply Real.exp_le_exp.mpr + apply Real.exp_le_exp.mpr + linarith + have he := henergy (movingRestoredTiers depth r m tierB) primes hprimes + d rinit sl sr fallback childBound pivotBound V outside p Dq sets β primeLo cutoff tier X Δ hi φ G + (movingRestoredActive depth r m) global Qμ Qfull setsReg (G (depth + 1)) cb cd + hlen hV hcard hVn hV0 hΔ hhi hwindow hH (movingRestoredTiers_lower depth r m tierB hB) + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout + (fun j => by simpa only [Qfull, m, depth, movingRestoredPrimeSets_bulk] using hν j) + hμP (hall (fun Q => Q ⊆ primes) (hμP depth) hνP) hμmass + (hall (fun Q => c / Real.exp (K * L) ≤ ∑ q ∈ Q, (q : ℝ)⁻¹) (hμmass depth) hνmass) + hμrange + (hall (fun Q => ∀ q ∈ Q, Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) + (fun q hq => hlow.trans (hμrange depth q hq)) hνrange) + (movingRestoredActive_bulk depth r m) + houtcover hinjp hHbig (fun j hj => hμtier j hj.le) + (movingRestoredPrimeSets_tier primes depth r m (Qμ depth) Qν tierB tier (hμtier depth le_rfl) hνtier) + hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep + (fun z hz q hq => hall (fun Q => q ∉ Q) (hdeleteμ z hz q hq depth) (hdeleteν z hz q hq)) + hdeletebulk hsetsReg + have hnrm := movingAmplitudeSymmetrizedRegularEnergy_norm_le primes hprimes outside + (fun j => primeSubsetPrior primes (Qμ j)) (fun j a => primeSubsetPrior_nonneg _ _ a) depth r m + childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d rinit cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ hφpos hφout G Qν (normalizedResidueFamily setsReg) (G (depth + 1)) btop + (fun a ha => hb a (primeSubsetPrior_support _ _ a ha)) + dsimp only at hnrm + rw [← movingRestoredPrimeSets_prior primes depth r m (Qμ depth) Qν] at hnrm + exact hnrm.trans (mul_le_mul_of_nonneg_left he (Real.exp_nonneg _)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialContradiction.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialContradiction.lean new file mode 100644 index 0000000000000000000000000000000000000000..c1e09868413ef0b012fa85bbe74fb13279cc3241 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialContradiction.lean @@ -0,0 +1,144 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedInitialFinalStatistic +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNormalizedFinalRate + +namespace OAI + +/-! # Contradiction at the last depth for the actual initial half-cutoff leaf -/ +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_initial_final_contradiction_varying_window + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (Bs BD Bz B Bφ Dφ c K : ℝ) + (hBs : 0 ≤ Bs) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) + (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) (hc : 0 < c) (hK : 0 ≤ K) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) : + ∀ᶠ k : ℕ in atTop, ∀ Wwin : ℝ, 0 ≤ Wwin → 8 * (K + 1) ≤ (k : ℝ) ^ 3 → + let A := movingFrequencyRate Bs BD Bz ((k : ℝ) ^ 4) k + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, ∀ b : ℕ, spectatorBulkCount k L = b + b → + let m := b + b + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot k 6 m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (d r : ℕ) (sl sr : Fin d → primes) (fallback : primes) + (childBound pivotBound V : ℕ → ℕ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot k 6 m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (H cb cd : ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let slot := movingTemplateBulk k 6 m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V k)).erase 0 + 6 + 4 * k = r + r → + Monotone V → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V k : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Δ ≤ spectatorBaseGap Bs ((k : ℝ) ^ 4) m → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, k ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot k 6 m) + 4 * k * 2 ^ k) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j < k → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V k ≤ primeLo → V k < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H ≤ L → + Real.exp (-B * (2 : ℝ) ^ k * m) ≤ + ‖movingTemplatePrimeAmplitude Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d r cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G k 6 m (smoothGiantPrimeRange H) (smoothGiantPrior (smoothGiantPrimeRange H) φ H) + ν (normalizedResidueFamily setsReg) ggiant favorable‖ → False := by + filter_upwards [eventually_moving_normalized_numeric_contradiction Bs BD Bz B + (diagonalOuterMajorant Bφ Dφ false) (diagonalOuterMajorant_pos Bφ Dφ false).le, + eventually_ge_atTop (2 : ℕ)] with k hnumeric hk + obtain ⟨n, rfl⟩ : ∃ n, k = n + 2 := ⟨k - 2, by omega⟩ + intro Wwin hWwin hdepth A + have hk0 : 0 < (n + 2) := by omega + have hA : 0 ≤ A := by + dsimp only [A, movingFrequencyRate] + have hlog : 0 ≤ Real.log (((n + 2 : ℕ) : ℝ) ^ 4) := Real.log_nonneg + (one_le_pow₀ (show (1 : ℝ) ≤ ((n + 2 : ℕ) : ℝ) by exact_mod_cast hk0) ) + have hlogr : 0 ≤ Real.log ((2 : ℝ) ^ (n + 2)) := Real.log_nonneg (one_le_pow₀ (by norm_num)) + exact mul_nonneg (by positivity) (by nlinarith [mul_nonneg hBz hlog]) + let gain := A + (2 * (B + 1) + 1) * (2 : ℝ) ^ (n + 2) + 1 + obtain ⟨ε, hε, hε1, primeCutoff, hpc, he⟩ := + P.moving_selected_initial_final_statistic C hM ψ n 6 (n + 2) hk0 (by omega) + A Wwin Bφ Dφ c K 1 gain hA hWwin hBφ hDφ hc hK (by norm_num) hdepth Dlog hDlog hloglip + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [he, hnumeric] with L he hnumeric + intro b hsize + have he := he b hsize + dsimp only at he ⊢ + intro tierB primes hprimes _ d r sl sr fallback childBound pivotBound V outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg H cb cd ggiant favorable + hlen hV hcard hVn hV0 hΔ hΔbound hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig hμtier hνtier + hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + hcg hlower + have hstat := he tierB primes hprimes d r sl sr fallback childBound pivotBound V outside p Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg H cb cd ggiant favorable + hlen hV hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig hμtier hνtier + hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have hid := movingTemplatePrimeAmplitude_statistic_eq primes hprimes outside + (fun j => primeSubsetPrior primes (Qμ j)) childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d r cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ hφout G (n + 2) 6 (b + b) (fun j => primeSubsetPrior primes (Qν j)) + (normalizedResidueFamily setsReg) ggiant favorable H + have hmcast : (spectatorBulkCount (n + 2) L : ℝ) = (b + b : ℕ) := by exact_mod_cast hsize + have hf := hnumeric (V (n + 2)) (by simpa only [hmcast] using hVn) hA Δ + (smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H) + (by simpa only [hmcast, spectatorBaseGap] using hΔbound) hcg _ _ hid + (by simpa only [hmcast] using hlower) + apply hf + simpa only [hmcast, gain, A, Nat.cast_pow, Nat.cast_ofNat, one_mul, mul_assoc, add_assoc] using hstat + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..ae5a959018707a0e868b928b19124e9494c96d91 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialDiagonal.lean @@ -0,0 +1,176 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedInitialAmplitudeEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalLeafMultiplier +import OAI.NumberTheory.Ostmann.Construction.InitialMovingHarmonicCost +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantActiveSupport + +namespace OAI + +/-! # The original diagonal with the retained-log arithmetic saving -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_initial_amplitude_diagonal + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n + 2 < k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, ∀ b : ℕ, spectatorBulkCount k L = b + b → + let m := b + b + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (d rinit : ℕ) (sl sr : Fin d → primes) (fallback : primes) + (childBound pivotBound V : ℕ → ℕ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd btop : ℝ) (lower : TreeLeafIndex (n + 2) × Fin r → ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let H := G ((n + 2) + 1) + let slot := movingTemplateBulk (n + 2) r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + 4 + r + 4 * (n + 2) = rinit + rinit → + Monotone V → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) (4 + r) m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j ≤ n + 2 → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ (n + 2), (q : ℝ) ≤ Real.exp btop) → + (∀ x, φ x ≤ 1) → + (∀ j : TreeLeafIndex (n + 2) × Fin r, ∀ q : primes, + (q : ℕ) ∈ Qν (j.1, .inl j.2) → Real.exp (lower j) ≤ (q : ℝ)) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → V (n + 2) < (q : ℕ)) → + (∀ q : smoothGiantPrimeRange H, smoothGiantPrior (smoothGiantPrimeRange H) φ H q ≠ 0 → + ∀ j (z : primes), (z : ℕ) ∈ Qν j → (q : ℕ) ≠ (z : ℕ)) → + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d rinit cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r m (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + (smoothGiantPrior (smoothGiantPrimeRange H) φ H) + (fun i => primeSubsetPrior primes (Qν i)) (normalizedResidueFamily setsReg) ggiant favorable ≤ + (Real.exp (smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H - (H - 1) - + ((∑ j, lower j) + (2 ^ (n + 2) : ℕ) * (2 * cb - 2))) * + ((Fintype.card (MovingRegularSlot (n + 2) r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Qν i, (q : ℝ)⁻¹)⁻¹)) * + (Real.exp (((2 ^ (n + 2) * 4 : ℕ) : ℝ) * btop + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + H) * + (4 * ((((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, henergy⟩ := + P.moving_selected_initial_amplitude_energy C hM ψ n r k hk hn + A Wwin Bφ Dφ c K εdiag gain hA hWwin hBφ hDφ hc hK hεdiag hdepth Dlog hDlog hloglip + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [henergy, eventually_ge_atTop (0 : ℝ)] with L henergy hL + intro b hsize + have henergy := henergy b hsize + dsimp only at henergy ⊢ + intro tierB primes hprimes _ d rinit sl sr fallback childBound pivotBound V outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg cb cd btop lower ggiant favorable + hlen hV hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb hφ1 hlower hvr hsep + have he := henergy tierB primes hprimes d rinit sl sr fallback childBound pivotBound V outside p Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg cb cd btop + hlen hV hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb + let m := b + b + let depth := n + 2 + let H := G (depth + 1) + have hVbound : (V depth : ℝ) ≤ Real.exp (H - 1) := by + apply (Nat.cast_le.mpr hNlo).trans + apply hloReal.le.trans + apply Real.exp_le_exp.mpr + apply le_trans (Real.exp_le_exp.mpr _) hHbig + nlinarith only [hL] + have hvg (q : smoothGiantPrimeRange H) + (hq : smoothGiantPrior (smoothGiantPrimeRange H) φ H q ≠ 0) : V depth < (q : ℕ) := by + have hq' := (smoothGiantPrior_active_bounds _ (smoothGiantPrimeRange_prime H) φ H hφout q hq).1 + exact_mod_cast hVbound.trans_lt hq' + have hX (q : smoothGiantPrimeRange H) + (hq : smoothGiantPrior (smoothGiantPrimeRange H) φ H q ≠ 0) : + Real.exp (H - 1) ≤ (q : ℝ) := + (smoothGiantPrior_active_bounds _ (smoothGiantPrimeRange_prime H) φ H hφout q hq).1.le + have hcost := movingAmplitude_initial_full_harmonic_cost primes + (smoothGiantPrimeRange H) (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + hprimes (smoothGiantPrimeRange_prime H) b d rinit cb cd sl sr fallback + p (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi + outside (fun j => primeSubsetPrior primes (Qμ j)) (fun j a => primeSubsetPrior_nonneg _ _ a) + childBound pivotBound V φ hφpos hφ1 G depth r hlen Qν + (fun j l => by rw [hν j, hν l]) hvg + (fun j q hq => hvr j q (primeSubsetPrior_support _ _ q hq)) + (fun q hq j z hz => hsep q hq j z (primeSubsetPrior_support _ _ z hz)) + (H - 1) hX lower (fun j q hq => hlower j q (primeSubsetPrior_support _ _ q hq)) + (normalizedResidueFamily setsReg) ggiant favorable + dsimp only at hcost + apply hcost.trans + apply mul_le_mul_of_nonneg_left he + apply mul_nonneg + · exact mul_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + · exact Finset.prod_nonneg (fun i _ => inv_nonneg.mpr + (Finset.sum_nonneg (fun q _ => inv_nonneg.mpr (Nat.cast_nonneg q)))) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialDiagonalDecay.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialDiagonalDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..58c9326cbc23845ede230b5111893a5ed25a337d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialDiagonalDecay.lean @@ -0,0 +1,169 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedInitialDiagonal +import OAI.NumberTheory.Ostmann.Construction.SelectedDiagonalBudget + +namespace OAI + +/-! # Decay of the original selected diagonal from its explicit cell-gap inequality -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_initial_diagonal_decay + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n + 2 < k) + (A Wwin Bφ Dφ c K εdiag Bs BD Bz B : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (hBs : 0 ≤ Bs) (hBD0 : 0 ≤ BD) (hBz : 9 ≤ Bz) + (hmassBudget : 4 * (K + 1) * r ≤ (k : ℝ) ^ 4) + (hBD : Bs + 2 * B + + (Real.log 2 - Real.log (1 / 16000 : ℝ) + 5 / 4 + 1 + Real.log 12 + 1 + εdiag) + 6 ≤ BD) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, ∀ b : ℕ, spectatorBulkCount k L = b + b → + let m := b + b + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (d rinit : ℕ) (sl sr : Fin d → primes) (fallback : primes) + (childBound pivotBound V : ℕ → ℕ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd btop : ℝ) (lower : TreeLeafIndex (n + 2) × Fin r → ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let H := G ((n + 2) + 1) + let slot := movingTemplateBulk (n + 2) r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + 4 + r + 4 * (n + 2) = rinit + rinit → + Monotone V → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Δ ≤ spectatorBaseGap Bs ((k : ℝ) ^ 4) m → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) (4 + r) m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j ≤ n + 2 → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ (n + 2), (q : ℝ) ≤ Real.exp btop) → + (∀ x, φ x ≤ 1) → + (∀ j : TreeLeafIndex (n + 2) × Fin r, ∀ q : primes, + (q : ℕ) ∈ Qν (j.1, .inl j.2) → Real.exp (lower j) ≤ (q : ℝ)) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → V (n + 2) < (q : ℕ)) → + (∀ q : smoothGiantPrimeRange H, smoothGiantPrior (smoothGiantPrimeRange H) φ H q ≠ 0 → + ∀ j (z : primes), (z : ℕ) ∈ Qν j → (q : ℕ) ≠ (z : ℕ)) → + (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + 1 + + ((2 ^ (n + 2) * 4 : ℕ) : ℝ) * btop - + ((∑ j, lower j) + (2 ^ (n + 2) : ℕ) * (2 * cb - 2)) ≤ + -spectatorStepGap BD Bz ((k : ℝ) ^ 4) (2 ^ (n + 2) : ℕ) m) → + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d rinit cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r m (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + (smoothGiantPrior (smoothGiantPrimeRange H) φ H) + (fun i => primeSubsetPrior primes (Qν i)) (normalizedResidueFamily setsReg) ggiant favorable ≤ + Real.exp (-(2 * B + 3) * (2 ^ (n + 2) : ℕ) * m) := by + let gain := max 0 ((Real.log 2 + Real.log ((k : ℝ) ^ 4 / (1 / 16000 : ℝ)) + + Real.log (2 ^ (n + 2) : ℕ) + 1 + 2 * B + 6) * (2 ^ (n + 2) : ℕ)) + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hdiag⟩ := + P.moving_selected_initial_amplitude_diagonal C hM ψ n r k hk hn + A Wwin Bφ Dφ c K εdiag gain hA hWwin hBφ hDφ hc hK hεdiag hdepth Dlog hDlog hloglip + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + have hnumeric := selected_diagonal_budget hM (n + 2) r k hk c K Bs BD Bz B 1 εdiag + hc hK hBs hBD0 (by norm_num) hεdiag.le (by simpa only [one_mul] using hmassBudget) hBz hBD + filter_upwards [hdiag, hnumeric] with L hdiag hnumeric + intro b hsize + have hdiag := hdiag b hsize + dsimp only at hnumeric + rw [hsize] at hnumeric + dsimp only at hdiag ⊢ + intro tierB primes hprimes _ d rinit sl sr fallback childBound pivotBound V outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg cb cd btop lower ggiant favorable + hlen hV hcard hVn hV0 hΔ hΔupper hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb hφ1 hlower hvr hsep hgap + have he := hdiag tierB primes hprimes d rinit sl sr fallback childBound pivotBound V outside p Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg cb cd btop lower ggiant favorable + hlen hV hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb hφ1 hlower hvr hsep + let m := b + b + let H := G ((n + 2) + 1) + let arch := Real.exp (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + 1 + + ((2 ^ (n + 2) * 4 : ℕ) : ℝ) * btop - + ((∑ j, lower j) + (2 ^ (n + 2) : ℕ) * (2 * cb - 2))) + have hglobal : (global.card : ℝ) ≤ Real.exp ((K + 1) * L) := by + apply le_trans _ hdel + exact_mod_cast (show global.card ≤ global.card + + (Fintype.card (MovingRegularSlot (n + 2) (4 + r) m) + 4 * (n + 2) * 2 ^ (n + 2)) + + outside.length by omega) + have hnumer := hnumeric global Qν hglobal hν hνmass arch (Real.exp_nonneg _) + (Real.exp_le_exp.mpr hgap) + apply he.trans + have hexp : + Real.exp (smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H - (H - 1) - + ((∑ j, lower j) + (2 ^ (n + 2) : ℕ) * (2 * cb - 2))) * + Real.exp (((2 ^ (n + 2) * 4 : ℕ) : ℝ) * btop + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + H) = arch := by + rw [← Real.exp_add] + congr 1 + ring + have hreassoc (a btop c d e : ℝ) : (a * btop * c) * (d * e) = (a * d) * (btop * c) * e := by ring + rw [hreassoc, hexp] + apply le_trans ?_ hnumer + dsimp only [gain, arch, m, H] + push_cast + gcongr + simpa only [Nat.cast_add] using hΔupper + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialEarlyDecay.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialEarlyDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..b1682736ee7d20ea63b106e8ba9fe267cc7846ed --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialEarlyDecay.lean @@ -0,0 +1,157 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedInitialEarlyDiagonal +import OAI.NumberTheory.Ostmann.Construction.EarlyDiagonalBudget + +namespace OAI + +/-! # The actual first two diagonals satisfy the iteration reserve -/ +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_initial_early_diagonal_decay + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n < k) (hearly : n ≤ 1) + (A Wwin Bφ Dφ c K εdiag Bs BD Bz B : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (hBs : 0 ≤ Bs) (hBD0 : 0 ≤ BD) (hBz : 9 ≤ Bz) + (hmassBudget : 4 * (K + 1) * r ≤ (k : ℝ) ^ 4) + (hBD : Bs + 2 * B + + (Real.log 2 - Real.log (1 / 16000 : ℝ) + 5 / 4 + 1 + Real.log 12 + 1 + εdiag) + 6 ≤ BD) : + ∀ᶠ L : ℝ in atTop, ∀ bsize : ℕ, spectatorBulkCount k L = bsize + bsize → + let m := bsize + bsize + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot n r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (d rinit : ℕ) (sl sr : Fin d → primes) (fallback : primes) + (childBound pivotBound V : ℕ → ℕ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi b : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot n r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd : ℝ) (lower : TreeLeafIndex n × Fin r → ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let H := G (n + 1) + let slot := movingTemplateBulk n r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + 4 + r + 4 * n = rinit + rinit → + Monotone V → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V n : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Δ ≤ spectatorBaseGap Bs ((k : ℝ) ^ 4) m → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, n ≤ tierB i) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot n (4 + r) m) + 4 * n * 2 ^ n) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j ≤ n → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V n ≤ primeLo → V n < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ n, (q : ℝ) ≤ Real.exp b) → + (∀ x, φ x ≤ 1) → + (∀ j : TreeLeafIndex n × Fin r, ∀ q : primes, + (q : ℕ) ∈ Qν (j.1, .inl j.2) → Real.exp (lower j) ≤ (q : ℝ)) → + (∀ i (q : primes), (q : ℕ) ∈ Qν i → V n < (q : ℕ)) → + (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + 1 + + ((2 ^ n * 4 : ℕ) : ℝ) * b - + ((∑ j, lower j) + (2 ^ n : ℕ) * (2 * cb - 2)) ≤ + -spectatorStepGap BD Bz ((k : ℝ) ^ 4) (2 ^ n : ℕ) m) → + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val bsize d rinit cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G n r m (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + (smoothGiantPrior (smoothGiantPrimeRange H) φ H) + (fun i => primeSubsetPrior primes (Qν i)) (normalizedResidueFamily setsReg) ggiant favorable ≤ + Real.exp (-(2 * B + 3) * (2 ^ n : ℕ) * m) := by + let gain := max 0 ((Real.log 2 + Real.log ((k : ℝ) ^ 4 / (1 / 16000 : ℝ)) + + Real.log (2 ^ n : ℕ) + 1 + 2 * B + 6) * (2 ^ n : ℕ)) + have hdiag := P.moving_selected_initial_early_log_diagonal C hM ψ n r k hk hn + A Wwin Bφ Dφ c K εdiag hA hWwin hBφ hDφ hc hK hεdiag hdepth + have hnumeric := selected_diagonal_budget hM n r k hk c K Bs BD Bz B 1 εdiag + hc hK hBs hBD0 (by norm_num) hεdiag.le (by simpa only [one_mul] using hmassBudget) hBz hBD + filter_upwards [hdiag, hnumeric] with L hdiag hnumeric + intro bsize hsize + have hdiag := hdiag bsize hsize + dsimp only at hdiag hnumeric ⊢ + rw [hsize] at hnumeric + intro tierB primes hprimes _ d rinit sl sr fallback childBound pivotBound V outside p _ Dq sets + primeLo cutoff tier X Δ hi b φ G global Qμ Qν setsReg cb cd lower ggiant favorable + hlen hV hcard hVn hV0 hΔ hΔupper hhi hwindow hH hB + hm hp hsets hsetsp hpupper hφ0 hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp hHbig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg hb hφ1 hlower hvr hgap + have he := hdiag tierB primes hprimes d rinit sl sr fallback childBound pivotBound V outside p Dq sets + primeLo cutoff tier X Δ hi b + φ G global Qμ Qν setsReg cb cd lower ggiant favorable + hlen hV hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hφ0 hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp hHbig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg hb hφ1 hlower hvr + let m := bsize + bsize + let H := G (n + 1) + let arch := Real.exp (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + 1 + + ((2 ^ n * 4 : ℕ) : ℝ) * b - + ((∑ j, lower j) + (2 ^ n : ℕ) * (2 * cb - 2))) + have hglobal : (global.card : ℝ) ≤ Real.exp ((K + 1) * L) := by + apply le_trans _ hdel + exact_mod_cast (show global.card ≤ global.card + + (Fintype.card (MovingRegularSlot n (4 + r) m) + 4 * n * 2 ^ n) + + outside.length by omega) + have hnumer := hnumeric global Qν hglobal hν hνmass arch (Real.exp_nonneg _) + (Real.exp_le_exp.mpr hgap) + apply he.trans + have hexp : + Real.exp (smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H - (H - 1) - + ((∑ j, lower j) + (2 ^ n : ℕ) * (2 * cb - 2))) * + Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * b + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + H) = arch := by + rw [← Real.exp_add] + congr 1 + ring + have hreassoc (a b c d e : ℝ) : (a * b * c) * (d * e) = (a * d) * (b * c) * e := by ring + rw [hreassoc, hexp] + have henergy := early_diagonal_energy_le n hearly (m : ℝ) + (Real.exp ((2 ^ n : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + εdiag * m)) + (Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) (Real.exp (-gain * m)) + (Nat.cast_nonneg _) (Real.exp_nonneg _) (Real.exp_nonneg _) (Real.exp_nonneg _) + apply (mul_le_mul_of_nonneg_left henergy (by positivity)).trans + apply le_trans ?_ hnumer + dsimp only [gain, arch, m, H] + push_cast + gcongr + simpa only [Nat.cast_add] using hΔupper + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialEarlyDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialEarlyDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbf3bc28a3382cf60a1133345267e2abc2956ab2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialEarlyDiagonal.lean @@ -0,0 +1,159 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedAmplitudeEnergy +import OAI.NumberTheory.Ostmann.Construction.InitialMovingEarlyEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalLeafMultiplier +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantActiveSupport + +namespace OAI + +/-! # Original first-step diagonals from the single-assignment arithmetic bound -/ +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_initial_early_log_diagonal + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n < k) + (A Wwin Bφ Dφ c K ε : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hε : 0 < ε) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) : + ∀ᶠ L : ℝ in atTop, ∀ bsize : ℕ, spectatorBulkCount k L = bsize + bsize → + let m := bsize + bsize + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot n r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (d rinit : ℕ) (sl sr : Fin d → primes) (fallback : primes) + (childBound pivotBound V : ℕ → ℕ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi b : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot n r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd : ℝ) (lower : TreeLeafIndex n × Fin r → ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let H := G (n + 1) + let slot := movingTemplateBulk n r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + 4 + r + 4 * n = rinit + rinit → + Monotone V → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V n : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, n ≤ tierB i) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot n (4 + r) m) + 4 * n * 2 ^ n) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j ≤ n → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V n ≤ primeLo → V n < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ n, (q : ℝ) ≤ Real.exp b) → + (∀ x, φ x ≤ 1) → + (∀ j : TreeLeafIndex n × Fin r, ∀ q : primes, + (q : ℕ) ∈ Qν (j.1, .inl j.2) → Real.exp (lower j) ≤ (q : ℝ)) → + (∀ i (q : primes), (q : ℕ) ∈ Qν i → V n < (q : ℕ)) → + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val bsize d rinit cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G n r m (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + (smoothGiantPrior (smoothGiantPrimeRange H) φ H) + (fun i => primeSubsetPrior primes (Qν i)) (normalizedResidueFamily setsReg) ggiant favorable ≤ + (Real.exp (smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H - (H - 1) - + ((∑ j, lower j) + (2 ^ n : ℕ) * (2 * cb - 2))) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Qν i, (q : ℝ)⁻¹)⁻¹)) * + (Real.exp (((2 ^ n * 4 : ℕ) : ℝ) * b + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + H) * + (4 * (Real.exp ((2 ^ n : ℕ) * Δ + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + ε * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))))) := by + filter_upwards [P.moving_selected_amplitude_regular_energy C hM ψ n r k hk hn.le + A Wwin Bφ Dφ c K ε hA hWwin hBφ hDφ hc hK hε hdepth, + eventually_ge_atTop (0 : ℝ)] with L henergy hL + intro bsize hsize + dsimp only at henergy ⊢ + rw [hsize] at henergy + intro tierB primes hprimes _ d rinit sl sr fallback childBound pivotBound V outside p _ Dq sets + primeLo cutoff tier X Δ hi b φ G global Qμ Qν setsReg cb cd lower ggiant favorable + hlen hV hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hφ0 hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp hHbig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg hb hφ1 hlower hvr + have he := henergy tierB primes hprimes childBound pivotBound V (movingCompactLeaf (V 0)) outside p Dq sets + primeLo cutoff tier X Δ hi b φ G global Qμ Qν setsReg + hV (movingCompactLeaf_zero _) (movingCompactLeaf_norm _) hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hφ0 hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp hHbig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg hb + let m := bsize + bsize + let H := G (n + 1) + have hexp : Real.exp ((11 / 1000 : ℝ) * L) ≤ H - 1 := by + apply le_trans (Real.exp_le_exp.mpr _) hHbig + nlinarith only [hL] + have hPbound (a : primes) : (a : ℝ) ≤ Real.exp (H - 1) := + (hupper a).trans (Real.exp_le_exp.mpr hexp) + have hVbound : (V n : ℝ) ≤ Real.exp (H - 1) := by + apply (Nat.cast_le.mpr hNlo).trans + apply hloReal.le.trans + apply Real.exp_le_exp.mpr + apply le_trans (Real.exp_le_exp.mpr _) hHbig + nlinarith only [hL] + obtain ⟨hvg, hsep⟩ := smoothGiantPrior_active_separation (smoothGiantPrimeRange H) primes + (smoothGiantPrimeRange_prime H) φ H hφout (V n) hVbound hPbound + have hX (q : smoothGiantPrimeRange H) + (hq : smoothGiantPrior (smoothGiantPrimeRange H) φ H q ≠ 0) : + Real.exp (H - 1) ≤ (q : ℝ) := + (smoothGiantPrior_active_bounds _ (smoothGiantPrimeRange_prime H) φ H hφout q hq).1.le + have hcost := movingAmplitude_initial_regular_harmonic_cost primes + (smoothGiantPrimeRange H) (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + hprimes (smoothGiantPrimeRange_prime H) bsize d rinit cb cd sl sr fallback p + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi + outside (fun j => primeSubsetPrior primes (Qμ j)) + (fun j a => primeSubsetPrior_nonneg _ _ a) childBound pivotBound V + φ hφ0 hφ1 G n r hlen Qν lower + (fun j q hq => hlower j q (primeSubsetPrior_support _ _ q hq)) + hvg (fun i q hq => hvr i q (primeSubsetPrior_support _ _ q hq)) + (fun q hq _ a _ => hsep q hq a) (H - 1) hX + (normalizedResidueFamily setsReg) ggiant favorable + have hplain := movingAmplitudeRegularEnergy_initial_le primes + (smoothGiantPrimeRange H) (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + bsize d rinit cb cd sl sr fallback p (fun i => normalizedResidueTransform (sets i)) + Dq Finset.univ ψ X (Real.exp Δ) hi outside + (fun j => primeSubsetPrior primes (Qμ j)) (fun j a => primeSubsetPrior_nonneg _ _ a) + childBound pivotBound V φ hφ0 G n r hlen Qν (normalizedResidueFamily setsReg) + exact hcost.trans (mul_le_mul_of_nonneg_left (hplain.trans he) (by + apply mul_nonneg + · exact mul_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + · exact Finset.prod_nonneg (fun i _ => inv_nonneg.mpr + (Finset.sum_nonneg (fun q _ => inv_nonneg.mpr (Nat.cast_nonneg q)))))) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialFinalStatistic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialFinalStatistic.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d8439bc39b1a0225cc44403ad44d9e1e38c9577 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialFinalStatistic.lean @@ -0,0 +1,139 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedInitialFullEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateAmplitudeStatistic + +namespace OAI + +/-! # The actual final prime statistic under the selected harmonic laws -/ +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_initial_final_statistic + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n + 2 ≤ k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, ∀ b : ℕ, spectatorBulkCount k L = b + b → + let m := b + b + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r₀ m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (d r : ℕ) (sl sr : Fin d → primes) (fallback : primes) + (childBound pivotBound V : ℕ → ℕ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r₀ m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (H cb cd : ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let slot := movingTemplateBulk (n + 2) r₀ m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + r₀ + 4 * (n + 2) = r + r → + Monotone V → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) r₀ m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j < n + 2 → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingTemplatePrimeStatistic primes outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d r cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r₀ m ν (normalizedResidueFamily setsReg) ggiant favorable + H (H - 1) (H + 1) (H - 1) (H + 1)‖ ^ 2 ≤ + diagonalOuterMajorant Bφ Dφ false * (2 * V (n + 2) + 1 : ℕ) * Real.exp 5 * + (4 * ((((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, henergy⟩ := + P.moving_selected_initial_full_energy C hM ψ n r₀ k hk hn + A Wwin Bφ Dφ c K εdiag gain hA hWwin hBφ hDφ hc hK hεdiag hdepth Dlog hDlog hloglip + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [henergy] with L henergy + intro b hsize + have he := henergy b hsize + dsimp only at he ⊢ + intro tierB primes hprimes _ d r sl sr fallback childBound pivotBound V outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg H cb cd ggiant favorable + hlen hV hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange houtcover hinjp hHbig hμtier hνtier + hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have hbound := he tierB primes hprimes d r sl sr fallback childBound pivotBound V outside p Dq sets β + primeLo cutoff tier X Δ hi φ G (fun _ => true) global Qμ Qν setsReg H cb cd + hlen hV hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange (fun _ => rfl) houtcover hinjp hHbig hμtier hνtier + hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have hmass (j) : ∑ q : primes, primeSubsetPrior primes (Qν j) q = 1 := by + apply primeSubsetPrior_mass primes (Qν j) (hνP j) + exact (lt_of_lt_of_le (div_pos hc (Real.exp_pos _)) (hνmass j)).ne' + have hidentical (i j) : primeSubsetPrior primes (Qν (movingTemplateBulk (n + 2) r₀ (b + b) i)) = + primeSubsetPrior primes (Qν (movingTemplateBulk (n + 2) r₀ (b + b) j)) := by + rw [hν i, hν j] + apply (movingTemplatePrimeStatistic_full_cell_bound primes hprimes outside + (fun j => primeSubsetPrior primes (Qμ j)) childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d r cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ hφpos Bφ Dφ hBφ hDφ hφ hlip hφout G (n + 2) r₀ (b + b) + (fun j => primeSubsetPrior primes (Qν j)) (fun j q => primeSubsetPrior_nonneg _ _ q) + hmass hidentical (normalizedResidueFamily setsReg) ggiant favorable H).trans + exact mul_le_mul_of_nonneg_left hbound + (mul_nonneg (mul_nonneg (diagonalOuterMajorant_pos Bφ Dφ false).le + (Nat.cast_nonneg _)) (Real.exp_nonneg _)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialFullEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialFullEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..da9db236f5340ec995246e8084a134d637e7e7b8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialFullEnergy.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedInitialSymmetrization +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSymmetrizedFullCell + +namespace OAI + +/-! # Full bulk symmetrization under the actual selected harmonic priors -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_initial_full_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n + 2 ≤ k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, ∀ b : ℕ, spectatorBulkCount k L = b + b → + let m := b + b + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r₀ m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (d r : ℕ) (sl sr : Fin d → primes) (fallback : primes) + (childBound pivotBound V : ℕ → ℕ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot (n + 2) r₀ m → Bool) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r₀ m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (H cb cd : ℝ), + let slot := movingTemplateBulk (n + 2) r₀ m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + r₀ + 4 * (n + 2) = r + r → + Monotone V → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) r₀ m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active (slot j) = true) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j, j < n + 2 → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingTemplateMaskedSymmetrizedEnergy primes _hprimes outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d r cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r₀ m ν active (normalizedResidueFamily setsReg) + H H false (H - 1) (H + 1) (H - 1) (H + 1) H‖ ≤ + 4 * ((((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hunit⟩ := + P.moving_selected_initial_symmetrized_energy C hM ψ n r₀ k hk hn + A Wwin Bφ Dφ c K εdiag gain hA hWwin hBφ hDφ hc hK hεdiag hdepth Dlog hDlog hloglip + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hunit] with L hunit + intro b hsize + have hunit := hunit b hsize + dsimp only at hunit ⊢ + intro tierB primes hprimes _ d r sl sr fallback childBound pivotBound V outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G active global Qμ Qν setsReg H cb cd + hlen hV hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive houtcover hinjp hHbig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + apply movingTemplateMaskedSymmetrizedEnergy_full_cell_bound primes hprimes outside + (fun j => primeSubsetPrior primes (Qμ j)) childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d r cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r₀ (b + b) + (fun j => primeSubsetPrior primes (Qν j)) active (normalizedResidueFamily setsReg) + H H false H H H _ + intro i j + have hu : H - 1 ≤ (if i then H else H - 1) := by split <;> linarith + have hr : H - 1 ≤ (if j then H else H - 1) := by split <;> linarith + have hv : (if i then H else H - 1) ≤ H := by split <;> linarith + exact hunit tierB primes hprimes d r sl sr fallback childBound pivotBound V outside p Dq sets β + primeLo cutoff tier X Δ hi φ G active global Qμ Qν setsReg H H false + (if i then H else H - 1) ((if i then H else H - 1) + 1) + (if j then H else H - 1) ((if j then H else H - 1) + 1) H cb cd + hlen hV hcard hVn hV0 hΔ hhi hwindow (hH.trans hu) (hH.trans hr) + (by linarith) (by linarith) le_rfl le_rfl (by linarith) hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive houtcover hinjp (hHbig.trans (by linarith)) (hHbig.trans hr) + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialSymmetrization.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialSymmetrization.lean new file mode 100644 index 0000000000000000000000000000000000000000..77d78e1ce7992efe9b62fd7f804c8d5af9d53a5d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedInitialSymmetrization.lean @@ -0,0 +1,167 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedTemplateEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedTemplateHalfLogGood +import OAI.NumberTheory.Ostmann.Construction.InitialMovingSymmetrizedEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompactEnergy + +namespace OAI + +/-! # Full bulk symmetrization under the actual selected harmonic priors -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_initial_symmetrized_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n + 2 ≤ k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, ∀ b : ℕ, spectatorBulkCount k L = b + b → + let m := b + b + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r₀ m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (d r : ℕ) (sl sr : Fin d → primes) (fallback : primes) + (childBound pivotBound V : ℕ → ℕ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot (n + 2) r₀ m → Bool) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r₀ m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center cb cd : ℝ), + let slot := movingTemplateBulk (n + 2) r₀ m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + r₀ + 4 * (n + 2) = r + r → + Monotone V → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) r₀ m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active (slot j) = true) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j, j < n + 2 → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingTemplateMaskedSymmetrizedEnergy primes _hprimes outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (initialMovingDataCutoff Subtype.val b d r cb cd sl sr fallback) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r₀ m ν active (normalizedResidueFamily setsReg) + Jleft Jright diagonal uG vG rG sG center‖ ≤ + (((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hgood⟩ := + P.moving_selected_template_half_log_good_correlation C hM ψ n r₀ k hk A Wwin Bφ Dφ c K gain + hA hWwin hBφ hDφ hc hK Dlog hDlog hloglip + ((2 ^ (n + 2) + 2 ^ (n + 2)) + (2 ^ (n + 2) + 2 ^ (n + 2))) (by omega) + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hgood, P.moving_selected_template_diagonal_energy C hM ψ (n + 2) r₀ k hk hn + A Wwin Bφ Dφ c K εdiag hA hWwin hBφ hDφ hc hK hεdiag hdepth] with L hg hd + intro b hsize + rw [hsize] at hg hd + dsimp only at hg hd ⊢ + intro tierB primes hprimes _ d r sl sr fallback childBound pivotBound V outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G active global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center cb cd + hlen hV hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + let m := b + b + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + have hlocal := hμtier + let f : ℤ → ℂ := fun s => if s = 0 then 0 else 1 + have hf0 : f 0 = 0 := by simp [f] + have hfnorm (s : ℤ) : ‖f s‖ ≤ 1 := by simp only [f]; split_ifs <;> simp + have hdiagonal := hd tierB primes hprimes childBound pivotBound V (movingCompactLeaf (V 0)) outside p Dq sets + primeLo cutoff tier X Δ hi φ G active global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV (movingCompactLeaf_zero _) (movingCompactLeaf_norm _) hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hB + (by omega) (fun i => hpc.trans (hp i)) hsets hsetsp hpupper hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive houtcover hinjp huBig hrBig hlocal hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg + change ‖mixedExternalAverage ν (V (n + 2)) uG vG rG sG center + (fun s y x z => + (‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p (fun _ => movingCompactLeaf (V 0)) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r₀ m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) * + movingTemplateExternalMultiplier primes hprimes (n + 2) r₀ m active outside + (normalizedResidueFamily setsReg) s φ Jleft Jright diagonal y x z)‖ ≤ _ at hdiagonal + rw [← movingTemplate_compact_energy Subtype.val p outside μ childBound pivotBound V + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi φ G + (n + 2) r₀ m ν + (fun s y x z => movingTemplateExternalMultiplier primes hprimes (n + 2) r₀ m active outside + (normalizedResidueFamily setsReg) s φ Jleft Jright diagonal y x z) + uG vG rG sG center] at hdiagonal + let slot := movingTemplateBulk (n + 2) r₀ m + let slots (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) (side : Bool) := + if side then slot ∘ perm.symm else (slot : _ → _) + have hpairs (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (hperm : 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2))) := + hg tierB primes hprimes childBound pivotBound V f outside p Dq sets β + primeLo cutoff tier X Δ hi φ G active perm global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center cb (initialPairedHalfLogSlots (n + 2) b (slots perm)) + (fun j => (initialPairedHalfLogSlots_length _ _ _ j).trans (by omega)) hV hf0 hfnorm hcard hVn hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hB + hm hp hsets hsetsp hpupper hperm hdlo hdhi hβ hbias hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive houtcover hinjp huBig hrBig hlocal hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have h := movingTemplate_initial_symmetrized_energy_bound primes hprimes (n + 2) r₀ b d r hm hlen + cb cd sl sr fallback outside μ ν (fun j q => primeSubsetPrior_nonneg primes (Qν j) q) + (fun j l => by dsimp only [ν]; rw [hν j, hν l]) + p (fun i => normalizedResidueTransform (sets i)) Dq childBound pivotBound V ψ X (Real.exp Δ) hi + φ hφpos G active hactive (normalizedResidueFamily setsReg) Jleft Jright diagonal uG vG rG sG center _ _ + (by positivity) (by positivity) hdiagonal hpairs + simpa only [add_assoc] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedLogAmplitudeEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedLogAmplitudeEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..b8239f6ce1cb32f21ac26162188e4ee922333320 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedLogAmplitudeEnergy.lean @@ -0,0 +1,162 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedTemplateLogFullEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSymmetrizedNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredTierSeparation + +namespace OAI + +/-! # The retained-log symmetrized amplitude with its original compensation law -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_log_symmetrized_amplitude_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n + 2 < k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd b : ℝ), + let H := G ((n + 2) + 1) + let slot := movingTemplateBulk (n + 2) r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) (4 + r) m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j : TreeLeafIndex (n + 2) × Fin r, tierB (j.1, .inl j.2) ≠ k) → + (∀ j, tierB (slot j) = k) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j (q : primes), (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ (n + 2), (q : ℝ) ≤ Real.exp b) → + movingAmplitudeSymmetrizedRegularEnergy primes (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r m Qν (normalizedResidueFamily setsReg) ≤ + Real.exp (((2 ^ (n + 2) * 4 : ℕ) : ℝ) * b + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + H) * + (4 * ((((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, henergy⟩ := + P.moving_selected_template_log_full_energy C hM ψ n (4 + r) k hk hn.le + A Wwin Bφ Dφ c K εdiag gain hA hWwin hBφ hDφ hc hK hεdiag hdepth Dlog hDlog hloglip + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [henergy, eventually_ge_atTop (0 : ℝ)] with L henergy hL + dsimp only at henergy ⊢ + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg cb cd b + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange hsmalltier hbulktier houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb + let m := spectatorBulkCount k L + let d := n + 2 + let Qfull := movingRestoredPrimeSets d r m (Qμ d) Qν + have hall (R : Finset ℕ → Prop) (h0 : R (Qμ d)) (h1 : ∀ j, R (Qν j)) : ∀ j, R (Qfull j) := by + intro j + dsimp only [Qfull, movingRestoredPrimeSets] + cases (movingReverseTemplate d r m).symm j with + | inl _ => exact h0 + | inr j => exact h1 j + have hlow : Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ + Real.exp (Real.exp ((1 / 100 : ℝ) * L)) := by + apply Real.exp_le_exp.mpr + apply Real.exp_le_exp.mpr + linarith + have he := henergy (movingRestoredTiers d r m tierB) primes hprimes + childBound pivotBound V f outside p Dq sets β primeLo cutoff tier X Δ hi φ G + (movingRestoredActive d r m) global Qμ Qfull setsReg (G (d + 1)) cb cd + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH (movingRestoredTiers_lower d r m tierB hB) + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout + (fun j => by simpa only [Qfull, m, d, movingRestoredPrimeSets_bulk] using hν j) + hμP (hall (fun Q => Q ⊆ primes) (hμP d) hνP) hμmass + (hall (fun Q => c / Real.exp (K * L) ≤ ∑ q ∈ Q, (q : ℝ)⁻¹) (hμmass d) hνmass) + hμrange + (hall (fun Q => ∀ q ∈ Q, Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) + (fun q hq => hlow.trans (hμrange d q hq)) hνrange) + (movingRestoredActive_bulk d r m) + (movingRestoredTiers_small d r m k hn.ne tierB hsmalltier) + (movingRestoredTiers_bulk d r m k tierB hbulktier) + houtcover hinjp hHbig hμtier + (movingRestoredPrimeSets_tier primes d r m (Qμ d) Qν tierB tier (hμtier d) hνtier) + hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep + (fun z hz q hq => hall (fun Q => q ∉ Q) (hdeleteμ z hz q hq d) (hdeleteν z hz q hq)) + hdeletebulk hsetsReg + have hnrm := movingAmplitudeSymmetrizedRegularEnergy_norm_le primes hprimes outside + (fun j => primeSubsetPrior primes (Qμ j)) (fun j a => primeSubsetPrior_nonneg _ _ a) d r m + childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ hφpos hφout G Qν (normalizedResidueFamily setsReg) (G (d + 1)) b + (fun a ha => hb a (primeSubsetPrior_support _ _ a ha)) + dsimp only at hnrm + rw [← movingRestoredPrimeSets_prior primes d r m (Qμ d) Qν] at hnrm + exact hnrm.trans (mul_le_mul_of_nonneg_left he (Real.exp_nonneg _)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedLogDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedLogDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..d85c3877494fe3c75cfbf8cd998ae0a53a9b611b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedLogDiagonal.lean @@ -0,0 +1,190 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedLogAmplitudeEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalLeafMultiplier +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAmplitudeSupportedCost +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantActiveSupport + +namespace OAI + +/-! # The original diagonal with the retained-log arithmetic saving -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_log_amplitude_diagonal + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r k : ℕ) (hk : 0 < k) (hn : n + 2 < k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (cb cd b : ℝ) (lower : TreeLeafIndex (n + 2) × Fin r → ℝ) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool), + let H := G ((n + 2) + 1) + let slot := movingTemplateBulk (n + 2) r m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) (4 + r) m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j : TreeLeafIndex (n + 2) × Fin r, tierB (j.1, .inl j.2) ≠ k) → + (∀ j, tierB (slot j) = k) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j (q : primes), (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (∀ q ∈ Qμ (n + 2), (q : ℝ) ≤ Real.exp b) → + (∀ x, φ x ≤ 1) → + (∀ j : TreeLeafIndex (n + 2) × Fin r, ∀ q : primes, + (q : ℕ) ∈ Qν (j.1, .inl j.2) → Real.exp (lower j) ≤ (q : ℝ)) → + (∀ q : primes, V (n + 2) < (q : ℕ)) → + movingAmplitudeDiagonal Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r m (smoothGiantPrimeRange H) + (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + (smoothGiantPrior (smoothGiantPrimeRange H) φ H) + (fun i => primeSubsetPrior primes (Qν i)) (normalizedResidueFamily setsReg) ggiant favorable ≤ + (Real.exp (smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H - (H - 1) - + ((∑ j, lower j) + (2 ^ (n + 2) : ℕ) * (cb - 1))) * + ((Fintype.card (MovingRegularSlot (n + 2) r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Qν i, (q : ℝ)⁻¹)⁻¹)) * + (Real.exp (((2 ^ (n + 2) * 4 : ℕ) : ℝ) * b + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + H) * + (4 * ((((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, henergy⟩ := + P.moving_selected_log_symmetrized_amplitude_energy C hM ψ n r k hk hn + A Wwin Bφ Dφ c K εdiag gain hA hWwin hBφ hDφ hc hK hεdiag hdepth Dlog hDlog hloglip + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [henergy, eventually_ge_atTop (0 : ℝ)] with L henergy hL + dsimp only at henergy ⊢ + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg cb cd b lower ggiant favorable + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange hsmalltier hbulktier houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb hφ1 hlower hvr + have he := henergy tierB primes hprimes childBound pivotBound V f outside p Dq sets β + primeLo cutoff tier X Δ hi φ G global Qμ Qν setsReg cb cd b + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν + hμP hνP hμmass hνmass hμrange hνrange hsmalltier hbulktier houtcover hinjp hHbig + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν + hdeletebulk hsetsReg hb + let m := spectatorBulkCount k L + let d := n + 2 + let H := G (d + 1) + have hexp : Real.exp ((11 / 1000 : ℝ) * L) ≤ H - 1 := by + apply le_trans (Real.exp_le_exp.mpr _) hHbig + nlinarith only [hL] + have hPbound (a : primes) : (a : ℝ) ≤ Real.exp (H - 1) := + (hupper a).trans (Real.exp_le_exp.mpr hexp) + have hVbound : (V d : ℝ) ≤ Real.exp (H - 1) := by + apply (Nat.cast_le.mpr hNlo).trans + apply hloReal.le.trans + apply Real.exp_le_exp.mpr + apply le_trans (Real.exp_le_exp.mpr _) hHbig + nlinarith only [hL] + obtain ⟨hvg, hsep⟩ := smoothGiantPrior_active_separation (smoothGiantPrimeRange H) primes + (smoothGiantPrimeRange_prime H) φ H hφout (V d) hVbound hPbound + have hX (q : smoothGiantPrimeRange H) + (hq : smoothGiantPrior (smoothGiantPrimeRange H) φ H q ≠ 0) : + Real.exp (H - 1) ≤ (q : ℝ) := + (smoothGiantPrior_active_bounds _ (smoothGiantPrimeRange_prime H) φ H hφout q hq).1.le + let F : MovingSlotState primes → ℤ → ℂ := movingOriginalLeaf Subtype.val p (fun _ => f) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi + have hF (x) : F x 0 = 0 := movingOriginalLeaf_zero Subtype.val p (fun _ => f) + (fun _ => hf0) (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi x + have hcost := movingAmplitude_symmetrized_full_harmonic_cost_supported primes + (smoothGiantPrimeRange H) (Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊) + hprimes (smoothGiantPrimeRange_prime H) + tier k outside cb cd (fun j => primeSubsetPrior primes (Qμ j)) + (fun j a => primeSubsetPrior_nonneg _ _ a) + (fun j a ha => hμtier j a (primeSubsetPrior_support _ _ a ha)) + childBound pivotBound V F hF φ hφpos hφ1 G d r m hn Qν + (fun j l => by rw [hν j, hν l]) + (fun j q hq => by rw [hνtier _ q (primeSubsetPrior_support _ _ q hq)]; exact hsmalltier j) + (fun j q hq => (hνtier _ q (primeSubsetPrior_support _ _ q hq)).trans (hbulktier j)) + lower (fun j q hq => hlower j q (primeSubsetPrior_support _ _ q hq)) + hvg hvr hsep (H - 1) hX (normalizedResidueFamily setsReg) ggiant favorable + have hFw : (fun x s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s) = + movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi := by + funext x s + exact (movingOriginalLeaf_mul Subtype.val p + (fun T => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ)) + (fun _ => f) (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi x s).symm + dsimp only at hcost + rw [hFw] at hcost + apply hcost.trans + apply mul_le_mul_of_nonneg_left he + apply mul_nonneg + · exact mul_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + · exact Finset.prod_nonneg (fun i _ => inv_nonneg.mpr + (Finset.sum_nonneg (fun q _ => inv_nonneg.mpr (Nat.cast_nonneg q)))) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedPhaseStatistic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedPhaseStatistic.lean new file mode 100644 index 0000000000000000000000000000000000000000..2c06d1c3e696f6a7dba518821d1c1082db8f472d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedPhaseStatistic.lean @@ -0,0 +1,129 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedSymmetrization +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPhaseStatisticBound + +namespace OAI + +/-! # The actual selected-prior arithmetic statistic has a full upper bound -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_phase_statistic_upper + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n + 2 ≤ k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (B : Type) [Fintype B] (tierB : B → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) (n + 2)) (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ B) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : B → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → MovingLeafLengthLE (n + 2) small r₀ → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card B + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j, j < (n + 2) → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingOriginalPhaseStatistic p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ G (n + 2) m small slot + (normalizedResidueFamily setsReg) ggiant favorable Jleft Jright diagonal uG vG rG sG center‖ ^ 2 ≤ + diagonalOuterMajorant Bφ Dφ diagonal * (2 * V (n + 2) + 1 : ℕ) * Real.exp 2 * + ((((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hsym⟩ := + P.moving_selected_symmetrized_energy C hM ψ n r₀ k hk hn A Wwin Bφ Dφ c K εdiag gain + hA hWwin hBφ hDφ hc hK hεdiag hdepth + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hsym] with L hsym + dsimp only at hsym ⊢ + intro B _ tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G small slot global Qμ Qν setsReg ggiant favorable Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have henergy := hsym B tierB primes hprimes childBound pivotBound V f outside p Dq sets β + primeLo cutoff tier X Δ hi φ G small slot global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have hidentical (j l) : primeSubsetPrior primes (Qν (slot j)) = + primeSubsetPrior primes (Qν (slot l)) := by rw [hν j, hν l] + have hmass (j : B) : ∑ q : primes, primeSubsetPrior primes (Qν j) q = 1 := by + apply primeSubsetPrior_mass primes (Qν j) (hνP j) + exact (lt_of_lt_of_le (div_pos hc (Real.exp_pos _)) (hνmass j)).ne' + exact movingOriginalPhaseStatistic_upper p (fun q : primes => (q : ℕ)) outside + (fun j => primeSubsetPrior primes (Qμ j)) (fun j => primeSubsetPrior primes (Qν j)) + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ hφpos Bφ Dφ hBφ hDφ hφ hlip hφout G (n + 2) + (spectatorBulkCount k L) small slot hsmall + (fun j q => primeSubsetPrior_nonneg primes (Qν j) q) hmass hidentical + (normalizedResidueFamily setsReg) ggiant favorable Jleft Jright diagonal uG vG rG sG center + hsG hvcenter _ (by positivity) henergy + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedPrimeEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedPrimeEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..f1af8a120b20de2c3e6287e4e65ceac1c2a64366 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedPrimeEnergy.lean @@ -0,0 +1,144 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeSelectedPriors +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalEnergyRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternEnumeration + +namespace OAI + +/-! # The actual coefficient energy under selected harmonic prime laws -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The Section 7 energy estimate with its original prime-pattern premise +fully supplied by the published progression estimate and the concrete cells. -/ +theorem PublishedProgressionInput.moving_selected_prime_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n ≤ k) + (A Wwin Bφ Dφ c K ε : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hε : 0 < ε) + (hdepth : 8 * (K + 1 + 1) ≤ (k : ℝ) ^ 3) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (B : Type) [Fintype B] (tierB : B → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : B → Finset ℕ) + (uG vG rG sG : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V n : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → + (∀ i ∈ flattenMovingSlots n small, i ∉ Set.range slot) → + (∀ i, n ≤ tierB i) → MovingLeafLengthLE n small r₀ → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card B + 4 * n * 2 ^ n) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ uG → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j, j < n → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V n ≤ primeLo → V n < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + ‖∑ a : transferFrequencyRange (V n), ∑ z : B → primes, ((∏ b, ν b (z b) : ℝ) : ℂ) * + complexPrimeInterval 1 0 rG sG (fun y => complexPrimeInterval 1 0 uG vG (fun x => + (‖movingFrequencyCoefficient (fun q : primes => (q : ℕ)) outside μ childBound pivotBound V + (movingOriginalLeaf (fun q : primes => (q : ℕ)) p (fun {_} _ => f) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G n a.val (treeLeafMap (List.map z) n small) + (treeLeafMap (List.map z) n (bulkSlotLeaves n m slot)) + ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊‖ ^ 2 : ℂ)))‖ ≤ + Real.exp ((2 ^ n : ℕ) * Δ + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + ε * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + have hCprior : 1 ≤ K + 1 := (selected_harmonic_family_bounds c K hc hK).1 + filter_upwards [P.movingPattern_prime_selected_priors_rate C hM ψ n r₀ k + A Wwin Bφ Dφ c K hA hWwin hc hK hBφ hDφ, + movingFrequencyCoefficient_original_pattern_rate ψ n k hk hn Bφ A (K + 1) ε + hA hCprior hε hdepth] with L hprime henergy + dsimp only + dsimp only at henergy + obtain ⟨D, hD, hdiv, henergy⟩ := henergy + intro B _ tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets + primeLo cutoff tier X Δ hi φ G small slot global Qμ Qν uG vG rG sG + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hsmall hB hsmallLen + hm hp hsets hsetsp hpupper hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let j₀ : TreeLeafIndex n × Fin (spectatorBulkCount k L) := + ⟨Classical.choice inferInstance, ⟨0, hm⟩⟩ + obtain ⟨N, e, hNcard⟩ := movingPattern_enumeration B (slot j₀) n + have hdel' (s) : ((global.card + (N s + 1) + outside.length : ℕ) : ℝ) ≤ + Real.exp ((K + 1) * L) := by + exact (Nat.cast_le.mpr (Nat.add_le_add_right + (Nat.add_le_add_left (hNcard s) global.card) outside.length)).trans hdel + apply henergy primes (Fin (spectatorBulkCount k L)) B p (fun q : primes => (q : ℕ)) outside + (fun j => primeSubsetPrior primes (Qμ j)) (fun j => primeSubsetPrior primes (Qν j)) + childBound pivotBound V (fun {_} _ => f) (fun i => normalizedResidueTransform (sets i)) + Dq Finset.univ X Δ hi φ G small (bulkSlotLeaves n _ slot) uG vG rG sG N e hV + (fun _ _ => hf0) hcard hVn hV0 + intro s t + let rep : ∀ c : Quotient s, {i : Bool × MovingSampleIndex n // Quotient.mk'' i = c} := + fun c => ⟨c.out, Quotient.out_eq' c⟩ + have hS : ∀ a ∈ Sfreq, a ≠ 0 := fun a ha => (Finset.mem_erase.mp ha).1 + have hN : ∀ a ∈ Sfreq, a.natAbs ≤ V n := by + intro a ha + exact (mem_transferFrequencyRange _ _).mp (Finset.mem_erase.mp ha).2 + have hdiv' (q : ℕ) (hq : q ≠ 0) (hsize : q ≤ (V n) ^ 2) : (q.divisors.card : ℝ) ≤ D := by + apply hdiv q hq + calc + (q : ℝ) ≤ ((V n : ℕ) : ℝ) ^ 2 := by exact_mod_cast hsize + _ ≤ (Real.exp (A * spectatorBulkCount k L)) ^ 2 := pow_le_pow_left₀ (Nat.cast_nonneg _) hVn 2 + _ = Real.exp (2 * A * spectatorBulkCount k L) := by + rw [← Real.exp_nat_mul] + congr 1 + ring + have hh := hprime (Real.exp Δ) hi (Real.one_le_exp_iff.mpr hΔ) hhi hwindow + B (Quotient s) (N s) (e s) tierB + (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b t)) + Sfreq t (V n) (V 0) D small slot (fun i => Quotient.mk'' i) rep primes hprimes + childBound pivotBound f outside p Dq sets primeLo cutoff tier X j₀ φ G global Qμ Qν + uG vG rG sG huG hrG huvG hrsG hvG hsG (fun _ => hsmall) hB (fun _ => hsmallLen) + rfl hS hN (fun _ a _ => hf a) hD hdiv' hm hp hsets hsetsp hpupper + hφ hlip hφout hShell (hdel' s) hout hν hμP hνP hμmass hνmass hμrange hνrange + houtcover hinjp huBig hrBig hVn hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband + hdeleteμ hdeletep + calc + _ ≤ _ := hh + _ = _ := by + rw [Fintype.card_prod, card_treeLeafIndex, Fintype.card_fin] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedPrimeStatistic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedPrimeStatistic.lean new file mode 100644 index 0000000000000000000000000000000000000000..34bc52561b77ab78bdc2344bcf2a40ed3a7f6d3b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedPrimeStatistic.lean @@ -0,0 +1,129 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedSymmetrization +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPrimeStatisticBound + +namespace OAI + +/-! # The actual selected-prior arithmetic statistic has a full upper bound -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_prime_statistic_upper + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n + 2 ≤ k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (B : Type) [Fintype B] (tierB : B → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) (n + 2)) (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ B) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : B → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → MovingLeafLengthLE (n + 2) small r₀ → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card B + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j, j < (n + 2) → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingOriginalPrimeStatistic p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ G (n + 2) m small slot + (normalizedResidueFamily setsReg) ggiant favorable Jleft Jright diagonal uG vG rG sG‖ ^ 2 ≤ + Real.exp (center - uG) ^ 2 * diagonalOuterMajorant Bφ Dφ diagonal * (2 * V (n + 2) + 1 : ℕ) * Real.exp 2 * + ((((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hsym⟩ := + P.moving_selected_symmetrized_energy C hM ψ n r₀ k hk hn A Wwin Bφ Dφ c K εdiag gain + hA hWwin hBφ hDφ hc hK hεdiag hdepth + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hsym] with L hsym + dsimp only at hsym ⊢ + intro B _ tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G small slot global Qμ Qν setsReg ggiant favorable Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have henergy := hsym B tierB primes hprimes childBound pivotBound V f outside p Dq sets β + primeLo cutoff tier X Δ hi φ G small slot global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have hidentical (j l) : primeSubsetPrior primes (Qν (slot j)) = + primeSubsetPrior primes (Qν (slot l)) := by rw [hν j, hν l] + have hmass (j : B) : ∑ q : primes, primeSubsetPrior primes (Qν j) q = 1 := by + apply primeSubsetPrior_mass primes (Qν j) (hνP j) + exact (lt_of_lt_of_le (div_pos hc (Real.exp_pos _)) (hνmass j)).ne' + exact movingOriginalPrimeStatistic_upper p (fun q : primes => (q : ℕ)) outside + (fun j => primeSubsetPrior primes (Qμ j)) (fun j => primeSubsetPrior primes (Qν j)) + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ hφpos Bφ Dφ hBφ hDφ hφ hlip hφout G (n + 2) + (spectatorBulkCount k L) small slot hsmall + (fun j q => primeSubsetPrior_nonneg primes (Qν j) q) hmass hidentical + (normalizedResidueFamily setsReg) ggiant favorable Jleft Jright diagonal uG vG rG sG center + hsG hvcenter _ (by positivity) henergy + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedStatistic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedStatistic.lean new file mode 100644 index 0000000000000000000000000000000000000000..4834d2396517869f92d9fd29995c185face16de6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedStatistic.lean @@ -0,0 +1,128 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedSymmetrization +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalStatisticBound + +namespace OAI + +/-! # The actual selected-prior arithmetic statistic has a full upper bound -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_statistic_upper + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n + 2 ≤ k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (B : Type) [Fintype B] (tierB : B → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) (n + 2)) (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ B) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : B → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → MovingLeafLengthLE (n + 2) small r₀ → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card B + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j, j < (n + 2) → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingOriginalStatistic p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ G (n + 2) m small slot + (normalizedResidueFamily setsReg) Jleft Jright diagonal uG vG rG sG center‖ ^ 2 ≤ + diagonalOuterMajorant Bφ Dφ diagonal * (2 * V (n + 2) + 1 : ℕ) * Real.exp 2 * + ((((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hsym⟩ := + P.moving_selected_symmetrized_energy C hM ψ n r₀ k hk hn A Wwin Bφ Dφ c K εdiag gain + hA hWwin hBφ hDφ hc hK hεdiag hdepth + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hsym] with L hsym + dsimp only at hsym ⊢ + intro B _ tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G small slot global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have henergy := hsym B tierB primes hprimes childBound pivotBound V f outside p Dq sets β + primeLo cutoff tier X Δ hi φ G small slot global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have hidentical (j l) : primeSubsetPrior primes (Qν (slot j)) = + primeSubsetPrior primes (Qν (slot l)) := by rw [hν j, hν l] + have hmass (j : B) : ∑ q : primes, primeSubsetPrior primes (Qν j) q = 1 := by + apply primeSubsetPrior_mass primes (Qν j) (hνP j) + exact (lt_of_lt_of_le (div_pos hc (Real.exp_pos _)) (hνmass j)).ne' + exact movingOriginalStatistic_upper p (fun q : primes => (q : ℕ)) outside + (fun j => primeSubsetPrior primes (Qμ j)) (fun j => primeSubsetPrior primes (Qν j)) + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ hφpos Bφ Dφ hBφ hDφ hφ hlip hφout G (n + 2) + (spectatorBulkCount k L) small slot hsmall + (fun j q => primeSubsetPrior_nonneg primes (Qν j) q) hmass hidentical + (normalizedResidueFamily setsReg) Jleft Jright diagonal uG vG rG sG center + hsG hvcenter _ (by positivity) henergy + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedSymmetrization.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedSymmetrization.lean new file mode 100644 index 0000000000000000000000000000000000000000..c20758f0c3082c14047489b7471acb600e68a3ee --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedSymmetrization.lean @@ -0,0 +1,136 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedDiagonalEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedGoodCorrelation +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalSymmetrization + +namespace OAI + +/-! # Full bulk symmetrization under the actual selected harmonic priors -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_symmetrized_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n + 2 ≤ k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (B : Type) [Fintype B] (tierB : B → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) (n + 2)) (slot : (TreeLeafIndex (n + 2) × Fin m) ↪ B) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : B → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i ∈ flattenMovingSlots (n + 2) small, i ∉ Set.range slot) → + (∀ i, (n + 2) ≤ tierB i) → MovingLeafLengthLE (n + 2) small r₀ → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card B + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j, j < (n + 2) → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + (movingOriginalSymmetrizedEnergy p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ G (n + 2) m small slot + (normalizedResidueFamily setsReg) Jleft Jright diagonal uG vG rG sG center).re ≤ + (((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hgood⟩ := + P.moving_selected_good_correlation C hM ψ n r₀ k hk A Wwin Bφ Dφ c K gain + hA hWwin hBφ hDφ hc hK + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hgood, P.moving_selected_diagonal_energy C hM ψ (n + 2) r₀ k hk hn + A Wwin Bφ Dφ c K εdiag hA hWwin hBφ hDφ hc hK hεdiag hdepth] with L hg hd + dsimp only at hg hd ⊢ + intro B _ tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G small slot global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have hfnorm (s : ℤ) : ‖f s‖ ≤ 1 := (hf s).trans (by split_ifs <;> norm_num) + have hdiagonal := hd B tierB primes hprimes childBound pivotBound V f outside p Dq sets + primeLo cutoff tier X Δ hi φ G small slot global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen + (by omega) (fun i => hpc.trans (hp i)) hsets hsetsp hpupper hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg + have hpairs (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin (spectatorBulkCount k L))) + (hperm : 4 * Fintype.card (arrangementGraph (spectatorBulkCount k L) perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2))) := + hg B tierB primes hprimes childBound pivotBound V f outside p Dq sets β + primeLo cutoff tier X Δ hi φ G small slot perm global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV hf0 hfnorm hcard hVn hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hsmall hB hsmallLen + hm hp hsets hsetsp hpupper hperm hdlo hdhi hβ hbias hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have hidentical (j l) : primeSubsetPrior primes (Qν (slot j)) = + primeSubsetPrior primes (Qν (slot l)) := by rw [hν j, hν l] + have h := movingOriginalSymmetrizedEnergy_bound p (fun q : primes => (q : ℕ)) outside + (fun j => primeSubsetPrior primes (Qμ j)) (fun j => primeSubsetPrior primes (Qν j)) + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ hφpos G (n + 2) (spectatorBulkCount k L) hm small slot hsmall + (fun j q => primeSubsetPrior_nonneg primes (Qν j) q) hidentical + (normalizedResidueFamily setsReg) Jleft Jright diagonal uG vG rG sG center _ _ + (by positivity) (by positivity) hdiagonal hpairs + simpa only [add_assoc] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d4921028fcedd7ad08f93599778dbb699268e9a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateEnergy.lean @@ -0,0 +1,179 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalMaskedPriors +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateDiagonalRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternEnumeration + +namespace OAI + +/-! # The actual mixed diagonal energy under selected harmonic prime laws -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +/-- The mixed diagonal energy estimate with its original arithmetic premise +fully supplied by the published progression estimate and the concrete cells. -/ +theorem PublishedProgressionInput.moving_selected_template_diagonal_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n ≤ k) + (A Wwin Bφ Dφ c K ε : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hε : 0 < ε) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot n r₀ m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot n r₀ m → Bool) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot n r₀ m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center : ℝ), + let small := movingTemplateSmall n r₀ m + let slot := movingTemplateBulk n r₀ m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V n : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i, n ≤ tierB i) → + 0 < m → (∀ i, 3 ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot n r₀ m) + 4 * n * 2 ^ n) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active (slot j) = true) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j, j < n → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V n ≤ primeLo → V n < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingWeightedDiagonalEnergy p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ G n small (bulkSlotLeaves n m slot) + (fun s => movingTemplateExternalMultiplier primes _hprimes n r₀ m active outside + (normalizedResidueFamily setsReg) s φ Jleft Jright diagonal) uG vG rG sG center‖ ≤ + Real.exp ((2 ^ n : ℕ) * Δ + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + ε * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + have hCprior : 1 ≤ K + 1 := (selected_harmonic_family_bounds c K hc hK).1 + filter_upwards [P.movingPattern_diagonal_selected_masked_priors_rate C hM ψ n r₀ k + A Wwin Bφ Dφ c K hA hWwin hc hK hBφ hDφ, + movingTemplateDiagonalEnergy_pattern_rate ψ n k hk hn Bφ A (K + 1) ε + hA hCprior hε hdepth] with L hprime henergy + dsimp only + dsimp only at henergy + obtain ⟨D, hD, hdiv, henergy⟩ := henergy + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets + primeLo cutoff tier X Δ hi φ G active global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hB + hm hp hsets hsetsp hpupper hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg + let B := MovingRegularSlot n r₀ (spectatorBulkCount k L) + let small := movingTemplateSmall n r₀ (spectatorBulkCount k L) + let slot := movingTemplateBulk n r₀ (spectatorBulkCount k L) + have hsmall := movingTemplateSmall_not_bulk n r₀ (spectatorBulkCount k L) + have hsmallLen := movingTemplateSmall_length n r₀ (spectatorBulkCount k L) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let j₀ : TreeLeafIndex n × Fin (spectatorBulkCount k L) := + ⟨Classical.choice inferInstance, ⟨0, hm⟩⟩ + obtain ⟨N, e, hNcard⟩ := movingPattern_enumeration B (slot j₀) n + have hdel' (s) : ((global.card + (N s + 1) + outside.length : ℕ) : ℝ) ≤ + Real.exp ((K + 1) * L) := by + exact (Nat.cast_le.mpr (Nat.add_le_add_right + (Nat.add_le_add_left (hNcard s) global.card) outside.length)).trans hdel + apply henergy r₀ primes hprimes p + (fun j => primeSubsetPrior primes (Qμ j)) (fun j => primeSubsetPrior primes (Qν j)) + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq + X Δ hi φ G active (normalizedResidueFamily setsReg) outside Jleft Jright diagonal + uG vG rG sG center N e hV hf0 hcard hVn hV0 + intro s t + let rep : ∀ c : Quotient s, {i : Bool × MovingSampleIndex n // Quotient.mk'' i = c} := + fun c => ⟨c.out, Quotient.out_eq' c⟩ + have hS : ∀ a ∈ Sfreq, a ≠ 0 := fun a ha => (Finset.mem_erase.mp ha).1 + have hN : ∀ a ∈ Sfreq, a.natAbs ≤ V n := by + intro a ha + exact (mem_transferFrequencyRange _ _).mp (Finset.mem_erase.mp ha).2 + have hdiv' (q : ℕ) (hq : q ≠ 0) (hsize : q ≤ (V n) ^ 2) : (q.divisors.card : ℝ) ≤ D := by + apply hdiv q hq + calc + (q : ℝ) ≤ ((V n : ℕ) : ℝ) ^ 2 := by exact_mod_cast hsize + _ ≤ (Real.exp (A * spectatorBulkCount k L)) ^ 2 := pow_le_pow_left₀ (Nat.cast_nonneg _) hVn 2 + _ = Real.exp (2 * A * spectatorBulkCount k L) := by + rw [← Real.exp_nat_mul] + congr 1 + ring + have hh := hprime (Real.exp Δ) hi (Real.one_le_exp_iff.mpr hΔ) hhi hwindow + B (Quotient s) (N s) (e s) tierB + (fun b => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n b t)) + Sfreq t (V n) (V 0) D small slot (fun i => Quotient.mk'' i) rep primes hprimes + childBound pivotBound f outside p Dq sets primeLo cutoff tier X j₀ φ G global Qμ Qν + (fun i => active (movingPatternTemplateEquiv n r₀ (spectatorBulkCount k L) (e s) i)) + (frequencyRoot n (frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n false t))) + setsReg Jleft Jright diagonal uG vG rG sG center + huG hrG huvG hrsG hvG hsG hvcenter (fun _ => hsmall) hB (fun _ => hsmallLen) + rfl hS hN (fun _ a _ => hf a) hD hdiv' hm hp hsets hsetsp hpupper + hφ hlip hφout hShell (hdel' s) hout hν hμP hνP hμmass hνmass hμrange hνrange + (fun i hi => movingPatternTemplate_inactive_not_bulk n r₀ (spectatorBulkCount k L) + (e s) active hactive i hi) houtcover hinjp huBig hrBig hVn hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband + hdeleteμ hdeletep hdeleteν + (hS _ (allFrequencyList_subtype_mem Sfreq n (frequencyPairProjection Sfreq n false t) _ + (frequencyRoot_mem_allFrequencyList n _))) + (hN _ (allFrequencyList_subtype_mem Sfreq n (frequencyPairProjection Sfreq n false t) _ + (frequencyRoot_mem_allFrequencyList n _))) hsetsReg + calc + _ ≤ _ := hh + _ ≤ _ := by + rw [Fintype.card_prod, card_treeLeafIndex, Fintype.card_fin] + have hw : 0 ≤ frequencyLeafWeight (pairedFrequencyLeaf Sfreq (V 0)) n t * + ((frequencySplitList Sfreq n t).map (pairFrequencySupportBound D)).prod := by + apply mul_nonneg + · exact frequencyLeafWeight_nonneg _ (fun _ => by + unfold pairedFrequencyLeaf + split_ifs <;> norm_num) n t + · apply List.prod_nonneg + intro a ha + obtain ⟨a, _, rfl⟩ := List.mem_map.mp ha + exact pairFrequencySupportBound_nonneg D a + have hκ : 0 ≤ (2 : ℝ) ^ Fintype.card (Quotient s) * + (Real.exp ((K + 1) * L)) ^ (4 * n * 2 ^ n - Fintype.card (Quotient s)) := by positivity + have hreserve : 0 ≤ + (((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt (Real.exp Δ)) ^ (2 ^ n) * + Bφ ^ (2 ^ n - 1)) ^ 2) * + ((2 : ℝ) ^ (2 ^ n * spectatorBulkCount k L) * 3 ^ (2 ^ n * spectatorBulkCount k L)) * + (frequencyLeafWeight (pairedFrequencyLeaf Sfreq (V 0)) n t * + ((frequencySplitList Sfreq n t).map (pairFrequencySupportBound D)).prod) * + 2 ^ (2 ^ n * spectatorBulkCount k L) := by positivity + nlinarith only [mul_nonneg hκ hreserve] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateHalfLogGood.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateHalfLogGood.lean new file mode 100644 index 0000000000000000000000000000000000000000..2bd942a07a0f6bf170e2886fba796475e5bbd2c4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateHalfLogGood.lean @@ -0,0 +1,168 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternHalfLogGoodMaskedPriors +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogFamilyRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternEnumeration + +namespace OAI + +/-! # The complete good-matching correlation under original selected harmonic priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_template_half_log_good_correlation + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) + (A Wwin Bφ Dφ c K gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) + (tlog : ℕ) (htlog : tlog ≤ 4 * 2 ^ (n + 2)) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r₀ m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot (n + 2) r₀ m → Bool) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r₀ m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center cb : ℝ) + (logSlots : Fin tlog → List (MovingRegularSlot (n + 2) r₀ m)), + let small := movingTemplateSmall (n + 2) r₀ m + let slot := movingTemplateBulk (n + 2) r₀ m + let wgt := fun (y : MovingRegularSlot (n + 2) r₀ m → primes) => + ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + (∀ j, (logSlots j).length ≤ m) → + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ 1) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) r₀ m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active (slot j) = true) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j, j < (n + 2) → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingWeightedMatchedCorrelation p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ G (n + 2) small (movingPatternBulkLeaves (n + 2) m slot perm) + (fun s y x z => wgt y * movingTemplateExternalMultiplier primes _hprimes (n + 2) r₀ m active outside + (normalizedResidueFamily setsReg) s φ Jleft Jright diagonal y x z) uG vG rG sG center‖ ≤ + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + have hCprior : 1 ≤ K + 1 := (selected_harmonic_family_bounds c K hc hK).1 + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hprime⟩ := + P.movingPattern_half_log_good_selected_masked_priors_rate C hM ψ n r₀ k A Wwin Bφ Dφ c K + (goodPatternGain (n + 2) (K + 1) A gain) hA hWwin hc hK hBφ hDφ + Dlog hDlog hloglip tlog htlog + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hprime, movingTemplateLogFamilyMatchedCorrelation_pattern_rate ψ (n + 2) k hk + A (K + 1) gain hA hCprior] with L hprime hcorr + dsimp only at hcorr ⊢ + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G active perm global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center cb logSlots + hslots hV hf0 hf hcard hVn hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hB + hm hp hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + let m := spectatorBulkCount k L + let B := MovingRegularSlot (n + 2) r₀ m + let small := movingTemplateSmall (n + 2) r₀ m + let slot := movingTemplateBulk (n + 2) r₀ m + have hsmall := movingTemplateSmall_not_bulk (n + 2) r₀ m + have hsmallLen := bulkSlotLeaves_length (n + 2) r₀ (fun j : TreeLeafIndex (n + 2) × Fin r₀ => ((j.1, Sum.inl j.2) : B)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + let _ := sampleSetoidFintype (Bool × MovingSampleIndex (n + 2)) + let j₀ : TreeLeafIndex (n + 2) × Fin (spectatorBulkCount k L) := + ⟨Classical.choice inferInstance, ⟨0, by omega⟩⟩ + obtain ⟨N, e, hNcard⟩ := movingPattern_enumeration B (slot j₀) (n + 2) + have hdel' (s) : ((global.card + (N s + 1) + outside.length : ℕ) : ℝ) ≤ + Real.exp ((K + 1) * L) := by + exact (Nat.cast_le.mpr (Nat.add_le_add_right + (Nat.add_le_add_left (hNcard s) global.card) outside.length)).trans hdel + apply hcorr r₀ primes hprimes p + (fun j => primeSubsetPrior primes (Qμ j)) (fun j => primeSubsetPrior primes (Qν j)) + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq + X Δ hi φ G active perm (normalizedResidueFamily setsReg) outside Jleft Jright diagonal + uG vG rG sG center cb tlog logSlots N e hV hf0 hcard + intro s t + let rep : ∀ c : Quotient s, {i : Bool × MovingSampleIndex (n + 2) // Quotient.mk'' i = c} := + fun c => ⟨c.out, Quotient.out_eq' c⟩ + have hS : ∀ a ∈ Sfreq, a ≠ 0 := fun a ha => (Finset.mem_erase.mp ha).1 + have hN : ∀ a ∈ Sfreq, a.natAbs ≤ V (n + 2) := by + intro a ha + exact (mem_transferFrequencyRange _ _).mp (Finset.mem_erase.mp ha).2 + have hh := hprime (Real.exp Δ) hi (Real.one_le_exp_iff.mpr hΔ) hhi hwindow + B (Quotient s) (N s) (e s) tierB + (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b t)) + Sfreq t (V (n + 2)) small slot perm (fun i => Quotient.mk'' i) rep primes hprimes + childBound pivotBound f outside p Dq sets β primeLo cutoff tier X j₀ φ G global Qμ Qν + (fun j => (logSlots j).map + (fun i => (e s).symm (.inl i))) cb + (fun i => active (movingPatternTemplateEquiv (n + 2) r₀ m (e s) i)) + (frequencyRoot (n + 2) (frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) false t))) + setsReg Jleft Jright diagonal uG vG rG sG center + (fun j => by + rw [List.length_map] + exact (hslots j).trans (by nlinarith only [Nat.one_le_pow (n + 2) 2 (by omega)])) + huG hrG huvG hrsG hvG hsG hvcenter (fun _ => hsmall) hB (fun _ => hsmallLen) + rfl hS hN hf hm hp hsets hsetsp hpupper hgood hdlo hdhi hβ hbias + hφ hlip hφout hShell (hdel' s) hout hν hμP hνP hμmass hνmass hμrange hνrange + (fun i hi => movingPatternTemplate_inactive_not_bulk (n + 2) r₀ m (e s) active hactive i hi) + houtcover hinjp huBig hrBig hVn hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband + hdeleteμ hdeletep hdeleteν hdeletebulk + (hS _ (allFrequencyList_subtype_mem Sfreq (n + 2) (frequencyPairProjection Sfreq (n + 2) false t) _ + (frequencyRoot_mem_allFrequencyList (n + 2) _))) + (hN _ (allFrequencyList_subtype_mem Sfreq (n + 2) (frequencyPairProjection Sfreq (n + 2) false t) _ + (frequencyRoot_mem_allFrequencyList (n + 2) _))) hsetsReg + simpa only [add_assoc] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateLogFullEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateLogFullEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..ac030c7c93070f5f2d174e5f5987b7146f152a15 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateLogFullEnergy.lean @@ -0,0 +1,136 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedTemplateLogSymmetrization +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSymmetrizedFullCell + +namespace OAI + +/-! # Full bulk symmetrization under the actual selected harmonic priors -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_template_log_full_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n + 2 ≤ k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r₀ m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot (n + 2) r₀ m → Bool) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r₀ m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (H cb cd : ℝ), + let slot := movingTemplateBulk (n + 2) r₀ m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ H - 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) r₀ m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active (slot j) = true) → + (∀ j : TreeLeafIndex (n + 2) × Fin r₀, tierB (j.1, .inl j.2) ≠ k) → + (∀ j, tierB (slot j) = k) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ H - 1 → + (∀ j (q : primes), (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingTemplateMaskedSymmetrizedEnergy primes _hprimes outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r₀ m ν active (normalizedResidueFamily setsReg) + H H false (H - 1) (H + 1) (H - 1) (H + 1) H‖ ≤ + 4 * ((((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hunit⟩ := + P.moving_selected_template_log_symmetrized_energy C hM ψ n r₀ k hk hn + A Wwin Bφ Dφ c K εdiag gain hA hWwin hBφ hDφ hc hK hεdiag hdepth Dlog hDlog hloglip + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hunit] with L hunit + dsimp only at hunit ⊢ + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G active global Qμ Qν setsReg H cb cd + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow hH hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive hsmalltier hbulktier houtcover hinjp hHbig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + apply movingTemplateMaskedSymmetrizedEnergy_full_cell_bound primes hprimes outside + (fun j => primeSubsetPrior primes (Qμ j)) childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r₀ (spectatorBulkCount k L) + (fun j => primeSubsetPrior primes (Qν j)) active (normalizedResidueFamily setsReg) + H H false H H H _ + intro i j + have hu : H - 1 ≤ (if i then H else H - 1) := by split <;> linarith + have hr : H - 1 ≤ (if j then H else H - 1) := by split <;> linarith + have hv : (if i then H else H - 1) ≤ H := by split <;> linarith + exact hunit tierB primes hprimes childBound pivotBound V f outside p Dq sets β + primeLo cutoff tier X Δ hi φ G active global Qμ Qν setsReg H H false + (if i then H else H - 1) ((if i then H else H - 1) + 1) + (if j then H else H - 1) ((if j then H else H - 1) + 1) H cb cd + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow (hH.trans hu) (hH.trans hr) + (by linarith) (by linarith) le_rfl le_rfl (by linarith) hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive hsmalltier hbulktier houtcover hinjp (hHbig.trans (by linarith)) (hHbig.trans hr) + hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateLogGood.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateLogGood.lean new file mode 100644 index 0000000000000000000000000000000000000000..c90baa9be7ea7a3508dd5cba79f60e9c2cca9aec --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateLogGood.lean @@ -0,0 +1,169 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternLogGoodMaskedPriors +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogMatchedRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternEnumeration + +namespace OAI + +/-! # The complete good-matching correlation under original selected harmonic priors -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_template_log_good_correlation + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) + (A Wwin Bφ Dφ c K gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r₀ m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot (n + 2) r₀ m → Bool) + (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r₀ m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center cb : ℝ), + let small := movingTemplateSmall (n + 2) r₀ m + let slot := movingTemplateBulk (n + 2) r₀ m + let logSlots := movingBulkPairedCutoffSlots (n + 2) (movingPatternBulkLeaves (n + 2) m slot perm) + let wgt := fun (y : MovingRegularSlot (n + 2) r₀ m → primes) => + ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ 1) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2)) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) r₀ m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active (slot j) = true) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j, j < (n + 2) → ∀ q : primes, (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingWeightedMatchedCorrelation p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ + ψ X (Real.exp Δ) hi φ G (n + 2) small (movingPatternBulkLeaves (n + 2) m slot perm) + (fun s y x z => wgt y * movingTemplateExternalMultiplier primes _hprimes (n + 2) r₀ m active outside + (normalizedResidueFamily setsReg) s φ Jleft Jright diagonal y x z) uG vG rG sG center‖ ≤ + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + have hCprior : 1 ≤ K + 1 := (selected_harmonic_family_bounds c K hc hK).1 + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hprime⟩ := + P.movingPattern_log_good_selected_masked_priors_rate C hM ψ n r₀ k A Wwin Bφ Dφ c K + (goodPatternGain (n + 2) (K + 1) A gain) hA hWwin hc hK hBφ hDφ + Dlog hDlog hloglip (2 ^ (n + 2) + 2 ^ (n + 2)) (by omega) + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hprime, movingTemplateLogMatchedCorrelation_pattern_rate ψ (n + 2) k hk + A (K + 1) gain hA hCprior] with L hprime hcorr + dsimp only at hcorr ⊢ + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G active perm global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center cb + hV hf0 hf hcard hVn hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hB + hm hp hsets hsetsp hpupper hgood hdlo hdhi hβ hbias hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + let m := spectatorBulkCount k L + let B := MovingRegularSlot (n + 2) r₀ m + let small := movingTemplateSmall (n + 2) r₀ m + let slot := movingTemplateBulk (n + 2) r₀ m + have hsmall := movingTemplateSmall_not_bulk (n + 2) r₀ m + have hsmallLen := bulkSlotLeaves_length (n + 2) r₀ (fun j : TreeLeafIndex (n + 2) × Fin r₀ => ((j.1, Sum.inl j.2) : B)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + let _ := sampleSetoidFintype (Bool × MovingSampleIndex (n + 2)) + let j₀ : TreeLeafIndex (n + 2) × Fin (spectatorBulkCount k L) := + ⟨Classical.choice inferInstance, ⟨0, by omega⟩⟩ + obtain ⟨N, e, hNcard⟩ := movingPattern_enumeration B (slot j₀) (n + 2) + have hdel' (s) : ((global.card + (N s + 1) + outside.length : ℕ) : ℝ) ≤ + Real.exp ((K + 1) * L) := by + exact (Nat.cast_le.mpr (Nat.add_le_add_right + (Nat.add_le_add_left (hNcard s) global.card) outside.length)).trans hdel + apply hcorr r₀ primes hprimes p + (fun j => primeSubsetPrior primes (Qμ j)) (fun j => primeSubsetPrior primes (Qν j)) + childBound pivotBound V f (fun i => normalizedResidueTransform (sets i)) Dq + X Δ hi φ G active perm (normalizedResidueFamily setsReg) outside Jleft Jright diagonal + uG vG rG sG center cb N e hV hf0 hcard + intro s t + let rep : ∀ c : Quotient s, {i : Bool × MovingSampleIndex (n + 2) // Quotient.mk'' i = c} := + fun c => ⟨c.out, Quotient.out_eq' c⟩ + have hS : ∀ a ∈ Sfreq, a ≠ 0 := fun a ha => (Finset.mem_erase.mp ha).1 + have hN : ∀ a ∈ Sfreq, a.natAbs ≤ V (n + 2) := by + intro a ha + exact (mem_transferFrequencyRange _ _).mp (Finset.mem_erase.mp ha).2 + have hh := hprime (Real.exp Δ) hi (Real.one_le_exp_iff.mpr hΔ) hhi hwindow + B (Quotient s) (N s) (e s) tierB + (fun b => frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) b t)) + Sfreq t (V (n + 2)) small slot perm (fun i => Quotient.mk'' i) rep primes hprimes + childBound pivotBound f outside p Dq sets β primeLo cutoff tier X j₀ φ G global Qμ Qν + (fun j => (movingBulkPairedCutoffSlots (n + 2) (movingPatternBulkLeaves (n + 2) m slot perm) j).map + (fun i => (e s).symm (.inl i))) cb + (fun i => active (movingPatternTemplateEquiv (n + 2) r₀ m (e s) i)) + (frequencyRoot (n + 2) (frequencyTreeMap Subtype.val (n + 2) (frequencyPairProjection Sfreq (n + 2) false t))) + setsReg Jleft Jright diagonal uG vG rG sG center + (fun j => by + rw [List.length_map] + have hj := movingBulkPairedCutoffSlots_length (n + 2) m + (movingPatternBulkLeaves (n + 2) m slot perm) + (fun b => by cases b <;> exact bulkSlotLeaves_length _ _ _) j + exact hj.trans (by nlinarith only [Nat.one_le_pow (n + 2) 2 (by omega)])) + huG hrG huvG hrsG hvG hsG hvcenter (fun _ => hsmall) hB (fun _ => hsmallLen) + rfl hS hN hf hm hp hsets hsetsp hpupper hgood hdlo hdhi hβ hbias + hφ hlip hφout hShell (hdel' s) hout hν hμP hνP hμmass hνmass hμrange hνrange + (fun i hi => movingPatternTemplate_inactive_not_bulk (n + 2) r₀ m (e s) active hactive i hi) + houtcover hinjp huBig hrBig hVn hμtier hνtier hNlo hNcut hcutlo hloReal hupper hpband + hdeleteμ hdeletep hdeleteν hdeletebulk + (hS _ (allFrequencyList_subtype_mem Sfreq (n + 2) (frequencyPairProjection Sfreq (n + 2) false t) _ + (frequencyRoot_mem_allFrequencyList (n + 2) _))) + (hN _ (allFrequencyList_subtype_mem Sfreq (n + 2) (frequencyPairProjection Sfreq (n + 2) false t) _ + (frequencyRoot_mem_allFrequencyList (n + 2) _))) hsetsReg + simpa only [add_assoc] using hh + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateLogSymmetrization.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateLogSymmetrization.lean new file mode 100644 index 0000000000000000000000000000000000000000..8eefd15f95adf090c2aab2d9a677f7a176ee0186 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSelectedTemplateLogSymmetrization.lean @@ -0,0 +1,152 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedTemplateEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSelectedTemplateLogGood +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogSymmetrizedEnergy + +namespace OAI + +/-! # Full bulk symmetrization under the actual selected harmonic priors -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem PublishedProgressionInput.moving_selected_template_log_symmetrized_energy + (P : PublishedProgressionInput) (C : ℝ) (hM : MertensEstimate C) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (hk : 0 < k) (hn : n + 2 ≤ k) + (A Wwin Bφ Dφ c K εdiag gain : ℝ) + (hA : 0 ≤ A) (hWwin : 0 ≤ Wwin) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hc : 0 < c) (hK : 0 ≤ K) (hεdiag : 0 < εdiag) + (hdepth : 8 * (K + 1) ≤ (k : ℝ) ^ 3) + (Dlog : ℝ) (hDlog : 0 ≤ Dlog) + (hloglip : ∀ x y, |logCellProfile x - logCellProfile y| ≤ Dlog * |x - y|) : + ∃ ε : ℝ, 0 < ε ∧ ε ≤ 1 ∧ ∃ primeCutoff : ℕ, 3 ≤ primeCutoff ∧ + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + let Cprior := K + 1 + ∀ (tierB : MovingRegularSlot (n + 2) r₀ m → ℕ) + (primes : Finset ℕ) (_hprimes : ∀ p ∈ primes, p.Prime) [Nonempty primes] + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (outside : List ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (Dq : ∀ i, (ZMod (p i))ˣ) (sets : ∀ i, Finset (ZMod (p i))) + (β : Fin m → ℝ) + (primeLo cutoff : ℕ) (tier : primes → ℕ) (X Δ hi : ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot (n + 2) r₀ m → Bool) + (global : Finset ℕ) (Qμ : ℕ → Finset ℕ) (Qν : MovingRegularSlot (n + 2) r₀ m → Finset ℕ) + (setsReg : ∀ q : ℕ, Finset (ZMod q)) + (Jleft Jright : ℝ) (diagonal : Bool) (uG vG rG sG center cb cd : ℝ), + let slot := movingTemplateBulk (n + 2) r₀ m + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + let S := primeLogCellSet 1 0 (Real.exp ((4 / 1000 : ℝ) * L)) + (Real.exp ((6 / 1000 : ℝ) * L)) + let Sfreq := (transferFrequencyRange (V (n + 2))).erase 0 + Monotone V → f 0 = 0 → + (∀ s, ‖f s‖ ≤ if s.natAbs ≤ V 0 then 1 else 0) → + (Sfreq.card : ℝ) ≤ Real.exp (A * m) → + (V (n + 2) : ℝ) ≤ Real.exp (A * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + 0 ≤ Δ → Real.exp Δ ≤ hi → hi - Real.exp Δ ≤ Real.exp (Wwin * m) → + 1 ≤ uG → 1 ≤ rG → uG ≤ vG → rG ≤ sG → vG ≤ uG + 1 → sG ≤ rG + 1 → vG ≤ center + 1 → + (∀ i, (n + 2) ≤ tierB i) → + 1 ≤ m → (∀ i, primeCutoff ≤ p i) → + (∀ i, (sets i).Nonempty) → (∀ i, (sets i).card < p i) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (∀ i, (1 / 3 : ℝ) ≤ residueDensity (sets i)) → + (∀ i, residueDensity (sets i) ≤ 2 / 3) → + (∀ i, 2 * β i ≤ ε) → + (∀ i (χ : MulChar (ZMod (p i)) ℂ), χ ≠ 1 → ∀ a : ZMod (p i), + ‖((sets i).card : ℂ)⁻¹ * ∑ x ∈ sets i, χ⁻¹ (-a - x)‖ ≤ β i) → + (∀ x, 0 ≤ φ x) → (∀ x, |φ x| ≤ Bφ) → (∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) → + (∀ x, 1 ≤ |x| → φ x = 0) → S ⊆ primes → + ((global.card + (Fintype.card (MovingRegularSlot (n + 2) r₀ m) + 4 * (n + 2) * 2 ^ (n + 2)) + outside.length : ℕ) : ℝ) ≤ Real.exp (Cprior * L) → + (∀ q ∈ outside, q.Prime) → (∀ j, Qν (slot j) = S \ global) → + (∀ j, Qμ j ⊆ primes) → (∀ j, Qν j ⊆ primes) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qμ j, (q : ℝ)⁻¹) → + (∀ j, c / Real.exp (K * L) ≤ ∑ q ∈ Qν j, (q : ℝ)⁻¹) → + (∀ j q, q ∈ Qμ j → Real.exp (Real.exp ((1 / 100 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j q, q ∈ Qν j → Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (q : ℝ)) → + (∀ j, active (slot j) = true) → + (∀ j : TreeLeafIndex (n + 2) × Fin r₀, tierB (j.1, .inl j.2) ≠ k) → + (∀ j, tierB (slot j) = k) → + (∀ q ∈ outside, ∃ i, p i = q) → Function.Injective p → + Real.exp ((49 / 1000 : ℝ) * L) ≤ center → Real.exp ((49 / 1000 : ℝ) * L) ≤ rG → + (∀ j (q : primes), (q : ℕ) ∈ Qμ j → tier q = j) → + (∀ j (q : primes), (q : ℕ) ∈ Qν j → tier q = tierB j) → + V (n + 2) ≤ primeLo → V (n + 2) < cutoff → cutoff ≤ primeLo → + (primeLo : ℝ) < Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) → + (∀ a : primes, (a : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, cutoff ≤ p i ∧ p i ≤ primeLo) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qμ j) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ z, selectedPageZero P (giantProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ j, q ∉ Qν j) → + (∀ z, selectedPageZero P (bulkProgressionCutoff L) = some z → ∀ q, + deletedConductorPrime z.modulus cutoff = some q → ∀ i, p i ≠ q) → + (∀ q, q.Prime → (setsReg q).Nonempty ∧ (setsReg q).card < q) → + ‖movingTemplateMaskedSymmetrizedEnergy primes _hprimes outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + (fun i => normalizedResidueTransform (sets i)) Dq Finset.univ ψ X (Real.exp Δ) hi) + φ G (n + 2) r₀ m ν active (normalizedResidueFamily setsReg) + Jleft Jright diagonal uG vG rG sG center‖ ≤ + (((2 ^ (n + 2) + 1) * (2 ^ (n + 2)) ^ (2 * 2 ^ (n + 2)) : ℕ) : ℝ) * + Real.exp ((2 ^ (n + 2) : ℝ) * m * + (-(3 / 4 : ℝ) * Real.log (2 ^ (n + 2) : ℕ) + 5 / 4)) * + (Real.exp ((2 ^ (n + 2) : ℕ) * Δ + + (Real.log 12 + 1) * (2 ^ (n + 2) : ℕ) * m + εdiag * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + obtain ⟨ε, hε, hε1, primeCutoff, hpc, hgood⟩ := + P.moving_selected_template_log_good_correlation C hM ψ n r₀ k hk A Wwin Bφ Dφ c K gain + hA hWwin hBφ hDφ hc hK Dlog hDlog hloglip + refine ⟨ε, hε, hε1, primeCutoff, hpc, ?_⟩ + filter_upwards [hgood, P.moving_selected_template_diagonal_energy C hM ψ (n + 2) r₀ k hk hn + A Wwin Bφ Dφ c K εdiag hA hWwin hBφ hDφ hc hK hεdiag hdepth] with L hg hd + dsimp only at hg hd ⊢ + intro tierB primes hprimes _ childBound pivotBound V f outside p _ Dq sets β + primeLo cutoff tier X Δ hi φ G active global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center cb cd + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hB + hm hp hsets hsetsp hpupper hdlo hdhi hβ hbias hφpos hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive hsmalltier hbulktier houtcover hinjp huBig hrBig hμtier hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + let m := spectatorBulkCount k L + let μ := fun j => primeSubsetPrior primes (Qμ j) + let ν := fun j => primeSubsetPrior primes (Qν j) + have hlocal := fun j (_ : j < n + 2) => hμtier j + have hfnorm (s : ℤ) : ‖f s‖ ≤ 1 := (hf s).trans (by split_ifs <;> norm_num) + have hdiagonal := hd tierB primes hprimes childBound pivotBound V f outside p Dq sets + primeLo cutoff tier X Δ hi φ G active global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center + hV hf0 hf hcard hVn hV0 hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hB + (by omega) (fun i => hpc.trans (hp i)) hsets hsetsp hpupper hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive houtcover hinjp huBig hrBig hlocal hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hsetsReg + have hpairs (perm : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (hperm : 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2))) := + hg tierB primes hprimes childBound pivotBound V f outside p Dq sets β + primeLo cutoff tier X Δ hi φ G active perm global Qμ Qν setsReg Jleft Jright diagonal uG vG rG sG center cb + hV hf0 hfnorm hcard hVn hΔ hhi hwindow huG hrG huvG hrsG hvG hsG hvcenter hB + hm hp hsets hsetsp hpupper hperm hdlo hdhi hβ hbias hφ hlip hφout hShell hdel hout hν hμP hνP hμmass hνmass + hμrange hνrange hactive houtcover hinjp huBig hrBig hlocal hνtier hNlo hNcut hcutlo hloReal + hupper hpband hdeleteμ hdeletep hdeleteν hdeletebulk hsetsReg + have hμlevels (j) (q : primes) (hq : μ j q ≠ 0) : tier q = j := + hμtier j q (primeSubsetPrior_support primes (Qμ j) q hq) + have hνlevels (y : MovingRegularSlot (n + 2) r₀ m → primes) + (hy : (∏ j, ν j (y j)) ≠ 0) (j) : tier (y j) = tierB j := + hνtier j (y j) (primeSubsetPrior_support primes (Qν j) (y j) + ((Finset.prod_ne_zero_iff.mp hy) j (Finset.mem_univ j))) + have h := movingTemplate_log_symmetrized_energy_bound primes hprimes (n + 2) r₀ m k hm hn tier outside cb cd + μ hμlevels ν (fun j q => primeSubsetPrior_nonneg primes (Qν j) q) + (fun j l => by dsimp only [ν]; rw [hν j, hν l]) + (fun y hy j => by rw [hνlevels y hy]; exact hsmalltier j) + (fun y hy j => by rw [hνlevels y hy]; exact hbulktier j) + p (fun i => normalizedResidueTransform (sets i)) Dq childBound pivotBound V f ψ X (Real.exp Δ) hi + φ hφpos G active hactive (normalizedResidueFamily setsReg) Jleft Jright diagonal uG vG rG sG center _ _ + (by positivity) (by positivity) hdiagonal hpairs + simpa only [add_assoc] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedAverageNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedAverageNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..1b8a3aa60859dae41380e0be720ece2b5a88f42c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedAverageNorm.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedAverages + +namespace OAI + +/-! # Concrete norm budgets for the retained arithmetic averages -/ + +namespace Ostmann +open scoped Classical BigOperators + +private theorem finiteMean_norm_le {A : Type*} [Fintype A] [Nonempty A] + (f : A → ℂ) (B : ℝ) (hf : ∀ a, ‖f a‖ ≤ B) : + ‖(Fintype.card A : ℂ)⁻¹ * ∑ a, f a‖ ≤ B := by + have hcard : (Fintype.card A : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + rw [norm_mul, norm_inv, Complex.norm_natCast] + calc + _ ≤ (Fintype.card A : ℝ)⁻¹ * ∑ _a : A, B := + mul_le_mul_of_nonneg_left ((norm_sum_le _ _).trans (Finset.sum_le_sum fun a _ => hf a)) + (inv_nonneg.mpr (Nat.cast_nonneg _)) + _ = B := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + rw [← mul_assoc, inv_mul_cancel₀ hcard, one_mul] + +theorem pageGiantWeight_norm_le_two (input : PublishedProgressionInput) (Q q a : ℕ) + (y : ℝ) (hy : 0 ≤ y) : ‖pageGiantWeight input Q q a y‖ ≤ 2 := by + have h := pageMultiplier_bounds + (fun a => pageCoefficient (pageAtModulus q (selectedPageZero input Q)) a) + (pageBeta (pageAtModulus q (selectedPageZero input Q))) y + (pageCoefficient_abs_le_one _) (pageBeta_le_one _) hy a + rw [pageGiantWeight, Complex.norm_real, Real.norm_of_nonneg h.1] + exact h.2 + +theorem movingFrequencyPageAverage_norm_le {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) + (y : ℝ) (hy : 0 ≤ y) : + ‖movingFrequencyPageAverage value outside F E T nodes R r input Q y‖ ≤ + 2 * (‖movingDataWeight (F false) (E false) (T false)‖ * + ‖movingDataWeight (F true) (E true) (T true)‖) := by + apply finiteMean_norm_le + intro z + have hf : ‖movingFrequencyPairFactor value outside F E T nodes R z.1.val z.2.val.val‖ ≤ + ‖movingDataWeight (F false) (E false) (T false)‖ * + ‖movingDataWeight (F true) (E true) (T true)‖ := by + unfold movingFrequencyPairFactor + split_ifs + · simp only [norm_mul, Complex.norm_conj, le_refl] + · exact (norm_zero : ‖(0 : ℂ)‖ = 0) ▸ mul_nonneg (norm_nonneg _) (norm_nonneg _) + rw [norm_mul] + calc + _ ≤ (‖movingDataWeight (F false) (E false) (T false)‖ * + ‖movingDataWeight (F true) (E true) (T true)‖) * 2 := + mul_le_mul hf (pageGiantWeight_norm_le_two input Q r z.2.val.val y hy) + (norm_nonneg _) (mul_nonneg (norm_nonneg _) (norm_nonneg _)) + _ = _ := mul_comm _ _ + +theorem movingSpectatorHaarAverage_norm_le {σ : Type*} (value : σ → ℕ) + (q : ℕ) [Fact q.Prime] (g : ZMod q → ℂ) (D : Bool → (ZMod q)ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (B : ℝ) (hB : 0 ≤ B) + (hg : ∀ z, ‖g z‖ ≤ B) : + ‖movingSpectatorHaarAverage value q g D T‖ ≤ B ^ (2 ^ (n + 1)) := by + apply finiteMean_norm_le + intro z + rw [movingSpectatorPairFactor, norm_mul, Complex.norm_conj] + calc + _ ≤ B ^ (2 ^ n) * B ^ (2 ^ n) := + mul_le_mul (movingModularSpectator_norm value q g (D false) B hB hg (T false) z.1 z.2) + (movingModularSpectator_norm value q g (D true) B hB hg (T true) z.1 z.2) + (norm_nonneg _) (pow_nonneg hB _) + _ = _ := by rw [← pow_add, pow_succ]; congr 1; omega + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedAverages.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedAverages.lean new file mode 100644 index 0000000000000000000000000000000000000000..724b4760d23f78a0bb14cae97f9b0005afe79d80 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedAverages.lean @@ -0,0 +1,119 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedPageCRT +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalProductError +import OAI.NumberTheory.Ostmann.Construction.FiniteEnumeration + +namespace OAI + +/-! # Explicit three-factor form of the original Page-weighted average -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingFrequencyPageAverage {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (input : PublishedProgressionInput) (Q : ℕ) (y : ℝ) : ℂ := + (Fintype.card (ZMod r × (ZMod r)ˣ) : ℂ)⁻¹ * + ∑ z : ZMod r × (ZMod r)ˣ, + movingFrequencyPairFactor value outside F E T nodes R z.1.val z.2.val.val * + pageGiantWeight input Q r z.2.val.val y + +noncomputable def movingSpectatorHaarAverage {σ : Type*} (value : σ → ℕ) + (q : ℕ) [Fact q.Prime] (g : ZMod q → ℂ) (D : Bool → (ZMod q)ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) : ℂ := + (Fintype.card (ZMod q × (ZMod q)ˣ) : ℂ)⁻¹ * + ∑ z : ZMod q × (ZMod q)ˣ, movingSpectatorPairFactor value q g D T z.1 z.2 + +theorem movingArithmeticPageFactor_averages {σ I : Type*} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : Bool → ∀ i, (ZMod (q i))ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (P : Finset ℕ) (S : Finset I) + [∀ p : P, Fact p.val.Prime] [∀ b, NeZero (movingArithmeticModuli r q P S b)] + (input : PublishedProgressionInput) (Q : ℕ) (y : ℝ) : + (∏ b, (Fintype.card (ZMod (movingArithmeticModuli r q P S b) × + (ZMod (movingArithmeticModuli r q P S b))ˣ) : ℂ)⁻¹ * + ∑ z, movingArithmeticPageFactor r q P S input Q y + (movingArithmeticLocalFactor q value outside F E g D T nodes R r P S) b z) = + movingFrequencyPageAverage value outside F E T nodes R r input Q y * + (∏ p : P, movingInternalHaarAverage value T p.val) * + ∏ i : S, movingSpectatorHaarAverage value (q i.val) (g i.val) + (fun side => D side i.val) T := by + simp only [Fintype.prod_sum_type, Fintype.prod_unique, movingArithmeticPageFactor, + movingArithmeticLocalFactor, movingArithmeticModuli, movingFrequencyPageAverage, + movingInternalHaarAverage, movingSpectatorHaarAverage] + rw [← mul_assoc] + congr 4 + +section +variable {σ I : Type*} (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : Bool → ∀ i, (ZMod (q i))ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (P : Finset ℕ) (S : Finset I) + [∀ p : P, Fact p.val.Prime] + [∀ b, NeZero (movingArithmeticModuli r q P S b)] + [NeZero (∏ b, movingArithmeticModuli r q P S b)] + (hf : ∀ side, (T side).Frequencies (· ≠ 0)) + (hR : ∀ side, (T side).frequencyProduct ∣ R) + (hfrequency : R ^ (n + 1) ∣ (r : ℤ)) + (hcover : ∀ side, ∀ o ∈ (T side).occurrences, + ∀ i ∈ o.current.compensationSlots, value i ∈ P) + (hc : Pairwise (fun b c => (movingArithmeticModuli r q P S b).Coprime + (movingArithmeticModuli r q P S c))) + (input : PublishedProgressionInput) (Q : ℕ) + (hpage : pageAtModulus (∏ b, movingArithmeticModuli r q P S b) (selectedPageZero input Q) = + pageAtModulus r (selectedPageZero input Q)) + +include hf hR hfrequency hcover hc hpage + +theorem movingSeparatedPairResidueCoefficient_page_factorization (y : ℝ) : + correctedMixedPairAverage input Q (∏ b, movingArithmeticModuli r q P S b) + (movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R) y = + movingFrequencyPageAverage value outside F E T nodes R r input Q y * + (∏ p : P, movingInternalHaarAverage value T p.val) * + ∏ i : S, movingSpectatorHaarAverage value (q i.val) (g i.val) + (fun side => D side i.val) T := by + rw [movingSeparatedPairResidueCoefficient_page_average q value outside F E g D T nodes + R r P S hf hR hfrequency hcover hc input Q hpage] + exact movingArithmeticPageFactor_averages q value outside F E g D T nodes R r P S input Q y + +/-- Remove all prime-square exclusions from the literal corrected average. +The frequency/Page factor and each spectator factor are retained exactly. -/ +theorem movingSeparatedPairResidueCoefficient_square_error + (tier : σ → ℕ) (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (hlevels : ∀ side, (T side).Levels tier) + (hfmod : ∀ p : P, ∀ side, (T side).Frequencies (fun s => (s : ZMod p.val) ≠ 0)) + (y B : ℝ) + (hweight : ‖movingFrequencyPageAverage value outside F E T nodes R r input Q y * + (∏ i : S, movingSpectatorHaarAverage value (q i.val) (g i.val) + (fun side => D side i.val) T)‖ * + (∏ p : P, movingInternalLineProbability value T p.val) ≤ B) : + ‖correctedMixedPairAverage input Q (∏ b, movingArithmeticModuli r q P S b) + (movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R) y - + movingFrequencyPageAverage value outside F E T nodes R r input Q y * + (∏ p : P, (movingInternalLineProbability value T p.val : ℂ)) * + ∏ i : S, movingSpectatorHaarAverage value (q i.val) (g i.val) + (fun side => D side i.val) T‖ ≤ + B * (2 * (2 ^ n - 1 : ℕ) * ∑ p : P, (p.val : ℝ)⁻¹) := by + rw [movingSeparatedPairResidueCoefficient_page_factorization q value outside F E g D T nodes + R r P S hf hR hfrequency hcover hc input Q hpage] + have h := movingInternalProduct_weighted_error tier value hprime hdisjoint T hlevels P hfmod + (movingFrequencyPageAverage value outside F E T nodes R r input Q y * + ∏ i : S, movingSpectatorHaarAverage value (q i.val) (g i.val) + (fun side => D side i.val) T) B hweight + convert h using 1 + congr 1 + ring + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedCRT.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedCRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..0719a7c1c31052c4dda25a7ba35b40806417c2c0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedCRT.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticModulus + +namespace OAI + +/-! # Exact CRT factorization of the original separated pair -/ + +namespace Ostmann +open scoped Classical BigOperators + +section +variable {σ I : Type*} (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : Bool → ∀ i, (ZMod (q i))ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (P : Finset ℕ) (S : Finset I) + [NeZero (∏ b, movingArithmeticModuli r q P S b)] + (hf : ∀ side, (T side).Frequencies (· ≠ 0)) + (hR : ∀ side, (T side).frequencyProduct ∣ R) + (hfrequency : R ^ (n + 1) ∣ (r : ℤ)) + (hcover : ∀ side, ∀ o ∈ (T side).occurrences, + ∀ i ∈ o.current.compensationSlots, value i ∈ P) + (hc : Pairwise (fun b c => (movingArithmeticModuli r q P S b).Coprime + (movingArithmeticModuli r q P S c))) + +include hf hR hfrequency hcover hc + +/-- Pointwise CRT identification, using the actual frequency recursion and +all actual internal occurrences, before any norm or average is taken. -/ +theorem movingSeparatedPairResidueCoefficient_crt + (z : ZMod (∏ b, movingArithmeticModuli r q P S b) × + (ZMod (∏ b, movingArithmeticModuli r q P S b))ˣ) : + movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R + z.1.val (z.2 : ZMod (∏ b, movingArithmeticModuli r q P S b)).val = + ∏ b, movingArithmeticLocalFactor q value outside F E g D T nodes R r P S b + (crtExternalPairEquiv (movingArithmeticModuli r q P S) hc z b) := by + let a := movingArithmeticModuli r q P S + let e := crtExternalPairEquiv a hc + let f := movingArithmeticLocalFactor q value outside F E g D T nodes R r P S + let x := z.1.val + let y := (z.2 : ZMod (∏ b, a b)).val + have hcasts (b) := crtExternalPairEquiv_casts a hc z b + have hfreq : f (.inl ()) (e z (.inl ())) = + movingFrequencyPairFactor value outside F E T nodes R x y := by + let v : ZMod r × (ZMod r)ˣ := e z (.inl ()) + have hl : (x : ZMod r) = v.1 := congrArg Prod.fst (hcasts (.inl ())) + have hr : (y : ZMod r) = (v.2 : ZMod r) := congrArg Prod.snd (hcasts (.inl ())) + have hx : (x : ℤ) ≡ (v.1.val : ℤ) [ZMOD (r : ℤ)] := by + apply (ZMod.intCast_eq_intCast_iff _ _ r).mp + simpa only [Int.cast_natCast, ZMod.natCast_zmod_val] using + hl + have hy : (y : ℤ) ≡ ((v.2 : ZMod r).val : ℤ) [ZMOD (r : ℤ)] := by + apply (ZMod.intCast_eq_intCast_iff _ _ r).mp + simpa only [Int.cast_natCast, ZMod.natCast_zmod_val] using + hr + exact (movingFrequencyPairFactor_modEq value outside F E T nodes R hf hR + x y v.1.val (v.2 : ZMod r).val r hfrequency hx hy).symm + have hint (p : P) : f (.inr (.inl p)) (e z (.inr (.inl p))) = + movingInternalPairFactor value T p.val x y := by + have hl : (x : ZMod (p.val ^ 2)) = (e z (.inr (.inl p))).1 := + congrArg Prod.fst (hcasts (.inr (.inl p))) + have hr : (y : ZMod (p.val ^ 2)) = + (show (ZMod (p.val ^ 2))ˣ from (e z (.inr (.inl p))).2).val := + congrArg Prod.snd (hcasts (.inr (.inl p))) + exact congrArg₂ (movingInternalPairFactor value T p.val) hl.symm hr.symm + have hspec (i : S) : f (.inr (.inr i)) (e z (.inr (.inr i))) = + movingSpectatorPairFactor value (q i.val) (g i.val) (fun side => D side i.val) T x y := by + have hl : (x : ZMod (q i.val)) = (e z (.inr (.inr i))).1 := + congrArg Prod.fst (hcasts (.inr (.inr i))) + have hr : (y : ZMod (q i.val)) = + (show (ZMod (q i.val))ˣ from (e z (.inr (.inr i))).2).val := + congrArg Prod.snd (hcasts (.inr (.inr i))) + exact congrArg₂ (movingSpectatorPairFactor value (q i.val) (g i.val) + (fun side => D side i.val) T) hl.symm hr.symm + change movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R x y = + ∏ b, f b (e z b) + rw [movingSeparatedPairResidueCoefficient_product q value outside F E g D S T nodes R P hcover] + simp only [Fintype.prod_sum_type, Fintype.prod_unique, hfreq, hint, hspec] + rw [Finset.prod_coe_sort P (fun p => movingInternalPairFactor value T p x y), + Finset.prod_coe_sort S (fun i => + movingSpectatorPairFactor value (q i) (g i) (fun side => D side i) T x y)] + ring + +/-- The Haar average of the original coefficient equals the product of its +frequency, internal-square and spectator averages. -/ +theorem movingSeparatedPairResidueCoefficient_average + [∀ b, NeZero (movingArithmeticModuli r q P S b)] : + (Fintype.card (ZMod (∏ b, movingArithmeticModuli r q P S b) × + (ZMod (∏ b, movingArithmeticModuli r q P S b))ˣ) : ℂ)⁻¹ * + (∑ z : ZMod (∏ b, movingArithmeticModuli r q P S b) × + (ZMod (∏ b, movingArithmeticModuli r q P S b))ˣ, movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R + z.1.val (z.2 : ZMod (∏ b, movingArithmeticModuli r q P S b)).val) = + ∏ b, (Fintype.card (ZMod (movingArithmeticModuli r q P S b) × + (ZMod (movingArithmeticModuli r q P S b))ˣ) : ℂ)⁻¹ * + ∑ z, movingArithmeticLocalFactor q value outside F E g D T nodes R r P S b z := by + simp_rw [movingSeparatedPairResidueCoefficient_crt q value outside F E g D T nodes + R r P S hf hR hfrequency hcover hc] + exact movingArithmeticBlocks_average r q P S hc _ + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedCoefficient.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..4b5db2cc3d279b194d5bfd85aaf104e08e84a81e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedCoefficient.lean @@ -0,0 +1,120 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOutsideResidues +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedCoefficient + +namespace OAI + +/-! # The original remainder coefficient in separated arithmetic coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingSeparatedSupport {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) + (R : ℤ) (x y : ℤ) : Prop := + movingRegularOutsidePairwise value outside T ∧ movingSquareLineSupport value T x y ∧ + (∀ f ∈ nodes, f.guard.frequencyBounds) ∧ + movingFrequencyGate value R T x y ∧ movingPrimeLineSupport value T x y + +noncomputable def movingSeparatedResidueCoefficient {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) (R : ℤ) (x y : ℤ) : ℂ := + if movingSeparatedSupport value outside T nodes R x y then + (∏ i ∈ S, movingModularSpectator value (q i) (g i) (D i) T x y) * movingDataWeight F E T + else 0 + +theorem movingSpectatorResidue_eq_modularProduct {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (hden : ∀ i ∈ S, T.ModularDenominators value (q i)) + (x y : ℤ) (hI : T.SignedIntegral value x y) : + movingSpectatorResidue q value g D S T x y = + ∏ i ∈ S, movingModularSpectator value (q i) (g i) (D i) T x y := by + apply Finset.prod_congr rfl + intro i hi + exact movingSignedSpectator_eq_modular value (q i) (g i) (D i) T (hden i hi) x y hI + +/-- Exact identity for the literal original reduced residue coefficient. +Its frequency factor has a frequency-only period; the other factors use +only internal-prime squares and individual spectator primes. -/ +theorem movingReducedResidueCoefficient_eq_separated {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (hcover : ∀ p ∈ outside, ∃ i ∈ S, q i = p) + (hg0 : ∀ i ∈ S, g i 0 = 0) + {n : ℕ} (T : MovingSlotData σ n) (hlevels : T.Levels tier) + (hf : T.Frequencies (· ≠ 0)) + (hsmall : ∀ i, T.Frequencies (fun f => IsCoprime f (value i : ℤ))) + (hfmod : ∀ i, T.Frequencies (fun f => (f : ZMod (value i)) ≠ 0)) + (R₀ : ℤ) (hR₀ : T.frequencyProduct ∣ R₀) + (hsmallR : ∀ i, IsCoprime (value i : ℤ) R₀) (hdistinct : T.CompensationDistinct value) + (hden : ∀ i ∈ S, T.ModularDenominators value (q i)) (a b : ℕ) : + let nodes := T.formulaNodes value (fun i => (hprime i).ne_zero) + childBound pivotBound hf (.prime false) (.prime true) + movingReducedResidueWeight value outside T a b + (movingResidueCoefficient q value F E g D S T nodes a b) = + movingSeparatedResidueCoefficient q value outside F E g D S T nodes R₀ a b := by + let hvalue := fun i => (hprime i).ne_zero + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let input := topGiantInput a b + let z := ∏ i ∈ S, movingModularSpectator value (q i) (g i) (D i) T (a : ℤ) (b : ℤ) + have hL : (HistoryFormula.prime false).value (fun j => (input j : ℚ)) = (a : ℚ) := by + simp [input, topGiantInput] + have hR : (HistoryFormula.prime true).value (fun j => (input j : ℚ)) = (b : ℚ) := by + simp [input, topGiantInput] + have hbridge := moving_formula_residue_frequency_internal_iff tier value hprime hdisjoint + R₀ hsmallR childBound pivotBound T hlevels hf hsmall hfmod hR₀ hdistinct + (.prime false) (.prime true) input a b hL hR + have hint := T.formulaNodes_signed_integral_iff value hvalue childBound pivotBound hf + (.prime false) (.prime true) input a b hL hR + have hspec (hI : T.SignedIntegral value a b) : movingSpectatorResidue q value g D S T a b = z := + movingSpectatorResidue_eq_modularProduct q value g D S T hden a b hI + have hmask : movingReducedResidueWeight value outside T a b + (movingResidueCoefficient q value F E g D S T nodes a b) = + if movingReducedResidueSupport value outside T a b ∧ movingResidueGate nodes input then + movingSpectatorResidue q value g D S T a b * movingDataWeight F E T else 0 := by + change (if movingReducedResidueSupport value outside T a b then + ((if movingResidueGate nodes input then 1 else 0) * + movingSpectatorResidue q value g D S T a b) * movingDataWeight F E T else 0) = _ + by_cases ha : movingReducedResidueSupport value outside T a b <;> + by_cases hb : movingResidueGate nodes input <;> simp [ha, hb] + change movingReducedResidueWeight value outside T a b + (movingResidueCoefficient q value F E g D S T nodes a b) = _ + rw [hmask] + by_cases hold : movingReducedResidueSupport value outside T a b ∧ movingResidueGate nodes input + · have haux := (movingSignedAuxiliaryUnits_split value outside T a b).mp hold.1.2.2 + have hs := hbridge.mp ⟨hold.2, haux.1⟩ + have hnew : movingSeparatedSupport value outside T nodes R₀ a b := + ⟨hold.1.1, hold.1.2.1, hs⟩ + have hI : T.SignedIntegral value a b := hint.mp (fun f hf => + (f.residueTests_iff input).mp (hold.2 f hf).1 |>.2) + rw [ite_eq_left hold] + change _ = if movingSeparatedSupport value outside T nodes R₀ a b then _ else 0 + rw [ite_eq_left hnew, hspec hI] + · rw [ite_eq_right hold] + unfold movingSeparatedResidueCoefficient + by_cases hnew : movingSeparatedSupport value outside T nodes R₀ a b + · rw [ite_eq_left hnew] + have hs := (moving_frequency_internal_split tier value hprime hdisjoint R₀ hsmallR + T hlevels hf hfmod hR₀ hdistinct a b).mp hnew.2.2.2 + have hres := (hbridge.mpr ⟨hnew.2.2.1, hnew.2.2.2⟩).1 + have hz : z = 0 := by + by_contra hz + have hout := movingModularSpectatorProduct_outside_units value q g D S hg0 outside hcover + T hden a b hs.1 hz + have haux := (movingSignedAuxiliaryUnits_split value outside T a b).mpr ⟨hs.2, hout⟩ + exact hold ⟨⟨hnew.1, hnew.2.1, haux⟩, hres⟩ + exact (show z * movingDataWeight F E T = 0 by rw [hz, zero_mul]).symm + · rw [ite_eq_right hnew] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedDiagonalComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedDiagonalComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe7120c51e8031b6dfdc3e2ea27333c263e0d90a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedDiagonalComparison.lean @@ -0,0 +1,134 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedRegularFactor +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterCoprimeComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedPageAverage + +namespace OAI + +/-! # Original diagonal giant comparison after integrating the regular primes -/ + +namespace Ostmann +universe u v w +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_original_separated_diagonal_haar_rate (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (I : Type v) (J : Type w) [Fintype J] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (R : ℤ) (_hR : ∀ b, (T b).frequencyProduct ∣ R) + (_hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (_hden : ∀ b i, i ∈ S → (T b).ModularDenominators value (p i)) + (_hcover : ∀ q ∈ outside, ∃ i ∈ S, p i = q) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ M : ℕ, ∀ _hM : NeZero M, + R ^ (n + 1) ∣ (M : ℤ) → + (∀ b, ∀ o ∈ (T b).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ (M : ℤ)) → + (∀ i ∈ S, (p i : ℤ) ∣ (M : ℤ)) → + (∏ i, reg i).Coprime M → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + ∀ hqeq : q = (∏ i, reg i) * M, + (∀ b, movingRegularOutsidePairwise value outside (T b)) → + Pairwise (fun i j => (reg i).Coprime (reg j)) → + (∀ i ∈ S, (∏ j, reg j).Coprime (p i)) → + pageAtModulus q (selectedPageZero P Q) = + pageAtModulus (M) (selectedPageZero P Q) → + (∀ i, (sreg : ZMod (reg i)) ≠ 0) → (∀ i, other i ≠ 0) → + (∀ i, greg i 0 = 0) → (∀ i, (∑ x : ZMod (reg i), ‖greg i x‖ ^ 2) = reg i) → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c0 := movingSeparatedPairResidueCoefficient p value outside F E g Dq S T nodes R + let c := fun a b => movingSeparatedPairResidueCoefficient p value outside F E g Dq S T nodes R a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + let : NeZero q := ⟨by omega⟩ + let : NeZero (M) := ⟨by + intro hz + rw [hz, mul_zero] at hqeq + omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * (((∏ i, if active i then (1 : ℝ) else 1 - (reg i : ℝ)⁻¹ : ℝ) : ℂ) * + correctedMixedPairAverage P Q (M) c0 y) / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_outer_coprime_mixed_haar_rate n C d] with L hL + intro σ I J _ p _ tier value hprime hdisjoint outside childBound pivotBound T hf t hT + hlevels hcoh hc hsmall hfmod F E g hg Dq S R hR hsmallR hden hcover + reg instReg hregular active sreg other greg ψ X lo hi hlo hhi φ G + Jleft Jright B D hB hD hφ hlip hout diagonal V hV M hM hfrequency hsquare hspectator hcop + Q q hQ hq hqQ hqeq houtside hreg hqs hpage hsreg hother hgreg henergy hlog + u v r s J0 hJ huv hshort hvJ hr hrs hrshort hqlog + dsimp only + intro A hA0 hA hbudget + let : NeZero M := hM + let : NeZero q := ⟨by omega⟩ + let : ∀ i, NeZero (reg i) := fun i => ⟨(Fact.out : (reg i).Prime).ne_zero⟩ + let : NeZero (∏ i, reg i) := ⟨Finset.prod_ne_zero_iff.mpr (fun i _ => (Fact.out : (reg i).Prime).ne_zero)⟩ + let : NeZero ((∏ i, reg i) * M) := ⟨mul_ne_zero (NeZero.ne _) (NeZero.ne _)⟩ + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c0 := movingSeparatedPairResidueCoefficient p value outside F E g Dq S T nodes R + let c := fun a b => c0 a b * (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + have hbase := hL σ value (fun i => (hprime i).ne_zero) childBound pivotBound T hf ψ X lo hi hlo hhi + φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV Q q hQ hq hqQ hlog + u v r s J0 hJ huv hshort hvJ hr hrs hrshort hqlog c A hA0 hA hbudget + dsimp only at hbase + have hfactor (x y : ℕ) : + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t x y * + (naturalRegularMultiplier reg active sreg other greg x y : ℂ) = + if x.Coprime y then c (x % q) (y % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal x y else 0 := by + have hMq : M ∣ q := by rw [hqeq]; exact dvd_mul_left _ _ + exact movingOriginalSupportedSeparatedRegular_modulus_factor p tier value hprime hdisjoint outside + childBound pivotBound F E g hg Dq S hcover ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + Jleft Jright diagonal T t hT hf hlevels hcoh hc hsmall hfmod R hR hsmallR hden + reg hregular active sreg other greg q + (hfrequency.trans (by exact_mod_cast hMq)) + (fun b o ho i hi => (hsquare b o ho i hi).trans (by exact_mod_cast hMq)) + (fun i hi => (hspectator i hi).trans (by exact_mod_cast hMq)) + (fun i => by rw [hqeq]; exact dvd_mul_of_dvd_left (Finset.dvd_prod_of_mem reg (Finset.mem_univ i)) M) x y + have hperiod (a b c d : ℕ) (hab : Nat.ModEq M a c) (hbd : Nat.ModEq M b d) : c0 a b = c0 c d := by + exact movingSeparatedPairResidueCoefficient_modEq p value outside F E g Dq S T nodes R hf hR + a b c d M hfrequency hsquare hspectator + (Int.natCast_modEq_iff.mpr hab) (Int.natCast_modEq_iff.mpr hbd) + have hcrt (y : ℝ) : correctedMixedPairAverage P Q q c y = + ((∏ i, if active i then (1 : ℝ) else 1 - (reg i : ℝ)⁻¹ : ℝ) : ℂ) * + correctedMixedPairAverage P Q M c0 y := by + have hpM : pageAtModulus ((∏ i, reg i) * M) (selectedPageZero P Q) = + pageAtModulus M (selectedPageZero P Q) := by simpa only [hqeq] using hpage + have hh := periodic_coefficient_regular_page_average P Q reg hreg M hcop hpM + active sreg other hsreg hother greg hgreg henergy c0 hperiod y + simpa only [← hqeq] using hh + simp_rw [hfactor] + simpa only [hcrt] using hbase + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedDiagonalRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedDiagonalRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..71cd24731833bcfb6f3813eceaa6b2ccced6ddbd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedDiagonalRate.lean @@ -0,0 +1,128 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedDiagonalComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterVariationScale +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedRegularNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantBounds + +namespace OAI + +/-! # Numerical giant comparison for the original diagonal -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_original_separated_diagonal_prime_rate (P : PublishedProgressionInput) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (Afreq Wwin B D : ℝ) + (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) (hB : 0 ≤ B) (hD : 0 ≤ D) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (σ J : Type) [Fintype J] (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) + (R : ℤ) (_hR : ∀ b, (T b).frequencyProduct ∣ R) + (_hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (_hden : ∀ b i, (T b).ModularDenominators value (p i)) + (_hcover : ∀ q ∈ outside, ∃ i, p i = q) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + 0 ≤ V → V ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + ∀ M : ℕ, ∀ _hM : NeZero M, + R ^ (n + 1) ∣ (M : ℤ) → + (∀ b, ∀ o ∈ (T b).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ (M : ℤ)) → + (∀ i, (p i : ℤ) ∣ (M : ℤ)) → (∏ i, reg i).Coprime M → + ∀ q : ℕ, ∀ hq : 1 ≤ q, q ≤ giantProgressionCutoff L → + ∀ hqeq : q = (∏ i, reg i) * M, + (∀ b, movingRegularOutsidePairwise value outside (T b)) → + Pairwise (fun i j => (reg i).Coprime (reg j)) → + (∀ i, (∏ j, reg j).Coprime (p i)) → + pageAtModulus q (selectedPageZero P (giantProgressionCutoff L)) = + pageAtModulus (M) (selectedPageZero P (giantProgressionCutoff L)) → + (∀ i, (sreg : ZMod (reg i)) ≠ 0) → (∀ i, other i ≠ 0) → + (∀ i, greg i 0 = 0) → (∀ i, (∑ x : ZMod (reg i), ‖greg i x‖ ^ 2) = reg i) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + (∀ b, ‖movingDataWeight (F b) (E b) (T b)‖ ≤ 1) → + (∀ i z, ‖g i z‖ ≤ p i) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c0 := movingSeparatedPairResidueCoefficient p value outside F E g Dq Finset.univ T nodes R + let : NeZero q := ⟨by omega⟩ + let : NeZero (M) := ⟨by + intro hz + rw [hz, mul_zero] at hqeq + omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq Finset.univ ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * (((∏ i, if active i then (1 : ℝ) else 1 - (reg i : ℝ)⁻¹ : ℝ) : ℂ) * + correctedMixedPairAverage P (giantProgressionCutoff L) (M) c0 y) / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + obtain ⟨C, hC, hbudget⟩ := moving_outer_variation_scale ψ n r₀ k Afreq Wwin B D 1 + hAfreq hWwin (by norm_num) + filter_upwards [P.moving_original_separated_diagonal_haar_rate n C 2, + eventually_ge_atTop (200 : ℝ)] with L hrate hL + dsimp only + intro σ J _ p _ tier value hprime hdisjoint outside childBound pivotBound T hf t hT + hlevels hcoh hc hsmall hfmod F E g hg Dq R hR hsmallR hden hcover reg _ hregular active sreg other greg + X lo hi hlo hhi φ G Jleft Jright hφ hlip hout diagonal V hV hV0 hVA hwindow hpupper + M hM hfrequency hsquare hspectator hcop q hq hqQ hqeq houtside hreg hqs hpage hsreg hother hgreg henergy + u v r s H hH huv hshort hvH hr hrs hrshort hweight hgnorm + have hMpos : 0 < M := Nat.pos_of_ne_zero hM.out + have hregq : (∏ i, reg i) ≤ q := by + change q = (∏ i, reg i) * M at hqeq + rw [hqeq] + exact Nat.le_mul_of_pos_right _ hMpos + have hqlog := giantProgressionCutoff_log_le (by omega : 0 < q) hqQ + have hregbound : (∏ i, (reg i : ℝ)) ≤ Real.exp (Real.exp ((12 / 1000 : ℝ) * L)) := by + rw [← Nat.cast_prod] + apply (Nat.cast_le.mpr hregq).trans + exact (Real.log_le_iff_le_exp (by exact_mod_cast (show 0 < q by omega))).mp hqlog + let amp := (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 * ∏ j, (reg j : ℝ) + have hamp0 : 0 ≤ amp := by dsimp only [amp]; positivity + have hamp : amp ≤ 4 * (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 * + Real.exp (1 * L + 1 * L * Real.exp ((12 / 1000 : ℝ) * L)) := by + have hL1 : 1 ≤ L := by linarith only [hL] + have hcoef : Real.exp ((12 / 1000 : ℝ) * L) ≤ + 1 * L + 1 * L * Real.exp ((12 / 1000 : ℝ) * L) := by + have hh := le_mul_of_one_le_left (Real.exp_nonneg ((12 / 1000 : ℝ) * L)) hL1 + linarith only [hh, hL1] + have hh := hregbound.trans (Real.exp_le_exp.mpr hcoef) + apply (mul_le_mul_of_nonneg_left hh (sq_nonneg _)).trans + nlinarith only [mul_nonneg (sq_nonneg (∏ i, (p i : ℝ) ^ (2 ^ n))) + (Real.exp_nonneg (1 * L + 1 * L * Real.exp ((12 / 1000 : ℝ) * L)))] + have hb := hbudget L (by linarith only [hL]) p V lo hi amp diagonal + hV0 hVA hhi hwindow hpupper hamp0 hamp + have hQ := giantProgressionCutoff_bounds L hL + apply hrate σ (Fin (spectatorBulkCount k L)) J p tier value hprime hdisjoint outside + childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod F E g hg Dq Finset.univ R hR hsmallR + (fun b i _ => hden b i) (fun q hq => by obtain ⟨i, hi⟩ := hcover q hq; exact ⟨i, Finset.mem_univ i, hi⟩) + reg hregular active sreg other greg ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD + hφ hlip hout diagonal V hV M hM hfrequency hsquare + (fun i _ => hspectator i) hcop (giantProgressionCutoff L) q hQ.1 hq hqQ hqeq houtside + hreg (fun i _ => hqs i) hpage hsreg hother hgreg henergy hQ.2 + u v r s H hH huv hshort hvH hr hrs hrshort hqlog amp hamp0 _ hb + intro a ha b hb + exact movingSeparatedPair_with_regular_norm p reg value outside F E g hgnorm Dq T _ + hweight active sreg other greg henergy R a b + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedModulusRange.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedModulusRange.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b23fd4a80ab75dd72ac75f09bc570443eac5be3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedModulusRange.lean @@ -0,0 +1,142 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantBounds + +namespace OAI + +/-! # The regular product and separated arithmetic modulus share one cutoff -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +/-- The regular primes are included before absorbing the logarithmic budget. +This retains the slack between the nongiant and giant progression scales. -/ +theorem movingArithmeticModuli_with_regular_giant_range (n : ℕ) (F K H : ℝ) + (hF : 0 ≤ F) (hK : 0 ≤ K) (hH : 0 ≤ H) : + ∀ᶠ L : ℝ in atTop, ∀ (m r : ℕ) (p : Fin m → ℕ) (P : Finset ℕ) (reg : ℕ), + (m : ℝ) ≤ K * L → P.card ≤ 4 * n * 2 ^ n → + (r : ℝ) ≤ Real.exp (F * m) → + (∀ q ∈ P, (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + (reg : ℝ) ≤ Real.exp (H * L * Real.exp ((11 / 1000 : ℝ) * L)) → + reg * (∏ b, movingArithmeticModuli r p P Finset.univ b) ≤ + giantProgressionCutoff L := by + let J : ℝ := 4 * n * 2 ^ n + let C := F * K + 2 * J + K + H + have hJ : 0 ≤ J := by dsimp only [J]; positivity + have hFK : 0 ≤ F * K := mul_nonneg hF hK + filter_upwards [arithmetic_exponent_absorption (11 / 1000) (12 / 1000) 0 C 1 1 + (by norm_num) (by norm_num) (by norm_num) (by norm_num), + eventually_ge_atTop (1 : ℝ)] with L hrate hL + intro m r p P reg hm hc hr hP hp hreg + apply Nat.le_floor + have hbound := movingArithmeticModuli_exp_bound m r p P F + (Real.exp ((11 / 1000 : ℝ) * L)) (Real.exp ((1 / 1000 : ℝ) * L)) hr hP hp + have htotal : ((reg * ∏ b, movingArithmeticModuli r p P Finset.univ b : ℕ) : ℝ) ≤ + Real.exp (F * m + 2 * P.card * Real.exp ((11 / 1000 : ℝ) * L) + + (m : ℝ) * Real.exp ((1 / 1000 : ℝ) * L) + H * L * Real.exp ((11 / 1000 : ℝ) * L)) := by + rw [Nat.cast_mul] + apply (mul_le_mul hreg hbound (Nat.cast_nonneg _) (Real.exp_nonneg _)).trans_eq + rw [← Real.exp_add] + congr 1 + ring + apply htotal.trans + change Real.exp _ ≤ Real.exp (Real.exp ((12 / 10000 : ℝ) * (10 * L))) + rw [show (12 / 10000 : ℝ) * (10 * L) = (12 / 1000 : ℝ) * L by ring] + apply Real.exp_le_exp.mpr + have hc' : (P.card : ℝ) ≤ J := by + dsimp only [J] + exact_mod_cast hc + have he : Real.exp ((1 / 1000 : ℝ) * L) ≤ Real.exp ((11 / 1000 : ℝ) * L) := + Real.exp_le_exp.mpr (by linarith) + have hKL : 0 ≤ K * L := mul_nonneg hK (by linarith) + have hmain := mul_le_mul_of_nonneg_left hm hF + have hi := mul_le_mul_of_nonneg_right hc' (Real.exp_nonneg ((11 / 1000 : ℝ) * L)) + have hiL : 2 * J * Real.exp ((11 / 1000 : ℝ) * L) ≤ + (2 * J * L) * Real.exp ((11 / 1000 : ℝ) * L) := by + exact mul_le_mul_of_nonneg_right + (le_mul_of_one_le_right (mul_nonneg (by norm_num) hJ) hL) (Real.exp_nonneg _) + have hs := mul_le_mul hm he (Real.exp_nonneg _) hKL + have hC1 : F * K ≤ C := by dsimp only [C]; linarith + have hC2 : 2 * J + K + H ≤ C := by dsimp only [C]; linarith + have hC1L := mul_le_mul_of_nonneg_right hC1 (show 0 ≤ L by linarith) + have hC2L := mul_le_mul_of_nonneg_right hC2 (show 0 ≤ L by linarith) + have hC2e := mul_le_mul_of_nonneg_right hC2L (Real.exp_nonneg ((11 / 1000 : ℝ) * L)) + simp only [pow_one, zero_mul, Real.exp_zero, one_mul] at hrate + nlinarith only [hmain, hi, hiL, hs, hC1L, hC2e, hrate] + +theorem movingPattern_regular_exp_range (n r₀ k : ℕ) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B C : Type) (N : ℕ) (e : Fin (N + 1) ≃ B ⊕ C) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (value : Fin (N + 1) → ℕ), + MovingLeafLengthLE n small r₀ → + (∀ i, (value i : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) : ℝ) ≤ + Real.exp (((2 ^ n : ℕ) : ℝ) * ((r₀ : ℝ) + (k : ℝ) ^ 4) * L * + Real.exp ((11 / 1000 : ℝ) * L)) := by + let K : ℝ := (2 ^ n : ℕ) * ((r₀ : ℝ) + (k : ℝ) ^ 4) + filter_upwards [eventually_ge_atTop (1 : ℝ)] with L hlarge + dsimp only + intro B C N e small slot value hsmall hvalue + apply (naturalProduct_exp_bound value (Real.exp ((11 / 1000 : ℝ) * L)) hvalue _).trans + apply Real.exp_le_exp.mpr + apply mul_le_mul_of_nonneg_right _ (Real.exp_nonneg _) + have hsmall' := moving_flatten_length_le n (movingPatternFiniteSmall e n small) r₀ + (movingLeafLengthLE_map _ n small r₀ hsmall) + have hbulk := moving_flatten_length_le n + (bulkSlotLeaves n (spectatorBulkCount k L) (movingPatternBulkEmbedding e slot)) + (spectatorBulkCount k L) (bulkSlotLeaves_length n _ _) + have hlen := Nat.cast_le (α := ℝ).mpr (Nat.add_le_add hsmall' hbulk) + have hm := spectatorBulkCount_upper k L (by linarith) + have hr := mul_le_mul_of_nonneg_left hlarge (Nat.cast_nonneg r₀) + have hh := mul_le_mul_of_nonneg_left (add_le_add hr hm) + (show (0 : ℝ) ≤ (2 ^ n : ℕ) by positivity) + rw [List.length_append, Nat.cast_add] + push_cast at hlen + apply hlen.trans + simpa only [K, mul_one, Nat.cast_pow, Nat.cast_ofNat, mul_add, add_mul, mul_assoc] using hh + +/-- The actual frequency tree, internal image and regular product fit the +same giant cutoff, rather than two separately exhausted budgets. -/ +theorem movingPattern_actual_separated_modulus_range (n r₀ k : ℕ) + (Cfreq : ℝ) (hCfreq : 0 ≤ Cfreq) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B C : Type) (N : ℕ) (e : Fin (N + 1) ≃ B ⊕ C) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (value : Fin (N + 1) → ℕ) + (S : Finset ℤ) (Nfreq : ℕ) (t : FrequencyTree (S × S) n) + (p : Fin m → ℕ) (P : Finset ℕ), + MovingLeafLengthLE n small r₀ → + (∀ i, (value i : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ Nfreq) → + (Nfreq : ℝ) ≤ Real.exp (Cfreq * m) → P.card ≤ 4 * n * 2 ^ n → + (∀ q ∈ P, q.Prime ∧ (q : ℝ) ≤ Real.exp (Real.exp ((11 / 1000 : ℝ) * L))) → + (∀ i, (p i).Prime ∧ (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + let reg := MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (movingPatternFiniteSmall e n small) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingPatternBulkEmbedding e slot))) + let M := ∏ b, movingArithmeticModuli (frequencyModelBase S n t ^ (n - 1 + 2)) + p P Finset.univ b + reg * M ≤ giantProgressionCutoff L := by + let D : ℕ := 2 * (2 ^ (n + 1) - 1) * (n - 1 + 2) + let H : ℝ := (2 ^ n : ℕ) * ((r₀ : ℝ) + (k : ℝ) ^ 4) + filter_upwards [movingArithmeticModuli_with_regular_giant_range n + ((D : ℝ) * Cfreq) ((k : ℝ) ^ 4) H + (by positivity) (by positivity) (by dsimp only [H]; positivity), + movingPattern_regular_exp_range n r₀ k, eventually_ge_atTop (0 : ℝ)] + with L hL hregular hL0 + dsimp only at hregular ⊢ + intro B C N e small slot value S Nfreq t p P hsmall hvalue hS hN hcard hP hp + let r := frequencyModelBase S n t ^ (n - 1 + 2) + have hr : (r : ℝ) ≤ Real.exp (((D : ℝ) * Cfreq) * spectatorBulkCount k L) := by + simpa only [mul_assoc, D, r] using frequencyModelModulus_exp_bound S Nfreq n t + (Cfreq * spectatorBulkCount k L) (fun s hs => (hS s hs).2) hN + exact hL (spectatorBulkCount k L) r p P _ (spectatorBulkCount_upper k L hL0) + hcard hr (fun q hq => (hP q hq).2) (fun i => (hp i).2) + (hregular B C N e small slot value hsmall hvalue) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..716ed08cfcdef87f678f0ead0e48f96773ab223f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedNorm.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedPair + +namespace OAI + +/-! # Pointwise bounds at the separated arithmetic modulus -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingSeparatedResidueCoefficient_norm {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (B : I → ℝ) (hB : ∀ i ∈ S, 0 ≤ B i) (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) + (R x y : ℤ) : + ‖movingSeparatedResidueCoefficient q value outside F E g D S T nodes R x y‖ ≤ + ‖movingDataWeight F E T‖ * ∏ i ∈ S, B i ^ (2 ^ n) := by + unfold movingSeparatedResidueCoefficient + split_ifs + · rw [norm_mul, norm_prod, mul_comm] + apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) + exact Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + (fun i hi => movingModularSpectator_norm value (q i) (g i) (D i) + (B i) (hB i hi) (hg i hi) T x y) + · simp only [norm_zero] + exact mul_nonneg (norm_nonneg _) (Finset.prod_nonneg fun i hi => pow_nonneg (hB i hi) _) + +theorem movingSeparatedPairResidueCoefficient_norm {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (B : I → ℝ) (hB : ∀ i ∈ S, 0 ≤ B i) (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (x y : ℕ) : + ‖movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R x y‖ ≤ + (‖movingDataWeight (F false) (E false) (T false)‖ * ∏ i ∈ S, B i ^ (2 ^ n)) * + (‖movingDataWeight (F true) (E true) (T true)‖ * ∏ i ∈ S, B i ^ (2 ^ n)) := by + unfold movingSeparatedPairResidueCoefficient + rw [norm_mul, Complex.norm_conj] + apply mul_le_mul + · exact movingSeparatedResidueCoefficient_norm q value outside _ _ g _ S B hB hg _ _ R x y + · exact movingSeparatedResidueCoefficient_norm q value outside _ _ g _ S B hB hg _ _ R x y + · exact norm_nonneg _ + · exact mul_nonneg (norm_nonneg _) (Finset.prod_nonneg fun i hi => pow_nonneg (hB i hi) _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedOuterComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedOuterComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..5c80ea0820d8b86917c1edec78ac582e04d4ed81 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedOuterComparison.lean @@ -0,0 +1,164 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedOuterFactor +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterCoprimeComparison + +namespace OAI + +/-! # The original-prior Haar comparison at the separated frequency/internal/spectator modulus -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_original_separated_regular_prime_haar_rate (P : PublishedProgressionInput) + {σ I J : Type*} [Fintype J] (p : I → ℕ) [∀ i, Fact (p i).Prime] (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (_hcover : ∀ q ∈ outside, ∃ i ∈ S, p i = q) + (R : ℤ) (_hR : ∀ b, (T b).frequencyProduct ∣ R) + (_hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (_hden : ∀ b i, i ∈ S → (T b).ModularDenominators value (p i)) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + R ^ (n + 1) ∣ (q : ℤ) → + (∀ b, ∀ o ∈ (T b).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ q) → + (∀ i ∈ S, (p i : ℤ) ∣ q) → (∀ i, reg i ∣ q) → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingSeparatedPairResidueCoefficient p value outside F E g Dq S T nodes R a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [(P.moving_outer_coprime_prime_haar_rate n C d).mono (fun _ h => h σ)] with L hL + intro tier value hprime hdisjoint outside childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod + F E g hg Dq S hcover R hR hsmallR hden reg instReg hregular active sreg other greg ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q hQ hq hqQ hfrequency hsquare hspectator hregM hlog u v r s hu huv hshort hr hrs hrshort hqlog + dsimp only + intro A hA0 hA hbudget + let hv := fun i => (hprime i).ne_zero + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingSeparatedPairResidueCoefficient p value outside F E g Dq S T nodes R a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + have h := hL value hv childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c A hA0 hA hbudget + dsimp only at h + have hfactor (x y : ℕ) : + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t x y * + (naturalRegularMultiplier reg active sreg other greg x y : ℂ) = + if x.Coprime y then c (x % q) (y % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal x y else 0 := by + exact movingOriginalSupportedSeparatedRegular_factor p tier value hprime hdisjoint outside + childBound pivotBound F E g hg Dq S hcover ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD + hφ hlip hout diagonal T t hT hf hlevels hcoh hc hsmall hfmod R hR hsmallR hden + reg hregular active sreg other greg q hfrequency hsquare hspectator hregM x y + simpa only [hfactor] using h + +theorem PublishedProgressionInput.moving_original_separated_regular_mixed_haar_rate (P : PublishedProgressionInput) + {σ I J : Type*} [Fintype J] (p : I → ℕ) [∀ i, Fact (p i).Prime] (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (_hcover : ∀ q ∈ outside, ∃ i ∈ S, p i = q) + (R : ℤ) (_hR : ∀ b, (T b).frequencyProduct ∣ R) + (_hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (_hden : ∀ b i, i ∈ S → (T b).ModularDenominators value (p i)) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + R ^ (n + 1) ∣ (q : ℤ) → + (∀ b, ∀ o ∈ (T b).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ q) → + (∀ i ∈ S, (p i : ℤ) ∣ q) → (∀ i, reg i ∣ q) → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingSeparatedPairResidueCoefficient p value outside F E g Dq S T nodes R a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * correctedMixedPairAverage P Q q c y / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [(P.moving_outer_coprime_mixed_haar_rate n C d).mono (fun _ h => h σ)] with L hL + intro tier value hprime hdisjoint outside childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod + F E g hg Dq S hcover R hR hsmallR hden reg instReg hregular active sreg other greg ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q hQ hq hqQ hfrequency hsquare hspectator hregM hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog + dsimp only + intro A hA0 hA hbudget + let hv := fun i => (hprime i).ne_zero + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun a b => movingSeparatedPairResidueCoefficient p value outside F E g Dq S T nodes R a b * + (guardedRegularMultiplier reg active sreg other greg a b : ℂ) + have h := hL value hv childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog c A hA0 hA hbudget + dsimp only at h + have hfactor (x y : ℕ) : + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t x y * + (naturalRegularMultiplier reg active sreg other greg x y : ℂ) = + if x.Coprime y then c (x % q) (y % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal x y else 0 := by + exact movingOriginalSupportedSeparatedRegular_factor p tier value hprime hdisjoint outside + childBound pivotBound F E g hg Dq S hcover ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD + hφ hlip hout diagonal T t hT hf hlevels hcoh hc hsmall hfmod R hR hsmallR hden + reg hregular active sreg other greg q hfrequency hsquare hspectator hregM x y + simpa only [hfactor] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedOuterFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedOuterFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..7350c58a2c2e8e7804040ca278d22bb93d421741 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedOuterFactor.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedPair +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedModulusFactor + +namespace OAI + +/-! # The original two-history weight at the separated CRT modulus -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate SchwartzMap + +theorem movingOriginalSupportedSeparatedRegular_factor {σ I J : Type*} [Fintype J] (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (hcover : ∀ p ∈ outside, ∃ i ∈ S, q i = p) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (hT : ∀ side, (T side).Follows (t side)) (hf : ∀ side, (T side).Frequencies (· ≠ 0)) + (hlevels : ∀ side, (T side).Levels tier) (hcoh : ∀ side, (T side).RegularCoherent) + (hc : ∀ side, (T side).CompensationPrimeData value) + (hsmall : ∀ side i, (T side).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ side i, (T side).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (R : ℤ) (hR : ∀ side, (T side).frequencyProduct ∣ R) + (hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (hden : ∀ side i, i ∈ S → (T side).ModularDenominators value (q i)) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (hregular : ∀ side, MovingSlotReversal.naturalProduct value (T side).regularSlots = ∏ i, reg i) + (active : J → Bool) (s : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (M : ℕ) (hfrequency : R ^ (n + 1) ∣ (M : ℤ)) + (hsquare : ∀ side, ∀ o ∈ (T side).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hspectator : ∀ i ∈ S, (q i : ℤ) ∣ M) (hregM : ∀ i, reg i ∣ M) (XL XR : ℕ) : + let hv := fun i => (hprime i).ne_zero + let nodes := fun side => (T side).formulaNodes value hv childBound pivotBound (hf side) + (.prime false) (.prime true) + let c := fun a b => movingSeparatedPairResidueCoefficient q value outside F E g Dq S T nodes R a b * + (guardedRegularMultiplier reg active s other greg a b : ℂ) + movingOriginalSupportedOuterPair q value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t XL XR * (naturalRegularMultiplier reg active s other greg XL XR : ℂ) = + if XL.Coprime XR then c (XL % M) (XR % M) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal XL XR else 0 := by + let hv := fun i => (hprime i).ne_zero + let nodes := fun side => (T side).formulaNodes value hv childBound pivotBound (hf side) + (.prime false) (.prime true) + let oldM := movingReducedPairModulus value hv outside childBound pivotBound T hf q S + have he := movingOriginalSupportedReducedRegular_factor q tier value hprime hdisjoint outside + childBound pivotBound F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD + hφ hlip hout diagonal T t hT hf hlevels hcoh hc hsmall hfmod reg hregular active s other greg XL XR + dsimp only at he ⊢ + have hback := movingReducedPairResidueCoefficient_modEq q value hv outside childBound pivotBound + F E g Dq S T hf (XL % oldM) (XR % oldM) XL XR + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XL oldM)) + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XR oldM)) + have hsep := movingReducedPairResidueCoefficient_eq_separated q tier value hprime hdisjoint outside + childBound pivotBound F E g Dq S hcover (fun i _ => hg i) T hlevels hf hsmall hfmod R hR hsmallR + (fun side => (hc side).distinct) hden XL XR + have hforward := movingSeparatedPairResidueCoefficient_modEq q value outside F E g Dq S T nodes R hf hR + XL XR (XL % M) (XR % M) M hfrequency hsquare hspectator + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XL M).symm) + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XR M).symm) + have hgreg := guardedRegularMultiplier_modEq reg active s other greg XL XR (XL % M) (XR % M) M + hregM (Nat.mod_modEq XL M).symm (Nat.mod_modEq XR M).symm + rw [hback, hsep, hforward, hgreg] at he + exact he + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPageCRT.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPageCRT.lean new file mode 100644 index 0000000000000000000000000000000000000000..66e1855035989f404051eebe9e0a88b89e5345d5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPageCRT.lean @@ -0,0 +1,108 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedCRT +import OAI.NumberTheory.Ostmann.ZeroDensity.PageRegularAverage + +namespace OAI + +/-! # Retaining the Page correction in the frequency block -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingArithmeticPageFactor {I : Type*} + (r : ℕ) (q : I → ℕ) (P : Finset ℕ) (S : Finset I) + (input : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (f : ∀ b, ZMod (movingArithmeticModuli r q P S b) × + (ZMod (movingArithmeticModuli r q P S b))ˣ → ℂ) : + ∀ b, ZMod (movingArithmeticModuli r q P S b) × + (ZMod (movingArithmeticModuli r q P S b))ˣ → ℂ + | .inl u, z => f (.inl u) z * + pageGiantWeight input Q r (show (ZMod r)ˣ from z.2).val.val y + | .inr b, z => f (.inr b) z + +theorem movingArithmeticPageFactor_product {I : Type*} + (r : ℕ) (q : I → ℕ) (P : Finset ℕ) (S : Finset I) + (input : PublishedProgressionInput) (Q : ℕ) (y : ℝ) + (f : ∀ b, ZMod (movingArithmeticModuli r q P S b) × + (ZMod (movingArithmeticModuli r q P S b))ˣ → ℂ) + (v : ∀ b, ZMod (movingArithmeticModuli r q P S b) × + (ZMod (movingArithmeticModuli r q P S b))ˣ) : + (∏ b, movingArithmeticPageFactor r q P S input Q y f b (v b)) = + (∏ b, f b (v b)) * + pageGiantWeight input Q r + (show (ZMod r)ˣ from (v (.inl ())).2).val.val y := by + simp only [Fintype.prod_sum_type, Fintype.prod_unique, movingArithmeticPageFactor] + ring + +section +variable {σ I : Type*} (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : Bool → ∀ i, (ZMod (q i))ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (r : ℕ) [NeZero r] (P : Finset ℕ) (S : Finset I) + [∀ b, NeZero (movingArithmeticModuli r q P S b)] + [NeZero (∏ b, movingArithmeticModuli r q P S b)] + (hf : ∀ side, (T side).Frequencies (· ≠ 0)) + (hR : ∀ side, (T side).frequencyProduct ∣ R) + (hfrequency : R ^ (n + 1) ∣ (r : ℤ)) + (hcover : ∀ side, ∀ o ∈ (T side).occurrences, + ∀ i ∈ o.current.compensationSlots, value i ∈ P) + (hc : Pairwise (fun b c => (movingArithmeticModuli r q P S b).Coprime + (movingArithmeticModuli r q P S c))) + (input : PublishedProgressionInput) (Q : ℕ) + (hpage : pageAtModulus (∏ b, movingArithmeticModuli r q P S b) (selectedPageZero input Q) = + pageAtModulus r (selectedPageZero input Q)) + +include hf hR hfrequency hcover hc hpage + +/-- The original Page-weighted mixed average factors exactly. Its Page term +stays in the frequency factor, with no absolute value or mean replacement. -/ +theorem movingSeparatedPairResidueCoefficient_page_average (y : ℝ) : + correctedMixedPairAverage input Q (∏ b, movingArithmeticModuli r q P S b) + (movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R) y = + ∏ b, (Fintype.card (ZMod (movingArithmeticModuli r q P S b) × + (ZMod (movingArithmeticModuli r q P S b))ˣ) : ℂ)⁻¹ * + ∑ z, movingArithmeticPageFactor r q P S input Q y + (movingArithmeticLocalFactor q value outside F E g D T nodes R r P S) b z := by + let a := movingArithmeticModuli r q P S + let e := crtExternalPairEquiv a hc + let f := movingArithmeticLocalFactor q value outside F E g D T nodes R r P S + let fP := movingArithmeticPageFactor r q P S input Q y f + have hpageA : pageAtModulus (∏ b, a b) (selectedPageZero input Q) = + pageAtModulus r (selectedPageZero input Q) := hpage + have he (z : ZMod (∏ b, a b) × (ZMod (∏ b, a b))ˣ) : + movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R + z.1.val (z.2 : ZMod (∏ b, a b)).val * + pageGiantWeight input Q (∏ b, a b) (z.2 : ZMod (∏ b, a b)).val y = + ∏ b, fP b (e z b) := by + have hcast := crtExternalPairEquiv_casts a hc z (.inl ()) + let v : ZMod r × (ZMod r)ˣ := e z (.inl ()) + have hm : Nat.ModEq r (z.2 : ZMod (∏ b, a b)).val (v.2 : ZMod r).val := by + apply (ZMod.natCast_eq_natCast_iff _ _ _).mp + have hh : ((z.2 : ZMod (∏ b, a b)).val : ZMod r) = (v.2 : ZMod r) := + congrArg Prod.snd hcast + simpa only [ZMod.natCast_zmod_val] using hh + have hp : pageGiantWeight input Q (∏ b, a b) (z.2 : ZMod (∏ b, a b)).val y = + pageGiantWeight input Q r (v.2 : ZMod r).val y := by + calc + _ = pageGiantWeight input Q r (z.2 : ZMod (∏ b, a b)).val y := by + simp only [pageGiantWeight, hpageA] + _ = _ := pageGiantWeight_modEq input Q r _ _ hm y + rw [movingSeparatedPairResidueCoefficient_crt q value outside F E g D T nodes + R r P S hf hR hfrequency hcover hc, hp] + exact (movingArithmeticPageFactor_product r q P S input Q y f (e z)).symm + unfold correctedMixedPairAverage + calc + _ = (Fintype.card (ZMod (∏ b, a b) × (ZMod (∏ b, a b))ˣ) : ℂ)⁻¹ * + (∑ z, ∏ b, fP b (e z b)) := by + congr 1 + apply Finset.sum_congr rfl + intro z _ + exact he z + _ = _ := movingArithmeticBlocks_average r q P S hc fP + +end +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPageDeletion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPageDeletion.lean new file mode 100644 index 0000000000000000000000000000000000000000..e97caa5c56ec909144b415906ebd6d589e02ebf7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPageDeletion.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantSupport +import OAI.NumberTheory.Ostmann.ZeroDensity.PageRegularAverage + +namespace OAI + +/-! # Conductor deletion for the separated diagonal modulus -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Prime factors in a regular block are disjoint from the frequency, +internal and spectator factors of the separated modulus. -/ +theorem movingArithmeticModuli_coprime_product {I J : Type*} [Fintype I] [Fintype J] + (r : ℕ) (p : I → ℕ) (P : Finset ℕ) (reg : J → ℕ) + (hp : ∀ i, (p i).Prime) (hP : ∀ q ∈ P, q.Prime) (hreg : ∀ j, (reg j).Prime) + (hr : ∀ j, (reg j).Coprime r) + (hregP : ∀ j q, q ∈ P → reg j ≠ q) (hregp : ∀ j i, reg j ≠ p i) : + (∏ j, reg j).Coprime (∏ b, movingArithmeticModuli r p P Finset.univ b) := by + rw [movingArithmeticModuli_product] + apply Nat.coprime_prod_left_iff.mpr + intro j _ + apply (hr j).mul_right + apply Nat.Coprime.mul_right + · apply Nat.Coprime.pow_right + apply Nat.coprime_prod_right_iff.mpr + intro q hq + exact (hreg j).coprime_iff_not_dvd.mpr (fun h => hregP j q hq + ((Nat.prime_dvd_prime_iff_eq (hreg j) (hP q hq)).mp h)) + · apply Nat.coprime_prod_right_iff.mpr + intro i _ + exact (hreg j).coprime_iff_not_dvd.mpr (fun h => hregp j i + ((Nat.prime_dvd_prime_iff_eq (hreg j) (hp i)).mp h)) + +/-- The prescribed deleted conductor prime is coprime to the full separated +arithmetic block. The frequency part is smaller than the deletion threshold. -/ +theorem frequencyModel_deleted_prime_coprime {I : Type*} [Fintype I] + (S : Finset ℤ) (n V cutoff : ℕ) (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) (hcut : V < cutoff) + (P : Finset ℕ) (p : I → ℕ) (hP : ∀ q ∈ P, q.Prime) (hp : ∀ i, (p i).Prime) + (q : ℕ) (hq : q.Prime) (hlarge : cutoff ≤ q) + (hneqP : q ∉ P) (hneqp : ∀ i, q ≠ p i) : + q.Coprime (∏ b, movingArithmeticModuli (frequencyModelBase S n t ^ (n - 1 + 2)) + p P Finset.univ b) := by + rw [movingArithmeticModuli_product] + apply ((prime_coprime_frequencyModelBase S V q n hq (hcut.trans_le hlarge) hS t).pow_right _).mul_right + apply Nat.Coprime.mul_right + · apply Nat.Coprime.pow_right + apply Nat.coprime_prod_right_iff.mpr + intro a ha + apply hq.coprime_iff_not_dvd.mpr + intro hd + exact hneqP (((Nat.prime_dvd_prime_iff_eq hq (hP a ha)).mp hd).symm ▸ ha) + · apply Nat.coprime_prod_right_iff.mpr + intro i _ + exact hq.coprime_iff_not_dvd.mpr (fun hd => hneqp i + ((Nat.prime_dvd_prime_iff_eq hq (hp i)).mp hd)) + +/-- The regular block contributes no Page correction under exactly the +conductor-prime deletion used to construct the original priors. -/ +theorem frequencyModel_regular_page_projection {I J : Type*} [Fintype I] [Fintype J] + (S : Finset ℤ) (n V cutoff : ℕ) (t : FrequencyTree (S × S) n) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) (hcut : V < cutoff) + (P : Finset ℕ) (p : I → ℕ) (reg : J → ℕ) (z : Option PrimitiveRealZero) + (hP : ∀ q ∈ P, q.Prime) (hp : ∀ i, (p i).Prime) + (hreg : ∀ j, (reg j).Prime ∧ cutoff ≤ reg j) + (hdeleteP : ∀ e, z = some e → ∀ q, + deletedConductorPrime e.modulus cutoff = some q → q ∉ P) + (hdeletep : ∀ e, z = some e → ∀ q, + deletedConductorPrime e.modulus cutoff = some q → ∀ i, q ≠ p i) + (hdeletereg : ∀ e, z = some e → ∀ q, + deletedConductorPrime e.modulus cutoff = some q → ∀ j, q ≠ reg j) : + pageAtModulus ((∏ j, reg j) * + ∏ b, movingArithmeticModuli (frequencyModelBase S n t ^ (n - 1 + 2)) p P Finset.univ b) z = + pageAtModulus (∏ b, movingArithmeticModuli (frequencyModelBase S n t ^ (n - 1 + 2)) + p P Finset.univ b) z := by + apply pageAtModulus_regular_factor z _ _ cutoff + · intro q hq hd + obtain ⟨j, _, hj⟩ := (hq.prime.dvd_finsetProd_iff reg).mp hd + have he := (Nat.prime_dvd_prime_iff_eq hq (hreg j).1).mp hj + exact he.symm ▸ (hreg j).2 + · intro e he q hq hd + have hs := deletedConductorPrime_spec hq + have harith := frequencyModel_deleted_prime_coprime S n V cutoff t hS hcut P p hP hp + q hs.1 hs.2.2 (hdeleteP e he q hq) (hdeletep e he q hq) + have hr : q.Coprime (∏ j, reg j) := by + apply Nat.coprime_prod_right_iff.mpr + intro j _ + exact hs.1.coprime_iff_not_dvd.mpr (fun h => hdeletereg e he q hq j + ((Nat.prime_dvd_prime_iff_eq hs.1 (hreg j).1).mp h)) + exact hs.1.coprime_iff_not_dvd.mp (hr.mul_right harith) hd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPair.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..667aa6f6443c95880db99b025e083934d13e9e4a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPair.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedCRT + +namespace OAI + +/-! # The separated two-history coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +noncomputable def movingSeparatedPairResidueCoefficient {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (a b : ℕ) : ℂ := + movingSeparatedResidueCoefficient q value outside (F false) (E false) g (Dq false) S + (T false) (nodes false) R a b * + conj (movingSeparatedResidueCoefficient q value outside (F true) (E true) g (Dq true) S + (T true) (nodes true) R a b) + +theorem movingSeparatedPairResidueCoefficient_modEq {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (hf : ∀ side, (T side).Frequencies (· ≠ 0)) + (hR : ∀ side, (T side).frequencyProduct ∣ R) + (a b c d : ℕ) (M : ℤ) (hfrequency : R ^ (n + 1) ∣ M) + (hsquare : ∀ side, ∀ o ∈ (T side).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hspectator : ∀ i ∈ S, (q i : ℤ) ∣ M) + (hL : (a : ℤ) ≡ (c : ℤ) [ZMOD M]) (hRight : (b : ℤ) ≡ (d : ℤ) [ZMOD M]) : + movingSeparatedPairResidueCoefficient q value outside F E g Dq S T nodes R a b = + movingSeparatedPairResidueCoefficient q value outside F E g Dq S T nodes R c d := by + have he (side : Bool) := movingSeparatedResidueCoefficient_modEq q value outside + (F side) (E side) g (Dq side) S (T side) (nodes side) R (hf side) (hR side) + a b c d M hfrequency (hsquare side) hspectator hL hRight + unfold movingSeparatedPairResidueCoefficient + rw [he false, he true] + +theorem movingReducedPairResidueCoefficient_eq_separated {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (hcover : ∀ p ∈ outside, ∃ i ∈ S, q i = p) (hg0 : ∀ i ∈ S, g i 0 = 0) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hlevels : ∀ side, (T side).Levels tier) + (hf : ∀ side, (T side).Frequencies (· ≠ 0)) + (hsmall : ∀ side i, (T side).Frequencies (fun f => IsCoprime f (value i : ℤ))) + (hfmod : ∀ side i, (T side).Frequencies (fun f => (f : ZMod (value i)) ≠ 0)) + (R : ℤ) (hR : ∀ side, (T side).frequencyProduct ∣ R) + (hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (hdistinct : ∀ side, (T side).CompensationDistinct value) + (hden : ∀ side i, i ∈ S → (T side).ModularDenominators value (q i)) (a b : ℕ) : + let nodes := fun side => (T side).formulaNodes value (fun i => (hprime i).ne_zero) + childBound pivotBound (hf side) (.prime false) (.prime true) + movingReducedPairResidueCoefficient q value outside F E g Dq S T nodes a b = + movingSeparatedPairResidueCoefficient q value outside F E g Dq S T nodes R a b := by + have he (side : Bool) := movingReducedResidueCoefficient_eq_separated q tier value hprime hdisjoint + outside childBound pivotBound (F side) (E side) g (Dq side) S hcover hg0 (T side) + (hlevels side) (hf side) (hsmall side) (hfmod side) R (hR side) hsmallR (hdistinct side) + (hden side) a b + dsimp only + unfold movingReducedPairResidueCoefficient movingSeparatedPairResidueCoefficient + rw [he false, he true] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPeriod.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPeriod.lean new file mode 100644 index 0000000000000000000000000000000000000000..f075043235dfed0fe2b51ecd2636c3dc61d4a8dd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedPeriod.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedCoefficient + +namespace OAI + +/-! # Periodicity after the arithmetic factors have been separated -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPrimeLineSupport_modEq {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (x y a b M : ℤ) + (hprime : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i : ℤ) ∣ M) + (hx : x ≡ a [ZMOD M]) (hy : y ≡ b [ZMOD M]) : + movingPrimeLineSupport value T x y ↔ movingPrimeLineSupport value T a b := by + apply forall₂_congr + intro o ho + apply forall₂_congr + intro i hi + have hL : (x : ZMod (value i)) = (a : ZMod (value i)) := + (ZMod.intCast_eq_intCast_iff _ _ _).mpr (hx.of_dvd (by exact_mod_cast hprime o ho i hi)) + have hR : (y : ZMod (value i)) = (b : ZMod (value i)) := + (ZMod.intCast_eq_intCast_iff _ _ _).mpr (hy.of_dvd (by exact_mod_cast hprime o ho i hi)) + dsimp only + rw [hL, hR] + +theorem movingSeparatedSupport_modEq {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) + (R : ℤ) (hf : T.Frequencies (· ≠ 0)) (hR : T.frequencyProduct ∣ R) + (x y a b M : ℤ) (hfrequency : R ^ (n + 1) ∣ M) + (hsquare : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hx : x ≡ a [ZMOD M]) (hy : y ≡ b [ZMOD M]) : + movingSeparatedSupport value outside T nodes R x y ↔ + movingSeparatedSupport value outside T nodes R a b := by + have hp : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i : ℤ) ∣ M := by + intro o ho i hi + exact (dvd_pow_self (value i : ℤ) (by decide : 2 ≠ 0)).trans (hsquare o ho i hi) + unfold movingSeparatedSupport + rw [movingSquareLineSupport_modEq value T x y a b M hsquare hx hy, + movingFrequencyGate_modEq value R T hf hR x y a b (hx.of_dvd hfrequency) (hy.of_dvd hfrequency), + movingPrimeLineSupport_modEq value T x y a b M hp hx hy] + +theorem movingSeparatedResidueCoefficient_modEq {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (nodes : List MovingFormulaNode) + (R : ℤ) (hf : T.Frequencies (· ≠ 0)) (hR : T.frequencyProduct ∣ R) + (x y a b M : ℤ) (hfrequency : R ^ (n + 1) ∣ M) + (hsquare : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hspectator : ∀ i ∈ S, (q i : ℤ) ∣ M) + (hx : x ≡ a [ZMOD M]) (hy : y ≡ b [ZMOD M]) : + movingSeparatedResidueCoefficient q value outside F E g D S T nodes R x y = + movingSeparatedResidueCoefficient q value outside F E g D S T nodes R a b := by + have hs := movingSeparatedSupport_modEq value outside T nodes R hf hR x y a b M hfrequency hsquare hx hy + have hprod : (∏ i ∈ S, movingModularSpectator value (q i) (g i) (D i) T x y) = + ∏ i ∈ S, movingModularSpectator value (q i) (g i) (D i) T a b := by + apply Finset.prod_congr rfl + intro i hi + have hL : (x : ZMod (q i)) = (a : ZMod (q i)) := + (ZMod.intCast_eq_intCast_iff _ _ _).mpr (hx.of_dvd (by exact_mod_cast hspectator i hi)) + have hR : (y : ZMod (q i)) = (b : ZMod (q i)) := + (ZMod.intCast_eq_intCast_iff _ _ _).mpr (hy.of_dvd (by exact_mod_cast hspectator i hi)) + rw [hL, hR] + simp only [movingSeparatedResidueCoefficient, hs, hprod] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..63c1fae61ff5ea0edee3065beaff6f36dcd14d3f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedProduct.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingInternalLocalFactor + +namespace OAI + +/-! # Product of the frequency, internal-prime and spectator factors -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +noncomputable def movingFrequencyPairSupport {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) {n : ℕ} (T : Bool → MovingSlotData σ n) + (nodes : Bool → List MovingFormulaNode) (R x y : ℤ) : Prop := + ∀ side, movingRegularOutsidePairwise value outside (T side) ∧ + (∀ f ∈ nodes side, f.guard.frequencyBounds) ∧ + movingFrequencyGate value R (T side) x y + +noncomputable def movingFrequencyPairFactor {σ : Type*} (value : σ → ℕ) + (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) + (nodes : Bool → List MovingFormulaNode) (R x y : ℤ) : ℂ := + if movingFrequencyPairSupport value outside T nodes R x y then + movingDataWeight (F false) (E false) (T false) * + conj (movingDataWeight (F true) (E true) (T true)) else 0 + +noncomputable def movingSpectatorPairFactor {σ : Type*} (value : σ → ℕ) + (q : ℕ) [Fact q.Prime] (g : ZMod q → ℂ) (D : Bool → (ZMod q)ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (x y : ZMod q) : ℂ := + movingModularSpectator value q g (D false) (T false) x y * + conj (movingModularSpectator value q g (D true) (T true) x y) + +/-- The coefficient of the literal original pair is a product over disjoint +arithmetic blocks. No Haar averaging or independence is assumed here. -/ +theorem movingSeparatedPairResidueCoefficient_product {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (D : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (R : ℤ) (P : Finset ℕ) + (hcover : ∀ side, ∀ o ∈ (T side).occurrences, + ∀ i ∈ o.current.compensationSlots, value i ∈ P) (x y : ℕ) : + movingSeparatedPairResidueCoefficient q value outside F E g D S T nodes R x y = + movingFrequencyPairFactor value outside F E T nodes R x y * + (∏ p ∈ P, movingInternalPairFactor value T p x y) * + ∏ i ∈ S, movingSpectatorPairFactor value (q i) (g i) (fun side => D side i) T x y := by + have hint := movingInternalPairFactor_product value T P hcover (x : ℤ) (y : ℤ) + simp only [Int.cast_natCast] at hint + rw [hint] + have hsplit : (∀ side, movingSeparatedSupport value outside (T side) (nodes side) R x y) ↔ + movingFrequencyPairSupport value outside T nodes R x y ∧ + (∀ side, movingPrimeLineSupport value (T side) x y ∧ + movingSquareLineSupport value (T side) x y) := by + simp only [movingSeparatedSupport, movingFrequencyPairSupport, Bool.forall_bool] + tauto + have hprod : (∏ i ∈ S, + movingSpectatorPairFactor value (q i) (g i) (fun side => D side i) T x y) = + (∏ i ∈ S, movingModularSpectator value (q i) (g i) (D false i) (T false) x y) * + conj (∏ i ∈ S, movingModularSpectator value (q i) (g i) (D true i) (T true) x y) := by + simp only [movingSpectatorPairFactor, Finset.prod_mul_distrib, map_prod] + rw [hprod] + unfold movingSeparatedPairResidueCoefficient movingSeparatedResidueCoefficient + movingFrequencyPairFactor + by_cases h0 : movingSeparatedSupport value outside (T false) (nodes false) R x y + · by_cases h1 : movingSeparatedSupport value outside (T true) (nodes true) R x y + · have hall : ∀ side, movingSeparatedSupport value outside (T side) (nodes side) R x y := by + simp only [Bool.forall_bool]; exact ⟨h0, h1⟩ + obtain ⟨hf, hi⟩ := hsplit.mp hall + simp only [ite_eq_left h0, ite_eq_left h1, ite_eq_left hf, ite_eq_left hi, map_mul, Int.cast_natCast] + ring + · have hall : ¬ (movingFrequencyPairSupport value outside T nodes R x y ∧ + ∀ side, movingPrimeLineSupport value (T side) x y ∧ + movingSquareLineSupport value (T side) x y) := fun h => h1 (hsplit.mpr h true) + by_cases hf : movingFrequencyPairSupport value outside T nodes R x y + · have hi := fun hi => hall ⟨hf, hi⟩ + simp only [ite_eq_left h0, ite_eq_right h1, ite_eq_left hf, ite_eq_right hi, + map_zero, mul_zero, zero_mul] + · simp only [ite_eq_left h0, ite_eq_right h1, ite_eq_right hf, + map_zero, mul_zero, zero_mul] + · have hall : ¬ (movingFrequencyPairSupport value outside T nodes R x y ∧ + ∀ side, movingPrimeLineSupport value (T side) x y ∧ + movingSquareLineSupport value (T side) x y) := fun h => h0 (hsplit.mpr h false) + by_cases hf : movingFrequencyPairSupport value outside T nodes R x y + · have hi := fun hi => hall ⟨hf, hi⟩ + simp only [ite_eq_right h0, ite_eq_left hf, ite_eq_right hi, mul_zero, zero_mul] + · simp only [ite_eq_right h0, ite_eq_right hf, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedRegularFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedRegularFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..41e8d88a5fd075b06479207248659174052881a2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedRegularFactor.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedSupportedPair + +namespace OAI + +/-! # The original regular multiplier at the separated arithmetic modulus -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate SchwartzMap + +theorem movingOriginalSupportedSeparatedRegular_modulus_factor {σ I J : Type*} [Fintype J] (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (hcover : ∀ p ∈ outside, ∃ i ∈ S, q i = p) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (Jleft Jright : ℝ) (diagonal : Bool) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (hT : ∀ side, (T side).Follows (t side)) (hf : ∀ side, (T side).Frequencies (· ≠ 0)) + (hlevels : ∀ side, (T side).Levels tier) (hcoh : ∀ side, (T side).RegularCoherent) + (hc : ∀ side, (T side).CompensationPrimeData value) + (hsmall : ∀ side i, (T side).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ side i, (T side).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (R : ℤ) (hR : ∀ side, (T side).frequencyProduct ∣ R) + (hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (hden : ∀ side i, i ∈ S → (T side).ModularDenominators value (q i)) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (hregular : ∀ side, MovingSlotReversal.naturalProduct value (T side).regularSlots = ∏ i, reg i) + (active : J → Bool) (s : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (M : ℕ) (hfrequency : R ^ (n + 1) ∣ (M : ℤ)) + (hsquare : ∀ side, ∀ o ∈ (T side).occurrences, + ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hspectator : ∀ i ∈ S, (q i : ℤ) ∣ M) + (hregM : ∀ i, reg i ∣ M) (XL XR : ℕ) : + let nodes := fun side => (T side).formulaNodes value (fun i => (hprime i).ne_zero) + childBound pivotBound (hf side) (.prime false) (.prime true) + let c := fun a b => movingSeparatedPairResidueCoefficient q value outside F E g Dq S T nodes R a b * + (guardedRegularMultiplier reg active s other greg a b : ℂ) + movingOriginalSupportedOuterPair q value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t XL XR * + (naturalRegularMultiplier reg active s other greg XL XR : ℂ) = + if XL.Coprime XR then c (XL % M) (XR % M) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal XL XR else 0 := by + dsimp only + let hv := fun i => (hprime i).ne_zero + let nodes := fun side => (T side).formulaNodes value hv childBound pivotBound (hf side) + (.prime false) (.prime true) + let oldM := movingReducedPairModulus value hv outside childBound pivotBound T hf q S + have he := movingOriginalSupportedOuterPair_reduced_factor q tier value hprime hdisjoint outside + childBound pivotBound F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD + hφ hlip hout diagonal T t hT hf hlevels hcoh hc hsmall hfmod (∏ i, reg i) hregular XL XR + have hback := movingReducedPairResidueCoefficient_modEq q value hv outside childBound pivotBound + F E g Dq S T hf (XL % oldM) (XR % oldM) XL XR + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XL oldM)) + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XR oldM)) + have hsep := movingReducedPairResidueCoefficient_eq_separated q tier value hprime hdisjoint outside + childBound pivotBound F E g Dq S hcover (fun i _ => hg i) T hlevels hf hsmall hfmod R hR hsmallR + (fun side => (hc side).distinct) hden XL XR + have hforward := movingSeparatedPairResidueCoefficient_modEq q value outside F E g Dq S T nodes R hf hR + XL XR (XL % M) (XR % M) M hfrequency hsquare hspectator + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XL M).symm) + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XR M).symm) + dsimp only at he hsep + rw [hback, hsep, hforward] at he + have hm := multiply_regular_after_support reg active s other greg XL XR _ _ _ he + have hgmod := guardedRegularMultiplier_modEq reg active s other greg XL XR (XL % M) (XR % M) M + hregM (Nat.mod_modEq XL M).symm (Nat.mod_modEq XR M).symm + rw [hgmod] at hm + exact hm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedRegularNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedRegularNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..35518ae92abbe84ac97df24eb797063d6fef1fa9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedRegularNorm.lean @@ -0,0 +1,41 @@ +import OAI.NumberTheory.Ostmann.Construction.RegularMultiplierNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedNorm + +namespace OAI + +/-! # Pointwise norm of the separated coefficient with regular primes -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingSeparatedPair_with_regular_norm {σ I J : Type*} [Fintype I] [Fintype J] + (p : I → ℕ) [∀ i, Fact (p i).Prime] (reg : J → ℕ) [∀ j, Fact (reg j).Prime] + (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (hg : ∀ i z, ‖g i z‖ ≤ p i) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (hweight : ∀ b, ‖movingDataWeight (F b) (E b) (T b)‖ ≤ 1) + (active : J → Bool) (s : ℤ) (other : ∀ j, ZMod (reg j)) + (greg : ∀ j, ZMod (reg j) → ℂ) + (henergy : ∀ j, (∑ x : ZMod (reg j), ‖greg j x‖ ^ 2) = reg j) (R : ℤ) (a b : ℕ) : + ‖movingSeparatedPairResidueCoefficient p value outside F E g Dq Finset.univ T nodes R a b * + (guardedRegularMultiplier reg active s other greg a b : ℂ)‖ ≤ + (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 * ∏ j, (reg j : ℝ) := by + have hc := movingSeparatedPairResidueCoefficient_norm p value outside F E g Dq Finset.univ + (fun i => (p i : ℝ)) (fun i _ => Nat.cast_nonneg _) (fun i _ => hg i) T nodes R a b + have hr := guardedRegularMultiplier_le_prime_product reg active s other greg henergy a b + have hprod : 0 ≤ ∏ i, (p i : ℝ) ^ (2 ^ n) := by positivity + have hcs : ‖movingSeparatedPairResidueCoefficient p value outside F E g Dq Finset.univ T nodes R a b‖ ≤ + (∏ i, (p i : ℝ) ^ (2 ^ n)) ^ 2 := by + apply hc.trans + have hh := mul_le_mul (mul_le_mul_of_nonneg_right (hweight false) hprod) + (mul_le_mul_of_nonneg_right (hweight true) hprod) (by positivity) (by positivity) + simpa only [one_mul, pow_two] using hh + rw [norm_mul, Complex.norm_real, Real.norm_of_nonneg hr.1] + exact mul_le_mul hcs hr.2 hr.1 (sq_nonneg _) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedSupportedPair.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedSupportedPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..61531ab913c27381ae395293c993ab98a124da6a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedSupportedPair.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedPair + +namespace OAI + +/-! # The original supported prime pair at the separated arithmetic modulus -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate SchwartzMap + +/-- The literal product in the original sampled coefficient square. -/ +noncomputable def movingOriginalSupportedPair {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (XL XR : ℕ) : ℂ := + movingSupportedWeight value outside (T false) XL XR + (movingOriginalGiantWeight q value childBound pivotBound (F false) (E false) g (Dq false) S + ψ X lo hi φ G (T false) (t false) XL XR) * + conj (movingSupportedWeight value outside (T true) XL XR + (movingOriginalGiantWeight q value childBound pivotBound (F true) (E true) g (Dq true) S + ψ X lo hi φ G (T true) (t true) XL XR)) + +theorem movingOriginalSupportedPair_separated_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (hcover : ∀ p ∈ outside, ∃ i ∈ S, q i = p) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (hT : ∀ side, (T side).Follows (t side)) (hf : ∀ side, (T side).Frequencies (· ≠ 0)) + (hlevels : ∀ side, (T side).Levels tier) (hcoh : ∀ side, (T side).RegularCoherent) + (hc : ∀ side, (T side).CompensationPrimeData value) + (hsmall : ∀ side i, (T side).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ side i, (T side).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (R : ℤ) (hR : ∀ side, (T side).frequencyProduct ∣ R) + (hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (hden : ∀ side i, i ∈ S → (T side).ModularDenominators value (q i)) + (Reg : ℕ) + (hregular : ∀ side, MovingSlotReversal.naturalProduct value (T side).regularSlots = Reg) + (M : ℕ) (hfrequency : R ^ (n + 1) ∣ (M : ℤ)) + (hsquare : ∀ side, ∀ o ∈ (T side).occurrences, + ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hspectator : ∀ i ∈ S, (q i : ℤ) ∣ M) + (XL XR : ℕ) (hXL : XL.Coprime Reg) (hXR : XR.Coprime Reg) : + let hv := fun i => (hprime i).ne_zero + let nodes := fun side => (T side).formulaNodes value hv childBound pivotBound (hf side) + (.prime false) (.prime true) + let c := movingSeparatedPairResidueCoefficient q value outside F E g Dq S T nodes R + movingOriginalSupportedPair q value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + T t XL XR = + if XL.Coprime XR then c (XL % M) (XR % M) * + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G XL XR else 0 := by + let hv := fun i => (hprime i).ne_zero + let nodes := fun side => (T side).formulaNodes value hv childBound pivotBound (hf side) + (.prime false) (.prime true) + let oldM := movingReducedPairModulus value hv outside childBound pivotBound T hf q S + have ht := movingReducedPairModulus_tests value hv outside childBound pivotBound T hf q S + have he := movingOriginalGiantWeight_reduced_pair_factor q tier value hprime hdisjoint outside + childBound pivotBound F E g hg Dq S ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + T t hT hf hlevels hcoh hc hsmall hfmod Reg hregular + XL XR (XL % oldM) (XR % oldM) oldM ht.1 ht.2.1 ht.2.2.1 ht.2.2.2 + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XL oldM).symm) + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XR oldM).symm) + have hback := movingReducedPairResidueCoefficient_modEq q value hv outside childBound pivotBound + F E g Dq S T hf (XL % oldM) (XR % oldM) XL XR + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XL oldM)) + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XR oldM)) + have hsep := movingReducedPairResidueCoefficient_eq_separated q tier value hprime hdisjoint outside + childBound pivotBound F E g Dq S hcover (fun i _ => hg i) T hlevels hf hsmall hfmod R hR hsmallR + (fun side => (hc side).distinct) hden XL XR + have hforward := movingSeparatedPairResidueCoefficient_modEq q value outside F E g Dq S T nodes R hf hR + XL XR (XL % M) (XR % M) M hfrequency hsquare hspectator + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XL M).symm) + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XR M).symm) + change movingOriginalSupportedPair q value outside childBound pivotBound F E g Dq S + ψ X lo hi φ G T t XL XR = + if XL.Coprime XR ∧ XL.Coprime Reg ∧ XR.Coprime Reg then + movingReducedPairResidueCoefficient q value outside F E g Dq S T nodes + (XL % oldM) (XR % oldM) * + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G XL XR else 0 at he + dsimp only at hsep ⊢ + rw [hback, hsep, hforward] at he + by_cases hp : XL.Coprime XR + · rw [ite_eq_left ⟨hp, hXL, hXR⟩] at he + rw [ite_eq_left hp] + exact he + · rw [ite_eq_right (fun h => hp h.1)] at he + rw [ite_eq_right hp] + exact he + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..e14a45d469611e3cae2127e2b95d322a78520eef --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSeparatedWeight.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedPeriod +import OAI.NumberTheory.Ostmann.Arithmetic.MovingReducedWeight + +namespace OAI + +/-! # The literal original weight at the separated modulus -/ + +namespace Ostmann +open scoped Classical SchwartzMap + +theorem MovingSlotData.CompensationPrimeData.distinct {σ : Type*} + {value : σ → ℕ} {n : ℕ} {T : MovingSlotData σ n} + (h : T.CompensationPrimeData value) : T.CompensationDistinct value := by + induction T with + | leaf => trivial + | node s CL CR U left right ihL ihR => + exact ⟨h.2.1, ihL h.2.2.2.1, ihR h.2.2.2.2⟩ + +/-- The original moving weight factors through the separated modulus. +No cleared ancestor denominator or internal prime enters the frequency +period assumed here; all remaining periods are prime squares or spectators. -/ +theorem movingOriginalGiantWeight_separated_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) + (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg0 : ∀ i, g i 0 = 0) + (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (hcover : ∀ p ∈ outside, ∃ i ∈ S, q i = p) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hlevels : T.Levels tier) (hcoh : T.RegularCoherent) (hc : T.CompensationPrimeData value) + (hf : T.Frequencies (· ≠ 0)) + (hsmall : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (R : ℤ) (hR : T.frequencyProduct ∣ R) (hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (hden : ∀ i ∈ S, T.ModularDenominators value (q i)) + (XL XR a b M : ℕ) (hfrequency : R ^ (n + 1) ∣ (M : ℤ)) + (hsquare : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hspectator : ∀ i ∈ S, (q i : ℤ) ∣ M) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hRight : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := T.formulaNodes value (fun i => (hprime i).ne_zero) + childBound pivotBound hf (.prime false) (.prime true) + movingSupportedWeight value outside T XL XR + (movingOriginalGiantWeight q value childBound pivotBound F E g Dq S ψ X lo hi φ G T t XL XR) = + if XL.Coprime XR ∧ + XL.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) ∧ + XR.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) then + movingSeparatedResidueCoefficient q value outside F E g Dq S T nodes R a b * + movingRealKernel value T nodes ψ X lo hi hlo hhi φ G XL XR else 0 := by + let nodes := T.formulaNodes value (fun i => (hprime i).ne_zero) + childBound pivotBound hf (.prime false) (.prime true) + have he := movingOriginalGiantWeight_reduced_factor q tier value hprime hdisjoint outside + childBound pivotBound F E g hg0 Dq S ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + T t hT hlevels hcoh hc hf hsmall hfmod XL XR XL XR 0 + (dvd_zero _) (fun _ _ => dvd_zero _) (dvd_zero _) (fun _ _ _ _ => dvd_zero _) + (Int.ModEq.refl _) (Int.ModEq.refl _) + dsimp only at he ⊢ + have hcsep := movingReducedResidueCoefficient_eq_separated q tier value hprime hdisjoint outside + childBound pivotBound F E g Dq S hcover (fun i _ => hg0 i) T hlevels hf hsmall hfmod + R hR hsmallR hc.distinct hden XL XR + have hperiod := movingSeparatedResidueCoefficient_modEq q value outside F E g Dq S T nodes R hf hR + XL XR a b M hfrequency hsquare hspectator hL hRight + rw [hcsep, hperiod] at he + exact he + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSignedFormulas.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSignedFormulas.lean new file mode 100644 index 0000000000000000000000000000000000000000..4fa8bbffbe1f6b938fd16aab7cf38d1dd3f9912a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSignedFormulas.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingIntegralFrequencySplit +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRealResidues + +namespace OAI + +/-! # Original rational node formulas and the signed integer recursion -/ + +namespace Ostmann +open scoped Classical + +theorem rational_int_div_integral_iff (N D : ℤ) (hD : D ≠ 0) : + (∃ z : ℤ, (N : ℚ) / D = z) ↔ D ∣ N := by + constructor + · rintro ⟨z, hz⟩ + have he := (div_eq_iff (Int.cast_ne_zero.mpr hD)).mp hz + have hi : N = z * D := by exact_mod_cast he + exact ⟨z, by simpa only [mul_comm] using hi⟩ + · rintro ⟨z, rfl⟩ + refine ⟨z, ?_⟩ + rw [Int.cast_mul] + exact mul_div_cancel_left₀ (z : ℚ) (Int.cast_ne_zero.mpr hD) + +theorem MovingSlotReversal.giantFormula_signed_value {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) (hs : step.rootFrequency ≠ 0) + (hu : naturalProduct value step.compensationSlots ≠ 0) + (L R : HistoryFormula Bool) (a : Bool → ℤ) (x y : ℤ) + (hL : L.value (fun b => (a b : ℚ)) = (x : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (y : ℚ)) : + (step.giantFormula value hs hu L R).value (fun b => (a b : ℚ)) = + (step.signedNumerator value x y : ℚ) / + (step.rootFrequency * (naturalProduct value step.compensationSlots : ℤ)) := by + simp only [giantFormula, HistoryFormula.value_solve, HistoryFormula.value_product, + HistoryFormula.value_external, hL, hR, signedNumerator, Int.cast_sub, Int.cast_mul, + Int.cast_natCast] + +theorem MovingSlotReversal.giantFormula_signed_integral_iff {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) (hs : step.rootFrequency ≠ 0) + (hu : naturalProduct value step.compensationSlots ≠ 0) + (L R : HistoryFormula Bool) (a : Bool → ℤ) (x y : ℤ) + (hL : L.value (fun b => (a b : ℚ)) = (x : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (y : ℚ)) : + (step.giantFormula value hs hu L R).IntegralAt a ↔ step.SignedIntegralAt value x y := by + change (∃ z : ℤ, (step.giantFormula value hs hu L R).value _ = (z : ℚ)) ↔ _ + rw [step.giantFormula_signed_value value hs hu L R a x y hL hR] + simp only [← Int.cast_mul] + rw [rational_int_div_integral_iff _ _ (mul_ne_zero hs (Int.natCast_ne_zero.mpr hu))] + change _ ∣ _ ↔ _ = _ + constructor + · intro hd + exact (Int.mul_ediv_cancel' hd).symm + · intro h + exact ⟨step.signedPivot value x y, h⟩ + +theorem MovingSlotReversal.giantFormula_of_signed_integral {σ : Type*} + (step : MovingSlotReversal σ) (value : σ → ℕ) (hs : step.rootFrequency ≠ 0) + (hu : naturalProduct value step.compensationSlots ≠ 0) + (L R : HistoryFormula Bool) (a : Bool → ℤ) (x y : ℤ) + (hL : L.value (fun b => (a b : ℚ)) = (x : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (y : ℚ)) + (hI : step.SignedIntegralAt value x y) : + (step.giantFormula value hs hu L R).value (fun b => (a b : ℚ)) = + (step.signedPivot value x y : ℚ) := by + rw [step.giantFormula_signed_value value hs hu L R a x y hL hR, hI] + push_cast + field_simp + +/-- The integrality entries of the original formula list impose exactly +the signed divisions. They do not need any real or positivity hypothesis. -/ +theorem MovingSlotData.formulaNodes_signed_integral_iff {σ : Type*} + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (L R : HistoryFormula Bool) (a : Bool → ℤ) (x y : ℤ) + (hL : L.value (fun b => (a b : ℚ)) = (x : ℚ)) + (hR : R.value (fun b => (a b : ℚ)) = (y : ℚ)) : + (∀ f ∈ T.formulaNodes value hvalue childBound pivotBound hf L R, f.newGiant.IntegralAt a) ↔ + T.SignedIntegral value x y := by + induction T generalizing L R x y with + | leaf => simp [formulaNodes, SignedIntegral] + | @node n s CL CR U left right ihL ihR => + let step := MovingSlotData.step s CL CR U left right false + have hU := MovingSlotReversal.naturalProduct_ne_zero value hvalue U + let G := step.giantFormula value hf.1 hU L R + have hroot := step.giantFormula_signed_integral_iff value hf.1 hU L R a x y hL hR + simp only [formulaNodes, List.forall_mem_cons, List.forall_mem_append] + change (G.IntegralAt a ∧ (∀ f ∈ left.formulaNodes value hvalue childBound pivotBound hf.2.1 G L, + f.newGiant.IntegralAt a) ∧ (∀ f ∈ right.formulaNodes value hvalue childBound pivotBound hf.2.2 G R, + f.newGiant.IntegralAt a)) ↔ _ + constructor + · rintro ⟨hG, hl, hr⟩ + have hI := hroot.mp hG + have hval := step.giantFormula_of_signed_integral value hf.1 hU L R a x y hL hR hI + exact ⟨hI, (ihL hf.2.1 G L _ _ hval hL).mp hl, (ihR hf.2.2 G R _ _ hval hR).mp hr⟩ + · rintro ⟨hI, hl, hr⟩ + have hval := step.giantFormula_of_signed_integral value hf.1 hU L R a x y hL hR hI + exact ⟨hroot.mpr hI, (ihL hf.2.1 G L _ _ hval hL).mpr hl, (ihR hf.2.2 G R _ _ hval hR).mpr hr⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSignedSpectator.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSignedSpectator.lean new file mode 100644 index 0000000000000000000000000000000000000000..51871ad3139ccbda39a6fc45caa58e238662585c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSignedSpectator.lean @@ -0,0 +1,165 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCongruence + +namespace OAI + +/-! # Signed residue representatives for the literal spectator recursion -/ + +namespace Ostmann +open scoped Classical + +/-- Clearing the input period makes division compatible with congruence, +even when the individual numerators are not divisible by the denominator. -/ +theorem int_modEq_ediv (c m x y : ℤ) (hc : c ≠ 0) + (h : x ≡ y [ZMOD c * m]) : x / c ≡ y / c [ZMOD m] := by + have hr : x % c = y % c := h.of_mul_right m + have hrem : x % c ≡ y % c [ZMOD c * m] := by rw [hr] + have hx : x - x % c = c * (x / c) := by + linear_combination -(Int.emod_add_mul_ediv x c) + have hy : y - y % c = c * (y / c) := by + linear_combination -(Int.emod_add_mul_ediv y c) + have hh := h.sub hrem + rw [hx, hy] at hh + exact Int.ModEq.mul_left_cancel' hc hh + +noncomputable def MovingSlotReversal.signedPivot {σ : Type*} (s : MovingSlotReversal σ) + (value : σ → ℕ) (XL XR : ℤ) : ℤ := + (s.leftFrequency * (XR * (naturalProduct value s.rightSlots : ℤ)) - + s.rightFrequency * (XL * (naturalProduct value s.leftSlots : ℤ))) / + (s.rootFrequency * (naturalProduct value s.compensationSlots : ℤ)) + +theorem MovingSlotReversal.signedPivot_nat {σ : Type*} (s : MovingSlotReversal σ) + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (hs : s.rootFrequency ≠ 0) + (XL XR : ℕ) (hI : s.IntegralAt value (XL, XR)) : + s.signedPivot value XL XR = (s.naturalPivot value XL XR : ℤ) := by + have he := hI.2 + simp only [Nat.cast_mul] at he + unfold signedPivot + rw [he, ← mul_assoc] + exact Int.mul_ediv_cancel_left _ + (mul_ne_zero hs (Nat.cast_ne_zero.mpr (naturalProduct_ne_zero value hvalue _))) + +noncomputable def movingSignedSpectator {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (g : ZMod q → ℂ) (D : (ZMod q)ˣ) : + {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℂ + | _, .leaf s regular, XL, XR => + g ((s : ZMod q) / ((D : ZMod q) * + ((XL * XR * (MovingSlotReversal.naturalProduct value regular : ℤ) : ℤ) : ZMod q))) + | _, .node s CL CR U left right, XL, XR => + let p := (MovingSlotData.step s CL CR U left right false).signedPivot value XL XR + if (p : ZMod q) = 0 then 0 else + movingSignedSpectator value g D left p XL * star (movingSignedSpectator value g D right p XR) + +/-- Signed representatives agree with the original natural recursion on +its proved integral support. No extra unit condition is imposed. -/ +theorem movingSignedSpectator_nat {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (g : ZMod q → ℂ) (D : (ZMod q)ˣ) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XL XR : ℕ) + (hI : T.Integral value XL XR) : + movingSignedSpectator value g D T XL XR = movingSlotSpectator value g D T XL XR := by + induction T generalizing XL XR with + | leaf s regular => + simp only [movingSignedSpectator, movingSlotSpectator, Int.cast_mul, Int.cast_natCast, Nat.cast_mul] + | node s CL CR U left right ihL ihR => + rw [movingSignedSpectator, movingSlotSpectator, + (MovingSlotData.step s CL CR U left right false).signedPivot_nat value hvalue hf.1 XL XR hI.1] + simp only [Int.cast_natCast] + split_ifs + · rfl + · rw [ihL hf.2.1 _ _ hI.2.1, ihR hf.2.2 _ _ hI.2.2] + +theorem MovingSlotReversal.signedPivot_modEq {σ : Type*} (s : MovingSlotReversal σ) + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (hs : s.rootFrequency ≠ 0) + (XL XR YL YR m : ℤ) + (hL : XL ≡ YL [ZMOD s.rootFrequency * (naturalProduct value s.compensationSlots : ℤ) * m]) + (hR : XR ≡ YR [ZMOD s.rootFrequency * (naturalProduct value s.compensationSlots : ℤ) * m]) : + s.signedPivot value XL XR ≡ s.signedPivot value YL YR [ZMOD m] := by + unfold signedPivot + apply int_modEq_ediv _ m _ _ + (mul_ne_zero hs (Nat.cast_ne_zero.mpr (naturalProduct_ne_zero value hvalue _))) + exact ((hR.mul_right (naturalProduct value s.rightSlots)).mul_left s.leftFrequency).sub + ((hL.mul_right (naturalProduct value s.leftSlots)).mul_left s.rightFrequency) + +/-- Signed representatives are periodic before imposing any real support. -/ +theorem movingSignedSpectator_modEq {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (g : ZMod q → ℂ) (D : (ZMod q)ˣ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (XL XR YL YR : ℤ) + (hL : (XL : ℤ) ≡ (YL : ℤ) [ZMOD (q : ℤ) * movingSpectatorDenominator value T]) + (hR : (XR : ℤ) ≡ (YR : ℤ) [ZMOD (q : ℤ) * movingSpectatorDenominator value T]) : + movingSignedSpectator value g D T XL XR = movingSignedSpectator value g D T YL YR := by + induction T generalizing XL XR YL YR with + | leaf s regular => + simp only [movingSpectatorDenominator, mul_one] at hL hR + have hl : (XL : ZMod q) = (YL : ZMod q) := by + exact_mod_cast (ZMod.intCast_eq_intCast_iff _ _ q).mpr hL + have hr : (XR : ZMod q) = (YR : ZMod q) := by + exact_mod_cast (ZMod.intCast_eq_intCast_iff _ _ q).mpr hR + simp only [movingSignedSpectator, Int.cast_mul, Int.cast_natCast, hl, hr] + | node s CL CR U left right ihL ihR => + let c : ℤ := s * (MovingSlotReversal.naturalProduct value U : ℤ) + let dl := movingSpectatorDenominator value left + let dr := movingSpectatorDenominator value right + let step := MovingSlotData.step s CL CR U left right false + let p := step.signedPivot value XL XR + let r := step.signedPivot value YL YR + have hL' : (XL : ℤ) ≡ (YL : ℤ) [ZMOD c * ((q : ℤ) * dl * dr)] := by + convert hL using 1 + dsimp [c, dl, dr, movingSpectatorDenominator] + ring + have hR' : (XR : ℤ) ≡ (YR : ℤ) [ZMOD c * ((q : ℤ) * dl * dr)] := by + convert hR using 1 + dsimp [c, dl, dr, movingSpectatorDenominator] + ring + have hp : (p : ℤ) ≡ (r : ℤ) [ZMOD (q : ℤ) * dl * dr] := + step.signedPivot_modEq value hvalue hf.1 XL XR YL YR _ hL' hR' + have hpq : (p : ZMod q) = (r : ZMod q) := by + have hp' := hp.of_dvd (show (q : ℤ) ∣ (q : ℤ) * dl * dr from + ⟨dl * dr, by ring⟩) + exact_mod_cast (ZMod.intCast_eq_intCast_iff _ _ q).mpr hp' + have hpl : (p : ℤ) ≡ (r : ℤ) [ZMOD (q : ℤ) * dl] := + hp.of_dvd ⟨dr, rfl⟩ + have hpr : (p : ℤ) ≡ (r : ℤ) [ZMOD (q : ℤ) * dr] := + hp.of_dvd ⟨dl, by ring⟩ + have hll : (XL : ℤ) ≡ (YL : ℤ) [ZMOD (q : ℤ) * dl] := + hL'.of_dvd ⟨c * dr, by ring⟩ + have hrr : (XR : ℤ) ≡ (YR : ℤ) [ZMOD (q : ℤ) * dr] := + hR'.of_dvd ⟨c * dl, by ring⟩ + have hl := ihL hf.2.1 p XL r YL hpl hll + have hr := ihR hf.2.2 p XR r YR hpr hrr + change (if (p : ZMod q) = 0 then 0 else + movingSignedSpectator value g D left p XL * star (movingSignedSpectator value g D right p XR)) = + (if (r : ZMod q) = 0 then 0 else + movingSignedSpectator value g D left r YL * star (movingSignedSpectator value g D right r YR)) + rw [hpq, hl, hr] + +theorem movingSlotSpectator_eq_residue {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) (g : ZMod q → ℂ) (D : (ZMod q)ˣ) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XL XR a b M : ℕ) + (hI : T.Integral value XL XR) + (hM : (q : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + movingSlotSpectator value g D T XL XR = movingSignedSpectator value g D T a b := by + rw [← movingSignedSpectator_nat value hvalue g D T hf XL XR hI] + exact movingSignedSpectator_modEq value hvalue g D T hf XL XR a b + (hL.of_dvd hM) (hR.of_dvd hM) + +theorem movingSignedSpectator_norm {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (g : ZMod q → ℂ) (D : (ZMod q)ˣ) + (B : ℝ) (hB : 0 ≤ B) (hg : ∀ z, ‖g z‖ ≤ B) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℤ) : + ‖movingSignedSpectator value g D T XL XR‖ ≤ B ^ (2 ^ n) := by + induction T generalizing XL XR with + | leaf s regular => simpa only [movingSignedSpectator, pow_zero, pow_one] using hg _ + | @node n s CL CR U left right ihL ihR => + rw [movingSignedSpectator] + split_ifs + · simpa only [norm_zero] using pow_nonneg hB (2 ^ (n + 1)) + · rw [norm_mul, norm_star] + calc + _ ≤ B ^ (2 ^ n) * B ^ (2 ^ n) := + mul_le_mul (ihL _ _) (ihR _ _) (norm_nonneg _) (pow_nonneg hB _) + _ = B ^ (2 ^ (n + 1)) := by rw [← pow_add, pow_succ]; congr 1; omega + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSignedUnits.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSignedUnits.lean new file mode 100644 index 0000000000000000000000000000000000000000..13fe129b475257cdecedebebba5a0750fc6701c1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSignedUnits.lean @@ -0,0 +1,139 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSignedSpectator +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairwiseSupport + +namespace OAI + +/-! # The giant unit tests on signed residue representatives -/ + +namespace Ostmann +open scoped Classical + +theorem int_modEq_isCoprime_iff {x y m : ℤ} (h : x ≡ y [ZMOD m]) : + IsCoprime x m ↔ IsCoprime y m := by + have transport {a b : ℤ} (hab : a ≡ b [ZMOD m]) (ha : IsCoprime a m) : + IsCoprime b m := by + obtain ⟨k, hk⟩ := hab.dvd + obtain ⟨u, v, huv⟩ := ha + refine ⟨u, v - u * k, ?_⟩ + linear_combination huv + u * hk + exact ⟨transport h, transport h.symm⟩ + +/-- The product records every frequency at or below this state. -/ +def MovingSlotData.frequencyProduct {σ : Type*} : {n : ℕ} → MovingSlotData σ n → ℤ + | _, .leaf s _ => s + | _, .node s _ _ _ left right => s * left.frequencyProduct * right.frequencyProduct + +theorem MovingSlotData.frequencies_isCoprime {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) (x : ℤ) : + T.Frequencies (fun s => IsCoprime x s) ↔ IsCoprime x T.frequencyProduct := by + induction T with + | leaf => rfl + | node s CL CR U left right ihL ihR => + simp only [Frequencies, frequencyProduct, IsCoprime.mul_right_iff, ihL, ihR, and_assoc] + +/-- Tests the two giants against every subtree frequency, every current +regular slot, and the fixed outside list. Mutual coprimality of the two +current giants is deliberately separate. -/ +def movingLocalGiantUnits {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℤ) : Prop := + IsCoprime XL T.frequencyProduct ∧ IsCoprime XR T.frequencyProduct ∧ + IsCoprime XL (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) ∧ + IsCoprime XR (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) ∧ + IsCoprime XL (outside.prod : ℤ) ∧ IsCoprime XR (outside.prod : ℤ) + +/-- Signed evaluation uses exact Euclidean division and hence is defined on +all residue representatives, including representatives off the real support. -/ +noncomputable def movingSignedGiantUnits {σ : Type*} (value : σ → ℕ) (outside : List ℕ) : + {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → Prop + | _, T@(.leaf _ _), XL, XR => movingLocalGiantUnits value outside T XL XR + | _, T@(.node s CL CR U left right), XL, XR => + let p := (MovingSlotData.step s CL CR U left right false).signedPivot value XL XR + movingLocalGiantUnits value outside T XL XR ∧ + movingSignedGiantUnits value outside left p XL ∧ + movingSignedGiantUnits value outside right p XR + +def movingNaturalGiantUnits {σ : Type*} (value : σ → ℕ) (outside : List ℕ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → Prop + | _, T@(.leaf _ _), XL, XR => movingLocalGiantUnits value outside T XL XR + | _, T@(.node s CL CR U left right), XL, XR => + let p := (MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR + movingLocalGiantUnits value outside T XL XR ∧ + movingNaturalGiantUnits value outside left p XL ∧ + movingNaturalGiantUnits value outside right p XR + +theorem movingSignedGiantUnits_nat {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (XL XR : ℕ) (hI : T.Integral value XL XR) : + movingSignedGiantUnits value outside T XL XR ↔ movingNaturalGiantUnits value outside T XL XR := by + induction T generalizing XL XR with + | leaf => rfl + | node s CL CR U left right ihL ihR => + simp only [movingSignedGiantUnits, movingNaturalGiantUnits, + (MovingSlotData.step s CL CR U left right false).signedPivot_nat value hvalue hf.1 XL XR hI.1, + ihL hf.2.1 _ _ hI.2.1, ihR hf.2.2 _ _ hI.2.2] + +/-- A period for precisely the current unit tests and their descendant +Euclidean divisions. No real inequalities are used in this definition. -/ +def movingGiantUnitPeriod {σ : Type*} (value : σ → ℕ) (outside : List ℕ) : + {n : ℕ} → MovingSlotData σ n → ℤ + | _, T@(.leaf _ _) => + T.frequencyProduct * (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) * outside.prod + | _, T@(.node s _ _ U left right) => + (T.frequencyProduct * (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) * outside.prod) * + (s * (MovingSlotReversal.naturalProduct value U : ℤ)) * + movingGiantUnitPeriod value outside left * movingGiantUnitPeriod value outside right + +theorem movingLocalGiantUnits_modEq {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR YL YR : ℤ) + (hL : XL ≡ YL [ZMOD T.frequencyProduct * + (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) * outside.prod]) + (hR : XR ≡ YR [ZMOD T.frequencyProduct * + (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) * outside.prod]) : + movingLocalGiantUnits value outside T XL XR ↔ movingLocalGiantUnits value outside T YL YR := by + have hfreq : T.frequencyProduct ∣ T.frequencyProduct * + (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) * outside.prod := + ⟨(MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) * outside.prod, by ring⟩ + have hreg : (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) ∣ T.frequencyProduct * + (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) * outside.prod := ⟨T.frequencyProduct * outside.prod, by ring⟩ + have hout : (outside.prod : ℤ) ∣ T.frequencyProduct * + (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) * outside.prod := ⟨T.frequencyProduct * (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ), by ring⟩ + unfold movingLocalGiantUnits + rw [int_modEq_isCoprime_iff (hL.of_dvd hfreq), int_modEq_isCoprime_iff (hR.of_dvd hfreq), + int_modEq_isCoprime_iff (hL.of_dvd hreg), int_modEq_isCoprime_iff (hR.of_dvd hreg), + int_modEq_isCoprime_iff (hL.of_dvd hout), int_modEq_isCoprime_iff (hR.of_dvd hout)] + +theorem movingSignedGiantUnits_modEq {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (XL XR YL YR : ℤ) + (hL : XL ≡ YL [ZMOD movingGiantUnitPeriod value outside T]) + (hR : XR ≡ YR [ZMOD movingGiantUnitPeriod value outside T]) : + movingSignedGiantUnits value outside T XL XR ↔ movingSignedGiantUnits value outside T YL YR := by + induction T generalizing XL XR YL YR with + | leaf s regular => exact movingLocalGiantUnits_modEq value outside _ _ _ _ _ hL hR + | node s CL CR U left right ihL ihR => + let T := MovingSlotData.node s CL CR U left right + let a := T.frequencyProduct * (MovingSlotReversal.naturalProduct value T.regularSlots : ℤ) * outside.prod + let c := s * (MovingSlotReversal.naturalProduct value U : ℤ) + let dl := movingGiantUnitPeriod value outside left + let dr := movingGiantUnitPeriod value outside right + have hd : movingGiantUnitPeriod value outside T = a * c * dl * dr := rfl + have hl : movingLocalGiantUnits value outside T XL XR ↔ movingLocalGiantUnits value outside T YL YR := + movingLocalGiantUnits_modEq value outside T XL XR YL YR + (hL.of_dvd ⟨c * dl * dr, by rw [hd]; ring⟩) + (hR.of_dvd ⟨c * dl * dr, by rw [hd]; ring⟩) + let step := MovingSlotData.step s CL CR U left right false + let p := step.signedPivot value XL XR + let r := step.signedPivot value YL YR + have hp : p ≡ r [ZMOD a * dl * dr] := + step.signedPivot_modEq value hvalue hf.1 XL XR YL YR _ + (hL.of_dvd ⟨1, by change a * c * dl * dr = c * (a * dl * dr) * 1; ring⟩) + (hR.of_dvd ⟨1, by change a * c * dl * dr = c * (a * dl * dr) * 1; ring⟩) + have hleft := ihL hf.2.1 p XL r YL + (hp.of_dvd ⟨a * dr, by ring⟩) (hL.of_dvd ⟨a * c * dr, by rw [hd]; ring⟩) + have hright := ihR hf.2.2 p XR r YR + (hp.of_dvd ⟨a * dl, by ring⟩) (hR.of_dvd ⟨a * c * dl, by rw [hd]; ring⟩) + exact and_congr hl (and_congr hleft hright) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotLines.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotLines.lean new file mode 100644 index 0000000000000000000000000000000000000000..e4cc32b74ce98f4abbf3a1cbf3d1a332ddb28919 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotLines.lean @@ -0,0 +1,155 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotPolynomials +import OAI.NumberTheory.Ostmann.Arithmetic.JointSampledComparison + +namespace OAI + +/-! # Simultaneous arithmetic replacement for concrete moving-giant slots -/ + +namespace Ostmann +open scoped BigOperators Classical + +noncomputable def movingSlotLine {σ : Type*} (path : List (MovingSlotReversal σ)) + (current : MovingSlotReversal σ) : PolynomialGiantLine σ := + movingHistoryLine (path.map MovingSlotReversal.polynomial) + current.polynomial.v current.polynomial.w + +theorem movingSlotLine_degree {σ : Type*} (path : List (MovingSlotReversal σ)) + (current : MovingSlotReversal σ) (k d : ℕ) + (hlen : path.length ≤ k) (hd : ∀ s ∈ path, s.lengthLE d) (hc : current.lengthLE d) : + (movingSlotLine path current).a.totalDegree ≤ (k + 1) * d ∧ + (movingSlotLine path current).b.totalDegree ≤ (k + 1) * d := by + have h := movingHistoryLine_degree (path.map MovingSlotReversal.polynomial) + current.polynomial.v current.polynomial.w d + (by intro s hs; obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs; exact t.polynomial_degree d (hd t ht)) + (current.polynomial_degree d hc).1 (current.polynomial_degree d hc).2.1 + have hb : ((path.map MovingSlotReversal.polynomial).length + 1) * d ≤ (k + 1) * d := by + simpa only [List.length_map] using Nat.mul_le_mul_right d (Nat.add_le_add_right hlen 1) + exact ⟨h.1.trans hb, h.2.trans hb⟩ + +theorem movingSlotLine_height {σ : Type*} (path : List (MovingSlotReversal σ)) + (current : MovingSlotReversal σ) (x : σ → ℝ) (k d : ℕ) (F T : ℝ) + (hF : 1 ≤ F) (hT : 1 ≤ T) (hlen : path.length ≤ k) + (hd : ∀ s ∈ path, s.lengthLE d ∧ s.frequencyLE F) + (hc : current.lengthLE d ∧ current.frequencyLE F) (hx : ∀ i, |x i| ≤ T) : + let φ := MvPolynomial.eval₂Hom (Int.castRingHom ℝ) x + |φ (movingSlotLine path current).a| ≤ (2 * (F * T ^ d)) ^ (k + 1) ∧ + |φ (movingSlotLine path current).b| ≤ (2 * (F * T ^ d)) ^ (k + 1) := by + have hK : 1 ≤ F * T ^ d := one_le_mul_of_one_le_of_one_le hF (one_le_pow₀ hT) + have hh := movingHistoryLine_value (path.map MovingSlotReversal.polynomial) + current.polynomial.v current.polynomial.w _ (F * T ^ d) (by linarith) + (by + intro s hs + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs + exact t.polynomial_height x F T d (hd t ht).2 hT (hd t ht).1 hx) + (current.polynomial_height x F T d hc.2 hT hc.1 hx).1 + (current.polynomial_height x F T d hc.2 hT hc.1 hx).2.1 + have hb : (2 * (F * T ^ d)) ^ ((path.map MovingSlotReversal.polynomial).length + 1) ≤ + (2 * (F * T ^ d)) ^ (k + 1) := by + apply pow_le_pow_right₀ (by linarith) + simpa only [List.length_map] using Nat.add_le_add_right hlen 1 + exact ⟨hh.1.trans hb, hh.2.trans hb⟩ + +theorem movingSlotLine_vars {σ : Type*} [DecidableEq σ] + (path : List (MovingSlotReversal σ)) (current : MovingSlotReversal σ) (S : Finset σ) + (hp : ∀ s ∈ path, (∀ i ∈ s.leftSlots, i ∈ S) ∧ (∀ i ∈ s.rightSlots, i ∈ S) ∧ + (∀ i ∈ s.compensationSlots, i ∈ S)) + (hc : (∀ i ∈ current.leftSlots, i ∈ S) ∧ (∀ i ∈ current.rightSlots, i ∈ S)) : + (movingSlotLine path current).a.vars ⊆ S ∧ (movingSlotLine path current).b.vars ⊆ S := by + have hsub (a : ℤ) (slots : List σ) (h : ∀ i ∈ slots, i ∈ S) : + (movingSlotCoefficient a slots).vars ⊆ S := + (movingSlotCoefficient_vars a slots).trans (fun i hi => h i (List.mem_toFinset.mp hi)) + apply movingHistoryLine_vars_subset + · intro s hs + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs + exact ⟨hsub _ _ (hp t ht).2.1, hsub _ _ (hp t ht).1, hsub _ _ (hp t ht).2.2⟩ + · exact hsub _ _ hc.2 + · exact hsub _ _ hc.1 + +/-- All occurrence tests for all representative internal primes are replaced +at once, under the original independent slot priors. The multiplier remains +complex-valued. Independence follows from absence of the tested coordinate in +the actual slot lists, including every ancestor compensation list. -/ +theorem moving_slot_joint_symbolic_comparison {A J O : Type*} + [Fintype A] [Nonempty A] [Fintype J] [Fintype O] {n : ℕ} + (value : A → ℤ) (hinj : Function.Injective value) + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (path : J → O → List (MovingSlotReversal (Fin (n + 1)))) + (current : J → O → MovingSlotReversal (Fin (n + 1))) + (base : J → O) (coordinate : J → Fin (n + 1)) + (k d : ℕ) (F T : ℝ) (hF : 1 ≤ F) (hT : 1 ≤ T) + (hlen : ∀ j o, (path j o).length ≤ k) + (hd : ∀ j o, (∀ s ∈ path j o, s.lengthLE d ∧ s.frequencyLE F) ∧ + (current j o).lengthLE d ∧ (current j o).frequencyLE F) + (habsent : ∀ j o, + (∀ s ∈ path j o, coordinate j ∉ s.leftSlots ∧ coordinate j ∉ s.rightSlots ∧ + coordinate j ∉ s.compensationSlots) ∧ + coordinate j ∉ (current j o).leftSlots ∧ coordinate j ∉ (current j o).rightSlots) + (hvalues : ∀ a, |(value a : ℝ)| ≤ T) + (μ : Fin (n + 1) → A → ℝ) (hμ : ∀ i a, 0 ≤ μ i a) + (hmass : ∀ i, ∑ a, μ i a = 1) + (α β V : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) + (hmax : ∀ i a, μ i a ≤ α) (hpmax : ∀ j a, μ (coordinate j) a ≤ β) + (hsize : ∀ j a, μ (coordinate j) a ≠ 0 → V ≤ Real.log (prime a : ℝ)) + (Ψ : (Fin (n + 1) → A) → (J × (Bool ⊕ O) → Bool) → ℂ) + (B : ℝ) (hB : 0 ≤ B) (hΨ : ∀ x flags, ‖Ψ x flags‖ ≤ B) : + let tests := fun t : J × (Bool ⊕ O) => + lineTestPolynomials (fun o => movingSlotLine (path t.1 o) (current t.1 o)) (base t.1) t.2 + ‖∑ x, (productPrior μ x : ℂ) * + (Ψ x (fun t => arithmeticTestFlag + (prime (x (coordinate t.1)) ∣ (integerTestValue value (tests t) x).natAbs)) - + Ψ x (fun t => arithmeticTestFlag (tests t = 0)))‖ ≤ + 2 * B * (Fintype.card J * (2 + Fintype.card O)) * + ((2 * ((k + 1) * d) : ℕ) * α + + (Real.log (2 * ((2 * (F * T ^ d)) ^ (k + 1)) ^ 2) / V) * β) := by + let lines := fun j o => movingSlotLine (path j o) (current j o) + let tests := fun t : J × (Bool ⊕ O) => lineTestPolynomials (lines t.1) (base t.1) t.2 + let H := (2 * (F * T ^ d)) ^ (k + 1) + have hH : 1 ≤ H := one_le_pow₀ (by + have := one_le_mul_of_one_le_of_one_le hF (one_le_pow₀ hT (n := d)) + linarith) + have hdeg (t : J × (Bool ⊕ O)) : (tests t).totalDegree ≤ 2 * ((k + 1) * d) := + lineTestPolynomials_degree_le (lines t.1) (base t.1) _ + (fun o => movingSlotLine_degree _ _ k d (hlen _ _) (fun s hs => (hd _ _).1 s hs |>.1) + (hd _ _).2.1) t.2 + have hheight (t : J × (Bool ⊕ O)) (x : Fin (n + 1) → A) : + |(integerTestValue value (tests t) x : ℝ)| ≤ 2 * H ^ 2 := by + rw [integerTestValue_real_cast] + apply lineTestPolynomials_value_le (lines t.1) (base t.1) _ H hH + intro o + exact movingSlotLine_height _ _ _ k d F T hF hT (hlen _ _) (hd _ _).1 (hd _ _).2 + (fun i => hvalues (x i)) + have hab (t : J × (Bool ⊕ O)) : coordinate t.1 ∉ (tests t).vars := by + let S : Finset (Fin (n + 1)) := Finset.univ.erase (coordinate t.1) + have hl (o : O) : (lines t.1 o).a.vars ⊆ S ∧ (lines t.1 o).b.vars ⊆ S := by + apply movingSlotLine_vars + · intro s hs + refine ⟨?_, ?_, ?_⟩ <;> intro i hi <;> apply Finset.mem_erase.mpr <;> + refine ⟨?_, Finset.mem_univ _⟩ + · exact fun h => (habsent t.1 o).1 s hs |>.1 (h ▸ hi) + · exact fun h => (habsent t.1 o).1 s hs |>.2.1 (h ▸ hi) + · exact fun h => (habsent t.1 o).1 s hs |>.2.2 (h ▸ hi) + · constructor <;> intro i hi <;> apply Finset.mem_erase.mpr <;> + refine ⟨?_, Finset.mem_univ _⟩ + · exact fun h => (habsent t.1 o).2.1 (h ▸ hi) + · exact fun h => (habsent t.1 o).2.2 (h ▸ hi) + exact fun h => Finset.notMem_erase _ _ + (lineTestPolynomials_vars_subset (lines t.1) (base t.1) S hl t.2 h) + have hh := joint_sampled_polynomial_comparison_le value hinj prime hpInj hprime tests + (fun t => coordinate t.1) hab μ hμ hmass α β V (2 * H ^ 2) hα hβ hV + (by nlinarith [sq_nonneg H]) hmax (fun t => hpmax t.1) (fun t => hsize t.1) hheight Ψ B hB hΨ + apply hh.trans + have hterm (t : J × (Bool ⊕ O)) : + ((tests t).totalDegree : ℝ) * α + (Real.log (2 * H ^ 2) / V) * β ≤ + ((2 * ((k + 1) * d) : ℕ) : ℝ) * α + (Real.log (2 * H ^ 2) / V) * β := by + have hd' : ((tests t).totalDegree : ℝ) ≤ ((2 * ((k + 1) * d) : ℕ) : ℝ) := by + exact_mod_cast hdeg t + exact add_le_add (mul_le_mul_of_nonneg_right hd' hα) le_rfl + have hsum := Finset.sum_le_sum (s := Finset.univ) (fun t _ => hterm t) + apply (mul_le_mul_of_nonneg_left hsum (mul_nonneg (by norm_num) hB)).trans_eq + simp only [Finset.sum_const, Finset.card_univ, Fintype.card_prod, Fintype.card_sum, + Fintype.card_bool, nsmul_eq_mul, Nat.cast_mul, Nat.cast_add, Nat.cast_ofNat, H] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotOccurrences.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotOccurrences.lean new file mode 100644 index 0000000000000000000000000000000000000000..b15b20897503c4042103ad900d5ea853edaaa8eb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotOccurrences.lean @@ -0,0 +1,134 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotLines + +namespace OAI + +/-! # Actual occurrence paths and absence of their compensation type -/ + +namespace Ostmann +open scoped Classical + +/-- At a node, the two regular lists exclude its moving giants. The +compensation list is inserted in both children by the sampler. -/ +inductive MovingSlotData (σ : Type*) : ℕ → Type _ + | leaf (s : ℤ) (regular : List σ) : MovingSlotData σ 0 + | node {n : ℕ} (s : ℤ) (leftRegular rightRegular compensation : List σ) + (left right : MovingSlotData σ n) : MovingSlotData σ (n + 1) + +def MovingSlotData.frequency {σ : Type*} : {n : ℕ} → MovingSlotData σ n → ℤ + | _, .leaf s _ => s + | _, .node s _ _ _ _ _ => s + +def MovingSlotData.step {σ : Type*} {n : ℕ} (s : ℤ) (CL CR u : List σ) + (left right : MovingSlotData σ n) (b : Bool) : MovingSlotReversal σ where + left := b + rootFrequency := s + leftFrequency := left.frequency + rightFrequency := right.frequency + leftSlots := CL + rightSlots := CR + compensationSlots := u + +structure MovingSlotOccurrence (σ : Type*) where + level : ℕ + current : MovingSlotReversal σ + path : List (MovingSlotReversal σ) + +def MovingSlotOccurrence.extend {σ : Type*} (o : MovingSlotOccurrence σ) + (s : MovingSlotReversal σ) : MovingSlotOccurrence σ := + { o with path := o.path ++ [s] } + +/-- Each root-to-occurrence path is recorded in the order of the cleared +ancestor recursion, so the newest reversal occurs first. -/ +def MovingSlotData.occurrences {σ : Type*} : {n : ℕ} → MovingSlotData σ n → List (MovingSlotOccurrence σ) + | _, .leaf _ _ => [] + | n + 1, .node s CL CR u left right => + ⟨n + 1, step s CL CR u left right false, []⟩ :: + (left.occurrences.map (fun o => o.extend (step s CL CR u left right true))) ++ + (right.occurrences.map (fun o => o.extend (step s CL CR u left right false))) + +def MovingSlotData.Levels {σ : Type*} (tier : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → Prop + | _, .leaf _ _ => True + | n + 1, .node _ CL CR u left right => + (∀ i ∈ CL, n + 1 ≤ tier i) ∧ (∀ i ∈ CR, n + 1 ≤ tier i) ∧ + (∀ i ∈ u, tier i = n) ∧ left.Levels tier ∧ right.Levels tier + +def MovingSlotOccurrence.AvoidsBelow {σ : Type*} (tier : σ → ℕ) + (o : MovingSlotOccurrence σ) : Prop := + (∀ s ∈ o.path, (∀ i ∈ s.leftSlots, o.level ≤ tier i) ∧ + (∀ i ∈ s.rightSlots, o.level ≤ tier i) ∧ + (∀ i ∈ s.compensationSlots, o.level ≤ tier i)) ∧ + (∀ i ∈ o.current.leftSlots, o.level ≤ tier i) ∧ + (∀ i ∈ o.current.rightSlots, o.level ≤ tier i) + +/-- The current compensation type is strictly below every variable in the +current numerator and all its ancestor denominators. This holds for every +occurrence simultaneously, including repeated occurrences of one sample. -/ +theorem MovingSlotData.occurrence_bounds {σ : Type*} (tier : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hT : T.Levels tier) : + ∀ o ∈ T.occurrences, 0 < o.level ∧ o.level + o.path.length ≤ n ∧ o.AvoidsBelow tier := by + induction T with + | leaf s regular => simp [occurrences] + | @node n s CL CR u left right ihL ihR => + intro o ho + rcases List.mem_cons.mp ho with ho | ho + · subst o + refine ⟨by change 0 < n + 1; omega, by change n + 1 + 0 ≤ n + 1; omega, ?_⟩ + exact ⟨by simp, hT.1, hT.2.1⟩ + · have hl := ihL hT.2.2.2.1 + have hr := ihR hT.2.2.2.2 + rcases List.mem_append.mp ho with ho | ho + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + obtain ⟨hp, hlen, ha, hb, hc⟩ := hl o' ho' + refine ⟨hp, ?_, ?_, hb, hc⟩ + · simpa only [MovingSlotOccurrence.extend, List.length_append, List.length_singleton] using + (show o'.level + (o'.path.length + 1) ≤ n + 1 by omega) + · intro t ht + rcases List.mem_append.mp ht with ht | ht + · exact ha t ht + · have he := List.mem_singleton.mp ht + subst t + refine ⟨?_, ?_, ?_⟩ + · intro i hi + exact (show o'.level ≤ n + 1 by omega).trans (hT.1 i hi) + · intro i hi + exact (show o'.level ≤ n + 1 by omega).trans (hT.2.1 i hi) + · intro i hi + change o'.level ≤ tier i + rw [hT.2.2.1 i hi] + omega + · obtain ⟨o', ho', rfl⟩ := List.mem_map.mp ho + obtain ⟨hp, hlen, ha, hb, hc⟩ := hr o' ho' + refine ⟨hp, ?_, ?_, hb, hc⟩ + · simpa only [MovingSlotOccurrence.extend, List.length_append, List.length_singleton] using + (show o'.level + (o'.path.length + 1) ≤ n + 1 by omega) + · intro t ht + rcases List.mem_append.mp ht with ht | ht + · exact ha t ht + · have he := List.mem_singleton.mp ht + subst t + refine ⟨?_, ?_, ?_⟩ + · intro i hi + exact (show o'.level ≤ n + 1 by omega).trans (hT.1 i hi) + · intro i hi + exact (show o'.level ≤ n + 1 by omega).trans (hT.2.1 i hi) + · intro i hi + change o'.level ≤ tier i + rw [hT.2.2.1 i hi] + omega + +theorem MovingSlotOccurrence.absent_of_level {σ : Type*} (tier : σ → ℕ) + (o : MovingSlotOccurrence σ) (ho : o.AvoidsBelow tier) (i : σ) (hi : tier i < o.level) : + (∀ s ∈ o.path, i ∉ s.leftSlots ∧ i ∉ s.rightSlots ∧ i ∉ s.compensationSlots) ∧ + i ∉ o.current.leftSlots ∧ i ∉ o.current.rightSlots := by + refine ⟨?_, ?_, ?_⟩ + · intro s hs + exact ⟨fun h => (not_le.mpr hi) ((ho.1 s hs).1 i h), + fun h => (not_le.mpr hi) ((ho.1 s hs).2.1 i h), + fun h => (not_le.mpr hi) ((ho.1 s hs).2.2 i h)⟩ + · exact fun h => (not_le.mpr hi) (ho.2.1 i h) + · exact fun h => (not_le.mpr hi) (ho.2.2 i h) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotPolynomials.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotPolynomials.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4025bdf7faa9601d0679641f7e102caa2266933 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotPolynomials.lean @@ -0,0 +1,164 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingLineComparison + +namespace OAI + +/-! # Actual slot products in the moving-giant line polynomials + +Lists retain multiplicities: an ancestral compensation prime may occur in +several descendant regular products. No squarefree polynomial is substituted. +-/ + +namespace Ostmann +open scoped BigOperators Classical + +noncomputable def movingSlotProduct {σ : Type*} (slots : List σ) : MvPolynomial σ ℤ := + (slots.map MvPolynomial.X).prod + +noncomputable def movingSlotCoefficient {σ : Type*} (s : ℤ) (slots : List σ) : + MvPolynomial σ ℤ := MvPolynomial.C s * movingSlotProduct slots + +theorem movingSlotProduct_eval {σ R : Type*} [CommRing R] + (f : ℤ →+* R) (x : σ → R) (slots : List σ) : + MvPolynomial.eval₂Hom f x (movingSlotProduct slots) = (slots.map x).prod := by + induction slots with + | nil => simp [movingSlotProduct] + | cons i slots ih => simpa [movingSlotProduct] using congrArg (x i * ·) ih + +theorem movingSlotCoefficient_eval {σ R : Type*} [CommRing R] + (f : ℤ →+* R) (x : σ → R) (s : ℤ) (slots : List σ) : + MvPolynomial.eval₂Hom f x (movingSlotCoefficient s slots) = + f s * (slots.map x).prod := by + simp only [movingSlotCoefficient, map_mul, MvPolynomial.eval₂Hom_C, + movingSlotProduct_eval] + +theorem movingSlotProduct_degree {σ : Type*} (slots : List σ) : + (movingSlotProduct slots).totalDegree ≤ slots.length := by + induction slots with + | nil => simp [movingSlotProduct] + | cons i slots ih => + change (MvPolynomial.X i * movingSlotProduct slots).totalDegree ≤ slots.length + 1 + exact (MvPolynomial.totalDegree_mul _ _).trans (by + rw [MvPolynomial.totalDegree_X] + omega) + +theorem movingSlotCoefficient_degree {σ : Type*} (s : ℤ) (slots : List σ) : + (movingSlotCoefficient s slots).totalDegree ≤ slots.length := by + exact (MvPolynomial.totalDegree_mul _ _).trans (by + simpa only [MvPolynomial.totalDegree_C, zero_add] using movingSlotProduct_degree slots) + +theorem movingSlotProduct_vars {σ : Type*} [DecidableEq σ] (slots : List σ) : + (movingSlotProduct slots).vars ⊆ slots.toFinset := by + induction slots with + | nil => simp [movingSlotProduct] + | cons i slots ih => + intro j hj + have h := MvPolynomial.vars_mul (MvPolynomial.X i) (movingSlotProduct slots) hj + rcases Finset.mem_union.mp h with h | h + · have hji : j = i := by + simpa only [MvPolynomial.vars_X, Finset.mem_singleton] using h + simp [hji] + · exact List.mem_toFinset.mpr (List.mem_cons_of_mem _ (List.mem_toFinset.mp (ih h))) + +theorem movingSlotCoefficient_vars {σ : Type*} [DecidableEq σ] (s : ℤ) (slots : List σ) : + (movingSlotCoefficient s slots).vars ⊆ slots.toFinset := by + intro i hi + have h := MvPolynomial.vars_mul (MvPolynomial.C s) (movingSlotProduct slots) hi + rcases Finset.mem_union.mp h with h | h + · rw [MvPolynomial.vars_C] at h + exact (Finset.notMem_empty _ h).elim + · exact movingSlotProduct_vars slots h + +theorem movingSlotProduct_abs_le {σ : Type*} (x : σ → ℝ) (slots : List σ) + (T : ℝ) (hT : 0 ≤ T) (hx : ∀ i ∈ slots, |x i| ≤ T) : + |(slots.map x).prod| ≤ T ^ slots.length := by + induction slots with + | nil => simp + | cons i slots ih => + simp only [List.map_cons, List.prod_cons, abs_mul, List.length_cons, pow_succ] + calc + |x i| * |(slots.map x).prod| ≤ T * T ^ slots.length := + mul_le_mul (hx i (by simp)) (ih fun j hj => hx j (by simp [hj])) + (abs_nonneg _) hT + _ = _ := mul_comm _ _ + +theorem movingSlotCoefficient_abs_le {σ : Type*} (x : σ → ℝ) (s : ℤ) + (slots : List σ) (F T : ℝ) (hF : |(s : ℝ)| ≤ F) (hT : 0 ≤ T) + (hx : ∀ i ∈ slots, |x i| ≤ T) : + |MvPolynomial.eval₂Hom (Int.castRingHom ℝ) x (movingSlotCoefficient s slots)| ≤ + F * T ^ slots.length := by + rw [movingSlotCoefficient_eval, abs_mul] + exact mul_le_mul hF (movingSlotProduct_abs_le x slots T hT hx) + (abs_nonneg _) (le_trans (abs_nonneg _) hF) + +theorem movingSlotCoefficient_ne_zero {σ K : Type*} [Field K] + (x : σ → K) (s : ℤ) (slots : List σ) + (hs : (s : K) ≠ 0) (hx : ∀ i ∈ slots, x i ≠ 0) : + MvPolynomial.eval₂Hom (Int.castRingHom K) x (movingSlotCoefficient s slots) ≠ 0 := by + rw [movingSlotCoefficient_eval] + apply mul_ne_zero hs + induction slots with + | nil => simp + | cons i slots ih => + exact mul_ne_zero (hx i (by simp)) (ih fun j hj => hx j (by simp [hj])) + +/-- The products multiplying the current two giants, together with the actual +compensation product in the denominator. Giants themselves are excluded. -/ +structure MovingSlotReversal (σ : Type*) where + left : Bool + rootFrequency : ℤ + leftFrequency : ℤ + rightFrequency : ℤ + leftSlots : List σ + rightSlots : List σ + compensationSlots : List σ + +namespace MovingSlotReversal + +noncomputable def polynomial {σ : Type*} (s : MovingSlotReversal σ) : PolynomialReversal σ where + left := s.left + v := movingSlotCoefficient s.leftFrequency s.rightSlots + w := movingSlotCoefficient s.rightFrequency s.leftSlots + u := movingSlotCoefficient s.rootFrequency s.compensationSlots + +def lengthLE {σ : Type*} (s : MovingSlotReversal σ) (d : ℕ) : Prop := + s.rightSlots.length ≤ d ∧ s.leftSlots.length ≤ d ∧ s.compensationSlots.length ≤ d + +def frequencyLE {σ : Type*} (s : MovingSlotReversal σ) (F : ℝ) : Prop := + |(s.leftFrequency : ℝ)| ≤ F ∧ |(s.rightFrequency : ℝ)| ≤ F ∧ + |(s.rootFrequency : ℝ)| ≤ F + +theorem polynomial_degree {σ : Type*} (s : MovingSlotReversal σ) (d : ℕ) + (h : s.lengthLE d) : + s.polynomial.v.totalDegree ≤ d ∧ s.polynomial.w.totalDegree ≤ d ∧ + s.polynomial.u.totalDegree ≤ d := + ⟨(movingSlotCoefficient_degree _ _).trans h.1, + (movingSlotCoefficient_degree _ _).trans h.2.1, + (movingSlotCoefficient_degree _ _).trans h.2.2⟩ + +theorem polynomial_height {σ : Type*} (s : MovingSlotReversal σ) (x : σ → ℝ) + (F T : ℝ) (d : ℕ) (hF : s.frequencyLE F) (hT : 1 ≤ T) + (hd : s.lengthLE d) (hx : ∀ i, |x i| ≤ T) : + let φ := MvPolynomial.eval₂Hom (Int.castRingHom ℝ) x + |φ s.polynomial.v| ≤ F * T ^ d ∧ |φ s.polynomial.w| ≤ F * T ^ d ∧ + |φ s.polynomial.u| ≤ F * T ^ d := by + have hF0 : 0 ≤ F := (abs_nonneg _).trans hF.1 + have hb (a : ℤ) (slots : List σ) (ha : |(a : ℝ)| ≤ F) (hlen : slots.length ≤ d) : + |MvPolynomial.eval₂Hom (Int.castRingHom ℝ) x (movingSlotCoefficient a slots)| ≤ F * T ^ d := + (movingSlotCoefficient_abs_le x a slots F T ha (by linarith) (fun i _ => hx i)).trans + (mul_le_mul_of_nonneg_left (pow_le_pow_right₀ hT hlen) hF0) + exact ⟨hb _ _ hF.1 hd.1, hb _ _ hF.2.1 hd.2.1, hb _ _ hF.2.2 hd.2.2⟩ + +theorem polynomial_units {σ K : Type*} [Field K] (s : MovingSlotReversal σ) + (x : σ → K) (hfreq : (s.leftFrequency : K) ≠ 0 ∧ + (s.rightFrequency : K) ≠ 0 ∧ (s.rootFrequency : K) ≠ 0) + (hx : ∀ i, x i ≠ 0) : + let φ := MvPolynomial.eval₂Hom (Int.castRingHom K) x + φ s.polynomial.v ≠ 0 ∧ φ s.polynomial.w ≠ 0 ∧ φ s.polynomial.u ≠ 0 := + ⟨movingSlotCoefficient_ne_zero x _ _ hfreq.1 (fun i _ => hx i), + movingSlotCoefficient_ne_zero x _ _ hfreq.2.1 (fun i _ => hx i), + movingSlotCoefficient_ne_zero x _ _ hfreq.2.2 (fun i _ => hx i)⟩ + +end MovingSlotReversal +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotRealization.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotRealization.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a80af8933b231499442607600e0f8fac7ff12d4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotRealization.lean @@ -0,0 +1,129 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotPolynomials + +namespace OAI + +/-! # Integer realization of the source-ordered slot rows -/ + +namespace Ostmann +open scoped BigOperators Classical + +namespace MovingSlotReversal + +/-- Each list is evaluated as its actual natural product, with multiplicities. -/ +def naturalProduct {σ : Type*} (value : σ → ℕ) (slots : List σ) : ℕ := + (slots.map value).prod + +theorem coefficient_nat_eval {σ K : Type*} [CommRing K] + (value : σ → ℕ) (s : ℤ) (slots : List σ) : + MvPolynomial.eval₂Hom (Int.castRingHom K) (fun i => (value i : K)) + (movingSlotCoefficient s slots) = (s : K) * (naturalProduct value slots : K) := by + rw [movingSlotCoefficient_eval] + congr 1 + induction slots with + | nil => simp [naturalProduct] + | cons i slots ih => + simpa only [List.map_cons, List.prod_cons, naturalProduct, Nat.cast_mul] using + (congrArg ((value i : K) * ·) ih) + +def naturalPivot {σ : Type*} (s : MovingSlotReversal σ) (value : σ → ℕ) (XL XR : ℕ) : ℕ := + movingGiantPivot s.rootFrequency s.leftFrequency s.rightFrequency + (naturalProduct value s.leftSlots) (naturalProduct value s.rightSlots) + (naturalProduct value s.compensationSlots) XL XR 1 1 + +def naturalStep {σ : Type*} (s : MovingSlotReversal σ) (value : σ → ℕ) + (pair : ℕ × ℕ) : ℕ × ℕ := + (s.naturalPivot value pair.1 pair.2, if s.left then pair.1 else pair.2) + +/-- This is exactly the integer equation at a supported reversal. -/ +def IntegralAt {σ : Type*} (s : MovingSlotReversal σ) (value : σ → ℕ) + (pair : ℕ × ℕ) : Prop := + 0 < s.naturalPivot value pair.1 pair.2 ∧ + s.leftFrequency * ((pair.2 * naturalProduct value s.rightSlots : ℕ) : ℤ) - + s.rightFrequency * ((pair.1 * naturalProduct value s.leftSlots : ℕ) : ℤ) = + s.rootFrequency * ((naturalProduct value s.compensationSlots * + s.naturalPivot value pair.1 pair.2 : ℕ) : ℤ) + +noncomputable def naturalReduction {σ : Type*} (q : ℕ) (value : σ → ℕ) : + MvPolynomial σ ℤ →+* ZMod q := + MvPolynomial.eval₂Hom (Int.castRingHom (ZMod q)) (fun i => (value i : ZMod q)) + +theorem polynomial_step_integer {σ : Type*} {q : ℕ} [Fact q.Prime] + (s : MovingSlotReversal σ) (value : σ → ℕ) (T : GiantRows (ZMod q)) + (x y : ZMod q) (pair : ℕ × ℕ) + (hpair : T.eval x y = ((pair.1 : ZMod q), (pair.2 : ZMod q))) + (hvalid : s.IntegralAt value pair) + (hunit : naturalReduction q value s.polynomial.v ≠ 0 ∧ + naturalReduction q value s.polynomial.w ≠ 0 ∧ naturalReduction q value s.polynomial.u ≠ 0) : + (T.movingReverse s.left (Units.mk0 (naturalReduction q value s.polynomial.v) hunit.1) + (Units.mk0 (naturalReduction q value s.polynomial.w) hunit.2.1) + (Units.mk0 (naturalReduction q value s.polynomial.u) hunit.2.2)).eval x y = + (((s.naturalStep value pair).1 : ZMod q), ((s.naturalStep value pair).2 : ZMod q)) := by + have hcast : ((if s.left then pair.1 else pair.2 : ℕ) : ZMod q) = + if s.left then (pair.1 : ZMod q) else (pair.2 : ZMod q) := by + split_ifs <;> rfl + change _ = ((s.naturalPivot value pair.1 pair.2 : ZMod q), + ((if s.left then pair.1 else pair.2 : ℕ) : ZMod q)) + rw [hcast] + apply GiantRows.movingReverse_integer_node T s.left _ _ _ x y pair.1 pair.2 + (s.naturalPivot value pair.1 pair.2) (naturalProduct value s.leftSlots) + (naturalProduct value s.rightSlots) 1 1 (naturalProduct value s.compensationSlots) + s.rootFrequency s.leftFrequency s.rightFrequency hpair + · simpa only [Units.val_mk0, polynomial, Nat.mul_one, naturalReduction] using + coefficient_nat_eval (K := ZMod q) value s.leftFrequency s.rightSlots + · simpa only [Units.val_mk0, polynomial, Nat.mul_one, naturalReduction] using + coefficient_nat_eval (K := ZMod q) value s.rightFrequency s.leftSlots + · simpa only [Units.val_mk0, polynomial, naturalReduction] using + coefficient_nat_eval (K := ZMod q) value s.rootFrequency s.compensationSlots + · simpa only [Nat.mul_one] using hvalid.2 + +end MovingSlotReversal + +/-- A path is written with its newest reversal first, matching the cleared +row recursion. Each step is performed over the integers before reduction. -/ +def movingSlotNaturalPath {σ : Type*} (value : σ → ℕ) : + List (MovingSlotReversal σ) → (ℕ × ℕ) → ℕ × ℕ + | [], pair => pair + | s :: path, pair => s.naturalStep value (movingSlotNaturalPath value path pair) + +def MovingSlotPathIntegral {σ : Type*} (value : σ → ℕ) : + List (MovingSlotReversal σ) → (ℕ × ℕ) → Prop + | [], _ => True + | s :: path, pair => MovingSlotPathIntegral value path pair ∧ + s.IntegralAt value (movingSlotNaturalPath value path pair) + +/-- The polynomial ancestor pair is the reduction of the actual integer +reversal path, rather than an unrelated invertible linear system. -/ +theorem movingSlotNaturalPath_realized {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (path : List (MovingSlotReversal σ)) (pair : ℕ × ℕ) + (hvalid : MovingSlotPathIntegral value path pair) + (hunit : ∀ s ∈ path, + MovingSlotReversal.naturalReduction q value s.polynomial.v ≠ 0 ∧ + MovingSlotReversal.naturalReduction q value s.polynomial.w ≠ 0 ∧ + MovingSlotReversal.naturalReduction q value s.polynomial.u ≠ 0) : + let φ := MvPolynomial.eval₂Hom (Int.castRingHom (ZMod q)) + (fun i => (value i : ZMod q)); + ((movingPolynomialAncestors (path.map MovingSlotReversal.polynomial)).normalized φ).eval + (pair.1 : ZMod q) (pair.2 : ZMod q) = + (((movingSlotNaturalPath value path pair).1 : ZMod q), + ((movingSlotNaturalPath value path pair).2 : ZMod q)) := by + let φ := MvPolynomial.eval₂Hom (Int.castRingHom (ZMod q)) (fun i => (value i : ZMod q)); + induction path with + | nil => + simp [movingPolynomialAncestors, PolynomialGiantRows.normalized, + PolynomialGiantRows.identity, GiantRows.identity, GiantRows.eval, movingSlotNaturalPath] + | cons s path ih => + have hs := hunit s (by simp) + have ht := fun t ht => hunit t (List.mem_cons_of_mem _ ht) + have hden : φ (movingPolynomialAncestors (path.map MovingSlotReversal.polynomial)).denominator ≠ 0 := by + apply movingPolynomialAncestors_denominator + intro t ht' + obtain ⟨u, hu, rfl⟩ := List.mem_map.mp ht' + exact (ht u hu).2.2 + change (((movingPolynomialAncestors (path.map MovingSlotReversal.polynomial)).movingReverse + s.left s.polynomial.v s.polynomial.w s.polynomial.u).normalized φ).eval _ _ = _ + rw [PolynomialGiantRows.normalized_movingReverse _ φ _ _ _ _ hden hs.1 hs.2.1 hs.2.2] + exact s.polynomial_step_integer value _ _ _ _ (ih hvalid.1 ht) hvalid.2 hs + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotRelabel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..66800a9abe1f1f63dbd89f83e713138eb8028029 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotRelabel.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingModularSpectator +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleSizes + +namespace OAI + +/-! # Relabelling repeated sampled slots by their equality-pattern classes -/ + +namespace Ostmann +open scoped Classical + +def MovingSlotReversal.map {σ τ : Type*} (f : σ → τ) (s : MovingSlotReversal σ) : + MovingSlotReversal τ where + left := s.left + rootFrequency := s.rootFrequency + leftFrequency := s.leftFrequency + rightFrequency := s.rightFrequency + leftSlots := s.leftSlots.map f + rightSlots := s.rightSlots.map f + compensationSlots := s.compensationSlots.map f + +def MovingSlotData.map {σ τ : Type*} (f : σ → τ) : + {n : ℕ} → MovingSlotData σ n → MovingSlotData τ n + | _, .leaf s regular => .leaf s (regular.map f) + | _, .node s CL CR u left right => + .node s (CL.map f) (CR.map f) (u.map f) (left.map f) (right.map f) + +@[simp] theorem MovingSlotData.frequency_map {σ τ : Type*} (f : σ → τ) + {n : ℕ} (T : MovingSlotData σ n) : (T.map f).frequency = T.frequency := by + cases T <;> rfl + +theorem MovingSlotData.frequencies_map {σ τ : Type*} (f : σ → τ) + (P : ℤ → Prop) {n : ℕ} (T : MovingSlotData σ n) : + (T.map f).Frequencies P ↔ T.Frequencies P := by + induction T with + | leaf => rfl + | node s CL CR u left right ihL ihR => + simp only [MovingSlotData.map, MovingSlotData.Frequencies, ihL, ihR] + +theorem MovingSlotData.size_map {σ τ : Type*} (f : σ → τ) + (d : ℕ) {n : ℕ} (T : MovingSlotData σ n) : (T.map f).SizeLE d ↔ T.SizeLE d := by + induction T with + | leaf => rfl + | node s CL CR u left right ihL ihR => + simp only [MovingSlotData.map, MovingSlotData.SizeLE, List.length_map, ihL, ihR] + +theorem MovingSlotData.levels_map {σ τ : Type*} (f : σ → τ) (tier : σ → ℕ) (tier' : τ → ℕ) + (htier : ∀ i, tier' (f i) = tier i) {n : ℕ} (T : MovingSlotData σ n) : + (T.map f).Levels tier' ↔ T.Levels tier := by + induction T with + | leaf => rfl + | node s CL CR u left right ihL ihR => + simp only [MovingSlotData.map, MovingSlotData.Levels, List.forall_mem_map, htier, ihL, ihR] + +theorem MovingSlotReversal.naturalProduct_map {σ τ : Type*} + (f : σ → τ) (value : τ → ℕ) (slots : List σ) : + naturalProduct value (slots.map f) = naturalProduct (value ∘ f) slots := by + simp only [naturalProduct, List.map_map] + +theorem MovingSlotReversal.modularPivot_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (q : ℕ) [Fact q.Prime] (s : MovingSlotReversal σ) (x y : ZMod q) : + (s.map f).modularPivot value q x y = s.modularPivot (value ∘ f) q x y := by + simp only [modularPivot, map, naturalProduct_map] + +theorem MovingSlotData.step_map {σ τ : Type*} (f : σ → τ) + {n : ℕ} (s : ℤ) (CL CR u : List σ) (left right : MovingSlotData σ n) (b : Bool) : + step s (CL.map f) (CR.map f) (u.map f) (left.map f) (right.map f) b = + (step s CL CR u left right b).map f := by + simp only [step, MovingSlotReversal.map, frequency_map] + +/-- Evaluation after identifying two labels is precisely evaluation at the +corresponding repeated prime value; no independence is asserted here. -/ +theorem movingModularSpectator_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (q : ℕ) [Fact q.Prime] (g : ZMod q → ℂ) (D : (ZMod q)ˣ) + {n : ℕ} (T : MovingSlotData σ n) (x y : ZMod q) : + movingModularSpectator value q g D (T.map f) x y = + movingModularSpectator (value ∘ f) q g D T x y := by + induction T generalizing x y with + | leaf => simp only [MovingSlotData.map, movingModularSpectator, MovingSlotReversal.naturalProduct_map] + | node s CL CR u left right ihL ihR => + simp only [MovingSlotData.map, movingModularSpectator, MovingSlotData.step_map, + MovingSlotReversal.modularPivot_map, ihL, ihR] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotSpectator.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotSpectator.lean new file mode 100644 index 0000000000000000000000000000000000000000..aeb0276389e34ff6ab5a443f2f5121f11329fe6e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotSpectator.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotSystem +import OAI.NumberTheory.Ostmann.Construction.SpectatorWeightFactorization + +namespace OAI + +/-! # Spectator factorization for the source moving-giant coefficient -/ + +namespace Ostmann +open scoped Classical + +def movingSlotModulus {σ : Type*} (value : σ → ℕ) (x : MovingSlotState σ) : ℕ := + match x with + | ⟨0, .leaf _ regular, XL, XR⟩ => XL * XR * MovingSlotReversal.naturalProduct value regular + | ⟨_ + 1, .node _ CL CR _ _ _, XL, XR⟩ => + XL * XR * MovingSlotReversal.naturalProduct value (CL ++ CR) + +noncomputable def movingSlotSpectator {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (g : ZMod q → ℂ) (D : (ZMod q)ˣ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → ℂ + | _, .leaf s regular, XL, XR => + g ((s : ZMod q) / ((D : ZMod q) * + ((XL * XR * MovingSlotReversal.naturalProduct value regular : ℕ) : ZMod q))) + | _, .node s CL CR u left right, XL, XR => + let p := (MovingSlotData.step s CL CR u left right false).naturalPivot value XL XR + if (p : ZMod q) = 0 then 0 else + movingSlotSpectator value g D left p XL * star (movingSlotSpectator value g D right p XR) + +/-- The full smooth/guarded coefficient factors by the actual spectator +history. All original cutoffs stay in the first factor. -/ +theorem movingSlotWeight_spectator {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (hextra : ∀ x s v w, extra x s v w ≠ 0 → + (historyPivot (movingSlotSystem value childBound pivotBound) x s v w : ZMod q) ≠ 0) + (g : ZMod q → ℂ) (D : (ZMod q)ˣ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (XL XR : ℕ) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => F x s * spectatorHistoryLeaf (movingSlotModulus value) g D x s) + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t = + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t * + movingSlotSpectator value g D T XL XR := by + let sys := movingSlotSystem value childBound pivotBound + let cutoff := movingSlotCutoff value childBound pivotBound extra + induction T generalizing XL XR with + | leaf s regular => + have hs : s = t := hT + simp only [recursiveTransferWeight, spectatorHistoryLeaf, movingSlotModulus, + movingSlotSpectator, hs] + | @node n s CL CR u left right ihL ihR => + let x : MovingSlotState σ := ⟨n + 1, .node s CL CR u left right, XL, XR⟩ + by_cases hw : recursiveTransferWeight sys F cutoff (n + 1) x t = 0 + · rw [recursiveTransferWeight_mul_leaf] + change recursiveTransferWeight sys F cutoff (n + 1) x t * _ = + recursiveTransferWeight sys F cutoff (n + 1) x t * _ + rw [hw, zero_mul, zero_mul] + · obtain ⟨P, hvalid, _, _⟩ := recursiveTransferWeight_nonzero_valid sys F cutoff _ x t hw + have hnode := recursiveTransferWeight_node sys F cutoff n x t P hvalid + have hcut : cutoff x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) ≠ 0 := by + intro hz + apply hw + rw [hnode, hz, Complex.ofReal_zero, zero_mul, zero_mul] + have hinfo : (0 < MovingSlotReversal.naturalProduct value u ∧ + MovingSlotReversal.naturalProduct value u ∣ P) ∧ + extra x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) ≠ 0 := by + change (if 0 < MovingSlotReversal.naturalProduct value u ∧ + MovingSlotReversal.naturalProduct value u ∣ historyPivot sys x t.1 + (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + then extra x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) else 0) ≠ 0 at hcut + rw [hvalid.historyPivot_eq] at hcut + split_ifs at hcut with hd + · exact ⟨hd, hcut⟩ + · exact False.elim (hcut rfl) + let p := P / MovingSlotReversal.naturalProduct value u + have hP : P = MovingSlotReversal.naturalProduct value u * p := + (Nat.mul_div_cancel' hinfo.1.2).symm + have hPq : (P : ZMod q) ≠ 0 := by + have h := hextra x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) hinfo.2 + rwa [hvalid.historyPivot_eq] at h + have hpq : (p : ZMod q) ≠ 0 := by + intro hp + apply hPq + rw [hP, Nat.cast_mul, hp, mul_zero] + have hrel : left.frequency * ((XR * MovingSlotReversal.naturalProduct value CR : ℕ) : ℤ) - + right.frequency * ((XL * MovingSlotReversal.naturalProduct value CL : ℕ) : ℤ) = + s * ((MovingSlotReversal.naturalProduct value u * p : ℕ) : ℤ) := by + simpa only [sys, movingSlotSystem, MovingSlotState.leftProduct, MovingSlotState.rightProduct, + x, ← hT.1, ← hT.2.1.root, ← hT.2.2.root, hP, Int.cast_natCast] using hvalid.relation + have hnat : (MovingSlotData.step s CL CR u left right false).naturalPivot value XL XR = p := by + unfold MovingSlotReversal.naturalPivot movingGiantPivot + simp only [MovingSlotData.step, Nat.mul_one] + rw [reconstructedPivot_of_eq _ _ (by simpa only [← hT.1] using hvalid.root_ne_zero) + (MovingSlotReversal.naturalProduct value u * p) hrel] + exact Nat.mul_div_cancel_left p hinfo.1.1 + rw [recursiveTransferWeight_node _ _ _ _ _ _ P hvalid, hnode] + change (cutoff x t.1 _ _ : ℂ) * + recursiveTransferWeight sys (fun x s => F x s * spectatorHistoryLeaf (movingSlotModulus value) g D x s) + cutoff n ⟨n, left, p, XL⟩ t.2.1 * + star (recursiveTransferWeight sys (fun x s => F x s * spectatorHistoryLeaf (movingSlotModulus value) g D x s) + cutoff n ⟨n, right, p, XR⟩ t.2.2) = + ((cutoff x t.1 _ _ : ℂ) * recursiveTransferWeight sys F cutoff n ⟨n, left, p, XL⟩ t.2.1 * + star (recursiveTransferWeight sys F cutoff n ⟨n, right, p, XR⟩ t.2.2)) * _ + rw [ihL t.2.1 hT.2.1 p XL, ihR t.2.2 hT.2.2 p XR] + rw [movingSlotSpectator, hnat, ite_eq_right hpq] + simp only [star_mul] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotStateRelabel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotStateRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d877f47927252c6e82274d5b5db7061dd18981d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotStateRelabel.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalGiantWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotRelabel + +namespace OAI + +/-! # Evaluating the original recursion in finite pattern coordinates -/ + +namespace Ostmann +open scoped Classical + +def MovingSlotState.map {σ τ : Type*} (f : σ → τ) (x : MovingSlotState σ) : + MovingSlotState τ := ⟨x.depth, x.data.map f, x.leftGiant, x.rightGiant⟩ + +@[simp] theorem MovingSlotState.map_depth {σ τ : Type*} (f : σ → τ) + (x : MovingSlotState σ) : (x.map f).depth = x.depth := rfl + +@[simp] theorem MovingSlotState.map_data {σ τ : Type*} (f : σ → τ) + (x : MovingSlotState σ) : (x.map f).data = x.data.map f := rfl + +@[simp] theorem MovingSlotState.map_leftGiant {σ τ : Type*} (f : σ → τ) + (x : MovingSlotState σ) : (x.map f).leftGiant = x.leftGiant := rfl + +@[simp] theorem MovingSlotState.map_rightGiant {σ τ : Type*} (f : σ → τ) + (x : MovingSlotState σ) : (x.map f).rightGiant = x.rightGiant := rfl + +@[simp] theorem MovingSlotState.leftProduct_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (x : MovingSlotState σ) : + (x.map f).leftProduct value = x.leftProduct (value ∘ f) := by + rcases x with ⟨n, T, XL, XR⟩ + cases T <;> simp only [MovingSlotState.map, MovingSlotData.map, + MovingSlotState.leftProduct, MovingSlotReversal.naturalProduct_map] + +@[simp] theorem MovingSlotState.rightProduct_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (x : MovingSlotState σ) : + (x.map f).rightProduct value = x.rightProduct (value ∘ f) := by + rcases x with ⟨n, T, XL, XR⟩ + cases T <;> simp only [MovingSlotState.map, MovingSlotData.map, + MovingSlotState.rightProduct, MovingSlotReversal.naturalProduct_map] + +@[simp] theorem MovingSlotState.compensation_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (x : MovingSlotState σ) : + (x.map f).compensation value = x.compensation (value ∘ f) := by + rcases x with ⟨n, T, XL, XR⟩ + cases T <;> simp only [MovingSlotState.map, MovingSlotData.map, + MovingSlotState.compensation, MovingSlotReversal.naturalProduct_map] + +@[simp] theorem MovingSlotState.child_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (b : Bool) (x : MovingSlotState σ) (P : ℕ) : + (x.map f).child value b P = (x.child (value ∘ f) b P).map f := by + rcases x with ⟨n, T, XL, XR⟩ + cases T <;> cases b <;> simp only [MovingSlotState.map, MovingSlotData.map, + MovingSlotState.child, MovingSlotReversal.naturalProduct_map, Bool.false_eq_true, + ite_true, ite_false] <;> rfl + +@[simp] theorem movingSlotSystem_leftState_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (childBound pivotBound : ℕ → ℕ) (x : MovingSlotState σ) (P : ℕ) : + (movingSlotSystem value childBound pivotBound).leftState (x.map f) P = + ((movingSlotSystem (value ∘ f) childBound pivotBound).leftState x P).map f := + MovingSlotState.child_map f value true x P + +@[simp] theorem movingSlotSystem_rightState_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (childBound pivotBound : ℕ → ℕ) (x : MovingSlotState σ) (P : ℕ) : + (movingSlotSystem value childBound pivotBound).rightState (x.map f) P = + ((movingSlotSystem (value ∘ f) childBound pivotBound).rightState x P).map f := + MovingSlotState.child_map f value false x P + +@[simp] theorem movingHistoryPivot_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (childBound pivotBound : ℕ → ℕ) (x : MovingSlotState σ) + (s v w : ℤ) : + historyPivot (movingSlotSystem value childBound pivotBound) (x.map f) s v w = + historyPivot (movingSlotSystem (value ∘ f) childBound pivotBound) x s v w := by + simp only [historyPivot, movingSlotSystem, MovingSlotState.leftProduct_map, + MovingSlotState.rightProduct_map] + +theorem movingValidTransferNode_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (childBound pivotBound : ℕ → ℕ) (x : MovingSlotState σ) + (s v w : ℤ) (P : ℕ) : + ValidTransferNode (movingSlotSystem value childBound pivotBound) (x.map f) s v w P ↔ + ValidTransferNode (movingSlotSystem (value ∘ f) childBound pivotBound) x s v w P := by + constructor <;> intro h + all_goals refine ⟨h.root_ne_zero, ?_, ?_, h.pivot_pos, h.pivot_bound, + h.left_bound, h.right_bound, ?_, h.pivot_unit⟩ + all_goals first + | simpa only [movingSlotSystem, MovingSlotState.rightProduct_map] using h.root_unit + | simpa only [movingSlotSystem, MovingSlotState.leftProduct_map, + MovingSlotState.rightProduct_map] using h.relation + | simpa only [movingSlotSystem, MovingSlotState.rightProduct_map, + MovingSlotState.map_depth] using h.range_gap + +/-- A relabeling evaluates every original pivot and guard, including the +integer division by the sampled compensation product. -/ +theorem movingRecursiveWeight_map {σ τ : Type*} (f : σ → τ) + (value : τ → ℕ) (childBound pivotBound : ℕ → ℕ) + (leaf : MovingSlotState τ → ℤ → ℂ) + (cutoff : MovingSlotState τ → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (x : MovingSlotState σ) (t : FrequencyTree ℤ n) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) leaf cutoff n (x.map f) t = + recursiveTransferWeight (movingSlotSystem (value ∘ f) childBound pivotBound) + (fun x => leaf (x.map f)) (fun x => cutoff (x.map f)) n x t := by + induction n generalizing x with + | zero => rfl + | succ n ih => + simp only [recursiveTransferWeight, movingHistoryPivot_map, movingValidTransferNode_map] + split_ifs + · simp only [movingSlotSystem_leftState_map, movingSlotSystem_rightState_map] + rw [ih, ih] + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotSystem.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotSystem.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d4d61ff6744114a8d7663be8678a390a63b74db --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSlotSystem.lean @@ -0,0 +1,171 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOccurrenceIntegrality +import OAI.NumberTheory.Ostmann.Construction.RecursiveTransferWeight + +namespace OAI + +/-! # The original recursive weight on moving-giant states + +A reconstructed pivot is the composite `u*p`; only its quotient `p` becomes +the new giant. The compensation primes remain in the regular child lists. +-/ + +namespace Ostmann +open scoped Classical + +structure MovingSlotState (σ : Type*) where + depth : ℕ + data : MovingSlotData σ depth + leftGiant : ℕ + rightGiant : ℕ + +def MovingSlotState.leftProduct {σ : Type*} (value : σ → ℕ) (x : MovingSlotState σ) : ℕ := + match x with + | ⟨0, .leaf _ _, _, _⟩ => 1 + | ⟨_ + 1, .node _ CL _ _ _ _, XL, _⟩ => XL * MovingSlotReversal.naturalProduct value CL + +def MovingSlotState.rightProduct {σ : Type*} (value : σ → ℕ) (x : MovingSlotState σ) : ℕ := + match x with + | ⟨0, .leaf _ _, _, _⟩ => 1 + | ⟨_ + 1, .node _ _ CR _ _ _, _, XR⟩ => XR * MovingSlotReversal.naturalProduct value CR + +def MovingSlotState.compensation {σ : Type*} (value : σ → ℕ) (x : MovingSlotState σ) : ℕ := + match x with + | ⟨0, .leaf _ _, _, _⟩ => 1 + | ⟨_ + 1, .node _ _ _ u _ _, _, _⟩ => MovingSlotReversal.naturalProduct value u + +def MovingSlotState.child {σ : Type*} (value : σ → ℕ) (left : Bool) + (x : MovingSlotState σ) (P : ℕ) : MovingSlotState σ := + match x with + | ⟨0, .leaf s regular, XL, XR⟩ => ⟨0, .leaf s regular, XL, XR⟩ + | ⟨n + 1, .node _ _ _ u L R, XL, XR⟩ => + ⟨n, if left then L else R, P / MovingSlotReversal.naturalProduct value u, + if left then XL else XR⟩ + +def movingSlotSystem {σ : Type*} (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) : + TransferHistorySystem (MovingSlotState σ) where + leftProduct := MovingSlotState.leftProduct value + rightProduct := MovingSlotState.rightProduct value + childBound x := childBound x.depth + pivotBound x := pivotBound x.depth + leftState := MovingSlotState.child value true + rightState := MovingSlotState.child value false + +/-- The extra support test is literal divisibility of the composite pivot by +its sampled compensation product. All smooth and other support factors stay +in `extra`. -/ +noncomputable def movingSlotCutoff {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (x : MovingSlotState σ) (s v w : ℤ) : ℝ := + if 0 < x.compensation value ∧ + x.compensation value ∣ historyPivot (movingSlotSystem value childBound pivotBound) x s v w + then extra x s v w else 0 + +def MovingSlotData.Follows {σ : Type*} : {n : ℕ} → + MovingSlotData σ n → FrequencyTree ℤ n → Prop + | _, .leaf s _, t => s = frequencyRoot 0 t + | _n + 1, .node s _ _ _ left right, t => + s = t.1 ∧ left.Follows t.2.1 ∧ right.Follows t.2.2 + +theorem MovingSlotData.Follows.root {σ : Type*} {n : ℕ} {T : MovingSlotData σ n} + {t : FrequencyTree ℤ n} (h : T.Follows t) : T.frequency = frequencyRoot n t := by + cases T with + | leaf => exact h + | node => exact h.1 + +theorem buildMovingSlotData_follows {σ : Type*} (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (samples : MovingSampleSlots σ n) : + (buildMovingSlotData n t small bulk samples).Follows t := by + induction samples with + | leaf => rfl + | node samples left right ihL ihR => exact ⟨rfl, ihL _ _ _, ihR _ _ _⟩ + +/-- Nonzero original recursive coefficients force exactly the integral support +of the concrete moving-giant sampler. This does not assign any prime law to +its reconstructed integer pivot. -/ +theorem movingSlotWeight_nonzero_integral {σ : Type*} + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (leaf : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (XL XR : ℕ) + (hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) leaf + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t ≠ 0) : + T.Integral value XL XR := by + let sys := movingSlotSystem value childBound pivotBound + let cutoff := movingSlotCutoff value childBound pivotBound extra + induction T generalizing XL XR with + | leaf s regular => trivial + | @node n s CL CR u left right ihL ihR => + let x : MovingSlotState σ := ⟨n + 1, .node s CL CR u left right, XL, XR⟩ + let P := historyPivot sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + have hvalid : ValidTransferNode sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) P := by + by_contra h + apply hw + change recursiveTransferWeight sys leaf cutoff (n + 1) x t = 0 + simp only [recursiveTransferWeight, P, h, ite_false] + have hnode := recursiveTransferWeight_node sys leaf cutoff n x t P hvalid + have hcut : cutoff x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) ≠ 0 := by + intro h + apply hw + rw [hnode, h, Complex.ofReal_zero, zero_mul, zero_mul] + have hdiv : 0 < MovingSlotReversal.naturalProduct value u ∧ + MovingSlotReversal.naturalProduct value u ∣ P := by + by_contra h + apply hcut + change (if 0 < MovingSlotReversal.naturalProduct value u ∧ + MovingSlotReversal.naturalProduct value u ∣ P then _ else 0) = 0 + exact ite_eq_right h + let p := P / MovingSlotReversal.naturalProduct value u + have hP : P = MovingSlotReversal.naturalProduct value u * p := by + exact (Nat.mul_div_cancel' hdiv.2).symm + have hp : 0 < p := by + by_contra hp + have hz : p = 0 := Nat.eq_zero_of_not_pos hp + have := hvalid.pivot_pos + rw [hP, hz, Nat.mul_zero] at this + omega + have hL : recursiveTransferWeight sys leaf cutoff n + ⟨n, left, p, XL⟩ t.2.1 ≠ 0 := by + intro h + apply hw + rw [hnode] + change (cutoff x t.1 _ _ : ℂ) * + recursiveTransferWeight sys leaf cutoff n ⟨n, left, p, XL⟩ t.2.1 * _ = 0 + rw [h, mul_zero, zero_mul] + have hR : recursiveTransferWeight sys leaf cutoff n + ⟨n, right, p, XR⟩ t.2.2 ≠ 0 := by + intro h + apply hw + rw [hnode] + change _ * star (recursiveTransferWeight sys leaf cutoff n ⟨n, right, p, XR⟩ t.2.2) = 0 + rw [h, star_zero, mul_zero] + have hrel : left.frequency * ((XR * MovingSlotReversal.naturalProduct value CR : ℕ) : ℤ) - + right.frequency * ((XL * MovingSlotReversal.naturalProduct value CL : ℕ) : ℤ) = + s * ((MovingSlotReversal.naturalProduct value u * p : ℕ) : ℤ) := by + simpa only [sys, movingSlotSystem, MovingSlotState.leftProduct, MovingSlotState.rightProduct, + x, ← hT.1, ← hT.2.1.root, ← hT.2.2.root, hP, Int.cast_natCast] using hvalid.relation + have hnat : (MovingSlotData.step s CL CR u left right false).naturalPivot value XL XR = p := by + unfold MovingSlotReversal.naturalPivot movingGiantPivot + simp only [MovingSlotData.step, Nat.mul_one] + rw [reconstructedPivot_of_eq _ _ (by simpa only [← hT.1] using hvalid.root_ne_zero) + (MovingSlotReversal.naturalProduct value u * p) hrel] + exact Nat.mul_div_cancel_left p hdiv.1 + change (_ ∧ _ ∧ _) + refine ⟨?_, ?_, ?_⟩ + · change 0 < (MovingSlotData.step s CL CR u left right false).naturalPivot value XL XR ∧ _ + constructor + · exact hnat.symm ▸ hp + · change left.frequency * ((XR * MovingSlotReversal.naturalProduct value CR : ℕ) : ℤ) - + right.frequency * ((XL * MovingSlotReversal.naturalProduct value CL : ℕ) : ℤ) = + s * ((MovingSlotReversal.naturalProduct value u * + (MovingSlotData.step s CL CR u left right false).naturalPivot value XL XR : ℕ) : ℤ) + rw [hnat] + exact hrel + · rw [hnat] + exact ihL t.2.1 hT.2.1 p XL hL + · rw [hnat] + exact ihR t.2.2 hT.2.2 p XR hR + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmallFrequencyUnits.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmallFrequencyUnits.lean new file mode 100644 index 0000000000000000000000000000000000000000..318471d84c08abf32981ce3bdf8319e79e25c7e3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmallFrequencyUnits.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullSupport + +namespace OAI + +/-! # The small-prime frequency tests follow from the actual range separation -/ + +namespace Ostmann + +theorem MovingSlotData.Frequencies.mono {σ : Type*} {P Q : ℤ → Prop} + {n : ℕ} {T : MovingSlotData σ n} (h : T.Frequencies P) (hPQ : ∀ s, P s → Q s) : + T.Frequencies Q := by + induction T with + | leaf => exact hPQ _ h + | node s CL CR U left right ihL ihR => exact ⟨hPQ s h.1, ihL h.2.1, ihR h.2.2⟩ + +theorem small_prime_frequency_unit (p : ℕ) (hp : p.Prime) (s : ℤ) + (hs : s ≠ 0) (hsp : s.natAbs < p) : IsCoprime s (p : ℤ) := by + rw [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast] + exact (hp.coprime_iff_not_dvd.mpr + (Nat.not_dvd_of_pos_of_lt (Int.natAbs_pos.mpr hs) hsp)).symm + +theorem MovingSlotData.small_frequency_units {σ : Type*} (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (V : ℕ) (hlarge : ∀ i, V < value i) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (hV : T.Frequencies (fun s => s.natAbs ≤ V)) : + ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ)) := by + intro i + induction T with + | leaf s regular => exact small_prime_frequency_unit (value i) (hprime i) s hf (hV.trans_lt (hlarge i)) + | node s CL CR U left right ihL ihR => + exact ⟨small_prime_frequency_unit (value i) (hprime i) s hf.1 (hV.1.trans_lt (hlarge i)), + ihL hf.2.1 hV.2.1, ihR hf.2.2 hV.2.2⟩ + +theorem MovingSlotData.small_frequency_residues {σ : Type*} (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (V : ℕ) (hlarge : ∀ i, V < value i) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (hV : T.Frequencies (fun s => s.natAbs ≤ V)) : + ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0) := by + intro i + let : Fact (value i).Prime := ⟨hprime i⟩ + apply (T.small_frequency_units value hprime V hlarge hf hV i).mono + intro s hs + have hu : IsUnit (s : ZMod (value i)) := by + apply isCoprime_zero_right.mp + simpa only [Int.cast_natCast, ZMod.natCast_self] using hs.intCast (R := ZMod (value i)) + exact hu.ne_zero + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmallProductLower.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmallProductLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..35cba4bda0c9afe3bcd2f3dbee5cc1b1a2e35a74 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmallProductLower.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredLogProduct + +namespace OAI + +/-! # Retaining the actual small-cell contribution to the regular modulus -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTemplate_small_product_lower {A : Type*} (value : A → ℕ) + (n r m : ℕ) (y : MovingRegularSlot n r m → A) + (lower : TreeLeafIndex n × Fin r → ℝ) + (hlower : ∀ j, Real.exp (lower j) ≤ (value (y (j.1, .inl j.2)) : ℝ)) : + Real.exp (∑ j, lower j) ≤ + ((∏ j : TreeLeafIndex n × Fin r, value (y (j.1, .inl j.2)) : ℕ) : ℝ) := by + rw [Real.exp_sum, Nat.cast_prod] + exact Finset.prod_le_prod₀ (fun j _ => Real.exp_nonneg _) (fun j _ => hlower j) + +theorem movingTemplateCoefficient_restored_bulk_product_lower {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (hvalue : ∀ a, 0 < value a) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (y : MovingRegularSlot n r m → σ) (hn : n < k) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (XL XR : ℕ) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n (4 + r) m s (movingRestoreSample n r m u y) XL XR ≠ 0) : + Real.exp ((2 ^ n : ℕ) * (cb - 1)) ≤ + ((∏ j : TreeLeafIndex n × Fin m, value (y (j.1, .inr j.2)) : ℕ) : ℝ) := by + have hut i : tier (u i) = n := + hμ n (u i) ((Finset.prod_ne_zero_iff.mp hu) i (Finset.mem_univ i)) + have hs : ∀ j : TreeLeafIndex n × Fin (4 + r), + tier (movingRestoreSample n r m u y (j.1, .inl j.2)) ≠ k := by + rintro ⟨j, i⟩ + refine Fin.addCases (fun i => ?_) (fun i => ?_) i + · dsimp only + rw [movingRestoreSample_compensation n r m u y (j, i), hut] + exact hn.ne + · dsimp only + rw [movingRestoreSample_small] + exact hsmall (j, i) + have hb : ∀ j : TreeLeafIndex n × Fin m, + tier (movingRestoreSample n r m u y (j.1, .inr j.2)) = k := by + intro j + change tier (movingRestoreSample n r m u y (movingTemplateBulk n (4 + r) m j)) = k + rw [movingRestoreSample_bulk] + exact hbulk j + have hlow := movingTemplateCoefficient_bulk_log_product_lower value tier hvalue k outside cb cd + μ hμ childBound pivotBound V F φ G n (4 + r) m s (movingRestoreSample n r m u y) + hn.le hs hb XL XR h + convert hlow using 1 + congr 2 + +theorem movingTemplateCoefficient_restored_full_product_lower {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (hvalue : ∀ a, 0 < value a) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (y : MovingRegularSlot n r m → σ) (hn : n < k) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (lower : TreeLeafIndex n × Fin r → ℝ) + (hlower : ∀ j, Real.exp (lower j) ≤ (value (y (j.1, .inl j.2)) : ℝ)) + (XL XR : ℕ) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n (4 + r) m s (movingRestoreSample n r m u y) XL XR ≠ 0) : + Real.exp ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1)) ≤ ((∏ i, value (y i) : ℕ) : ℝ) := by + have hs := movingTemplate_small_product_lower value n r m y lower hlower + have hb := movingTemplateCoefficient_restored_bulk_product_lower value tier hvalue k outside cb cd + μ hμ childBound pivotBound V F φ G n r m s u hu y hn hsmall hbulk XL XR h + rw [Real.exp_add] + convert mul_le_mul hs hb (Real.exp_nonneg _) (Nat.cast_nonneg _) using 1 + rw [← Nat.cast_mul] + congr 1 + simp only [MovingRegularSlot, Fintype.prod_prod_type, Fintype.prod_sum_type, + Finset.prod_mul_distrib] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmoothPolynomials.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmoothPolynomials.lean new file mode 100644 index 0000000000000000000000000000000000000000..c05e62fa71a791af1118c393a5a44c20b2d93da8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmoothPolynomials.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNodeCutoffFactor +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFourierBudget + +namespace OAI + +/-! # One polynomial family for all node cutoffs and Fourier leaves -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingSmoothPolynomialFactors {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) + (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) : + Fin (2 ^ n + (T.nodeCutoffPolynomials value L R).length) → ClippedPolynomialFactor := + Fin.append (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi) + (movingNodeCutoffFactors value T L R φ G B D hB hD hφ hlip) + +theorem movingSmoothPolynomialFactors_value {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) + (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (z : ℝ) : + smoothPolynomialWeight (movingSmoothPolynomialFactors value T L R ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip) z = + smoothPolynomialWeight (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi) z * + movingRealNodeCutoff value φ G T (L.eval z) (R.eval z) := by + simp only [smoothPolynomialWeight, movingSmoothPolynomialFactors, Fin.prod_univ_add, + Fin.append_left, Fin.append_right] + exact congrArg (_ * ·) (movingNodeCutoffFactors_value value T L R φ G B D hB hD hφ hlip hout z) + +theorem movingSmoothPolynomialFactors_budget {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : T.Frequencies (fun s => |(s : ℝ)| ≤ V)) (φ : ℝ → ℝ) + (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) : + smoothPolynomialBudget (movingSmoothPolynomialFactors value T L R ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip) ≤ + movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1) := by + have he : smoothPolynomialBudget (movingSmoothPolynomialFactors value T L R ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip) = + smoothPolynomialBudget (movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi) * + smoothPolynomialBudget (movingNodeCutoffFactors value T L R φ G B D hB hD hφ hlip) := by + simp only [smoothPolynomialBudget, movingSmoothPolynomialFactors, Fin.prod_univ_add, + Fin.append_left, Fin.append_right] + rw [he, movingNodeCutoffFactors_budget] + apply mul_le_mul_of_nonneg_right + (movingFourierPolynomialFactors_budget value T L R ψ X lo hi V hlo hhi hV) + have he2 : 0 ≤ Real.exp (2 : ℝ) - 1 := sub_nonneg.mpr (Real.one_le_exp (by norm_num)) + positivity + +/-- The complete smooth family uses only the Fourier leaves' derivative +roots. Logarithmic node cutoffs add no cuts and no large-center factor. -/ +theorem movingSmoothPolynomialFactors_variation {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hL : L.natDegree ≤ 1) (hR : R.natDegree ≤ 1) + (hV : T.Frequencies (fun s => |(s : ℝ)| ≤ V)) (φ : ℝ → ℝ) + (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) : + ∃ S : Finset ℝ, S.card ≤ 2 ^ n ∧ ∀ (u : ℕ → ℝ), Monotone u → ∀ N : ℕ, + rootCellCode S (u 0) = rootCellCode S (u (N - 1)) → + discreteVariation (fun j => smoothPolynomialWeight + (movingSmoothPolynomialFactors value T L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) (u j)) N ≤ + movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1) := by + let F := movingFourierPolynomialFactors value T L R ψ X lo hi hlo hhi + let H := movingSmoothPolynomialFactors value T L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + let S := polynomialRootCuts (fun i => (F i).polynomial.derivative) + have hdeg (i : Fin (2 ^ n)) : (F i).polynomial.derivative.natDegree ≤ 1 := by + have h := movingFourierPolynomialFactors_degree value T L R ψ X lo hi hlo hhi hL hR i + change (F i).polynomial.natDegree ≤ 2 at h + exact (Polynomial.natDegree_derivative_le _).trans (by omega) + refine ⟨S, ?_, ?_⟩ + · exact (polynomialRootCuts_card _).trans (by + calc + _ ≤ ∑ _i : Fin (2 ^ n), 1 := Finset.sum_le_sum (fun i _ => hdeg i) + _ = _ := by simp) + · intro u hu N hcode + apply (smoothPolynomialWeight_variation H S ?_ u hu N hcode).trans + (movingSmoothPolynomialFactors_budget value T L R ψ X lo hi V hlo hhi hV φ G B D hB hD hφ hlip) + intro i r hr + revert hr + refine Fin.addCases ?_ ?_ i + · intro j + simp only [H, movingSmoothPolynomialFactors, Fin.append_left] + change r ∈ (F j).polynomial.derivative.roots → r ∈ S + intro h + exact Finset.mem_biUnion.mpr ⟨j, Finset.mem_univ _, Multiset.mem_toFinset.mpr h⟩ + · intro j + simp only [H, movingSmoothPolynomialFactors, Fin.append_right] + change r ∈ (movingNodeCutoffFactors value T L R φ G B D hB hD hφ hlip j).polynomial.derivative.roots → r ∈ S + rw [movingNodeCutoffFactors_no_derivative_roots value T L R hL hR φ G B D hB hD hφ hlip j] + simp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmoothPrimeComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmoothPrimeComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..f37dd81f5b184ceeacbf78b86318308c66a8f5b8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSmoothPrimeComparison.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SmoothPrimeComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSmoothPolynomials + +namespace OAI + +/-! # Published prime comparison for the full moving smooth factor -/ + +namespace Ostmann +open MeasureTheory +open scoped SchwartzMap + +/-- The actual moving Fourier leaves and all logarithmic node cutoffs have +one uniform prime-to-Page comparison. The cut set has at most one derivative +root per leaf; the error contains no mesh count and no node-center factor. -/ +theorem moving_smooth_prime_comparison {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hL : L.natDegree ≤ 1) (hR : R.natDegree ≤ 1) + (hV : T.Frequencies (fun s => |(s : ℝ)| ≤ V)) (φ : ℝ → ℝ) + (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) : + ∃ S : Finset ℝ, S.card ≤ 2 ^ n ∧ + ∀ (P : PublishedProgressionInput) (Q q a : ℕ), + 2 ≤ Q → 1 ≤ q → q ≤ Q → a.Coprime q → + ∀ u v : ℝ, 1 ≤ u → u ≤ v → v ≤ u + 1 → + rootCellCode S (Real.exp u) = rootCellCode S (Real.exp v) → + ‖complexPrimeInterval q a u v (fun y => smoothPolynomialWeight + (movingSmoothPolynomialFactors value T L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (Real.exp y)) - + ∫ y in Set.Ioc u v, smoothPolynomialWeight + (movingSmoothPolynomialFactors value T L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) + (Real.exp y) * (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + (movingFourierVariationBudget ψ V lo hi n * + (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt u) + + Real.exp (-P.kappa * u / Real.log (4 * (Q : ℝ)))) := by + obtain ⟨S, hcard, hvar⟩ := movingSmoothPolynomialFactors_variation value T L R ψ X lo hi V + hlo hhi hL hR hV φ G B D hB hD hφ hlip + refine ⟨S, hcard, ?_⟩ + intro P Q q a hQ hq hqQ ha u v hu huv hshort hcode + apply P.continuous_prime_comparison hQ hq hqQ ha u v hu huv hshort _ + ((continuous_smoothPolynomialWeight _).comp Real.continuous_exp).continuousOn + intro s hs N hs0 hsN + apply hvar (fun j => Real.exp (s j)) (Real.exp_monotone.comp hs) N + have hlo' : Real.exp u ≤ Real.exp (s (N - 1)) := by + rw [← hs0] + exact Real.exp_le_exp.mpr (hs (Nat.zero_le _)) + have hhi' : Real.exp (s (N - 1)) ≤ Real.exp v := by + rw [← hsN] + exact Real.exp_le_exp.mpr (hs (Nat.sub_le _ _)) + rw [hs0] + exact (rootCellCode_convex S hlo' hhi' hcode).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorCells.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..f71e278e70c2fb9ac381ebf9cf196475b0745233 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorCells.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCongruence +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedCells +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticPrimeComparison + +namespace OAI + +/-! # The original spectator product inside the prime-cell comparison -/ + +namespace Ostmann +open scoped Classical BigOperators +open MeasureTheory + +theorem movingSpectatorProduct_modEq {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (M XL XR YL : ℕ) + (hM : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hX : T.Integral value XL XR) (hY : T.Integral value YL XR) + (hres : (XL : ℤ) ≡ (YL : ℤ) [ZMOD M]) : + (∏ i ∈ S, movingSlotSpectator value (g i) (D i) T XL XR) = + ∏ i ∈ S, movingSlotSpectator value (g i) (D i) T YL XR := by + apply Finset.prod_congr rfl + intro i hi + exact movingSlotSpectator_modEq value hvalue (g i) (D i) T hf XL XR YL XR hX hY + (hres.of_dvd (hM i hi)) (Int.ModEq.refl _) + +theorem movingSpectatorProduct_norm {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (B : I → ℝ) (hB : ∀ i ∈ S, 0 ≤ B i) + (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : + ‖∏ i ∈ S, movingSlotSpectator value (g i) (D i) T XL XR‖ ≤ + ∏ i ∈ S, B i ^ (2 ^ n) := by + rw [norm_prod] + apply Finset.prod_le_prod₀ + · intro i hi + exact norm_nonneg _ + · intro i hi + exact movingSlotSpectator_norm value (g i) (D i) (B i) (hB i hi) (hg i hi) T XL XR + +/-- This is the literal moving spectator recursion under the original +arithmetic indicator. Its residue constancy is proved above; it is not an +extra input to the prime comparison. -/ +theorem PublishedProgressionInput.moving_spectator_prime_comparison + (P : PublishedProgressionInput) {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (B : I → ℝ) (hB : ∀ i ∈ S, 0 ≤ B i) (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M Q : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hQ : 2 ≤ Q) (hq : 1 ≤ M) (hqQ : M ≤ Q) (ha : a.Coprime M) + (u v : ℝ) (hu : 1 ≤ u) (huv : u ≤ v) (hshort : v ≤ u + 1) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) : + ∃ (s : ℕ → ℝ) (N : ℕ) (d : ℕ → ℂ), + Monotone s ∧ s 0 = u ∧ s N = v ∧ + N ≤ (movingTopRootCuts value hvalue childBound pivotBound T hf XR).card + + (∑ i, (F i).polynomial.derivative.natDegree) + 1 ∧ + (∀ j, ‖d j‖ ≤ ∏ i ∈ S, B i ^ (2 ^ n)) ∧ + ‖complexPrimeInterval M a u v (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + ∏ i ∈ S, movingSlotSpectator value (g i) (D i) T ⌊Real.exp y⌋₊ XR) * + smoothPolynomialWeight F (Real.exp y)) - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + d j * smoothPolynomialWeight F (Real.exp y) * + (selectedPrimeLogDensity P Q M a y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, + (‖d j‖ * smoothPolynomialBudget F * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ)))) + + 2 * (∏ i ∈ S, B i ^ (2 ^ n)) * smoothPolynomialBudget F * Real.exp (-(s j))) := by + let roots := movingPrimeRootCuts value hvalue childBound pivotBound T hf XR F + have hS : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ roots := + Finset.subset_union_left + have hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ roots := by + intro i r hr + exact Finset.mem_union_right _ (Finset.mem_biUnion.mpr + ⟨i, Finset.mem_univ _, Multiset.mem_toFinset.mpr hr⟩) + have hprod : 0 ≤ ∏ i ∈ S, B i ^ (2 ^ n) := by + apply Finset.prod_nonneg + intro i hi + exact pow_nonneg (hB i hi) _ + obtain ⟨s, N, d, hs, hs0, hsN, hN, hd, herr⟩ := P.moving_supported_prime_comparison + value hvalue childBound pivotBound T hf XR a M Q hM hQ hq hqQ ha u v hu huv hshort + F roots hS hroots (fun XL => ∏ i ∈ S, movingSlotSpectator value (g i) (D i) T XL XR) + (∏ i ∈ S, B i ^ (2 ^ n)) hprod + (fun XL _ => movingSpectatorProduct_norm q value g D S B hB hg T XL XR) + (fun XL YL hX hY hres _ => movingSpectatorProduct_modEq q value hvalue g D S T hf + M XL XR YL hMq (hX.integral value hvalue childBound pivotBound T XL XR) + (hY.integral value hvalue childBound pivotBound T YL XR) hres) + exact ⟨s, N, d, hs, hs0, hsN, hN.trans + (Nat.add_le_add_right (movingPrimeRootCuts_card value hvalue childBound pivotBound T hf XR F) 1), + hd, herr⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorCongruence.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorCongruence.lean new file mode 100644 index 0000000000000000000000000000000000000000..908c8687a31eca89c393fa44786dff8589d910a2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorCongruence.lean @@ -0,0 +1,153 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSlotSpectator +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPeriodBound + +namespace OAI + +/-! # Residue constancy of the actual moving spectator recursion + +The extra denominator clears the integer divisions along both children. +No coprimality between a spectator prime and a node frequency is required. +-/ + +namespace Ostmann +open scoped Classical + +def movingSpectatorDenominator {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℤ + | _, .leaf _ _ => 1 + | _, .node s _ _ U left right => + s * (MovingSlotReversal.naturalProduct value U : ℤ) * + movingSpectatorDenominator value left * movingSpectatorDenominator value right + +theorem movingSpectatorDenominator_ne_zero {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) : movingSpectatorDenominator value T ≠ 0 := by + induction T with + | leaf => exact one_ne_zero + | node s CL CR U left right ihL ihR => + exact mul_ne_zero (mul_ne_zero (mul_ne_zero hf.1 + (Nat.cast_ne_zero.mpr (MovingSlotReversal.naturalProduct_ne_zero value hvalue U))) + (ihL hf.2.1)) (ihR hf.2.2) + +/-- Exact division by the node denominator loses that factor of the input +period. Both pivots are the original integer pivots. -/ +theorem MovingSlotReversal.pivot_modEq {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (s : MovingSlotReversal σ) + (hs : s.rootFrequency ≠ 0) (XL XR YL YR : ℕ) (m : ℤ) + (hX : s.IntegralAt value (XL, XR)) (hY : s.IntegralAt value (YL, YR)) + (hL : (XL : ℤ) ≡ (YL : ℤ) [ZMOD + s.rootFrequency * (naturalProduct value s.compensationSlots : ℤ) * m]) + (hR : (XR : ℤ) ≡ (YR : ℤ) [ZMOD + s.rootFrequency * (naturalProduct value s.compensationSlots : ℤ) * m]) : + (s.naturalPivot value XL XR : ℤ) ≡ (s.naturalPivot value YL YR : ℤ) [ZMOD m] := by + have h := ((hR.mul_right (naturalProduct value s.rightSlots)).mul_left s.leftFrequency).sub + ((hL.mul_right (naturalProduct value s.leftSlots)).mul_left s.rightFrequency) + have hx := hX.2 + have hy := hY.2 + simp only [Nat.cast_mul] at hx hy + rw [hx, hy] at h + simp only [← mul_assoc] at h + exact Int.ModEq.mul_left_cancel' + (mul_ne_zero hs (Nat.cast_ne_zero.mpr (naturalProduct_ne_zero value hvalue _))) h + +/-- On integral histories, the full spectator function is constant on the +cleared top residue class, including its zero-at-nonunit convention. -/ +theorem movingSlotSpectator_modEq {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (g : ZMod q → ℂ) (D : (ZMod q)ˣ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (XL XR YL YR : ℕ) + (hX : T.Integral value XL XR) (hY : T.Integral value YL YR) + (hL : (XL : ℤ) ≡ (YL : ℤ) [ZMOD (q : ℤ) * movingSpectatorDenominator value T]) + (hR : (XR : ℤ) ≡ (YR : ℤ) [ZMOD (q : ℤ) * movingSpectatorDenominator value T]) : + movingSlotSpectator value g D T XL XR = movingSlotSpectator value g D T YL YR := by + induction T generalizing XL XR YL YR with + | leaf s regular => + simp only [movingSpectatorDenominator, mul_one] at hL hR + have hl : (XL : ZMod q) = (YL : ZMod q) := by + exact_mod_cast (ZMod.intCast_eq_intCast_iff _ _ q).mpr hL + have hr : (XR : ZMod q) = (YR : ZMod q) := by + exact_mod_cast (ZMod.intCast_eq_intCast_iff _ _ q).mpr hR + simp only [movingSlotSpectator, Nat.cast_mul, hl, hr] + | node s CL CR U left right ihL ihR => + let c : ℤ := s * (MovingSlotReversal.naturalProduct value U : ℤ) + let dl := movingSpectatorDenominator value left + let dr := movingSpectatorDenominator value right + let step := MovingSlotData.step s CL CR U left right false + let p := step.naturalPivot value XL XR + let r := step.naturalPivot value YL YR + have hL' : (XL : ℤ) ≡ (YL : ℤ) [ZMOD c * ((q : ℤ) * dl * dr)] := by + convert hL using 1 + dsimp [c, dl, dr, movingSpectatorDenominator] + ring + have hR' : (XR : ℤ) ≡ (YR : ℤ) [ZMOD c * ((q : ℤ) * dl * dr)] := by + convert hR using 1 + dsimp [c, dl, dr, movingSpectatorDenominator] + ring + have hp : (p : ℤ) ≡ (r : ℤ) [ZMOD (q : ℤ) * dl * dr] := + step.pivot_modEq value hvalue hf.1 XL XR YL YR _ hX.1 hY.1 hL' hR' + have hpq : (p : ZMod q) = (r : ZMod q) := by + have hp' := hp.of_dvd (show (q : ℤ) ∣ (q : ℤ) * dl * dr from + ⟨dl * dr, by ring⟩) + exact_mod_cast (ZMod.intCast_eq_intCast_iff _ _ q).mpr hp' + have hpl : (p : ℤ) ≡ (r : ℤ) [ZMOD (q : ℤ) * dl] := + hp.of_dvd ⟨dr, rfl⟩ + have hpr : (p : ℤ) ≡ (r : ℤ) [ZMOD (q : ℤ) * dr] := + hp.of_dvd ⟨dl, by ring⟩ + have hll : (XL : ℤ) ≡ (YL : ℤ) [ZMOD (q : ℤ) * dl] := + hL'.of_dvd ⟨c * dr, by ring⟩ + have hrr : (XR : ℤ) ≡ (YR : ℤ) [ZMOD (q : ℤ) * dr] := + hR'.of_dvd ⟨c * dl, by ring⟩ + have hl := ihL hf.2.1 p XL r YL hX.2.1 hY.2.1 hpl hll + have hr := ihR hf.2.2 p XR r YR hX.2.2 hY.2.2 hpr hrr + change (if (p : ZMod q) = 0 then 0 else + movingSlotSpectator value g D left p XL * star (movingSlotSpectator value g D right p XR)) = + (if (r : ZMod q) = 0 then 0 else + movingSlotSpectator value g D left r YL * star (movingSlotSpectator value g D right r YR)) + rw [hpq, hl, hr] + +/-- The extra modulus has only one frequency and one compensation product +per internal node. Bulk-list lengths do not enter it. -/ +theorem movingSpectatorDenominator_bound {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (B : ℕ) + (hf : T.Frequencies (fun s => s.natAbs ≤ B)) + (hU : T.CompensationBound value B) : + (movingSpectatorDenominator value T).natAbs ≤ B ^ (2 * (2 ^ n - 1)) := by + induction T with + | leaf => simp [movingSpectatorDenominator] + | @node n s CL CR U left right ihL ihR => + have he : 2 + (2 * (2 ^ n - 1) + 2 * (2 ^ n - 1)) = 2 * (2 ^ (n + 1) - 1) := by + have hp : 1 ≤ 2 ^ n := Nat.one_le_pow _ _ (by omega) + rw [pow_succ] + omega + simp only [movingSpectatorDenominator, Int.natAbs_mul, Int.natAbs_natCast] + calc + _ ≤ B * B * B ^ (2 * (2 ^ n - 1)) * B ^ (2 * (2 ^ n - 1)) := + Nat.mul_le_mul (Nat.mul_le_mul (Nat.mul_le_mul hf.1 hU.1) + (ihL hf.2.1 hU.2.1)) (ihR hf.2.2 hU.2.2) + _ = B ^ (2 + (2 * (2 ^ n - 1) + 2 * (2 ^ n - 1))) := by + simp only [pow_add, pow_two] + ring + _ = _ := congrArg (B ^ ·) he + +theorem movingSlotSpectator_norm {σ : Type*} {q : ℕ} [Fact q.Prime] + (value : σ → ℕ) (g : ZMod q → ℂ) (D : (ZMod q)ˣ) + (B : ℝ) (hB : 0 ≤ B) (hg : ∀ z, ‖g z‖ ≤ B) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : + ‖movingSlotSpectator value g D T XL XR‖ ≤ B ^ (2 ^ n) := by + induction T generalizing XL XR with + | leaf s regular => simpa only [movingSlotSpectator, pow_zero, pow_one] using hg _ + | @node n s CL CR U left right ihL ihR => + rw [movingSlotSpectator] + split_ifs + · simp only [norm_zero] + exact pow_nonneg hB _ + · rw [norm_mul, norm_star] + calc + _ ≤ B ^ (2 ^ n) * B ^ (2 ^ n) := + mul_le_mul (ihL _ _) (ihR _ _) (norm_nonneg _) (pow_nonneg hB _) + _ = B ^ (2 ^ (n + 1)) := by rw [← pow_add, pow_succ]; congr 1; omega + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorCost.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorCost.lean new file mode 100644 index 0000000000000000000000000000000000000000..8bd3c161705eadd8c57c441c35db40322220a287 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorCost.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSpectatorGain +import OAI.NumberTheory.Ostmann.Arithmetic.FrozenSupportedArithmetic + +namespace OAI + +/-! # Pointwise cost of the actual normalized spectator transforms -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem normalizedResidueTransform_norm_le_sqrt {p : ℕ} [NeZero p] + (S : Finset (ZMod p)) (hS : S.Nonempty) (hSp : S.card < p) (x : ZMod p) : + ‖normalizedResidueTransform S x‖ ≤ Real.sqrt (p : ℝ) := by + have hx : ‖normalizedResidueTransform S x‖ ^ 2 ≤ + ∑ y : ZMod p, ‖normalizedResidueTransform S y‖ ^ 2 := + Finset.single_le_sum (f := fun y : ZMod p => ‖normalizedResidueTransform S y‖ ^ 2) + (fun y _ => sq_nonneg _) (Finset.mem_univ x) + rw [normalizedResidueTransform_energy S hS hSp] at hx + nlinarith [Real.sq_sqrt (Nat.cast_nonneg p : (0 : ℝ) ≤ p), + Real.sqrt_nonneg (p : ℝ), norm_nonneg (normalizedResidueTransform S x)] + +theorem normalizedResidueTransform_norm_le_prime {p : ℕ} [NeZero p] + (S : Finset (ZMod p)) (hS : S.Nonempty) (hSp : S.card < p) (x : ZMod p) : + ‖normalizedResidueTransform S x‖ ≤ p := by + apply (normalizedResidueTransform_norm_le_sqrt S hS hSp x).trans + have hp : (1 : ℝ) ≤ p := by exact_mod_cast Nat.one_le_iff_ne_zero.mpr (NeZero.ne p) + nlinarith [Real.sq_sqrt (Nat.cast_nonneg p : (0 : ℝ) ≤ p), Real.sqrt_nonneg (p : ℝ)] + +/-- A common prime upper bound controls all actual pointwise spectator +factors. This cost is retained in the cell error, separate from signed gain. -/ +theorem moving_spectator_product_cost (n m : ℕ) (p : Fin m → ℕ) + (V : ℝ) (hp : ∀ i, (p i : ℝ) ≤ Real.exp V) : + (∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) ≤ + Real.exp ((2 ^ (n + 1) : ℕ) * (m : ℝ) * V) := by + calc + _ ≤ ∏ _i : Fin m, (Real.exp V) ^ (2 ^ (n + 1)) := by + apply Finset.prod_le_prod₀ + · intro i _ + positivity + · intro i _ + exact pow_le_pow_left₀ (Nat.cast_nonneg _) (hp i) _ + _ = _ := by + simp only [← Real.exp_nat_mul, Finset.prod_const, Finset.card_univ, Fintype.card_fin] + congr 1 + ring + +theorem moving_spectator_linear_cost (n m : ℕ) (p : Fin m → ℕ) + (K L A : ℝ) (hK : 0 ≤ K) (hL : 0 ≤ L) (_hA : 0 ≤ A) + (hm : (m : ℝ) ≤ K * L) (hamp : A ≤ Real.exp (K * L)) + (hp : ∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) : + A * (∏ i, (p i : ℝ) ^ (2 ^ (n + 1))) ≤ + Real.exp ((((2 ^ (n + 1) : ℕ) : ℝ) + 1) * K * L * + Real.exp ((1 / 1000 : ℝ) * L)) := by + have hE : 1 ≤ Real.exp ((1 / 1000 : ℝ) * L) := + Real.one_le_exp_iff.mpr (by positivity) + calc + _ ≤ Real.exp (K * L) * + Real.exp ((2 ^ (n + 1) : ℕ) * (m : ℝ) * Real.exp ((1 / 1000 : ℝ) * L)) := + mul_le_mul hamp (moving_spectator_product_cost n m p _ hp) + (Finset.prod_nonneg fun i _ => by positivity) (Real.exp_nonneg _) + _ ≤ _ := by + rw [← Real.exp_add] + apply Real.exp_le_exp.mpr + have hm' := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hm (Nat.cast_nonneg (2 ^ (n + 1)))) + (Real.exp_nonneg ((1 / 1000 : ℝ) * L)) + have hKL := mul_le_mul_of_nonneg_left hE (mul_nonneg hK hL) + nlinarith + +theorem moving_frozen_residue_coefficient_norm {σ J : Type*} + (base : σ → ℕ) (slot : J ↪ σ) (outside : List ℕ) + (F : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℂ) + (E : Bool → {k : ℕ} → MovingSlotData σ k → ℤ → ℤ → ℤ → ℝ) + (n m : ℕ) (data : Bool → MovingSlotData σ n) (childBound : ℕ → ℕ) + (R : ℤ) (r : ℕ) [NeZero r] (P : PublishedProgressionInput) (Q : ℕ) + (y : ℝ) (hy : 0 ≤ y) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (S : ∀ i, Finset (ZMod (p i))) (hS : ∀ i, (S i).Nonempty) + (hSp : ∀ i, (S i).card < p i) + (t : Bool → FrequencyTree ℤ n) (small : Bool → TreeLeafTuple (List σ) n) + (samples : Bool → MovingSampleSlots σ n) + (twist : ∀ i, Bool → (ZMod (p i))ˣ) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (a : J → (ZMod r)ˣ) (z : ∀ i, TreeLeafIndex n × Fin m → (ZMod (p i))ˣ) : + ‖frozenBulkFrequencyFactor base slot outside F E data childBound R r P Q y a * + ∏ i, frozenBulkSpectatorHaar base n m t small samples (twist i) perm + (normalizedResidueTransform (S i)) (z i)‖ ≤ + (2 * (‖movingDataWeight (F false) (E false) (data false)‖ * + ‖movingDataWeight (F true) (E true) (data true)‖)) * + ∏ i, (p i : ℝ) ^ (2 ^ (n + 1)) := by + rw [norm_mul, norm_prod] + apply mul_le_mul + (frozenBulkFrequencyFactor_norm_le base slot outside F E data childBound R r P Q y hy a) + (Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) (fun i _ => + frozenBulkSpectatorHaar_norm_le base n m t small samples (twist i) perm + (normalizedResidueTransform (S i)) (p i) (Nat.cast_nonneg _) + (normalizedResidueTransform_norm_le_prime (S i) (hS i) (hSp i)) (z i))) + (Finset.prod_nonneg fun _ _ => norm_nonneg _) (by positivity) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorModulus.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..52e9b78408cb752b39ed03fc6ea9168eaeb875c0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorModulus.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCells +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPeriodScale + +namespace OAI + +/-! # A concrete modulus for arithmetic support and all spectator trees -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingSpectatorModulus {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (q : I → ℕ) (S : Finset I) : ℕ := + movingTopPeriod value hvalue childBound pivotBound T hf * + (movingSpectatorDenominator value T).natAbs * ∏ i ∈ S, q i + +theorem movingSpectatorModulus_pos {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (q : I → ℕ) (S : Finset I) + (hq : ∀ i ∈ S, 0 < q i) : + 0 < movingSpectatorModulus value hvalue childBound pivotBound T hf q S := by + exact Nat.mul_pos (Nat.mul_pos (movingTopPeriod_pos value hvalue childBound pivotBound T hf) + (Int.natAbs_pos.mpr (movingSpectatorDenominator_ne_zero value hvalue T hf))) + (Finset.prod_pos hq) + +theorem movingTopPeriod_dvd_spectatorModulus {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (q : I → ℕ) (S : Finset I) : + movingTopPeriod value hvalue childBound pivotBound T hf ∣ + movingSpectatorModulus value hvalue childBound pivotBound T hf q S := by + exact ⟨(movingSpectatorDenominator value T).natAbs * ∏ i ∈ S, q i, by + simp only [movingSpectatorModulus, mul_assoc]⟩ + +theorem spectator_dvd_movingSpectatorModulus {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (q : I → ℕ) (S : Finset I) + (i : I) (hi : i ∈ S) : + (q i : ℤ) * movingSpectatorDenominator value T ∣ + (movingSpectatorModulus value hvalue childBound pivotBound T hf q S : ℤ) := by + obtain ⟨z, hz⟩ := Int.dvd_natAbs.mpr (dvd_refl (movingSpectatorDenominator value T)) + obtain ⟨w, hw⟩ := Finset.dvd_prod_of_mem q hi + refine ⟨(movingTopPeriod value hvalue childBound pivotBound T hf : ℤ) * z * w, ?_⟩ + simp only [movingSpectatorModulus, Nat.cast_mul, hz, hw] + ring + +theorem movingSpectatorModulus_bound {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (q : I → ℕ) (S : Finset I) + (B : ℕ) (hB : 1 ≤ B) (hfreq : T.Frequencies (fun s => s.natAbs ≤ B)) + (hcomp : T.CompensationBound value B) : + movingSpectatorModulus value hvalue childBound pivotBound T hf q S ≤ + B ^ (4 * (4 ^ n - 1) + 2 * (2 ^ n - 1)) * ∏ i ∈ S, q i := by + unfold movingSpectatorModulus + apply Nat.mul_le_mul_right + calc + _ ≤ B ^ (4 * (4 ^ n - 1)) * B ^ (2 * (2 ^ n - 1)) := + Nat.mul_le_mul (movingTopPeriod_bound value hvalue childBound pivotBound T hf B hB hfreq hcomp) + (movingSpectatorDenominator_bound value T B hfreq hcomp) + _ = _ := (pow_add _ _ _).symm + +/-- This bound applies to a fixed finite set of distinct spectator primes +using only their upper endpoint. No prime number theorem is required. -/ +theorem small_spectator_product_bound (S : Finset ℕ) (R : ℕ) + (hS : ∀ q ∈ S, 0 < q ∧ q ≤ R) : ∏ q ∈ S, q ≤ R ^ R := by + have hsub : S ⊆ Finset.Icc 1 R := by + intro q hq + exact Finset.mem_Icc.mpr ⟨(hS q hq).1, (hS q hq).2⟩ + have hcard : S.card ≤ R := (Finset.card_le_card hsub).trans (by simp) + calc + _ ≤ ∏ _q ∈ S, R := Finset.prod_le_prod (fun q hq => (hS q hq).2) + _ = R ^ S.card := by simp + _ ≤ R ^ R := by + by_cases hR : R = 0 + · subst R + have : S = ∅ := Finset.card_eq_zero.mp (by omega) + subst S + simp + · exact Nat.pow_le_pow_right (by omega) hcard + +theorem small_spectator_product_exp (S : Finset ℕ) (R : ℕ) + (hS : ∀ q ∈ S, 0 < q ∧ q ≤ R) (x : ℝ) (hx : 0 ≤ x) + (hR : (R : ℝ) ≤ Real.exp x) : + (∏ q ∈ S, q : ℕ) ≤ Real.exp (x * Real.exp x) := by + calc + ((∏ q ∈ S, q : ℕ) : ℝ) ≤ (R : ℝ) ^ R := by + exact_mod_cast small_spectator_product_bound S R hS + _ ≤ (Real.exp x) ^ R := by gcongr + _ = Real.exp ((R : ℝ) * x) := (Real.exp_nat_mul x R).symm + _ ≤ Real.exp (x * Real.exp x) := by + apply Real.exp_le_exp.mpr + nlinarith + +theorem movingSpectatorModulus_exp {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (S : Finset ℕ) + (B : ℕ) (hB : 1 ≤ B) (hfreq : T.Frequencies (fun s => s.natAbs ≤ B)) + (hcomp : T.CompensationBound value B) (b r : ℝ) + (hb : (B : ℝ) ≤ Real.exp b) (hr : ((∏ q ∈ S, q : ℕ) : ℝ) ≤ Real.exp r) : + (movingSpectatorModulus value hvalue childBound pivotBound T hf id S : ℝ) ≤ + Real.exp (((4 * (4 ^ n - 1) + 2 * (2 ^ n - 1) : ℕ) : ℝ) * b + r) := by + calc + _ ≤ (B : ℝ) ^ (4 * (4 ^ n - 1) + 2 * (2 ^ n - 1)) * (∏ q ∈ S, q : ℕ) := by + exact_mod_cast movingSpectatorModulus_bound value hvalue childBound pivotBound T hf id S B hB hfreq hcomp + _ ≤ (Real.exp b) ^ (4 * (4 ^ n - 1) + 2 * (2 ^ n - 1)) * Real.exp r := by gcongr + _ = _ := by rw [← Real.exp_nat_mul, ← Real.exp_add] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..9a243057ddf0cbe33bfa4964ee9c48197037ce93 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorProduct.lean @@ -0,0 +1,44 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullSpectator + +namespace OAI + +/-! # All spectator factors in the source recursive coefficient -/ + +namespace Ostmann +open scoped BigOperators Classical + +/-- Factor every spectator while retaining the full smooth and arithmetic +coefficient. This identity includes zero-support terms. -/ +theorem movingSlotWeight_spectator_product {σ I : Type*} + (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + (hextra : ∀ i x s v w, extra x s v w ≠ 0 → + (historyPivot (movingSlotSystem value childBound pivotBound) x s v w : ZMod (q i)) ≠ 0) + (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (XL XR : ℕ) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => F x s * ∏ i ∈ S, spectatorHistoryLeaf (movingSlotModulus value) (g i) (D i) x s) + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t = + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t * + ∏ i ∈ S, movingSlotSpectator value (g i) (D i) T XL XR := by + induction S using Finset.induction_on generalizing F with + | empty => simp only [Finset.prod_empty, mul_one] + | @insert i S hi ih => + simp only [Finset.prod_insert hi] + have he : (fun x s => F x s * (spectatorHistoryLeaf (movingSlotModulus value) (g i) (D i) x s * + ∏ j ∈ S, spectatorHistoryLeaf (movingSlotModulus value) (g j) (D j) x s)) = + (fun x s => (F x s * ∏ j ∈ S, spectatorHistoryLeaf (movingSlotModulus value) (g j) (D j) x s) * + spectatorHistoryLeaf (movingSlotModulus value) (g i) (D i) x s) := by + funext x s + ring + rw [he, movingSlotWeight_spectator value childBound pivotBound _ extra (hextra i) + (g i) (D i) T t hT XL XR, ih] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorRangeUnits.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorRangeUnits.lean new file mode 100644 index 0000000000000000000000000000000000000000..65f80743045e642bd4b3f94d1ccb7924a631b0ba --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorRangeUnits.lean @@ -0,0 +1,69 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternSpectatorUnits +import OAI.NumberTheory.Ostmann.Arithmetic.BulkResidueCoprime +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkFrozen +import OAI.NumberTheory.Ostmann.Construction.SpectatorBulkScale + +namespace OAI + +/-! # The actual separated prime ranges imply all spectator unit tests -/ + +namespace Ostmann +open Filter +open scoped Classical + +theorem prime_cast_ne_zero_of_lt {q : ℕ} [Fact q.Prime] (p : ℕ) (hp : p.Prime) + (hqp : q < p) : (p : ZMod q) ≠ 0 := by + apply IsUnit.ne_zero + apply (ZMod.isUnit_iff_coprime p q).mpr + exact (Nat.coprime_primes hp (Fact.out : q.Prime)).mpr (Ne.symm (ne_of_lt hqp)) + +/-- The spectator primes are far smaller than every original nongiant +prime. This supplies the small-word and internal-sample unit tests for each +pattern without any restriction on their actual residue values. -/ +theorem movingPattern_spectator_units_of_ranges {B C : Type*} {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (small : Bool → TreeLeafTuple (List B) n) + (slot : (TreeLeafIndex n × Fin m) ↪ B) + (hsmall : ∀ b, ∀ j ∈ flattenMovingSlots n (small b), j ∉ Set.range slot) + (base : Fin (N + 1) → ℕ) + (hbase : ∀ i ∉ Set.range (movingPatternBulkEmbedding e slot), (base i).Prime) + (L : ℝ) (hL : 0 < L) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (hp : ∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) + (hlarge : ∀ j, j ∉ Set.range (movingPatternBulkEmbedding e slot) → + Real.exp (Real.exp ((39 / 10000 : ℝ) * L)) ≤ (base j : ℝ)) : + (∀ i b, ∀ j ∈ flattenMovingSlots n (small b), + (base (e.symm (.inl j)) : ZMod (p i)) ≠ 0) ∧ + (∀ i c, (base (e.symm (.inr c)) : ZMod (p i)) ≠ 0) := by + have hunits (i : Fin m) (j : Fin (N + 1)) + (hj : j ∉ Set.range (movingPatternBulkEmbedding e slot)) : + (base j : ZMod (p i)) ≠ 0 := by + apply prime_cast_ne_zero_of_lt _ (hbase j hj) + have hlt : (p i : ℝ) < base j := (hp i).trans_lt ((Real.exp_lt_exp.mpr + (Real.exp_lt_exp.mpr (by nlinarith))).trans_le (hlarge j hj)) + exact_mod_cast hlt + constructor + · intro i b j hj + apply hunits + rintro ⟨k, hk⟩ + apply hsmall b j hj + refine ⟨k, ?_⟩ + exact Sum.inl.inj (e.symm.injective hk) + · intro i c + exact hunits i _ (movingPatternBulkEmbedding_internal_absent e slot c) + +/-- The original finite Fourier cutoff lies below every selected spectator +prime, uniformly in the linear bulk length. -/ +theorem moving_spectator_frequency_range (k : ℕ) (A a : ℝ) + (hA : 0 ≤ A) (ha : 0 < a) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (B : ℕ) (p : Fin m → ℕ), (B : ℝ) ≤ Real.exp (A * m) → + (∀ i, Real.exp (Real.exp (a * L)) ≤ (p i : ℝ)) → + ∀ s : ℤ, s.natAbs ≤ B → ∀ i, s.natAbs < p i := by + filter_upwards [frequency_modulus_lt_spectators A ((k : ℝ) ^ 4) a hA (by positivity) ha, + eventually_ge_atTop (0 : ℝ)] with L hlt hL + dsimp only + intro B p hB hp s hs i + exact hs.trans_lt (hlt _ B p (spectatorBulkCount_upper k L hL) hB hp i) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorScale.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorScale.lean new file mode 100644 index 0000000000000000000000000000000000000000..eb1219aad2a21fdb193f8a66851f2badf2609e87 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSpectatorScale.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorModulus + +namespace OAI + +/-! # Spectator periods fit the same published progression range -/ + +namespace Ostmann +open Filter Asymptotics + +theorem movingSpectator_exponent_budget (n : ℕ) (C : ℝ) : + ∀ᶠ L : ℝ in atTop, + ((4 * (4 ^ n - 1) + 2 * (2 ^ n - 1) : ℕ) : ℝ) * + (C * L + C * Real.exp ((1 / 100 : ℝ) * L)) + + ((1 / 1000 : ℝ) * L) * Real.exp ((1 / 1000 : ℝ) * L) ≤ + Real.exp ((12 / 1000 : ℝ) * L) := by + let E : ℝ := (4 * (4 ^ n - 1) + 2 * (2 ^ n - 1) : ℕ) + have hlin : (fun L : ℝ => (E * C) * L) =o[atTop] + (fun L => Real.exp ((12 / 1000 : ℝ) * L)) := by + simpa only [pow_one] using + (isLittleO_pow_exp_pos_mul_atTop 1 (by norm_num : (0 : ℝ) < 12 / 1000)).const_mul_left (E * C) + have hexp : (fun L : ℝ => (E * C) * Real.exp ((1 / 100 : ℝ) * L)) =o[atTop] + (fun L => Real.exp ((12 / 1000 : ℝ) * L)) := by + simpa only [Real.rpow_zero, mul_one] using + (isLittleO_exp_mul_rpow_of_lt 0 (by norm_num : (1 / 100 : ℝ) < 12 / 1000)).const_mul_left (E * C) + have hspec : (fun L : ℝ => (1 / 1000 : ℝ) * + (Real.exp ((1 / 1000 : ℝ) * L) * L)) =o[atTop] + (fun L => Real.exp ((12 / 1000 : ℝ) * L)) := by + simpa only [Real.rpow_one] using + (isLittleO_exp_mul_rpow_of_lt 1 (by norm_num : (1 / 1000 : ℝ) < 12 / 1000)).const_mul_left (1 / 1000) + filter_upwards [((hlin.add hexp).add hspec).bound (by norm_num : (0 : ℝ) < 1)] with L hL + simp only [Real.norm_eq_abs, abs_of_pos (Real.exp_pos _), one_mul] at hL + have h := (le_abs_self _).trans hL + change E * (C * L + C * Real.exp ((1 / 100 : ℝ) * L)) + + ((1 / 1000 : ℝ) * L) * Real.exp ((1 / 1000 : ℝ) * L) ≤ _ + nlinarith only [h] + +/-- The cutoff is uniform in the actual tree and the spectator prime set. +The period includes both integer division denominators and all spectators. -/ +theorem movingSpectator_progression_range {σ : Type*} (n : ℕ) (C : ℝ) : + ∀ᶠ L : ℝ in atTop, ∀ (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (B : ℕ), 1 ≤ B → + T.Frequencies (fun s => s.natAbs ≤ B) → T.CompensationBound value B → + (B : ℝ) ≤ Real.exp (C * L + C * Real.exp ((1 / 100 : ℝ) * L)) → + ∀ (S : Finset ℕ) (R : ℕ), (∀ q ∈ S, 0 < q ∧ q ≤ R) → + (R : ℝ) ≤ Real.exp ((1 / 1000 : ℝ) * L) → + movingSpectatorModulus value hvalue childBound pivotBound T hf id S ≤ + ⌊Real.exp (Real.exp ((12 / 1000 : ℝ) * L))⌋₊ := by + filter_upwards [movingSpectator_exponent_budget n C, eventually_ge_atTop (0 : ℝ)] with L hL hL0 + intro value hvalue childBound pivotBound T hf B hB hfreq hcomp hb S R hS hR + apply Nat.le_floor + apply (movingSpectatorModulus_exp value hvalue childBound pivotBound T hf S B hB hfreq hcomp + _ _ hb (small_spectator_product_exp S R hS _ (by positivity) hR)).trans + exact Real.exp_le_exp.mpr hL + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSplitModulusBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSplitModulusBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..77fdc0146940bb51ed4101246af618fb37163ab8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSplitModulusBound.lean @@ -0,0 +1,47 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularCoprime +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularResidues +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullModulusScale + +namespace OAI + +/-! # The split regular/auxiliary modulus retains the proved size bound -/ + +namespace Ostmann +open scoped BigOperators Classical + +theorem movingSplitModulus_dvd_full {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (R : ℕ) + (hR : MovingSlotReversal.naturalProduct value (T false).regularSlots = R) + (hcop : R.Coprime (movingReducedPairModulus value hvalue outside childBound pivotBound T hf q S)) : + R * movingReducedPairModulus value hvalue outside childBound pivotBound T hf q S ∣ + movingFullPairModulus value hvalue outside childBound pivotBound T hf q S := by + have hroot : R ∣ movingFullPairModulus value hvalue outside childBound pivotBound T hf q S := by + rw [← hR] + have hz := (movingRegularProduct_dvd_unitPeriod value outside (T false)).trans + ((movingFullPairModulus_tests value hvalue outside childBound pivotBound T hf q S).2.2.1 false) + exact_mod_cast hz + exact hcop.mul_dvd_of_dvd_of_dvd hroot + (movingReducedPairModulus_dvd_full value hvalue outside childBound pivotBound T hf q S) + +theorem movingSplitModulus_bound {σ I : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (hout : outside.prod ≠ 0) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (q : I → ℕ) (S : Finset I) (hq : ∀ i ∈ S, 0 < q i) + (R : ℕ) (hR : MovingSlotReversal.naturalProduct value (T false).regularSlots = R) + (hcop : R.Coprime (movingReducedPairModulus value hvalue outside childBound pivotBound T hf q S)) + (B : ℕ) (hB : 1 ≤ B) (hfreq : ∀ b, (T b).Frequencies (fun s => s.natAbs ≤ B)) + (hcomp : ∀ b, (T b).CompensationBound value B) + (hregular : ∀ b, (T b).RegularBound value B) (houtB : outside.prod ≤ B) : + R * movingReducedPairModulus value hvalue outside childBound pivotBound T hf q S ≤ + (B ^ movingFullModulusExponent n * ∏ i ∈ S, q i) ^ 4 := by + exact (Nat.le_of_dvd + (movingFullPairModulus_pos value hvalue outside hout childBound pivotBound T hf q S hq) + (movingSplitModulus_dvd_full value hvalue outside childBound pivotBound T hf q S R hR hcop)).trans + (movingFullPairModulus_bound value hvalue outside childBound pivotBound T hf q S B hB hfreq hcomp hregular houtB) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSquareLines.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSquareLines.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f3b0999d90582d4ffd9007becec963c2a5e416e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSquareLines.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingClearedRows +import OAI.NumberTheory.Ostmann.Arithmetic.SquareLiftExclusions + +namespace OAI + +/-! # Prime-square exclusions for the actual moving occurrence lines -/ + +namespace Ostmann +open scoped BigOperators Classical + +@[simp] theorem naturalReduction_square {σ : Type*} (p : ℕ) (value : σ → ℕ) + (f : MvPolynomial σ ℤ) : + squareReduction p (MovingSlotReversal.naturalReduction (p ^ 2) value f) = + MovingSlotReversal.naturalReduction p value f := by + have he : (squareReduction p).comp (MovingSlotReversal.naturalReduction (p ^ 2) value) = + MovingSlotReversal.naturalReduction p value := by + ext i <;> simp [MovingSlotReversal.naturalReduction] + exact DFunLike.congr_fun he f + +theorem movingSlotLine_square_denominator_unit {σ : Type*} {p : ℕ} [Fact p.Prime] + (value : σ → ℕ) (path : List (MovingSlotReversal σ)) (current : MovingSlotReversal σ) + (hu : ∀ s ∈ path, MovingSlotReversal.naturalReduction p value s.polynomial.u ≠ 0) : + IsUnit (MovingSlotReversal.naturalReduction (p ^ 2) value + (movingSlotLine path current).denominator) := by + apply (isUnit_square_iff _).mpr + rw [naturalReduction_square] + apply movingPolynomialAncestors_denominator + intro s hs + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs + exact hu t ht + +/-- The exact numerator test modulo p² is the cleared line test at the two +original giants. Only ancestor denominators need to be units. -/ +theorem movingSlotLine_square_zero_iff {σ : Type*} {p : ℕ} [Fact p.Prime] + (value : σ → ℕ) (path : List (MovingSlotReversal σ)) + (current : MovingSlotReversal σ) (XL XR : ℕ) + (hvalid : MovingSlotPathIntegral value path (XL, XR)) + (hu : ∀ s ∈ path, MovingSlotReversal.naturalReduction p value s.polynomial.u ≠ 0) : + let φ := MovingSlotReversal.naturalReduction (p ^ 2) value + let pair := movingSlotNaturalPath value path (XL, XR) + φ (movingSlotLine path current).a * (XL : ZMod (p ^ 2)) + + φ (movingSlotLine path current).b * (XR : ZMod (p ^ 2)) = 0 ↔ + (p : ℤ) ^ 2 ∣ + current.leftFrequency * + ((pair.2 * MovingSlotReversal.naturalProduct value current.rightSlots : ℕ) : ℤ) - + current.rightFrequency * + ((pair.1 * MovingSlotReversal.naturalProduct value current.leftSlots : ℕ) : ℤ) := by + let N : ℤ := current.leftFrequency * + (((movingSlotNaturalPath value path (XL, XR)).2 * + MovingSlotReversal.naturalProduct value current.rightSlots : ℕ) : ℤ) - + current.rightFrequency * + (((movingSlotNaturalPath value path (XL, XR)).1 * + MovingSlotReversal.naturalProduct value current.leftSlots : ℕ) : ℤ) + have he : MovingSlotReversal.naturalReduction (p ^ 2) value (movingSlotLine path current).a * + (XL : ZMod (p ^ 2)) + + MovingSlotReversal.naturalReduction (p ^ 2) value (movingSlotLine path current).b * (XR : ZMod (p ^ 2)) = + MovingSlotReversal.naturalReduction (p ^ 2) value + (movingSlotLine path current).denominator * (N : ZMod (p ^ 2)) := by + simpa only [MovingSlotReversal.naturalReduction, N, Int.cast_sub, Int.cast_mul, + Int.cast_natCast] using + movingSlotLine_cleared_numerator (R := ZMod (p ^ 2)) value path current XL XR hvalid + change _ = 0 ↔ (p : ℤ) ^ 2 ∣ N + rw [he, (movingSlotLine_square_denominator_unit value path current hu).mul_right_eq_zero] + convert ZMod.intCast_zmod_eq_zero_iff_dvd N (p ^ 2) using 1 + norm_cast + +/-- The uniform lift loss for any finite collection of actual occurrences. +All rows are proved nonzero from the ancestor and current frequency units. -/ +theorem movingSlotLines_square_loss {σ I : Type*} [Fintype I] {p : ℕ} [Fact p.Prime] + (value : σ → ℕ) (path : I → List (MovingSlotReversal σ)) + (current : I → MovingSlotReversal σ) + (hunit : ∀ i s, s ∈ path i → + MovingSlotReversal.naturalReduction p value s.polynomial.v ≠ 0 ∧ + MovingSlotReversal.naturalReduction p value s.polynomial.w ≠ 0 ∧ + MovingSlotReversal.naturalReduction p value s.polynomial.u ≠ 0) + (hc : ∀ i, MovingSlotReversal.naturalReduction p value (current i).polynomial.v ≠ 0 ∧ + MovingSlotReversal.naturalReduction p value (current i).polynomial.w ≠ 0) + (x₀ y₀ : ZMod p) (hy : y₀ ≠ 0) + (hbase : ∀ i, MovingSlotReversal.naturalReduction p value (movingSlotLine (path i) (current i)).a * x₀ + + MovingSlotReversal.naturalReduction p value (movingSlotLine (path i) (current i)).b * y₀ = 0) + (F : SquareLiftPairs p x₀ y₀ → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hF : ∀ v, ‖F v‖ ≤ B) : + let φ := MovingSlotReversal.naturalReduction (p ^ 2) value + ‖∑ v ∈ Finset.univ.filter (fun v : SquareLiftPairs p x₀ y₀ => ∃ i, + φ (movingSlotLine (path i) (current i)).a * v.1.1 + + φ (movingSlotLine (path i) (current i)).b * v.2.1 = 0), F v‖ / (p : ℝ) ^ 2 ≤ + B * (Fintype.card I : ℝ) / p := by + apply square_lift_nonzero_rows_removed_mass_le _ _ x₀ y₀ hy + · intro i + simp only [naturalReduction_square] + apply movingHistoryLine_nonzero + · intro s hs + obtain ⟨t, ht, rfl⟩ := List.mem_map.mp hs + exact hunit i t ht + · exact (hc i).1 + · exact (hc i).2 + · simpa only [naturalReduction_square] using hbase + · exact hB + · exact hF + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSquareSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSquareSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..3d9df6bebfa90de25581d46e6056aa25e062a98b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSquareSupport.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairwiseSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOccurrenceUnits + +namespace OAI + +/-! # The explicit prime-square tests for the full moving history -/ + +namespace Ostmann + +def MovingSlotData.CompensationPrimeData {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → Prop + | _, .leaf _ _ => True + | _, .node s _ _ U left right => + (∀ b ∈ U.map value, b.Prime) ∧ (U.map value).Pairwise Nat.Coprime ∧ + (∀ b ∈ U.map value, ¬ b ∣ s.natAbs) ∧ + left.CompensationPrimeData value ∧ right.CompensationPrimeData value + +/-- Equality patterns may identify samples at different nodes; only the +entries made together in one compensation vector have to be distinct. -/ +def MovingSlotData.CompensationDistinct {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → Prop + | _, .leaf _ _ => True + | _, .node _ _ _ U left right => + (U.map value).Pairwise Nat.Coprime ∧ + left.CompensationDistinct value ∧ right.CompensationDistinct value + +def MovingSampleSlots.DistinctCompensations {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSampleSlots σ n → Prop + | _, .leaf => True + | n + 1, .node samples left right => + ((flattenMovingSlots n (movingCompensationSlots n samples)).map value).Pairwise Nat.Coprime ∧ + left.DistinctCompensations value ∧ right.DistinctCompensations value + +theorem buildMovingSlotData_compensation_distinct {σ : Type*} (value : σ → ℕ) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) (h : samples.DistinctCompensations value) : + (buildMovingSlotData n t small bulk samples).CompensationDistinct value := by + induction samples with + | leaf => trivial + | node samples left right ihL ihR => + exact ⟨h.1, ihL _ _ _ h.2.1, ihR _ _ _ h.2.2⟩ + +/-- The manuscript's size separation proves the frequency-prime coprimality +required by the square tests. It is not an additional analytic input. -/ +theorem MovingSlotData.compensationPrimeData_of_ranges {σ : Type*} (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (V : ℕ) (hlarge : ∀ i, V < value i) + {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (hV : T.Frequencies (fun s => s.natAbs ≤ V)) + (hdistinct : T.CompensationDistinct value) : T.CompensationPrimeData value := by + induction T with + | leaf => trivial + | node s CL CR U left right ihL ihR => + refine ⟨?_, hdistinct.1, ?_, ihL hf.2.1 hV.2.1 hdistinct.2.1, + ihR hf.2.2 hV.2.2 hdistinct.2.2⟩ + · intro b hb + obtain ⟨i, _, rfl⟩ := List.mem_map.mp hb + exact hprime i + · intro b hb + obtain ⟨i, _, rfl⟩ := List.mem_map.mp hb + exact Nat.not_dvd_of_pos_of_lt (Int.natAbs_pos.mpr hf.1) (hV.1.trans_lt (hlarge i)) + +/-- The numerator at every node is tested before division by the node's +frequency or by its compensation product. -/ +def MovingSlotData.PrimeSquareTests {σ : Type*} (value : σ → ℕ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → Prop + | _, .leaf _ _, _, _ => True + | _, .node s CL CR U left right, XL, XR => + let p := (MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR + (∀ b ∈ U.map value, ¬ (b : ℤ) ^ 2 ∣ + left.frequency * ((XR * MovingSlotReversal.naturalProduct value CR : ℕ) : ℤ) - + right.frequency * ((XL * MovingSlotReversal.naturalProduct value CL : ℕ) : ℤ)) ∧ + left.PrimeSquareTests value p XL ∧ right.PrimeSquareTests value p XR + +theorem MovingSlotData.newCompensationUnits_iff_squareTests {σ : Type*} + (value : σ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hprime : T.CompensationPrimeData value) (XL XR : ℕ) (hI : T.Integral value XL XR) : + T.NewCompensationUnits value XL XR ↔ T.PrimeSquareTests value XL XR := by + induction T generalizing XL XR with + | leaf => rfl + | node s CL CR U left right ihL ihR => + have hs := moving_compensation_square_tests (U.map value) + ((MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR) + s hprime.1 hprime.2.1 hprime.2.2.1 + have he : (∀ b ∈ U.map value, ¬ (b : ℤ) ^ 2 ∣ + left.frequency * ((XR * MovingSlotReversal.naturalProduct value CR : ℕ) : ℤ) - + right.frequency * ((XL * MovingSlotReversal.naturalProduct value CL : ℕ) : ℤ)) ↔ + (∀ b ∈ U.map value, ¬ (b : ℤ) ^ 2 ∣ s * + ((MovingSlotReversal.naturalProduct value U * + (MovingSlotData.step s CL CR U left right false).naturalPivot value XL XR : ℕ) : ℤ)) := by + have hrel := hI.1.2 + dsimp only [MovingSlotData.step] at hrel + rw [hrel] + rfl + change (_ ∧ _ ∧ _) ↔ _ ∧ _ ∧ _ + rw [ihL hprime.2.2.2.1 _ _ hI.2.1, ihR hprime.2.2.2.2 _ _ hI.2.2, he] + exact and_congr (by simpa only [MovingSlotReversal.naturalProduct, hprime.2.1, true_and] using hs) + Iff.rfl + +/-- An exact reduction of all pairwise slot tests to the top support and the +explicit numerator exclusions modulo b², for the original integral tree. -/ +theorem MovingSlotData.fullPairwise_iff_squareTests {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (hcoh : T.RegularCoherent) + (hprime : T.CompensationPrimeData value) (XL XR : ℕ) + (hI : T.Integral value XL XR) (hfreq : T.CrossFrequencyUnits value XL XR) : + T.FullPairwise value XL XR ↔ T.CurrentPairwise value XL XR ∧ T.PrimeSquareTests value XL XR := by + rw [T.fullPairwise_iff value hcoh XL XR hI hfreq, + T.newCompensationUnits_iff_squareTests value hprime XL XR hI] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingStatisticDecay.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingStatisticDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..636f27cbf03dfd32cbbf4513bd306b6e11994feb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingStatisticDecay.lean @@ -0,0 +1,143 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticErrorRates +import OAI.NumberTheory.Ostmann.Construction.SpectatorBulkScale + +namespace OAI + +/-! # Exponential decay of the full selected-statistic bound at fixed depth -/ + +namespace Ostmann +open Filter + +/-- Fixed constants are absorbed by a strict linear-exponent margin. -/ +theorem eventually_bulk_exp_margin (k : ℕ) (hk : 0 < k) (K a b : ℝ) + (hK : 0 ≤ K) (hab : a < b) : + ∀ᶠ L : ℝ in atTop, K * Real.exp (a * spectatorBulkCount k L) ≤ + Real.exp (b * spectatorBulkCount k L) := by + filter_upwards [(spectatorBulkCount_tendsto k hk).eventually + (eventually_ge_atTop (Real.log (K + 1) / (b - a)))] with L hL + have hmargin := (div_le_iff₀ (sub_pos.mpr hab)).mp hL + calc + _ ≤ (K + 1) * Real.exp (a * spectatorBulkCount k L) := + mul_le_mul_of_nonneg_right (by linarith) (Real.exp_pos _).le + _ = Real.exp (Real.log (K + 1) + a * spectatorBulkCount k L) := by + rw [Real.exp_add, Real.exp_log (by linarith)] + _ ≤ _ := Real.exp_le_exp.mpr (by nlinarith) + +/-- The retained arithmetic error beats every fixed exponential in the bulk size. -/ +theorem eventually_bulk_arithmetic_error (k : ℕ) (T : ℝ) : + ∀ᶠ L : ℝ in atTop, Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) ≤ + Real.exp (-T * spectatorBulkCount k L) := by + let C := max T 0 * (k : ℝ) ^ 4 + have hC : 0 ≤ C := mul_nonneg (le_max_right _ _) (by positivity) + filter_upwards [arithmetic_exponent_absorption 0 (12 / 10000) 0 C 1 1 + (by norm_num) (by norm_num) (by norm_num) (by norm_num), + eventually_ge_atTop (0 : ℝ)] with L hL hL0 + have hm : T * spectatorBulkCount k L ≤ C * L := by + apply (mul_le_mul_of_nonneg_right (le_max_left _ _) (Nat.cast_nonneg _)).trans + exact (mul_le_mul_of_nonneg_left (spectatorBulkCount_upper k L hL0) + (le_max_right _ _)).trans_eq (by dsimp only [C]; ring) + simp only [pow_one, zero_mul, Real.exp_zero, mul_one, one_mul] at hL + apply Real.exp_le_exp.mpr + nlinarith [mul_nonneg hC hL0] + +theorem eventually_scaled_bulk_arithmetic_error (k : ℕ) (hk : 0 < k) + (K a T : ℝ) (hK : 0 ≤ K) : + ∀ᶠ L : ℝ in atTop, + K * Real.exp (a * spectatorBulkCount k L) * + Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) ≤ + Real.exp (-T * spectatorBulkCount k L) := by + filter_upwards [eventually_bulk_arithmetic_error k (a + T + 1), + eventually_bulk_exp_margin k hk K (-(T + 1)) (-T) hK (by linarith)] with L herror hmargin + apply le_trans (mul_le_mul_of_nonneg_left herror + (mul_nonneg hK (Real.exp_pos _).le)) + have heq : K * Real.exp (a * spectatorBulkCount k L) * + Real.exp (-(a + T + 1) * spectatorBulkCount k L) = + K * Real.exp (-(T + 1) * spectatorBulkCount k L) := by + rw [mul_assoc, ← Real.exp_add] + congr 2 + ring + rwa [heq] + +/-- This is the numerical bound occurring in the selected-prior theorem, +including the root-frequency mass and all five arithmetic errors. -/ +theorem eventually_moving_statistic_decay (k : ℕ) (hk : 0 < k) + (C K A badRate diagRate gain T : ℝ) (hC : 0 ≤ C) (hK : 0 ≤ K) (hA : 0 ≤ A) + (hbad : A + badRate + diagRate < -T) (hgood : A - gain < -T) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ V : ℕ, (V : ℝ) ≤ Real.exp (A * m) → ∀ η : ℂ, + ‖η‖ ^ 2 ≤ C * (2 * V + 1 : ℕ) * Real.exp 2 * + (K * Real.exp (badRate * m) * + (Real.exp (diagRate * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) → + ‖η‖ ^ 2 ≤ Real.exp (-T * m) := by + let K₀ := 3 * C * Real.exp 2 + have hK₀ : 0 ≤ K₀ := by dsimp only [K₀]; positivity + filter_upwards [eventually_bulk_exp_margin k hk (4 * K₀ * K) + (A + badRate + diagRate) (-T) (by positivity) hbad, + eventually_bulk_exp_margin k hk (4 * K₀) (A - gain) (-T) (by positivity) hgood, + eventually_scaled_bulk_arithmetic_error k hk (4 * (5 * K₀ * K)) (A + badRate) T (by positivity), + eventually_scaled_bulk_arithmetic_error k hk (4 * (5 * K₀)) A T (by positivity)] + with L h₁ h₃ h₂ h₄ + dsimp only + intro V hV η hη + let m := spectatorBulkCount k L + have hmass : ((2 * V + 1 : ℕ) : ℝ) ≤ 3 * Real.exp (A * m) := by + have he : 1 ≤ Real.exp (A * m) := Real.one_le_exp (mul_nonneg hA (Nat.cast_nonneg _)) + push_cast + dsimp only [m] at he ⊢ + linarith + have hupper := hη.trans (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hmass hC) (Real.exp_pos _).le) + (by positivity)) + have heq : C * (3 * Real.exp (A * m)) * Real.exp 2 * + (K * Real.exp (badRate * m) * + (Real.exp (diagRate * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) = + K₀ * K * Real.exp ((A + badRate + diagRate) * m) + + 5 * K₀ * K * Real.exp ((A + badRate) * m) * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) + + K₀ * Real.exp ((A - gain) * m) + + 5 * K₀ * Real.exp (A * m) * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + dsimp only [K₀] + simp only [add_mul, sub_mul, Real.exp_add, Real.exp_sub, Real.exp_neg, neg_mul] + ring + change ‖η‖ ^ 2 ≤ C * (3 * Real.exp (A * m)) * Real.exp 2 * _ at hupper + rw [heq] at hupper + dsimp only [m] at hupper + nlinarith only [hupper, h₁, h₂, h₃, h₄] + +/-- Substitute the original bottom gap before applying the exponential margin. -/ +theorem eventually_moving_statistic_decay_with_base (k : ℕ) (hk : 0 < k) + (r C K A badRate D ε gain T : ℝ) + (hr : 0 ≤ r) (hC : 0 ≤ C) (hK : 0 ≤ K) (hA : 0 ≤ A) + (hbad : A + r * badRate + (r * D + (Real.log 12 + 1) * r + ε) < -T) + (hgood : A - gain < -T) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ V : ℕ, (V : ℝ) ≤ Real.exp (A * m) → ∀ Δ : ℝ, Δ ≤ D * m → ∀ η : ℂ, + ‖η‖ ^ 2 ≤ C * (2 * V + 1 : ℕ) * Real.exp 2 * + (K * Real.exp (r * m * badRate) * + (Real.exp (r * Δ + (Real.log 12 + 1) * r * m + ε * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) + + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L))) → + ‖η‖ ^ 2 ≤ Real.exp (-T * m) := by + filter_upwards [eventually_moving_statistic_decay k hk C K A (r * badRate) + (r * D + (Real.log 12 + 1) * r + ε) gain T hC hK hA hbad hgood] with L hd + dsimp only at hd ⊢ + rw [show (r * badRate) * (spectatorBulkCount k L : ℝ) = + r * spectatorBulkCount k L * badRate by ring] at hd + intro V hV Δ hΔ η hη + have hb : Real.exp (r * Δ + (Real.log 12 + 1) * r * spectatorBulkCount k L + + ε * spectatorBulkCount k L) ≤ + Real.exp ((r * D + (Real.log 12 + 1) * r + ε) * spectatorBulkCount k L) := by + apply Real.exp_le_exp.mpr + nlinarith only [mul_le_mul_of_nonneg_left hΔ hr] + let err := 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) + have hi := mul_le_mul_of_nonneg_left (add_le_add hb (le_refl err)) + (mul_nonneg hK (Real.exp_pos (r * spectatorBulkCount k L * badRate)).le) + have hi' := add_le_add + (add_le_add hi (le_refl (Real.exp (-gain * spectatorBulkCount k L)))) (le_refl err) + exact hd V hV η (hη.trans (mul_le_mul_of_nonneg_left hi' + (mul_nonneg (mul_nonneg hC (Nat.cast_nonneg _)) (Real.exp_pos 2).le))) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSumFactors.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSumFactors.lean new file mode 100644 index 0000000000000000000000000000000000000000..cabcc47e302c06d54060feb45b0c42fded8181ec --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSumFactors.lean @@ -0,0 +1,17 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularTransfer + +namespace OAI + +/-! # A shared dependent Fourier family for disjoint prime lists -/ + +namespace Ostmann + +/-- The dependent disjoint union of two families, with its motive explicit. -/ +def movingSumFactors {J I : Type*} (Q : J → ℕ) (L : I → ℕ) + (gQ : ∀ j, ZMod (Q j) → ℂ) (gL : ∀ i, ZMod (L i) → ℂ) : + ∀ i, ZMod (Sum.elim Q L i) → ℂ := + Sum.rec (motive := fun i => ZMod (Sum.elim Q L i) → ℂ) gQ gL + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportCells.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..d515b20971b603f0b53c413350abdad6a7657a62 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportCells.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingResidueTests + +namespace OAI + +/-! # Constructed residue and root cells for full moving arithmetic support -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingArithmeticPeriod (nodes : List MovingFormulaNode) : ℕ := + (nodes.map MovingFormulaNode.residuePeriod).prod + +noncomputable def movingArithmeticRootCuts (nodes : List MovingFormulaNode) + (a : Bool → ℤ) (coord : Bool) : Finset ℝ := + nodes.toFinset.biUnion fun f => polynomialRootCuts (f.guard.polynomials a coord) + +theorem movingArithmeticPeriod_pos (nodes : List MovingFormulaNode) + (hfreq : ∀ f ∈ nodes, f.guard.right ≠ 0 ∧ f.guard.root ≠ 0) : + 0 < movingArithmeticPeriod nodes := by + induction nodes with + | nil => simp [movingArithmeticPeriod] + | cons f nodes ih => + have hf := hfreq f (by simp) + have hn := ih (fun g hg => hfreq g (List.mem_cons_of_mem _ hg)) + exact Nat.mul_pos (f.residuePeriod_pos hf.1 hf.2) hn + +theorem movingArithmeticPeriod_dvd (nodes : List MovingFormulaNode) + (f : MovingFormulaNode) (hf : f ∈ nodes) : f.residuePeriod ∣ movingArithmeticPeriod nodes := + List.dvd_prod (List.mem_map.mpr ⟨f, hf, rfl⟩) + +theorem movingArithmeticRootCuts_mem (nodes : List MovingFormulaNode) + (a : Bool → ℤ) (coord : Bool) (f : MovingFormulaNode) (hf : f ∈ nodes) + (j : Fin 3) (x : ℝ) (hx : x ∈ (f.guard.polynomials a coord j).roots) : + x ∈ movingArithmeticRootCuts nodes a coord := by + apply Finset.mem_biUnion.mpr + refine ⟨f, List.mem_toFinset.mpr hf, ?_⟩ + exact Finset.mem_biUnion.mpr ⟨j, Finset.mem_univ _, Multiset.mem_toFinset.mpr hx⟩ + +/-- A concrete cardinality budget for the constructed root cuts. -/ +theorem movingArithmeticRootCuts_card (nodes : List MovingFormulaNode) + (a : Bool → ℤ) (coord : Bool) : + (movingArithmeticRootCuts nodes a coord).card ≤ + ∑ f ∈ nodes.toFinset, ∑ j : Fin 3, (f.guard.polynomials a coord j).natDegree := by + apply (Finset.card_biUnion_le).trans + exact Finset.sum_le_sum (fun f _ => polynomialRootCuts_card (f.guard.polynomials a coord)) + +/-- The complete node support is constant on the explicitly constructed +root and residue cells. It is the actual arithmetic support, not an assumed +regularity property of the coefficient. -/ +theorem movingFormulaNodes_holds_invariant (nodes : List MovingFormulaNode) + (a : Bool → ℤ) (coord : Bool) (z w : ℤ) + (hres : ∀ i, movingGiantUpdate a coord z i ≡ movingGiantUpdate a coord w i + [ZMOD movingArithmeticPeriod nodes]) + (hcell : rootCellCode (movingArithmeticRootCuts nodes a coord) (z : ℝ) = + rootCellCode (movingArithmeticRootCuts nodes a coord) (w : ℝ)) : + (∀ f ∈ nodes, f.guard.ValidAt (movingGiantUpdate a coord z) ∧ + f.newGiant.IntegralAt (movingGiantUpdate a coord z)) ↔ + (∀ f ∈ nodes, f.guard.ValidAt (movingGiantUpdate a coord w) ∧ + f.newGiant.IntegralAt (movingGiantUpdate a coord w)) := by + apply forall_congr' + intro f + apply imp_congr_right + intro hf + rw [f.holds_polynomials, f.holds_polynomials] + have hres' := f.residueTests_modEq (movingGiantUpdate a coord z) (movingGiantUpdate a coord w) + (fun i => (hres i).of_dvd (by exact_mod_cast movingArithmeticPeriod_dvd nodes f hf)) + apply and_congr hres' + apply and_congr Iff.rfl + apply forall_congr' + intro j + exact polynomial_nonneg_iff_of_root_cell (f.guard.polynomials a coord j) + (movingArithmeticRootCuts nodes a coord) + (movingArithmeticRootCuts_mem nodes a coord f hf j) hcell + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..e60189a8e5a9512fc9f588f23abf66ceb1ef5b5b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportWeight.lean @@ -0,0 +1,151 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTopCells + +namespace OAI + +/-! # Separating the exact arithmetic indicator from the recursive weight -/ + +namespace Ostmann +open scoped Classical + +/-- Evaluation along the forced integer pivots with just the arithmetic +indicators removed. The same leaf and node factors remain. -/ +noncomputable def movingUnrestrictedWeight {σ : Type*} (value : σ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) + (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) : + {n : ℕ} → MovingSlotData σ n → ℕ → ℕ → ℂ + | _, .leaf s regular, XL, XR => F ⟨0, .leaf s regular, XL, XR⟩ s + | n + 1, .node s CL CR u left right, XL, XR => + let p := (MovingSlotData.step s CL CR u left right false).naturalPivot value XL XR + (extra ⟨n + 1, .node s CL CR u left right, XL, XR⟩ s left.frequency right.frequency : ℂ) * + movingUnrestrictedWeight value F extra left p XL * + star (movingUnrestrictedWeight value F extra right p XR) + +noncomputable def movingArithmeticIndicator {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : ℂ := + if T.ArithmeticSupport value childBound pivotBound XL XR then 1 else 0 + +theorem movingSlotWeight_arithmeticSupport {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hf : T.Frequencies (· ≠ 0)) (XL XR : ℕ) + (hw : recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t ≠ 0) : + T.ArithmeticSupport value childBound pivotBound XL XR := by + let a := topGiantInput XL XR + have hL : (HistoryFormula.prime false).value (fun b => (a b : ℚ)) = (XL : ℚ) := by + simp [a, topGiantInput] + have hR : (HistoryFormula.prime true).value (fun b => (a b : ℚ)) = (XR : ℚ) := by + simp [a, topGiantInput] + exact (T.formulaNodes_iff value hvalue childBound pivotBound hf XL XR _ _ a hL hR).mp + (movingSlotWeight_formulaNodes value hvalue childBound pivotBound F extra T t hT hf + XL XR _ _ a hL hR hw) + +/-- The support indicator itself forces the exact positive integer recursion. -/ +theorem MovingSlotData.ArithmeticSupport.integral {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) + (hsupport : T.ArithmeticSupport value childBound pivotBound XL XR) : + T.Integral value XL XR := by + induction T generalizing XL XR with + | leaf => trivial + | @node n s CL CR u left right ihL ihR => + obtain ⟨Q, hQ, hdiv, hleft, hright⟩ := hsupport + let U := MovingSlotReversal.naturalProduct value u + let step := MovingSlotData.step s CL CR u left right false + have hU : 0 < U := Nat.pos_of_ne_zero (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) + have hp : step.naturalPivot value XL XR = Q / U := by + change reconstructedPivot _ s / U = Q / U + congr 1 + apply reconstructedPivot_of_eq _ _ hQ.root_ne_zero Q + simpa only [step, MovingSlotData.step, Nat.mul_one, movingSlotSystem, + MovingSlotState.leftProduct, MovingSlotState.rightProduct] using hQ.relation + have hQeq : Q = U * (Q / U) := (Nat.mul_div_cancel' hdiv).symm + change (step.IntegralAt value (XL, XR) ∧ _ ∧ _) + refine ⟨?_, ?_, ?_⟩ + · change 0 < step.naturalPivot value XL XR ∧ _ + rw [hp] + refine ⟨Nat.div_pos (Nat.le_of_dvd hQ.pivot_pos hdiv) hU, ?_⟩ + change left.frequency * ((XR * MovingSlotReversal.naturalProduct value CR : ℕ) : ℤ) - + right.frequency * ((XL * MovingSlotReversal.naturalProduct value CL : ℕ) : ℤ) = + s * ((U * (Q / U) : ℕ) : ℤ) + rw [← hQeq] + exact hQ.relation + · rw [hp] + exact ihL _ _ hleft + · rw [hp] + exact ihR _ _ hright + +/-- On the derived support every guard evaluates to one, so only the original +leaf weights and extra node factors remain. -/ +theorem movingSlotWeight_eq_unrestricted {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (XL XR : ℕ) (hsupport : T.ArithmeticSupport value childBound pivotBound XL XR) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t = + movingUnrestrictedWeight value F extra T XL XR := by + let sys := movingSlotSystem value childBound pivotBound + let cutoff := movingSlotCutoff value childBound pivotBound extra + induction T generalizing XL XR with + | leaf s regular => + have hs : s = t := hT + simp only [recursiveTransferWeight, movingUnrestrictedWeight, hs] + | @node n s CL CR u left right ihL ihR => + obtain ⟨Q, hQ, hdiv, hleft, hright⟩ := hsupport + let x : MovingSlotState σ := ⟨n + 1, .node s CL CR u left right, XL, XR⟩ + let U := MovingSlotReversal.naturalProduct value u + let p := (MovingSlotData.step s CL CR u left right false).naturalPivot value XL XR + have hU : 0 < U := Nat.pos_of_ne_zero (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) + have hQ' : ValidTransferNode sys x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) Q := by + simpa only [← hT.1, ← hT.2.1.root, ← hT.2.2.root] using hQ + have hp : Q / U = p := by + rw [← hQ'.historyPivot_eq] + simp only [historyPivot, sys, movingSlotSystem, MovingSlotState.leftProduct, + MovingSlotState.rightProduct, x, ← hT.1, ← hT.2.1.root, ← hT.2.2.root, + p, MovingSlotReversal.naturalPivot, MovingSlotData.step, movingGiantPivot, Nat.mul_one, U] + have hc : cutoff x t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) = + extra x s left.frequency right.frequency := by + change (if 0 < U ∧ U ∣ historyPivot sys x t.1 _ _ then _ else 0) = _ + rw [hQ'.historyPivot_eq, ite_eq_left ⟨hU, hdiv⟩] + simp only [← hT.1, ← hT.2.1.root, ← hT.2.2.root] + rw [recursiveTransferWeight_node sys F cutoff n x t Q hQ', hc] + change (extra x s left.frequency right.frequency : ℂ) * + recursiveTransferWeight sys F cutoff n ⟨n, left, Q / U, XL⟩ t.2.1 * + star (recursiveTransferWeight sys F cutoff n ⟨n, right, Q / U, XR⟩ t.2.2) = _ + rw [ihL t.2.1 hT.2.1 (Q / U) XL hleft, ihR t.2.2 hT.2.2 (Q / U) XR hright, hp] + rfl + +/-- This factorization includes every zero-support term; it is suitable for +weighted prime sums without conditioning away the original arithmetic tests. -/ +theorem movingSlotWeight_indicator_factor {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (extra : MovingSlotState σ → ℤ → ℤ → ℤ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hf : T.Frequencies (· ≠ 0)) (XL XR : ℕ) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) F + (movingSlotCutoff value childBound pivotBound extra) n ⟨n, T, XL, XR⟩ t = + movingArithmeticIndicator value childBound pivotBound T XL XR * + movingUnrestrictedWeight value F extra T XL XR := by + by_cases hs : T.ArithmeticSupport value childBound pivotBound XL XR + · rw [movingArithmeticIndicator, ite_eq_left hs, one_mul] + exact movingSlotWeight_eq_unrestricted value hvalue childBound pivotBound F extra T t hT XL XR hs + · rw [movingArithmeticIndicator, ite_eq_right hs, zero_mul] + by_contra hn + exact hs (movingSlotWeight_arithmeticSupport value hvalue childBound pivotBound F extra T t hT hf XL XR hn) + +theorem movingArithmeticIndicator_cells {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XL YL XR : ℕ) + (hres : (XL : ℤ) ≡ (YL : ℤ) [ZMOD movingTopPeriod value hvalue childBound pivotBound T hf]) + (hcell : rootCellCode (movingTopRootCuts value hvalue childBound pivotBound T hf XR) (XL : ℝ) = + rootCellCode (movingTopRootCuts value hvalue childBound pivotBound T hf XR) (YL : ℝ)) : + movingArithmeticIndicator value childBound pivotBound T XL XR = + movingArithmeticIndicator value childBound pivotBound T YL XR := by + unfold movingArithmeticIndicator + rw [moving_top_support_cells value hvalue childBound pivotBound T hf XL YL XR hres hcell] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedCells.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..94db0e86e807fc6655c431b0fb7d7c752e845ba0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedCells.lean @@ -0,0 +1,129 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticCells + +namespace OAI + +/-! # Cell values for supported residue weights -/ + +namespace Ostmann +open scoped Classical BigOperators +open MeasureTheory + +noncomputable def movingSupportedCellValue {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (XR a M : ℕ) (S : Finset ℝ) (w : ℕ → ℂ) (code : S → Ordering) : ℂ := + if h : ∃ XL : ℕ, (XL : ℤ) ≡ (a : ℤ) [ZMOD M] ∧ + rootCellCode S (XL : ℝ) = code ∧ T.ArithmeticSupport value childBound pivotBound XL XR + then w (Classical.choose h) else 0 + +theorem movingSupportedCellValue_norm {σ : Type*} (value : σ → ℕ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (XR a M : ℕ) (S : Finset ℝ) (w : ℕ → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hw : ∀ XL, T.ArithmeticSupport value childBound pivotBound XL XR → ‖w XL‖ ≤ B) + (code : S → Ordering) : + ‖movingSupportedCellValue value childBound pivotBound T XR a M S w code‖ ≤ B := by + unfold movingSupportedCellValue + split_ifs with h + · exact hw _ (Classical.choose_spec h).2.2 + · simpa only [norm_zero] using hB + +/-- The cell representative is used only on the proved original support. +Its value is independent of the representative by the supplied local identity. -/ +theorem movingSupportedCellValue_eq {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M : ℕ) + (S : Finset ℝ) (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hS : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ S) + (w : ℕ → ℂ) + (hw : ∀ XL YL, T.ArithmeticSupport value childBound pivotBound XL XR → + T.ArithmeticSupport value childBound pivotBound YL XR → + (XL : ℤ) ≡ (YL : ℤ) [ZMOD M] → + rootCellCode S (XL : ℝ) = rootCellCode S (YL : ℝ) → w XL = w YL) + (XL : ℕ) (hres : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) : + movingArithmeticIndicator value childBound pivotBound T XL XR * w XL = + movingSupportedCellValue value childBound pivotBound T XR a M S w + (rootCellCode S (XL : ℝ)) := by + unfold movingSupportedCellValue movingArithmeticIndicator + by_cases hX : T.ArithmeticSupport value childBound pivotBound XL XR + · have hE : ∃ YL : ℕ, (YL : ℤ) ≡ (a : ℤ) [ZMOD M] ∧ + rootCellCode S (YL : ℝ) = rootCellCode S (XL : ℝ) ∧ + T.ArithmeticSupport value childBound pivotBound YL XR := ⟨XL, hres, rfl, hX⟩ + rw [ite_eq_left hX, dite_eq_left hE, one_mul] + have hc := Classical.choose_spec hE + exact hw XL _ hX hc.2.2 (hres.trans hc.1.symm) hc.2.1.symm + · have hE : ¬ ∃ YL : ℕ, (YL : ℤ) ≡ (a : ℤ) [ZMOD M] ∧ + rootCellCode S (YL : ℝ) = rootCellCode S (XL : ℝ) ∧ + T.ArithmeticSupport value childBound pivotBound YL XR := by + rintro ⟨YL, hresY, hcode, hY⟩ + have ht := moving_top_support_cells value hvalue childBound pivotBound T hf YL XL XR + ((hresY.trans hres.symm).of_dvd (by exact_mod_cast hM)) + (rootCellCode_eq_of_subset _ S hS _ _ hcode) + exact hX (ht.mp hY) + rw [ite_eq_right hX, dite_eq_right hE, zero_mul] + +theorem movingSupportedPrimeInterval_cells {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M : ℕ) + (S : Finset ℝ) (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hS : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ S) + (w : ℕ → ℂ) + (hw : ∀ XL YL, T.ArithmeticSupport value childBound pivotBound XL XR → + T.ArithmeticSupport value childBound pivotBound YL XR → + (XL : ℤ) ≡ (YL : ℤ) [ZMOD M] → + rootCellCode S (XL : ℝ) = rootCellCode S (YL : ℝ) → w XL = w YL) + (u v : ℝ) (f : ℝ → ℂ) : + complexPrimeInterval M a u v (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + w ⌊Real.exp y⌋₊) * f y) = + complexPrimeInterval M a u v (fun y => + movingSupportedCellValue value childBound pivotBound T XR a M S w + (rootCellCode S (Real.exp y)) * f y) := by + apply complexPrimeInterval_congr + intro p hp hprime hpa + have hp0 : (0 : ℝ) < p := by exact_mod_cast hprime.pos + rw [Real.exp_log hp0, Nat.floor_natCast] + rw [movingSupportedCellValue_eq value hvalue childBound pivotBound T hf XR a M S hM hS + w hw p (Int.natCast_modEq_iff.mpr hpa)] + +/-- The original gate times a residue weight is compared without deleting +boundary primes or changing the retained Page density. -/ +theorem PublishedProgressionInput.moving_supported_prime_comparison + (P : PublishedProgressionInput) {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR a M Q : ℕ) + (hM : movingTopPeriod value hvalue childBound pivotBound T hf ∣ M) + (hQ : 2 ≤ Q) (hq : 1 ≤ M) (hqQ : M ≤ Q) (ha : a.Coprime M) + (u v : ℝ) (hu : 1 ≤ u) (huv : u ≤ v) (hshort : v ≤ u + 1) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) (S : Finset ℝ) + (hS : movingTopRootCuts value hvalue childBound pivotBound T hf XR ⊆ S) + (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (w : ℕ → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hwB : ∀ XL, T.ArithmeticSupport value childBound pivotBound XL XR → ‖w XL‖ ≤ B) + (hw : ∀ XL YL, T.ArithmeticSupport value childBound pivotBound XL XR → + T.ArithmeticSupport value childBound pivotBound YL XR → + (XL : ℤ) ≡ (YL : ℤ) [ZMOD M] → + rootCellCode S (XL : ℝ) = rootCellCode S (YL : ℝ) → w XL = w YL) : + ∃ (s : ℕ → ℝ) (N : ℕ) (d : ℕ → ℂ), + Monotone s ∧ s 0 = u ∧ s N = v ∧ N ≤ S.card + 1 ∧ (∀ j, ‖d j‖ ≤ B) ∧ + ‖complexPrimeInterval M a u v (fun y => + (movingArithmeticIndicator value childBound pivotBound T ⌊Real.exp y⌋₊ XR * + w ⌊Real.exp y⌋₊) * smoothPolynomialWeight F (Real.exp y)) - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + d j * smoothPolynomialWeight F (Real.exp y) * + (selectedPrimeLogDensity P Q M a y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, + (‖d j‖ * smoothPolynomialBudget F * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ)))) + + 2 * B * smoothPolynomialBudget F * Real.exp (-(s j))) := by + obtain ⟨s, N, d, hs, hs0, hsN, hN, hd, herr⟩ := P.root_cell_prime_comparison hQ hq hqQ ha + u v hu huv hshort F S hroots + (movingSupportedCellValue value childBound pivotBound T XR a M S w) B hB + (movingSupportedCellValue_norm value childBound pivotBound T XR a M S w B hB hwB) + refine ⟨s, N, d, hs, hs0, hsN, hN, hd, ?_⟩ + rw [movingSupportedPrimeInterval_cells value hvalue childBound pivotBound T hf XR a M S + hM hS w hw] + exact herr + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedOuterComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedOuterComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..df0483bf159d9e8e8ab06d20321530c1da4cdd6f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedOuterComparison.lean @@ -0,0 +1,138 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedOuterFactor +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterCoprimeComparison + +namespace OAI + +/-! # Corrected Haar comparison for the literal fully supported history pair -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_original_supported_prime_haar_rate (P : PublishedProgressionInput) + {σ I : Type*} (p : I → ℕ) [∀ i, Fact (p i).Prime] (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + q = movingFullPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p S → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := movingFullPairResidueCoefficient p value outside F E g Dq S T nodes + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊)) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [(P.moving_outer_coprime_prime_haar_rate n C d).mono (fun _ h => h σ)] with L hL + intro tier value hprime hdisjoint outside childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod + F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q hQ hq hqQ hqeq hlog u v r s hu huv hshort hr hrs hrshort hqlog + dsimp only + intro A hA0 hA hbudget + let hv := fun i => (hprime i).ne_zero + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := movingFullPairResidueCoefficient p value outside F E g Dq S T nodes + have h := hL value hv childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c A hA0 hA hbudget + dsimp only at h + have hfactor (x y : ℕ) : + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t x y = + if x.Coprime y then c (x % q) (y % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal x y else 0 := by + rw [hqeq] + exact movingOriginalSupportedOuterPair_factor p tier value hprime hdisjoint outside childBound pivotBound + F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal + T t hT hf hlevels hcoh hc hsmall hfmod x y + simpa only [hfactor] using h + +theorem PublishedProgressionInput.moving_original_supported_mixed_haar_rate (P : PublishedProgressionInput) + {σ I : Type*} (p : I → ℕ) [∀ i, Fact (p i).Prime] (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hc : ∀ b, (T b).CompensationPrimeData value) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + q = movingFullPairModulus value (fun i => (hprime i).ne_zero) outside childBound pivotBound T hf p S → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := movingFullPairResidueCoefficient p value outside F E g Dq S T nodes + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * (A * giantOuterScalar diagonal) * movingOuterVariationBudget ψ V lo hi n B D diagonal ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊)) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * correctedMixedPairAverage P Q q c y / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [(P.moving_outer_coprime_mixed_haar_rate n C d).mono (fun _ h => h σ)] with L hL + intro tier value hprime hdisjoint outside childBound pivotBound T hf t hT hlevels hcoh hc hsmall hfmod + F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal V hV + Q q hQ hq hqQ hqeq hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog + dsimp only + intro A hA0 hA hbudget + let hv := fun i => (hprime i).ne_zero + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := movingFullPairResidueCoefficient p value outside F E g Dq S T nodes + have h := hL value hv childBound pivotBound T hf ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout + diagonal V hV Q q hQ hq hqQ hlog u v r s J hJ huv hshort hvJ hr hrs hrshort hqlog c A hA0 hA hbudget + dsimp only at h + have hfactor (x y : ℕ) : + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t x y = + if x.Coprime y then c (x % q) (y % q) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal x y else 0 := by + rw [hqeq] + exact movingOriginalSupportedOuterPair_factor p tier value hprime hdisjoint outside childBound pivotBound + F E g hg Dq S ψ X lo hi hlo hhi φ G Jleft Jright B D hB hD hφ hlip hout diagonal + T t hT hf hlevels hcoh hc hsmall hfmod x y + simpa only [hfactor] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedOuterFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedOuterFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..f12b0b7b7bf908490126832555dd370d96752996 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedOuterFactor.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedPair +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullModulus +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterKernel + +namespace OAI + +/-! # Literal supported two-history weights with their original outer priors -/ + +namespace Ostmann +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +noncomputable def movingFullPairResidueCoefficient {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : Bool → MovingSlotData σ n) (nodes : Bool → List MovingFormulaNode) + (a b : ℕ) : ℂ := + movingResidueSupportedWeight value outside (T false) a b + (movingResidueCoefficient q value (F false) (E false) g (Dq false) S (T false) (nodes false) a b) * + conj (movingResidueSupportedWeight value outside (T true) a b + (movingResidueCoefficient q value (F true) (E true) g (Dq true) S (T true) (nodes true) a b)) + +noncomputable def movingOriginalSupportedOuterPair {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) {n : ℕ} (T : Bool → MovingSlotData σ n) + (t : Bool → FrequencyTree ℤ n) (XL XR : ℕ) : ℂ := + (movingSupportedWeight value outside (T false) XL XR + (movingOriginalGiantWeight q value childBound pivotBound (F false) (E false) g (Dq false) S + ψ X lo hi φ G (T false) (t false) XL XR) * + conj (movingSupportedWeight value outside (T true) XL XR + (movingOriginalGiantWeight q value childBound pivotBound (F true) (E true) g (Dq true) S + ψ X lo hi φ G (T true) (t true) XL XR))) * + giantOuterWeight φ Jleft Jright diagonal XL XR + +theorem movingOriginalSupportedOuterPair_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (hT : ∀ b, (T b).Follows (t b)) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hlevels : ∀ b, (T b).Levels tier) (hcoh : ∀ b, (T b).RegularCoherent) + (hc : ∀ b, (T b).CompensationPrimeData value) + (hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (XL XR : ℕ) : + let hv := fun i => (hprime i).ne_zero + let M := movingFullPairModulus value hv outside childBound pivotBound T hf q S + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := movingFullPairResidueCoefficient q value outside F E g Dq S T nodes + movingOriginalSupportedOuterPair q value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + Jleft Jright diagonal T t XL XR = + if XL.Coprime XR then c (XL % M) (XR % M) * + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal XL XR else 0 := by + dsimp only + let hv := fun i => (hprime i).ne_zero + let M := movingFullPairModulus value hv outside childBound pivotBound T hf q S + have ht := movingFullPairModulus_tests value hv outside childBound pivotBound T hf q S + have h := movingOriginalGiantWeight_supported_pair_factor q tier value hprime hdisjoint outside childBound pivotBound + F E g hg Dq S ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout T t hT hf hlevels hcoh hc hsmall hfmod + XL XR (XL % M) (XR % M) M ht.1 ht.2.1 ht.2.2.1 ht.2.2.2 + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XL M).symm) + (Int.natCast_modEq_iff.mpr (Nat.mod_modEq XR M).symm) + dsimp only [movingOriginalSupportedOuterPair] + rw [h] + by_cases hp : XL.Coprime XR + · rw [ite_eq_left hp, ite_eq_left hp] + exact mul_assoc _ _ _ + · rw [ite_eq_right hp, ite_eq_right hp, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedPair.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..6f9b33057679735609856a9ab982a37f0842d2d9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedPair.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportedWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPair + +namespace OAI + +/-! # The fully supported two-history coefficient and its residue mask -/ + +namespace Ostmann +open scoped BigOperators Classical ComplexConjugate SchwartzMap + +theorem movingSupportedPair_norm {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (a b : ℤ) (c : Bool → ℂ) : + ‖movingResidueSupportedWeight value outside (T false) a b (c false) * + conj (movingResidueSupportedWeight value outside (T true) a b (c true))‖ ≤ + ‖c false * conj (c true)‖ := by + simp only [norm_mul, Complex.norm_conj] + exact mul_le_mul (movingResidueSupportedWeight_norm value outside _ a b _) + (movingResidueSupportedWeight_norm value outside _ a b _) (norm_nonneg _) (norm_nonneg _) + +theorem movingOriginalGiantWeight_supported_pair_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : Bool → MovingSlotData σ n) (t : Bool → FrequencyTree ℤ n) + (hT : ∀ b, (T b).Follows (t b)) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (hlevels : ∀ b, (T b).Levels tier) (hcoh : ∀ b, (T b).RegularCoherent) + (hc : ∀ b, (T b).CompensationPrimeData value) + (hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (XL XR a b M : ℕ) + (hM : ∀ b, movingTopPeriod value (fun i => (hprime i).ne_zero) childBound pivotBound (T b) (hf b) ∣ M) + (hMq : ∀ b, ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value (T b) ∣ (M : ℤ)) + (hunit : ∀ b, movingGiantUnitPeriod value outside (T b) ∣ (M : ℤ)) + (hsquare : ∀ b, ∀ o ∈ (T b).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ (M : ℤ)) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := fun side => movingResidueSupportedWeight value outside (T side) a b + (movingResidueCoefficient q value (F side) (E side) g (Dq side) S (T side) (nodes side) a b) + movingSupportedWeight value outside (T false) XL XR + (movingOriginalGiantWeight q value childBound pivotBound (F false) (E false) g (Dq false) S + ψ X lo hi φ G (T false) (t false) XL XR) * + conj (movingSupportedWeight value outside (T true) XL XR + (movingOriginalGiantWeight q value childBound pivotBound (F true) (E true) g (Dq true) S + ψ X lo hi φ G (T true) (t true) XL XR)) = + if XL.Coprime XR then (c false * conj (c true)) * + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G XL XR else 0 := by + dsimp only + rw [movingOriginalGiantWeight_full_factor q tier value hprime hdisjoint outside childBound pivotBound + (F false) (E false) g hg (Dq false) S ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + (T false) (t false) (hT false) (hlevels false) (hcoh false) (hc false) (hf false) + (hsmall false) (hfmod false) XL XR a b M (hM false) (hMq false) (hunit false) (hsquare false) hL hR, + movingOriginalGiantWeight_full_factor q tier value hprime hdisjoint outside childBound pivotBound + (F true) (E true) g hg (Dq true) S ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + (T true) (t true) (hT true) (hlevels true) (hcoh true) (hc true) (hf true) + (hsmall true) (hfmod true) XL XR a b M (hM true) (hMq true) (hunit true) (hsquare true) hL hR] + by_cases hp : XL.Coprime XR + · rw [ite_eq_left hp, ite_eq_left hp, ite_eq_left hp, map_mul, movingRealKernelPair] + ring + · rw [ite_eq_right hp, ite_eq_right hp, ite_eq_right hp, map_zero, mul_zero] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedPairHaarComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedPairHaarComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..91885786cd9d2487cdb405c41816da41867f03f2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedPairHaarComparison.lean @@ -0,0 +1,176 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedSupportedPair +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairCoprimeComparison +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationSupport + +namespace OAI + +/-! # The original prime-pair Haar comparison at the separated frequency/internal/spectator modulus -/ + +namespace Ostmann +universe u v +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_original_supported_pair_haar_rate_uniform (P : PublishedProgressionInput) + (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u) (I : Type v) (p : I → ℕ) [∀ i, Fact (p i).Prime], + ∀ (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (_hcover : ∀ q ∈ outside, ∃ i ∈ S, p i = q) + (R : ℤ) (_hR : ∀ b, (T b).frequencyProduct ∣ R) + (_hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (_hden : ∀ b i, i ∈ S → (T b).ModularDenominators value (p i)) + (Reg : ℕ) + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = Reg) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + R ^ (n + 1) ∣ (q : ℤ) → + (∀ b, ∀ o ∈ (T b).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ q) → + (∀ i ∈ S, (p i : ℤ) ∣ q) → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + 0 < Reg → Real.log (Reg : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := movingSeparatedPairResidueCoefficient p value outside F E g Dq S T nodes R + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * A * (movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + movingOriginalSupportedPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊)) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_pair_coprime_prime_haar_rate_uniform n C d, + eventually_gt_atTop (0 : ℝ)] with L hL hL0 + intro σ I p _ tier value hprime hdisjoint outside childBound pivotBound T hf t hT hlevels hcoh hsmall hfmod + F E g hg Dq S hcover R hR hsmallR hden Reg hregular ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout V hV + Q q hQ hq hqQ hfrequency hsquare hspectator hlog u v r s hu huv hshort hr hrs hrshort hqlog hReg0 hReglog + dsimp only + intro A hA0 hA hbudget + by_cases hd : ∀ b, (T b).CompensationDistinct value + · have hc : ∀ b, (T b).CompensationPrimeData value := fun b => + (T b).compensationPrimeData_of_units value hprime (hsmall b) (hd b) + let hv := fun i => (hprime i).ne_zero + let nodes := fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true) + let c := movingSeparatedPairResidueCoefficient p value outside F E g Dq S T nodes R + let f := fun x y : ℕ => movingOriginalSupportedPair p value outside childBound pivotBound F E g Dq S + ψ X lo hi φ G T t x y + let f₀ := fun x y : ℕ => if x.Coprime y then c (x % q) (y % q) * + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G x y else 0 + have h := hL σ value hv childBound pivotBound T hf ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + V hV Q q hQ hq hqQ hlog u v r s hu huv hshort hr hrs hrshort hqlog c A hA0 hA hbudget + dsimp only at h + have hfactor (x : ℕ) (hx : x ∈ Finset.Ioc ⌊Real.exp u⌋₊ ⌊Real.exp v⌋₊) (hxp : x.Prime) + (y : ℕ) (hy : y ∈ Finset.Ioc ⌊Real.exp r⌋₊ ⌊Real.exp s⌋₊) (hyp : y.Prime) : f x y = f₀ x y := by + have hXL : x.Coprime Reg := hxp.coprime_iff_not_dvd.mpr (fun hd => + (not_le_of_gt (giant_interval_gt_modulus L hL0 Reg hReg0 hReglog u v hu x hx)) + (Nat.le_of_dvd hReg0 hd)) + have hXR : y.Coprime Reg := hyp.coprime_iff_not_dvd.mpr (fun hd => + (not_le_of_gt (giant_interval_gt_modulus L hL0 Reg hReg0 hReglog r s hr y hy)) + (Nat.le_of_dvd hReg0 hd)) + exact movingOriginalSupportedPair_separated_factor p tier value hprime hdisjoint outside + childBound pivotBound F E g hg Dq S hcover ψ X lo hi hlo hhi φ G B D hB hD + hφ hlip hout T t hT hf hlevels hcoh hc hsmall hfmod R hR hsmallR hden + Reg hregular q hfrequency hsquare hspectator x y hXL hXR + have heq : complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v + (fun x => f ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊)) = + complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v + (fun x => f₀ ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊)) := by + apply complexPrimeInterval_congr + intro y hy hyp _ + rw [Real.exp_log (by exact_mod_cast hyp.pos), Nat.floor_natCast] + apply complexPrimeInterval_congr + intro x hx hxp _ + rw [Real.exp_log (by exact_mod_cast hxp.pos), Nat.floor_natCast] + exact hfactor x hx hxp y hy hyp + change ‖complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v + (fun x => f ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊)) - _‖ ≤ _ + rw [heq] + exact h + · obtain ⟨b, hb⟩ := not_forall.mp hd + have horiginal (XL XR : ℕ) : + movingOriginalSupportedPair p value outside childBound pivotBound F E g Dq S + ψ X lo hi φ G T t XL XR = 0 := by + have hz := movingSupportedWeight_zero_of_compensation_collision value outside + (T b) (hcoh b) hb XL XR + cases b <;> simp only [movingOriginalSupportedPair, hz, map_zero, zero_mul, mul_zero] + have hsep (nodes : Bool → List MovingFormulaNode) (a b' : ℕ) : + movingSeparatedPairResidueCoefficient p value outside F E g Dq S T nodes R a b' = 0 := by + have hz := movingSeparatedResidueCoefficient_zero_of_compensation_collision p value outside + (F b) (E b) g (Dq b) S (T b) (nodes b) R a b' (hcoh b) hb + cases b <;> simp only [movingSeparatedPairResidueCoefficient, hz, map_zero, zero_mul, mul_zero] + simp [horiginal, hsep, correctedPrimePairAverage, complexPrimeInterval] + positivity + +theorem PublishedProgressionInput.moving_original_supported_pair_haar_rate (P : PublishedProgressionInput) + {σ : Type u} {I : Type v} (p : I → ℕ) [∀ i, Fact (p i).Prime] (n : ℕ) (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) (S : Finset I) + (_hcover : ∀ q ∈ outside, ∃ i ∈ S, p i = q) + (R : ℤ) (_hR : ∀ b, (T b).frequencyProduct ∣ R) + (_hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (_hden : ∀ b i, i ∈ S → (T b).ModularDenominators value (p i)) + (Reg : ℕ) + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = Reg) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (_hB : 0 ≤ B) (_hD : 0 ≤ D) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + ∀ Q q : ℕ, 2 ≤ Q → ∀ hq : 1 ≤ q, q ≤ Q → + R ^ (n + 1) ∣ (q : ℤ) → + (∀ b, ∀ o ∈ (T b).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ q) → + (∀ i ∈ S, (p i : ℤ) ∣ q) → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v r s : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + Real.log (q : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + 0 < Reg → Real.log (Reg : ℝ) ≤ Real.exp ((12 / 1000 : ℝ) * L) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c := movingSeparatedPairResidueCoefficient p value outside F E g Dq S T nodes R + ∀ A : ℝ, 0 ≤ A → (∀ a < q, ∀ b < q, ‖c a b‖ ≤ A) → + 2 * A * (movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) ^ 2 ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + letI : NeZero q := ⟨by omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v (fun x => + movingOriginalSupportedPair p value outside childBound pivotBound F E g Dq S ψ X lo hi φ G + T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊)) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingRealKernelPair value T nodes ψ X lo hi hlo hhi φ G (Real.exp x) (Real.exp y) * + correctedPrimePairAverage P Q q c x y / ((x : ℂ) * (y : ℂ)))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_original_supported_pair_haar_rate_uniform n C d] with L hL + exact hL σ I p + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedRegularProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedRegularProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a2b23a87a6b6c674e0c7ba64811641a0892328a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedRegularProduct.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularMultiplierIdentity +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularCollisionSupport + +namespace OAI + +/-! # The genuine common-product factor on the entire original sample space -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingOriginalSupportedOuterPair_regular_product {B C I : Type*} [Fintype I] + {N n m : ℕ} (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) (value : Fin (N + 1) → ℕ) + (hprime : ∀ i, (value i).Prime) (outside : List ℕ) + (p : I → ℕ) [∀ i, Fact (p i).Prime] + (gspec : ∀ i, ZMod (p i) → ℂ) (Dq : Bool → ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) + (childBound pivotBound : ℕ → ℕ) + (F : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℂ) + (E : Bool → {d : ℕ} → MovingSlotData (Fin (N + 1)) d → ℤ → ℤ → ℤ → ℝ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (XL XR : ℕ) : + let slots := movingPatternRegularSlots e n m small slot + let q := fun i : Fin slots.length => value (slots.get i) + let : ∀ i, Fact (q i).Prime := fun _ => ⟨hprime _⟩ + let T := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let W := movingOriginalSupportedOuterPair p value outside childBound pivotBound F E gspec Dq + Finset.univ ψ X lo hi φ G Jleft Jright diagonal T t XL XR + W * (naturalRegularMultiplier q (fun _ => true) s + (fun i => (movingRegularOther value outside slots i : ZMod (q i))) + (fun i => greg (q i)) XL XR : ℂ) = + W * (‖primeProductTransform greg (outside.prod * XL * XR) + (MovingSlotReversal.naturalProduct value slots) s‖ ^ 2 : ℝ) := by + dsimp only + let T := movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern + let slots := movingPatternRegularSlots e n m small slot + let : ∀ i : Fin slots.length, Fact (value (slots.get i)).Prime := fun _ => ⟨hprime _⟩ + by_cases hgood : movingRegularOutsidePairwise value outside (T false) + · rw [movingPattern_regular_multiplier_eq_primeProduct e t small slot pattern value hprime + outside greg s XL XR hgood] + · have hbad : ¬ ∀ b, movingRegularOutsidePairwise value outside (T b) := fun h => hgood (h false) + have hz := movingOriginalSupportedOuterPair_zero_of_not_regular p value outside childBound + pivotBound F E gspec Dq Finset.univ ψ X lo hi φ G Jleft Jright diagonal T t hbad XL XR + change _ * _ = _ * _ + rw [hz, zero_mul, zero_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedSeparatedDiagonalRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedSeparatedDiagonalRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..83f9a7e2e14fd303da9f7621c4d37d4b42587eee --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedSeparatedDiagonalRate.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedDiagonalRate +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCompensationSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOuterVariationScale +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedRegularNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternGiantBounds + +namespace OAI + +/-! # Numerical giant comparison for the original diagonal -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators Classical SchwartzMap + +theorem PublishedProgressionInput.moving_original_supported_separated_diagonal_prime_rate (P : PublishedProgressionInput) + (ψ : 𝓢(ℝ, ℂ)) (n r₀ k : ℕ) (Afreq Wwin B D : ℝ) + (hAfreq : 0 ≤ Afreq) (hWwin : 0 ≤ Wwin) (hB : 0 ≤ B) (hD : 0 ≤ D) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (σ J : Type) [Fintype J] (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (_hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (T : Bool → MovingSlotData σ n) (hf : ∀ b, (T b).Frequencies (· ≠ 0)) + (t : Bool → FrequencyTree ℤ n) (_hT : ∀ b, (T b).Follows (t b)) + (_hlevels : ∀ b, (T b).Levels tier) (_hcoh : ∀ b, (T b).RegularCoherent) + (_hsmall : ∀ b i, (T b).Frequencies (fun s => IsCoprime s (value i : ℤ))) + (_hfmod : ∀ b i, (T b).Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (F : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : Bool → {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (_hg : ∀ i, g i 0 = 0) + (Dq : Bool → ∀ i, (ZMod (p i))ˣ) + (R : ℤ) (_hR : ∀ b, (T b).frequencyProduct ∣ R) + (_hsmallR : ∀ i, IsCoprime (value i : ℤ) R) + (_hden : ∀ b i, (T b).ModularDenominators value (p i)) + (_hcover : ∀ q ∈ outside, ∃ i, p i = q) + (reg : J → ℕ) [∀ i, Fact (reg i).Prime] + (_hregular : ∀ b, MovingSlotReversal.naturalProduct value (T b).regularSlots = ∏ i, reg i) + (active : J → Bool) (sreg : ℤ) (other : ∀ i, ZMod (reg i)) (greg : ∀ i, ZMod (reg i) → ℂ) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (Jleft Jright : ℝ) + (_hφ : ∀ x, |φ x| ≤ B) (_hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (_hout : ∀ x, 1 ≤ |x| → φ x = 0) (diagonal : Bool) (V : ℝ), (∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) → + 0 ≤ V → V ≤ Real.exp (Afreq * m) → hi - lo ≤ Real.exp (Wwin * m) → + (∀ i, (p i : ℝ) ≤ Real.exp (Real.exp ((1 / 1000 : ℝ) * L))) → + ∀ M : ℕ, ∀ _hM : NeZero M, + R ^ (n + 1) ∣ (M : ℤ) → + (∀ b, ∀ o ∈ (T b).occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ (M : ℤ)) → + (∀ i, (p i : ℤ) ∣ (M : ℤ)) → (∏ i, reg i).Coprime M → + ∀ q : ℕ, ∀ hq : 1 ≤ q, q ≤ giantProgressionCutoff L → + ∀ hqeq : q = (∏ i, reg i) * M, + (∀ b, movingRegularOutsidePairwise value outside (T b)) → + Pairwise (fun i j => (reg i).Coprime (reg j)) → + (∀ i, (∏ j, reg j).Coprime (p i)) → + pageAtModulus q (selectedPageZero P (giantProgressionCutoff L)) = + pageAtModulus (M) (selectedPageZero P (giantProgressionCutoff L)) → + (∀ i, (sreg : ZMod (reg i)) ≠ 0) → (∀ i, other i ≠ 0) → + (∀ i, greg i 0 = 0) → (∀ i, (∑ x : ZMod (reg i), ‖greg i x‖ ^ 2) = reg i) → + ∀ u v r s J : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ J → u ≤ v → v ≤ u + 1 → v ≤ J + 1 → + Real.exp ((49 / 1000 : ℝ) * L) ≤ r → r ≤ s → s ≤ r + 1 → + (∀ b, ‖movingDataWeight (F b) (E b) (T b)‖ ≤ 1) → + (∀ i z, ‖g i z‖ ≤ p i) → + let nodes := fun b => (T b).formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound (hf b) (.prime false) (.prime true) + let c0 := movingSeparatedPairResidueCoefficient p value outside F E g Dq Finset.univ T nodes R + let : NeZero q := ⟨by omega⟩ + let : NeZero (M) := ⟨by + intro hz + rw [hz, mul_zero] at hqeq + omega⟩ + ‖complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J (fun x => + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq Finset.univ ψ X lo hi φ G + Jleft Jright diagonal T t ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ * + (naturalRegularMultiplier reg active sreg other greg ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊ : ℂ))) - + (∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + movingOuterKernel value T nodes ψ X lo hi hlo hhi φ G Jleft Jright diagonal (Real.exp x) (Real.exp y) * + (Real.exp (x - J) : ℂ) * (((∏ i, if active i then (1 : ℝ) else 1 - (reg i : ℝ)⁻¹ : ℝ) : ℂ) * + correctedMixedPairAverage P (giantProgressionCutoff L) (M) c0 y) / (y : ℂ))‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) + Real.exp (-Real.exp ((1225 / 100000 : ℝ) * L)) := by + filter_upwards [P.moving_original_separated_diagonal_prime_rate ψ n r₀ k Afreq Wwin B D + hAfreq hWwin hB hD] with L hrate + dsimp only + intro σ J _ p _ tier value hprime hdisjoint outside childBound pivotBound T hf t hT + hlevels hcoh hsmall hfmod F E g hg Dq R hR hsmallR hden hcover reg _ hregular active sreg other greg + X lo hi hlo hhi φ G Jleft Jright hφ hlip hout diagonal V hV hV0 hVA hwindow hpupper + M hM hfrequency hsquare hspectator hcop q hq hqQ hqeq houtside hreg hqs hpage hsreg hother hgreg henergy + u v r s H hH huv hshort hvH hr hrs hrshort hweight hgnorm + by_cases hd : ∀ b, (T b).CompensationDistinct value + · have hc : ∀ b, (T b).CompensationPrimeData value := fun b => + (T b).compensationPrimeData_of_units value hprime (hsmall b) (hd b) + exact hrate σ J p tier value hprime hdisjoint outside childBound pivotBound T hf t hT + hlevels hcoh hc hsmall hfmod F E g hg Dq R hR hsmallR hden hcover reg hregular active sreg other greg + X lo hi hlo hhi φ G Jleft Jright hφ hlip hout diagonal V hV hV0 hVA hwindow hpupper + M hM hfrequency hsquare hspectator hcop q hq hqQ hqeq houtside hreg hqs hpage + hsreg hother hgreg henergy u v r s H hH huv hshort hvH hr hrs hrshort hweight hgnorm + · obtain ⟨b, hb⟩ := not_forall.mp hd + have horiginal (XL XR : ℕ) : + movingOriginalSupportedOuterPair p value outside childBound pivotBound F E g Dq Finset.univ + ψ X lo hi φ G Jleft Jright diagonal T t XL XR = 0 := by + have hz := movingSupportedWeight_zero_of_compensation_collision value outside + (T b) (hcoh b) hb XL XR + cases b <;> simp only [movingOriginalSupportedOuterPair, hz, map_zero, zero_mul, mul_zero] + have hsep (nodes : Bool → List MovingFormulaNode) (a b' : ℕ) : + movingSeparatedPairResidueCoefficient p value outside F E g Dq Finset.univ T nodes R a b' = 0 := by + have hz := movingSeparatedResidueCoefficient_zero_of_compensation_collision p value outside + (F b) (E b) g (Dq b) Finset.univ (T b) (nodes b) R a b' (hcoh b) hb + cases b <;> simp only [movingSeparatedPairResidueCoefficient, hz, map_zero, zero_mul, mul_zero] + simp [horiginal, hsep, correctedMixedPairAverage, complexPrimeInterval, complexIntegerInterval] + positivity + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..790e787e6b6d15bab996d9f47e7483edff2a06b3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSupportedWeight.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullResidues +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalGiantWeight + +namespace OAI + +/-! # Full manuscript support on the literal recursive giant weight -/ + +namespace Ostmann +open scoped Classical SchwartzMap + +noncomputable def movingFullSupport {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : Prop := + movingFullOutsidePairwise value outside T XL XR ∧ movingNaturalGiantUnits value outside T XL XR + +/-- Multiplying by this mask retains all current-state coprimality and all +subtree-frequency unit tests, including the fixed outside list. -/ +noncomputable def movingSupportedWeight {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) (z : ℂ) : ℂ := + if movingFullSupport value outside T XL XR then z else 0 + +noncomputable def movingResidueSupportedWeight {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (a b : ℤ) (z : ℂ) : ℂ := + if movingFullResidueSupport value outside T a b then z else 0 + +theorem movingResidueSupportedWeight_norm {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (a b : ℤ) (z : ℂ) : + ‖movingResidueSupportedWeight value outside T a b z‖ ≤ ‖z‖ := by + unfold movingResidueSupportedWeight + split_ifs <;> simp + +theorem movingSupportedWeight_residue {σ : Type*} (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hlevels : T.Levels tier) (hcoh : T.RegularCoherent) (hc : T.CompensationPrimeData value) + (hf : T.Frequencies (· ≠ 0)) + (hsmall : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (XL XR a b : ℕ) (M : ℤ) (z : ℂ) (hI : z ≠ 0 → T.Integral value XL XR) + (hunit : movingGiantUnitPeriod value outside T ∣ M) + (hsquare : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ M) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + movingSupportedWeight value outside T XL XR z = + if XL.Coprime XR then movingResidueSupportedWeight value outside T a b z else 0 := by + by_cases hz : z = 0 + · simp [movingSupportedWeight, movingResidueSupportedWeight, hz] + · have hs := movingFullSupport_residue_iff tier value hprime hdisjoint outside T hlevels hcoh hc + hf hsmall hfmod XL XR a b M (hI hz) hunit hsquare hL hR + unfold movingSupportedWeight movingFullSupport movingResidueSupportedWeight + rw [hs] + split_ifs <;> simp_all + +theorem movingOriginalGiantWeight_integral {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hf : T.Frequencies (· ≠ 0)) (XL XR : ℕ) + (hw : movingOriginalGiantWeight q value childBound pivotBound F E g Dq S + ψ X lo hi φ G T t XL XR ≠ 0) : T.Integral value XL XR := by + exact MovingSlotData.ArithmeticSupport.integral value hvalue childBound pivotBound T XL XR + (movingSlotWeight_arithmeticSupport value hvalue childBound pivotBound _ _ T t hT hf XL XR hw) + +/-- Exact factorization of the fully supported coefficient, with the single +nonperiodic top-pair coprimality indicator still visible. -/ +theorem movingOriginalGiantWeight_full_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (tier : σ → ℕ) (value : σ → ℕ) + (hprime : ∀ i, (value i).Prime) (hdisjoint : ∀ i j, tier i ≠ tier j → value i ≠ value j) + (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hlevels : T.Levels tier) (hcoh : T.RegularCoherent) (hc : T.CompensationPrimeData value) + (hf : T.Frequencies (· ≠ 0)) + (hsmall : ∀ i, T.Frequencies (fun s => IsCoprime s (value i : ℤ))) + (hfmod : ∀ i, T.Frequencies (fun s => (s : ZMod (value i)) ≠ 0)) + (XL XR a b M : ℕ) + (hM : movingTopPeriod value (fun i => (hprime i).ne_zero) childBound pivotBound T hf ∣ M) + (hMq : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (hunit : movingGiantUnitPeriod value outside T ∣ (M : ℤ)) + (hsquare : ∀ o ∈ T.occurrences, ∀ i ∈ o.current.compensationSlots, (value i ^ 2 : ℤ) ∣ (M : ℤ)) + (hL : (XL : ℤ) ≡ (a : ℤ) [ZMOD M]) (hR : (XR : ℤ) ≡ (b : ℤ) [ZMOD M]) : + let nodes := T.formulaNodes value (fun i => (hprime i).ne_zero) childBound pivotBound hf (.prime false) (.prime true) + movingSupportedWeight value outside T XL XR + (movingOriginalGiantWeight q value childBound pivotBound F E g Dq S ψ X lo hi φ G T t XL XR) = + if XL.Coprime XR then + movingResidueSupportedWeight value outside T a b + (movingResidueCoefficient q value F E g Dq S T nodes a b) * + movingRealKernel value T nodes ψ X lo hi hlo hhi φ G XL XR else 0 := by + dsimp only + have hvalue : ∀ i, value i ≠ 0 := fun i => (hprime i).ne_zero + rw [movingSupportedWeight_residue tier value hprime hdisjoint outside T hlevels hcoh hc hf + hsmall hfmod XL XR a b M _ + (movingOriginalGiantWeight_integral q value hvalue childBound pivotBound F E g Dq S + ψ X lo hi φ G T t hT hf XL XR) hunit hsquare hL hR, + movingOriginalGiantWeight_factor q value hvalue childBound pivotBound F E g hg Dq S + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout T t hT hf XL XR a b M hM hMq hL hR] + split_ifs + · unfold movingResidueSupportedWeight + split_ifs <;> simp + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedFullCell.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedFullCell.lean new file mode 100644 index 0000000000000000000000000000000000000000..17586d4f61c3830686f6e6dafe0b28b39b004126 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedFullCell.lean @@ -0,0 +1,28 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNormalizedSymmetrizedEnergy +import OAI.NumberTheory.Ostmann.Characters.MixedExternalPartition + +namespace OAI + +/-! # The full smooth cell for the original symmetrized coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTemplateMaskedSymmetrizedEnergy_full_cell_bound + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (ν : MovingRegularSlot n r m → P → ℝ) (active : MovingRegularSlot n r m → Bool) + (greg : ∀ q : ℕ, ZMod q → ℂ) (Jleft Jright : ℝ) (diagonal : Bool) + (H K center E : ℝ) + (h : ∀ i j : Bool, ‖movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G + n r m ν active greg Jleft Jright diagonal + (if i then H else H - 1) ((if i then H else H - 1) + 1) + (if j then K else K - 1) ((if j then K else K - 1) + 1) center‖ ≤ E) : + ‖movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G + n r m ν active greg Jleft Jright diagonal (H - 1) (H + 1) (K - 1) (K + 1) center‖ ≤ 4 * E := by + exact mixedExternalAverage_full_cell_bound ν (V n) H K center E _ h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedMaskedEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedMaskedEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..a1999aa10b83590c17c57f3a6f6a9708ef048edc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedMaskedEnergy.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSymmetrizedMaskedKernel + +namespace OAI + +/-! # The bulk-averaged masked energy under the original restored prior -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingSymmetrizedMaskedTemplateEnergy + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (greg : ∀ q : ℕ, ZMod q → ℂ) + (weight : (MovingRegularSlot n (4 + r) m → P) → ℝ) : ℝ := + ∑ x : MovingRegularSlot n (4 + r) m → P, + (∏ i, movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i)) i (x i)) * + (weight x * ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + ∑ X : Pg, smoothGiantPrior Pg φ (G (n + 1)) X * + ∑ s : transferFrequencyRange (V n), + movingSymmetrizedMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G n r m + greg x p X s.val) + +theorem movingSymmetrizedMaskedTemplateKernel_nonneg + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (x : MovingRegularSlot n (4 + r) m → P) (p X : ℕ) (s : ℤ) : + 0 ≤ movingSymmetrizedMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G n r m greg x p X s := by + unfold movingSymmetrizedMaskedTemplateKernel + dsimp only + apply mul_nonneg (sq_nonneg _) + unfold naturalRegularMultiplier + apply Finset.prod_nonneg + intro i _ + split <;> positivity + +/-- A bound on the original support suffices: no support is conditioned into +or removed from the independent restored law. -/ +theorem movingSymmetrizedMaskedTemplateEnergy_weight_le + (P Pg I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (hμ : ∀ j a, 0 ≤ μ j a) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hφ : ∀ t, 0 ≤ φ t) (G : ℕ → ℝ) (n r m : ℕ) + (Q : MovingRegularSlot n r m → Finset ℕ) (greg : ∀ q : ℕ, ZMod q → ℂ) + (weight : (MovingRegularSlot n (4 + r) m → P) → ℝ) (B : ℝ) + (hweight : ∀ x, (∏ i, movingTemplateRestoredPrior n r m (μ n) + (fun i => primeSubsetPrior P (Q i)) i (x i)) ≠ 0 → weight x ≤ B) : + movingSymmetrizedMaskedTemplateEnergy P Pg I hP outside μ childBound pivotBound V F φ G n r m Q greg weight ≤ + B * movingSymmetrizedMaskedTemplateEnergy P Pg I hP outside μ childBound pivotBound V F φ G n r m Q greg (fun _ => 1) := by + unfold movingSymmetrizedMaskedTemplateEnergy + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro x _ + let mass := ∏ i, movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i)) i (x i) + have hm : 0 ≤ mass := by + apply Finset.prod_nonneg + intro i _ + unfold movingTemplateRestoredPrior + cases he : (movingReverseTemplate n r m).symm i with + | inl j => exact hμ n (x i) + | inr j => exact primeSubsetPrior_nonneg P (Q j) (x i) + by_cases hz : mass = 0 + · change mass * _ ≤ B * (mass * _) + simp only [hz, zero_mul, mul_zero, le_refl] + have hE : 0 ≤ ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + ∑ X : Pg, smoothGiantPrior Pg φ (G (n + 1)) X * + ∑ s : transferFrequencyRange (V n), + movingSymmetrizedMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G n r m greg x p X s.val := by + apply Finset.sum_nonneg + intro p _ + apply mul_nonneg (hφ _) + apply Finset.sum_nonneg + intro X _ + apply mul_nonneg (smoothGiantPrior_nonneg Pg φ (G (n + 1)) hφ X) + exact Finset.sum_nonneg (fun s _ => movingSymmetrizedMaskedTemplateKernel_nonneg P hP outside μ + childBound pivotBound V F φ G n r m greg x p X s.val) + have ht := mul_le_mul_of_nonneg_left + (mul_le_mul_of_nonneg_right (hweight x hz) hE) hm + convert ht using 1 + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedMaskedIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedMaskedIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..cb08e61e39137d3d84a2611235686eed90324933 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedMaskedIntegral.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSymmetrizedMaskedEnergy +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantMixedInterval + +namespace OAI + +/-! # The masked energy with its exact integer and harmonic-prime scales -/ + +namespace Ostmann +open scoped Classical BigOperators + +private theorem masked_energy_fubini {S A X T : Type} + [Fintype S] [Fintype A] [Fintype X] + (I : Finset T) (M : A → ℂ) (w : T → ℂ) (ρ : X → ℂ) + (F : S → A → T → X → ℂ) : + (∑ a, M a * ∑ p ∈ I, w p * ∑ x, ρ x * ∑ s, F s a p x) = + ∑ s, ∑ a, M a * ∑ x, ρ x * ∑ p ∈ I, w p * F s a p x := by + simp only [Finset.mul_sum] + conv_lhs => + arg 2 + ext a + arg 2 + ext p + rw [Finset.sum_comm] + conv_lhs => + arg 2 + ext a + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro a _ + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro p _ + ring + +theorem movingSymmetrizedMaskedTemplateEnergy_interval + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (center : ℝ) : + let H := G (n + 1) + let Pg := smoothGiantPrimeRange H + let I := Finset.Ioc ⌊Real.exp (H - 1)⌋₊ ⌊Real.exp (H + 1)⌋₊ + let ν := movingTemplateRestoredPrior n r m (μ n) (fun i => primeSubsetPrior P (Q i)) + (movingSymmetrizedMaskedTemplateEnergy P Pg I hP outside μ childBound pivotBound V F φ G n r m Q greg + (fun _ => 1) : ℂ) = + (Real.exp (smoothGiantLogNormalizer Pg φ H + center) : ℂ) * + mixedExternalAverage ν (V n) (H - 1) (H + 1) (H - 1) (H + 1) center + (fun s x z y => (φ (z - H) : ℂ) * (φ (y - H) : ℂ) * + (movingSymmetrizedMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G n r m greg + x ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ s : ℝ)) := by + intro H Pg I ν + have h := smoothGiant_mixed_external_interval ν (V n) φ H H center hout + (fun s x p q => (movingSymmetrizedMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G + n r m greg x p q s : ℝ)) + apply Eq.trans _ h + unfold movingSymmetrizedMaskedTemplateEnergy + simp only [one_mul, Complex.ofReal_sum, Complex.ofReal_mul] + have hf := masked_energy_fubini (S := transferFrequencyRange (V n)) + (A := MovingRegularSlot n (4 + r) m → P) (X := Pg) (T := ℕ) I + (fun x => ((∏ i, ν i (x i) : ℝ) : ℂ)) + (fun p => (φ (Real.log p - H) : ℂ)) + (fun q : Pg => (smoothGiantPrior Pg φ H q : ℂ)) + (fun s x p q => (movingSymmetrizedMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G + n r m greg x p q s.val : ℝ)) + convert hf using 1 + simp only [Pg, I, finite_univ_canonical] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedMaskedKernel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedMaskedKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e2ba8f85e4a9affeaa0397484ae621dd5683f8c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedMaskedKernel.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSymmetrizedProductLower +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMaskedTemplateEnergy + +namespace OAI + +/-! # The restored multiplier of the actual bulk-averaged coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingBulkAveragedTemplateCoefficient {A : Type} [Fintype A] + (value : A → ℕ) (outside : List ℕ) (μ : ℕ → A → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState A → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (x : MovingRegularSlot n r m → A) (XL XR : ℕ) : ℂ := + mixedBulkSymmetrize n m (movingTemplateBulk n r m) + (fun _ y _ _ => movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n r m s y XL XR) 0 x 0 0 + +theorem movingBulkAveragedTemplateCoefficient_restore {A : Type} [Fintype A] + (value : A → ℕ) (outside : List ℕ) (μ : ℕ → A → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState A → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) (XL XR : ℕ) : + movingBulkAveragedTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m s (movingRestoreSample n r m u y) XL XR = + movingSymmetrizedTemplateCoefficient value outside μ childBound pivotBound V F φ G + n r m s u y XL XR := by + simp only [movingBulkAveragedTemplateCoefficient, movingSymmetrizedTemplateCoefficient, + mixedBulkSymmetrize, finiteFamilyAverage, movingRestoreSample_bulk_action] + +theorem movingBulkAveragedTemplateCoefficient_nonzero_injective {A : Type} [Fintype A] + (value : A → ℕ) (hprime : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → A → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState A → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (x : MovingRegularSlot n r m → A) (XL XR : ℕ) + (h : movingBulkAveragedTemplateCoefficient value outside μ childBound pivotBound V F φ G + n r m s x XL XR ≠ 0) : Function.Injective (value ∘ x) := by + obtain ⟨e, he⟩ := mixedBulkSymmetrize_ne_zero n m (movingTemplateBulk n r m) _ 0 x 0 0 h + have hi := movingTemplateCoefficient_nonzero_injective value outside μ childBound pivotBound V + F φ G n r m s (selectedBulkSample (movingTemplateBulk n r m) e x) XL XR + (fun i => hprime _) he + exact (selectedBulkSample_injective_iff (movingTemplateBulk n r m) e value x).mp hi + +noncomputable def movingSymmetrizedMaskedTemplateKernel + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (x : MovingRegularSlot n (4 + r) m → P) (p X : ℕ) (s : ℤ) : ℝ := + let q := fun i => (x i : ℕ) + let _ : ∀ i, Fact (q i).Prime := fun i => ⟨hP _ (x i).property⟩ + ‖movingBulkAveragedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n (4 + r) m s x p X‖ ^ 2 * + naturalRegularMultiplier q (movingRestoredActive n r m) s + (fun i => ((outside.prod * tupleCofactor q i : ℕ) : ZMod (q i))) + (fun i => greg (q i)) p X + +theorem movingSymmetrizedMaskedTemplateKernel_restore + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (u : TreeLeafIndex n × Fin 4 → P) (y : MovingRegularSlot n r m → P) + (p X : ℕ) (s : ℤ) : + movingSymmetrizedMaskedTemplateKernel P hP outside μ childBound pivotBound V F φ G n r m greg + (movingRestoreSample n r m u y) p X s = + ‖movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m s u y p X * + primeProductTransform greg (p * (∏ i, (u i : ℕ)) * outside.prod * X) + (∏ i, (y i : ℕ)) s‖ ^ 2 := by + unfold movingSymmetrizedMaskedTemplateKernel + dsimp only + rw [movingBulkAveragedTemplateCoefficient_restore] + by_cases hC : movingSymmetrizedTemplateCoefficient Subtype.val outside μ childBound pivotBound V + F φ G n r m s u y p X = 0 + · simp only [hC, norm_zero, zero_pow (by norm_num : 2 ≠ 0), zero_mul] + have hfull : Function.Injective (Subtype.val ∘ movingRestoreSample n r m u y) := + movingBulkAveragedTemplateCoefficient_nonzero_injective Subtype.val + (fun a => hP _ a.property) outside μ childBound pivotBound V F φ G n (4 + r) m s + (movingRestoreSample n r m u y) p X (by rwa [movingBulkAveragedTemplateCoefficient_restore]) + have hy : Function.Injective (Subtype.val ∘ y) := by + intro i j hij + apply Sum.inr.inj + apply (movingReverseTemplate n r m).injective + apply hfull + simpa only [Function.comp_apply, movingRestoreSample, Equiv.symm_apply_apply, + Sum.elim_inr] using hij + have he := naturalRegularMultiplier_restored_primeProduct Subtype.val + (fun a : P => hP _ a.property) n r m u y hy greg outside.prod p X s + dsimp only at he + simp only [Function.comp_def] at he + rw [he, norm_mul, mul_pow] + congr 3 + ac_rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedProductLower.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedProductLower.lean new file mode 100644 index 0000000000000000000000000000000000000000..c91daa45e267fc5841733c8dc2fa0fcf56f3388a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingSymmetrizedProductLower.lean @@ -0,0 +1,94 @@ +import OAI.NumberTheory.Ostmann.Construction.SelectedBulkSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullHarmonicCost + +namespace OAI + +/-! # The full harmonic denominator survives bulk symmetrization -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingSymmetrizedTemplateCoefficient {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (u : TreeLeafIndex n × Fin 4 → σ) (y : MovingRegularSlot n r m → σ) + (XL XR : ℕ) : ℂ := + mixedBulkSymmetrize n m (movingTemplateBulk n r m) + (fun _ z _ _ => movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m s (movingRestoreSample n r m u z) XL XR) 0 y 0 0 + +theorem selectedBulkSample_prod {B J A M : Type*} [Fintype B] [CommMonoid M] + (slot : J ↪ B) (e : Equiv.Perm J) (value : A → M) (y : B → A) : + (∏ i, value (selectedBulkSample slot e y i)) = ∏ i, value (y i) := by + exact (selectedBulkPerm slot e).symm.prod_comp (fun i => value (y i)) + +theorem movingSymmetrizedTemplateCoefficient_full_product_lower {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (hvalue : ∀ a, 0 < value a) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (y : MovingRegularSlot n r m → σ) (hn : n < k) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (lower : TreeLeafIndex n × Fin r → ℝ) + (hlower : ∀ j, Real.exp (lower j) ≤ (value (y (j.1, .inl j.2)) : ℝ)) + (XL XR : ℕ) + (h : movingSymmetrizedTemplateCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n r m s u y XL XR ≠ 0) : + Real.exp ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1)) ≤ + ((∏ i, value (y i) : ℕ) : ℝ) := by + obtain ⟨e, he⟩ := mixedBulkSymmetrize_ne_zero n m (movingTemplateBulk n r m) _ 0 y 0 0 h + have hs (j : TreeLeafIndex n × Fin r) : + tier (selectedBulkSample (movingTemplateBulk n r m) e y (j.1, .inl j.2)) ≠ k := by + rw [selectedBulkSample_template_small] + exact hsmall j + have hb (j : TreeLeafIndex n × Fin m) : + tier (selectedBulkSample (movingTemplateBulk n r m) e y (j.1, .inr j.2)) = k := by + change tier (selectedBulkSample (movingTemplateBulk n r m) e y + (movingTemplateBulk n r m j)) = k + rw [selectedBulkSample_bulk] + exact hbulk (e.symm j) + have hl (j : TreeLeafIndex n × Fin r) : + Real.exp (lower j) ≤ + (value (selectedBulkSample (movingTemplateBulk n r m) e y (j.1, .inl j.2)) : ℝ) := by + rw [selectedBulkSample_template_small] + exact hlower j + have hp := movingTemplateCoefficient_restored_full_product_lower value tier hvalue k outside cb cd + μ hμ childBound pivotBound V F φ G n r m s u hu + (selectedBulkSample (movingTemplateBulk n r m) e y) hn hs hb lower hl XL XR he + rwa [selectedBulkSample_prod] at hp + +theorem movingSymmetrizedTemplateCoefficient_full_harmonic_cost_le {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (hvalue : ∀ a, 0 < value a) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (y : MovingRegularSlot n r m → σ) (hn : n < k) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (lower : TreeLeafIndex n × Fin r → ℝ) + (hlower : ∀ j, Real.exp (lower j) ≤ (value (y (j.1, .inl j.2)) : ℝ)) + (XL XR : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) (cg Gmin : ℝ) + (hX : Real.exp Gmin ≤ (XR : ℝ)) + (h : movingSymmetrizedTemplateCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n r m s u y XL XR ≠ 0) : + (Real.exp cg / XR) * ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, value (y i) : ℕ) : ℝ)⁻¹ ≤ + Real.exp (cg - Gmin - ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1))) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) := by + exact moving_harmonic_full_counterpart_le n r m Q cg Gmin + ((∑ j, lower j) + (2 ^ n : ℕ) * (cb - 1)) XR (value ∘ y) hX + (movingSymmetrizedTemplateCoefficient_full_product_lower value tier hvalue k outside cb cd μ hμ + childBound pivotBound V F φ G n r m s u hu y hn hsmall hbulk lower hlower XL XR h) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTaggedPrimeCore.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTaggedPrimeCore.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff5aefdcfc1a4739f12f9587eca92ee28a5cbefc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTaggedPrimeCore.lean @@ -0,0 +1,46 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplatePrimeCore +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOneGiant + +namespace OAI + +/-! # The transfer's tagged full factor is the arithmetic prime core -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +/-- This identifies the full factor used in the literal integer-node +recursion with the prime statistic at its original two prime arguments. -/ +theorem movingTemplatePrimeCore_eq_tagged {σ I : Type} [Fintype σ] + (pSpec : I → ℕ) [∀ i, Fact (pSpec i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (pSpec i) → ℂ) (Dq : ∀ i, (ZMod (pSpec i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n r m : ℕ) (s : ℤ) (y : MovingRegularSlot n r m → σ) + (q : Bool → ℕ) [∀ b, Fact (q b).Prime] + (hprime : ∀ i, (value (y i)).Prime) + (greg ggiant : ∀ p : ℕ, ZMod p → ℂ) (favorable : ℕ → Bool) : + movingPrimeCore pSpec value outside μ childBound pivotBound V f g Dq S ψ X lo hi φ G + n m (movingTemplateSmall n r m) (movingTemplateBulk n r m) greg ggiant favorable + s y (Real.log (q true)) (Real.log (q false)) = + movingTaggedTransform (Sum.elim q (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s * + movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value pSpec (fun _ => f) g Dq S ψ X lo hi) φ G n r m s y + (q true) (q false) := by + let : ∀ i, Fact ((value ∘ y) i).Prime := fun i => ⟨hprime i⟩ + have h := movingTemplatePrimeCore_eq_full pSpec value outside μ childBound pivotBound V f + g Dq S ψ X lo hi φ G n r m s y q hprime greg ggiant favorable + have ht := movingTaggedTransform_full q (value ∘ y) greg ggiant favorable outside.prod s + apply h.trans + apply congrArg (fun z : ℂ => z * movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value pSpec (fun _ => f) g Dq S ψ X lo hi) φ G n r m s y (q true) (q false)) + convert ht.symm using 1 + unfold movingRegularTransform + apply Finset.prod_congr rfl + intro i _ + cases i <;> rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTargetTotal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTargetTotal.lean new file mode 100644 index 0000000000000000000000000000000000000000..8e225efe29f9164fd1c3fed64a1d5ce18d881d13 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTargetTotal.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingProtectedTarget + +namespace OAI + +/-! # The backwards target construction preserves the original total log size -/ + +namespace Ostmann +open scoped BigOperators + +theorem movingCompensationTargetError_ofFn (k : ℕ) (d : Fin k → ℝ) : + movingCompensationTargetError (List.ofFn d) = ∑ i : Fin k, (2 : ℝ) ^ (i : ℕ) * d i := by + induction k with + | zero => simp [movingCompensationTargetError] + | succ k ih => + rw [List.ofFn_succ, movingCompensationTargetError, ih, Fin.sum_univ_succ] + simp only [Fin.val_zero, pow_zero, one_mul, Fin.val_succ, pow_succ] + calc + _ = d 0 + ∑ i : Fin k, 2 * (2 ^ (i : ℕ) * d i.succ) := by + rw [← Finset.mul_sum] + ring + _ = _ := by + congr 1 + apply Finset.sum_congr rfl + intro i _ + ring + +theorem movingCompensationTargetError_gaps (k : ℕ) (BD Bz L : ℝ) : + movingCompensationTargetError (movingCompensationGaps k BD Bz L) = + ∑ i : Fin k, spectatorStepGap BD Bz ((k : ℝ) ^ 4) ((2 : ℝ) ^ (i : ℕ)) + (spectatorBulkCount k L) := by + unfold movingCompensationGaps + rw [movingCompensationTargetError_ofFn] + apply Finset.sum_congr rfl + intro i _ + have hr : (2 : ℝ) ^ (i : ℕ) ≠ 0 := by positivity + field_simp + +theorem moving_protected_and_compensation_total (k : ℕ) (BD Bz L logX G td Δ₀ : ℝ) : + let gaps := movingCompensationGaps k BD Bz L + let J := movingProtectedTarget k logX G td + (Δ₀ + ∑ i : Fin k, spectatorStepGap BD Bz ((k : ℝ) ^ 4) + ((2 : ℝ) ^ (i : ℕ)) (spectatorBulkCount k L)) + 2 * G + 2 * td + J + (movingCompensationTargets J gaps).sum = logX + Δ₀ := by + intro gaps J + have hs := movingCompensationTargets_sum J gaps + have hlen : gaps.length = k := movingCompensationGaps_length k BD Bz L + rw [hlen, movingCompensationTargetError_gaps] at hs + have hJ : (2 : ℝ) ^ k * J = logX - 2 * G - 2 * td + + (Δ₀ + ∑ i : Fin k, spectatorStepGap BD Bz ((k : ℝ) ^ 4) + ((2 : ℝ) ^ (i : ℕ)) (spectatorBulkCount k L)) := by + dsimp [J, movingProtectedTarget] + field_simp + linarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateAmplitude.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateAmplitude.lean new file mode 100644 index 0000000000000000000000000000000000000000..99088bbff4183b41a1d12b3e1a8af657afe74c0b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateAmplitude.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingAveragedIntegerNode +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantPrior + +namespace OAI + +/-! # The original prime amplitude on each restored regular template -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The finite prime amplitude, with both giants and every regular slot +sampled from their original laws. The root frequency is not renormalized. -/ +noncomputable def movingTemplatePrimeAmplitude {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg : Finset ℕ) (ρ : Pg → ℝ) (ν : MovingRegularSlot n r m → σ → ℝ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : ℂ := + ∑ XL : Pg, (ρ XL : ℂ) * ∑ XR : Pg, (ρ XR : ℂ) * + ∑ s : transferFrequencyRange (V n), + ∑ y : MovingRegularSlot n r m → σ, ((∏ i, ν i (y i) : ℝ) : ℂ) * + (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n r m + s.val y XL XR * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then (XL : ℕ) else (XR : ℕ)) (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s.val) + +/-- The next amplitude is exactly the extended integer off-diagonal, +including its original compensation factors and the two inherited regular +laws. No prime is reweighted or resampled by this identity. -/ +theorem movingTemplatePrimeAmplitude_next {σ : Type} [Fintype σ] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg : Finset ℕ) (hPg : ∀ q ∈ Pg, q.Prime) (ρ : Pg → ℝ) + (ν : MovingRegularSlot (n + 1) r m → σ → ℝ) + (hlarge : ∀ q : Pg, V (n + 1) < (q : ℕ)) + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : ∀ XR : Pg, ∀ right, movingTemplateSidePrior n r m ν false right ≠ 0 → + 2 * pivotBound (n + 1) * childBound (n + 1) < (XR : ℕ) * ∏ i, value (right i)) + (hRH : ∀ XR : Pg, ∀ right, movingTemplateSidePrior n r m ν false right ≠ 0 → + ∀ q, q.Prime → q ∣ (XR : ℕ) * (∏ i, value (right i)) → V (n + 1) < q) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G (n + 1) r m + Pg ρ ν greg ggiant favorable = + ∑ XL : Pg, (ρ XL : ℂ) * ∑ XR : Pg, (ρ XR : ℂ) * + ∑ s : transferFrequencyRange (V (n + 1)), + ∑ u : TreeLeafIndex n × Fin 4 → σ, + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * + ∑ left : MovingRegularSlot n r m → σ, (movingTemplateSidePrior n r m ν true left : ℂ) * + ∑ right : MovingRegularSlot n r m → σ, (movingTemplateSidePrior n r m ν false right : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + movingTemplateIntegerFourierTerm value outside μ childBound pivotBound V F φ G + n r m I XL XR s.val left right greg ggiant favorable u v.val w.val := by + unfold movingTemplatePrimeAmplitude + apply Finset.sum_congr rfl + intro XL _ + congr 1 + apply Finset.sum_congr rfl + intro XR _ + congr 1 + apply Finset.sum_congr rfl + intro s _ + exact movingTemplateCoefficient_averaged_integer_node value hvalue outside μ + childBound pivotBound V hV F hF φ G n r m s.val + ((mem_transferFrequencyRange _ _).mp s.property) ν XL XR + (hPg _ XL.property) (hPg _ XR.property) (hlarge XL) (hlarge XR) + I hI hφ hchild (hgap XR) (hRH XR) hcomp greg ggiant favorable + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateAmplitudeRestore.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateAmplitudeRestore.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce6fc6b8a251209ad266fdbcd6e5da945113a393 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateAmplitudeRestore.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateAmplitude + +namespace OAI + +/-! # Restoring the original independent compensation law in the amplitude -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingTemplateRestoredPrior {σ : Type} (n r m : ℕ) + (μ : σ → ℝ) (ν : MovingRegularSlot n r m → σ → ℝ) : + MovingRegularSlot n (4 + r) m → σ → ℝ := fun i => + Sum.elim (fun _ => μ) ν ((movingReverseTemplate n r m).symm i) + +/-- The original current amplitude is the giant-transfer expression with +one shared compensation draw outside its two giant and frequency sums. -/ +theorem movingTemplatePrimeAmplitude_restore {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (Pg : Finset ℕ) (ρ : Pg → ℝ) (ν : MovingRegularSlot n r m → σ → ℝ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + movingTemplatePrimeAmplitude value outside μ childBound pivotBound V F φ G n (4 + r) m + Pg ρ (movingTemplateRestoredPrior n r m (μ n) ν) greg ggiant favorable = + ∑ u : TreeLeafIndex n × Fin 4 → σ, ((∏ i, μ n (u i) : ℝ) : ℂ) * + ∑ XL : Pg, (ρ XL : ℂ) * ∑ XR : Pg, (ρ XR : ℂ) * + ∑ s : transferFrequencyRange (V n), + ∑ y : MovingRegularSlot n r m → σ, ((∏ i, ν i (y i) : ℝ) : ℂ) * + (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m + s.val (movingRestoreSample n r m u y) XL XR * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then (XL : ℕ) else (XR : ℕ)) + (value ∘ movingRestoreSample n r m u y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s.val) := by + unfold movingTemplatePrimeAmplitude + have hinner (XL XR : Pg) (s : transferFrequencyRange (V n)) := + movingReverseTemplate_average n r m (movingTemplateRestoredPrior n r m (μ n) ν) + (fun y => movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m s.val y XL XR * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then (XL : ℕ) else (XR : ℕ)) (value ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s.val) + simp_rw [hinner] + simp only [Finset.mul_sum] + conv_lhs => + arg 2 + ext XL + arg 2 + ext XR + rw [Finset.sum_comm] + conv_lhs => + arg 2 + ext XL + rw [Finset.sum_comm] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro u _ + apply Finset.sum_congr rfl + intro XL _ + apply Finset.sum_congr rfl + intro XR _ + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro y _ + simp only [movingTemplateRestoredPrior, Equiv.symm_apply_apply, Sum.elim_inl, + Sum.elim_inr] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateAmplitudeStatistic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateAmplitudeStatistic.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ae6ad8cdb273cd48623c149a03f3e5bdab12479 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateAmplitudeStatistic.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplatePrimeStatisticBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateAmplitude + +namespace OAI + +/-! # Exact giant-prior normalization for the data-dependent template statistic -/ +namespace Ostmann +open scoped Classical BigOperators + +local instance templateStatisticSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +theorem movingTemplatePrimeAmplitude_smooth_average + (P : Finset ℕ) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (ν : MovingRegularSlot n r m → P → ℝ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (H : ℝ) : + movingTemplatePrimeAmplitude Subtype.val outside μ childBound pivotBound V F φ G n r m + (smoothGiantPrimeRange H) (smoothGiantPrior (smoothGiantPrimeRange H) φ H) ν + greg ggiant favorable = + smoothGiantExternalAverage ν (V n) φ H H (fun s y XL XR => + movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G n r m s y XL XR * + movingTaggedTransform (Sum.elim (fun b : Bool => if b then XL else XR) (Subtype.val ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s) := by + unfold movingTemplatePrimeAmplitude smoothGiantExternalAverage + simp only [finite_univ_canonical, Finset.mul_sum] + conv_lhs => + arg 2 + ext XL + rw [Finset.sum_comm] + conv_lhs => rw [Finset.sum_comm] + conv_lhs => + arg 2 + ext s + arg 2 + ext XL + rw [Finset.sum_comm] + conv_lhs => + arg 2 + ext s + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr (by ext; simp only [Finset.mem_univ]) + intro y _ + conv_lhs => rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro XR _ + apply Finset.sum_congr rfl + intro XL _ + ring + +theorem movingTemplatePrimeAmplitude_statistic_eq + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) (n r m : ℕ) + (ν : MovingRegularSlot n r m → P → ℝ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (H : ℝ) : + movingTemplatePrimeAmplitude Subtype.val outside μ childBound pivotBound V F φ G n r m + (smoothGiantPrimeRange H) (smoothGiantPrior (smoothGiantPrimeRange H) φ H) ν + greg ggiant favorable = + (Real.exp (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H) : ℂ) * + movingTemplatePrimeStatistic P outside μ childBound pivotBound V F φ G n r m ν + greg ggiant favorable H (H - 1) (H + 1) (H - 1) (H + 1) := by + rw [movingTemplatePrimeAmplitude_smooth_average, smoothGiantExternalAverage_eq _ _ _ _ _ hout] + rw [show smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H + + smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H = + 2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H by ring] + apply congrArg (fun z : ℂ => + (Real.exp (2 * smoothGiantLogNormalizer (smoothGiantPrimeRange H) φ H) : ℂ) * z) + unfold movingTemplatePrimeStatistic + refine primeExternalAverage_congr_primes ν (V n) (H - 1) (H + 1) (H - 1) (H + 1) _ _ ?_ + intro s y XL XR hXL hXR + let q := fun b : Bool => if b then XL else XR + let _ : ∀ b, Fact (q b).Prime := fun b => ⟨by cases b <;> assumption⟩ + let _ : ∀ i, Fact ((Subtype.val ∘ y) i).Prime := fun i => ⟨hP _ (y i).property⟩ + have ht : movingTaggedTransform (Sum.elim q (Subtype.val ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s = + movingRegularTransform (Sum.elim q (Subtype.val ∘ y)) + (fun i => match i with + | .inl b => fun t => if favorable (q b) then complexUnitPhase (ggiant (q b) t) else 0 + | .inr j => greg (y j)) outside.prod s := by + unfold movingTaggedTransform movingRegularTransform + apply Finset.prod_congr rfl + intro i _ + cases i <;> rfl + have hf := movingTemplateCoefficient_full_transform Subtype.val outside μ childBound pivotBound V F + φ G n r m s y q (fun i => hP _ (y i).property) greg ggiant favorable + have hcore : movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F + φ G n r m s y XL XR * movingTaggedTransform (Sum.elim q (Subtype.val ∘ y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s = + (giantPairPhase ggiant favorable outside.prod (∏ i, (y i : ℕ)) XL XR s * + primeProductTransform greg (outside.prod * XL * XR) (∏ i, (y i : ℕ)) s) * + movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G n r m s y XL XR := by + rw [mul_comm, ht] + exact hf + have hp : (0 : ℝ) < XL := Nat.cast_pos.mpr hXL.pos + have hr : (0 : ℝ) < XR := Nat.cast_pos.mpr hXR.pos + simp only [Real.exp_log hp, Real.exp_log hr, Nat.floor_natCast] + rw [show (fun b : Bool => if b then XL else XR) = q from rfl, hcore] + simp only [movingGiantPhase, movingExternalRegularFactor, movingTemplate_product, + Real.exp_log hp, Real.exp_log hr, Nat.floor_natCast, giantOuterWeight, + Bool.false_eq_true, ite_false, mul_one, positiveLogCutoff, hp, hr, ite_true] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateCoefficient.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateCoefficient.lean new file mode 100644 index 0000000000000000000000000000000000000000..6824d0113f5574a0c46253bec37ee393877f006b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateCoefficient.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeCoefficientNode +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplatePair + +namespace OAI + +/-! # The original coefficient on the complete regular-slot template -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingTemplateCoefficient {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (y : MovingRegularSlot n r m → σ) (XL XR : ℕ) : ℂ := + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n s + (treeLeafMap (List.map y) n (movingTemplateSmall n r m)) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m (movingTemplateBulk n r m))) XL XR + +theorem movingTemplateCompensationEquiv_restore {σ : Type*} (n : ℕ) + (a : TreeLeafTuple (Fin 4 → σ) n) : + (treeLeafTupleEquiv (Fin 4 → σ) n).symm + (fun j i => movingTemplateCompensationEquiv σ n a (j, i)) = a := by + change (treeLeafTupleEquiv (Fin 4 → σ) n).symm + (treeLeafTupleEquiv (Fin 4 → σ) n a) = a + exact Equiv.symm_apply_apply _ _ + +theorem movingTemplateCoefficient_restored {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (a : TreeLeafTuple (Fin 4 → σ) n) (y : MovingRegularSlot n r m → σ) (XL XR : ℕ) : + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m s + (movingRestoreSample n r m (movingTemplateCompensationEquiv σ n a) y) XL XR = + movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G n s + (appendMovingSlotLeaves n (movingCompensationSlots n a) + (treeLeafMap (List.map y) n (movingTemplateSmall n r m))) + (treeLeafMap (List.map y) n (bulkSlotLeaves n m (movingTemplateBulk n r m))) XL XR := by + unfold movingTemplateCoefficient + rw [movingRestoreSample_small_leaves, movingRestoreSample_bulk_leaves, + movingTemplateCompensationEquiv_restore] + +/-- Pair the surviving templates and restore each sampled compensation vector +in both children. This is the actual product recursion on the prescribed roles. -/ +theorem movingTemplateCoefficient_prime_node {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (hs : s ≠ 0) (hsV : s.natAbs ≤ V (n + 1)) + (left right : MovingRegularSlot n r m → σ) (XL XR : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) + (hVL : V (n + 1) < XL) (hVR : V (n + 1) < XR) : + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G (n + 1) r m s + (movingTemplatePairSample n r m left right) XL XR = + ∑ a : TreeLeafTuple (Fin 4 → σ) n, (movingCompensationPrior (μ n) n a : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + let CL := flattenMovingSlots n (treeLeafMap (List.map left) n (movingTemplateSmall n r m)) ++ + flattenMovingSlots n (treeLeafMap (List.map left) n (bulkSlotLeaves n m (movingTemplateBulk n r m))) + let CR := flattenMovingSlots n (treeLeafMap (List.map right) n (movingTemplateSmall n r m)) ++ + flattenMovingSlots n (treeLeafMap (List.map right) n (bulkSlotLeaves n m (movingTemplateBulk n r m))) + let u := flattenMovingSlots n (movingCompensationSlots n a) + let p := movingTopPivot value CL CR u XL XR s v.val w.val + movingPrimeNodeFactor value outside childBound pivotBound φ G n CL CR u XL XR s v.val w.val * + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m v.val + (movingRestoreSample n r m (movingTemplateCompensationEquiv σ n a) left) p XL * + star (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w.val + (movingRestoreSample n r m (movingTemplateCompensationEquiv σ n a) right) p XR) := by + rw [movingTemplateCoefficient, movingTemplatePairSample_small, movingTemplatePairSample_bulk] + rw [movingFrequencyCoefficient_prime_node value outside μ childBound pivotBound V hV F hF + φ G n s hs hsV _ _ XL XR hXL hXR hVL hVR] + simp only [movingTemplateCoefficient_restored] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..b0a57e04c5283d66d18fbcc240876a897e11cec9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateDiagonal.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOneGiantDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateWeightedSupport + +namespace OAI + +/-! # The original restored coefficient in the grouped diagonal estimate -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Every support condition in the grouped diagonal estimate follows from +the original coefficient and the prescribed prime/frequency ranges. Only +the mass of an actual product/frequency fibre remains to be bounded. -/ +theorem movingTemplate_restored_diagonal_le {σ A : Type} [Fintype σ] [Fintype A] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) (outside : List ℕ) + (μ : ℕ → σ → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → σ) (p : ℕ) + (X : A → ℕ) (hX : ∀ a, (X a).Prime) + (y : A → MovingRegularSlot n r m → σ) (v : A → ℤ) + (α : A → ℝ) (hα : ∀ a, 0 ≤ α a) (θ : ℕ × ℕ × ℤ → ℝ) + (hv : ∀ a, (v a).natAbs ≤ V n) + (hvg : ∀ a, V n < X a) (hvr : ∀ a i, V n < value (y a i)) + (hsep : ∀ a b i, X a ≠ value (y b i)) + (hmass : ∀ k, (∑ a, if (X a, (∏ i, value (y a i)), v a) = k then α a else 0) ≤ θ k) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let _ : ∀ a i, Fact (((value ∘ y a) i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let C := fun a => movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m (v a) (movingRestoreSample n r m u (y a)) p (X a) + let D := p * (∏ i, value (u i)) * outside.prod + (pivotDiagonal (fun a => X a * ∏ i, value (y a i)) v + (fun a => (α a : ℂ) * C a * + movingRegularTransform (movingOneGiantModuli (X a) (value ∘ y a)) + (movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable) D (v a))).re ≤ + ∑ a, α a * θ (X a, (∏ i, value (y a i)), v a) * + ‖C a * primeProductTransform greg (D * X a) (∏ i, value (y a i)) (v a)‖ ^ 2 := by + let : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let : ∀ a i, Fact (((value ∘ y a) i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let C := fun a => movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m (v a) (movingRestoreSample n r m u (y a)) p (X a) + have hc a (ha : (α a : ℂ) * C a ≠ 0) : C a ≠ 0 := right_ne_zero_of_mul ha + have hi a (ha : (α a : ℂ) * C a ≠ 0) : Function.Injective (value ∘ y a) := by + have hs := movingTemplateCoefficient_restored_support value outside μ childBound pivotBound V F + φ G n r m (v a) u (y a) p (X a) (hc a ha) + intro i j hij + by_contra hne + have hh := hs.2.2.1 (show (Sum.inr i : Unit ⊕ MovingRegularSlot n r m) ≠ .inr j from + fun he => hne (Sum.inr.inj he)) + change (value (y a i)).Coprime (value (y a j)) at hh + change value (y a i) = value (y a j) at hij + rw [hij] at hh + exact (hvalue (y a j)).ne_one (by simpa only [Nat.coprime_self] using hh) + have hz a (ha : (α a : ℂ) * C a ≠ 0) : v a ≠ 0 := by + intro he + apply hc a ha + simpa only [C, movingTemplateCoefficient, he] using + movingFrequencyCoefficient_zero value outside μ childBound pivotBound V F hF φ G n + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (movingTemplateSmall n (4 + r) m)) + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m))) p (X a) + exact movingOneGiant_weighted_pivot_diagonal_le X (fun a => value ∘ y a) greg ggiant favorable + (p * (∏ i, value (u i)) * outside.prod) v α C θ hα hi hz + (fun a _ => (hv a).trans_lt (hvg a)) (fun a _ i => (hv a).trans_lt (hvr a i)) + (fun a b _ _ i => hsep a b i) hmass + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateDiagonalPatterns.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateDiagonalPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..c13fec16022b59ebc1061a146c9d3bb210b85297 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateDiagonalPatterns.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateExternalMultiplier + +namespace OAI + +/-! # The signed equality-pattern expansion of the actual masked diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateWeightedDiagonalMean_patterns + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n r m : ℕ) + (t : Bool → FrequencyTree ℤ n) (active : MovingRegularSlot n r m → Bool) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → P → ℝ) (ν : MovingRegularSlot n r m → P → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), + Fin (N s + 1) ≃ MovingRegularSlot n r m ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let small := movingTemplateSmall n r m + let slot := movingTemplateBulk n r m + let W := movingTemplateExternalMultiplier P hP n r m active outside greg sreg φ + Jleft Jright diagonal + movingWeightedDiagonalMean p Subtype.val outside μ ν childBound pivotBound f g Dq Finset.univ + ψ X lo hi φ G n t small (bulkSlotLeaves n m slot) W u v a b center = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → P, + movingOriginalPatternWeight (e s) μ ν Subtype.val n (fun i => Quotient.mk'' i) + (movingOriginalPatternDiagonalObservable (e s) t small slot (fun i => Quotient.mk'' i) + P hP p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) + greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center) x := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + rw [movingWeightedDiagonalMean_patterns p Subtype.val outside μ ν] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro x _ + unfold movingOriginalPatternWeight + congr 1 + unfold movingPatternInjectionGuard + split_ifs + · apply movingWeightedDiagonalKernel_fin (e s) t (movingTemplateSmall n r m) + (movingTemplateBulk n r m) (fun i => Quotient.mk'' i) P hP p g Dq + (movingPatternRegularSlots (e s) n m (movingTemplateSmall n r m) (movingTemplateBulk n r m)).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m (movingTemplateSmall n r m) (movingTemplateBulk n r m))) + greg sreg f outside childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center + intro z y + exact movingTemplateExternalMultiplier_pattern P hP n r m (e s) active outside greg sreg φ + Jleft Jright diagonal x z y + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateDiagonalRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateDiagonalRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc7450f9f1b9f593df29f24b87f3b1773d4230eb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateDiagonalRate.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateEnergyPatterns +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticDiagonalPatternNormRate + +namespace OAI + +/-! # Applying the numerical pattern budget to the original masked energy -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateDiagonalEnergy_pattern_rate + (ψ : 𝓢(ℝ, ℂ)) (n k : ℕ) (hk : 0 < k) (hn : n ≤ k) + (Bwindow Cfreq Cprior ε : ℝ) (hCfreq : 0 ≤ Cfreq) (hCprior : 1 ≤ Cprior) + (hε : 0 < ε) (hdepth : 8 * Cprior ≤ (k : ℝ) ^ 3) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∃ D : ℝ, 0 ≤ D ∧ + (∀ d : ℕ, d ≠ 0 → (d : ℝ) ≤ Real.exp (2 * Cfreq * m) → + (d.divisors.card : ℝ) ≤ D) ∧ + ∀ (r₀ : ℕ) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → primes → ℝ) (ν : MovingRegularSlot n r₀ m → primes → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (X Δ hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot n r₀ m → Bool) + (greg : ∀ q : ℕ, ZMod q → ℂ) (outside : List ℕ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ MovingRegularSlot n r₀ m ⊕ Quotient s), + let small := movingTemplateSmall n r₀ m + let slot := movingTemplateBulk n r₀ m + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let K := ((SchwartzMap.seminorm ℝ 0 0 ψ / Real.sqrt (Real.exp Δ)) ^ (2 ^ n) * + Bwindow ^ (2 ^ n - 1)) ^ 2 * + ((2 : ℝ) ^ (2 ^ n * m) * 4 * 3 ^ (2 ^ n * m)) * 2 ^ (2 ^ n * m) + let err := Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n + (fun i => Quotient.mk'' i) + (movingOriginalPatternDiagonalObservable (e s) (trees t) small slot + (fun i => Quotient.mk'' i) primes hprimes p g Dq + (movingPatternRegularSlots (e s) n m small slot).get (fun i => active (movingPatternTemplateEquiv n r₀ m (e s) i)) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside + childBound pivotBound ψ X (Real.exp Δ) hi φ G Jleft Jright diagonal u v r w center) x + Monotone V → f 0 = 0 → + (Sfreq.card : ℝ) ≤ Real.exp (Cfreq * m) → + (V n : ℝ) ≤ Real.exp (Cfreq * m) → + (V 0 : ℝ) ≤ Real.exp (Δ + Real.sqrt (4 * m)) → + (∀ s t, ‖term t s‖ ≤ + ((2 : ℝ) ^ Fintype.card (Quotient s) * + (Real.exp (Cprior * L)) ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) * + (err + K * (frequencyLeafWeight (pairedFrequencyLeaf Sfreq (V 0)) n t * + ((frequencySplitList Sfreq n t).map (pairFrequencySupportBound D)).prod))) → + ‖movingWeightedDiagonalEnergy p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f g Dq Finset.univ ψ X (Real.exp Δ) hi φ G n small + (bulkSlotLeaves n m slot) + (fun s => movingTemplateExternalMultiplier primes hprimes n r₀ m active outside greg s φ + Jleft Jright diagonal) u v r w center‖ ≤ + Real.exp ((2 ^ n : ℕ) * Δ + (Real.log 12 + 1) * (2 ^ n : ℕ) * m + ε * m) + + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + filter_upwards [arithmetic_diagonal_pattern_norm_rate ψ n k hk hn + Bwindow Cfreq Cprior ε hCfreq hCprior hε hdepth] with L hrate + dsimp only at hrate ⊢ + obtain ⟨D, hD, hdiv, hrate⟩ := hrate + refine ⟨D, hD, hdiv, ?_⟩ + intro r₀ primes hprimes p _ μ ν childBound pivotBound V f g Dq X Δ hi φ G + active greg outside Jleft Jright diagonal u v r w center N e + let m := spectatorBulkCount k L + let small := movingTemplateSmall n r₀ m + let slot := movingTemplateBulk n r₀ m + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n (fun i => Quotient.mk'' i) + (movingOriginalPatternDiagonalObservable (e s) (trees t) small slot (fun i => Quotient.mk'' i) + primes hprimes p g Dq (movingPatternRegularSlots (e s) n m small slot).get (fun i => active (movingPatternTemplateEquiv n r₀ m (e s) i)) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside childBound pivotBound + ψ X (Real.exp Δ) hi φ G Jleft Jright diagonal u v r w center) x + intro hV hf hcard hVn hV0 hterm + have hS : ∀ s ∈ Sfreq, s ≠ 0 ∧ s.natAbs ≤ V n := by + intro s hs + exact ⟨(Finset.mem_erase.mp hs).1, + (mem_transferFrequencyRange _ _).mp (Finset.mem_erase.mp hs).2⟩ + have hsum := hrate Sfreq (V n) (V 0) Δ + (Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L))) hcard hS hVn hV0 (by positivity) le_rfl + (fun s t => (‖term t s‖ : ℂ)) (by + intro s t + rw [Complex.norm_real, Real.norm_of_nonneg (norm_nonneg _)] + exact hterm s t) + have hnonneg : 0 ≤ ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ‖term t s‖ := by positivity + simp only [← Complex.ofReal_sum, Complex.norm_real, Real.norm_of_nonneg hnonneg] at hsum + have hactual := movingTemplateDiagonalEnergy_pattern_bound primes hprimes outside n r₀ + (spectatorBulkCount k L) active p μ ν childBound pivotBound V f hf g Dq ψ X (Real.exp Δ) + hi φ G greg Jleft Jright diagonal u v r w center hV N e + apply hactual.trans + rw [Finset.sum_comm] + exact hsum + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateEnergyPatterns.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateEnergyPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..25bc6ac7e044d4ac38eb0c3fad17b5c824f2e0e9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateEnergyPatterns.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateDiagonalPatterns +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedDiagonalHistories + +namespace OAI + +/-! # The actual masked energy is bounded by its original signed pattern means -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateDiagonalEnergy_pattern_bound + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) + (n r m : ℕ) (active : MovingRegularSlot n r m → Bool) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → P → ℝ) (ν : MovingRegularSlot n r m → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) (hV : Monotone V) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), + Fin (N s + 1) ≃ MovingRegularSlot n r m ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let small := movingTemplateSmall n r m + let slot := movingTemplateBulk n r m + let W := fun s => movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → P, + movingOriginalPatternWeight (e s) μ ν Subtype.val n (fun i => Quotient.mk'' i) + (movingOriginalPatternDiagonalObservable (e s) (trees t) small slot (fun i => Quotient.mk'' i) + P hP p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) + greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center) x + ‖movingWeightedDiagonalEnergy p Subtype.val outside μ ν childBound pivotBound V f g Dq + Finset.univ ψ X lo hi φ G n small (bulkSlotLeaves n m slot) W u v a b center‖ ≤ + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ∑ s : Setoid (Bool × MovingSampleIndex n), ‖term t s‖ := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + apply (movingWeightedDiagonalEnergy_history_bound P outside n m p μ ν childBound pivotBound V + f hf g Dq ψ X lo hi φ G (movingTemplateSmall n r m) + (bulkSlotLeaves n m (movingTemplateBulk n r m)) + (fun s => movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal) u v a b center hV).trans + apply Finset.sum_le_sum + intro t _ + rw [movingTemplateWeightedDiagonalMean_patterns P hP n r m _ active p μ ν g Dq greg _ + f outside childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center N e] + exact norm_sum_le _ _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateEnumeration.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateEnumeration.lean new file mode 100644 index 0000000000000000000000000000000000000000..57e865eabbbafef07cbe9754e66db7a839971844 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateEnumeration.lean @@ -0,0 +1,63 @@ +import Mathlib.Data.List.NodupEquivFin +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRestoredMultiplier + +namespace OAI + +/-! # The canonical full list contains every template coordinate once -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTemplateSlotList_nodup (n r m : ℕ) : + (movingTemplateSlotList n r m).Nodup := by + unfold movingTemplateSlotList movingTemplateSmall + apply List.nodup_append.mpr + refine ⟨bulkSlotLeaves_nodup n r _ ?_, + bulkSlotLeaves_nodup n m _ (movingTemplateBulk n r m).injective, ?_⟩ + · intro i j h + exact Prod.ext (congrArg (fun z : MovingRegularSlot n r m => z.1) h) + (Sum.inl.inj (congrArg (fun z : MovingRegularSlot n r m => z.2) h)) + · intro a ha b hb hab + obtain ⟨i, rfl⟩ := (mem_flatten_bulkSlotLeaves n r _ a).mp ha + obtain ⟨j, rfl⟩ := (mem_flatten_bulkSlotLeaves n m _ b).mp hb + have hh : (Sum.inl i.2 : Fin r ⊕ Fin m) = Sum.inr j.2 := + congrArg (fun z : MovingRegularSlot n r m => z.2) hab + cases hh + +noncomputable def movingTemplateListEquiv (n r m : ℕ) : + Fin (movingTemplateSlotList n r m).length ≃ MovingRegularSlot n r m := + List.Nodup.getEquivOfForallMemList (movingTemplateSlotList n r m) + (movingTemplateSlotList_nodup n r m) (mem_movingTemplateSlotList n r m) + +@[simp] theorem movingTemplateListEquiv_apply (n r m : ℕ) + (i : Fin (movingTemplateSlotList n r m).length) : + movingTemplateListEquiv n r m i = (movingTemplateSlotList n r m).get i := rfl + +/-- Enumerating the full template does not change its masked cofactor product. -/ +theorem movingTemplate_multiplier_list {A : Type*} (value : A → ℕ) + (hprime : ∀ a, (value a).Prime) (n r m : ℕ) + (x : MovingRegularSlot n r m → A) (active : MovingRegularSlot n r m → Bool) + (g : ∀ q : ℕ, ZMod q → ℂ) (D XL XR : ℕ) (s : ℤ) : + let L := movingTemplateSlotList n r m + let p := fun i : Fin L.length => value (x (L.get i)) + let _ : ∀ i, Fact (p i).Prime := fun _ => ⟨hprime _⟩ + let _ : ∀ i, Fact ((value ∘ x) i).Prime := fun _ => ⟨hprime _⟩ + naturalRegularMultiplier p (fun i => active (L.get i)) s + (fun i => ((D * tupleCofactor p i : ℕ) : ZMod (p i))) + (fun i => g (p i)) XL XR = + naturalRegularMultiplier (value ∘ x) active s + (fun i => ((D * tupleCofactor (value ∘ x) i : ℕ) : ZMod ((value ∘ x) i))) + (fun i => g (value (x i))) XL XR := by + dsimp only + let _ : ∀ i, Fact ((value ∘ x) i).Prime := fun _ => ⟨hprime _⟩ + let _ : ∀ i : Fin (movingTemplateSlotList n r m).length, + Fact (value (x ((movingTemplateSlotList n r m).get i))).Prime := fun _ => ⟨hprime _⟩ + rw [naturalRegularMultiplier_eq_transform_norm, naturalRegularMultiplier_eq_transform_norm] + have he := movingRegularTransform_equiv (movingTemplateListEquiv n r m) (value ∘ x) + (fun i z => if active i then g (value (x i)) z else 1) (D * XL * XR) s + exact congrArg (fun z : ℂ => ‖z‖ ^ 2) he + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateExternalMultiplier.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateExternalMultiplier.lean new file mode 100644 index 0000000000000000000000000000000000000000..d200fc0eed8ea0d3412c739ccd93bea8cab9675c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateExternalMultiplier.lean @@ -0,0 +1,48 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplatePatternMultiplier +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedDiagonalRelabel + +namespace OAI + +/-! # The original exterior multiplier in template and pattern coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingTemplateExternalMultiplier + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n r m : ℕ) + (active : MovingRegularSlot n r m → Bool) (outside : List ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) (φ : ℝ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) + (x : MovingRegularSlot n r m → P) (z y : ℝ) : ℂ := + let q := fun i => (x i : ℕ) + let _ : ∀ i, Fact (q i).Prime := fun i => ⟨hP _ (x i).property⟩ + (giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ : ℂ) * + (naturalRegularMultiplier q active s + (fun i => ((outside.prod * tupleCofactor q i : ℕ) : ZMod (q i))) + (fun i => greg (q i)) ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ : ℝ) + +theorem movingTemplateExternalMultiplier_pattern {C : Type*} {N : ℕ} + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n r m : ℕ) + (e : Fin (N + 1) ≃ MovingRegularSlot n r m ⊕ C) + (active : MovingRegularSlot n r m → Bool) (outside : List ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) (φ : ℝ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) + (x : Fin (N + 1) → P) (z y : ℝ) : + movingTemplateExternalMultiplier P hP n r m active outside greg s φ Jleft Jright diagonal + (fun i => x (e.symm (.inl i))) z y = + movingPatternExternalMultiplier P hP + (movingPatternRegularSlots e n m (movingTemplateSmall n r m) (movingTemplateBulk n r m)).get + (fun i => active (movingPatternTemplateEquiv n r m e i)) + (fun x => movingRegularOther (fun j => (x j : ℕ)) outside + (movingPatternRegularSlots e n m (movingTemplateSmall n r m) (movingTemplateBulk n r m))) + greg s φ Jleft Jright diagonal x z y := by + have h := movingTemplate_pattern_multiplier n r m e (fun i => (x i : ℕ)) + (fun i => hP _ (x i).property) active outside greg ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ s + unfold movingTemplateExternalMultiplier movingPatternExternalMultiplier + dsimp only + exact congrArg (fun a : ℝ => + (giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ : ℂ) * a) h.symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateHarmonicDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateHarmonicDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..432bcb4489aa9822a352a60f0be5e1e8d21d5de8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateHarmonicDiagonal.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicDiagonal +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantPrior + +namespace OAI + +/-! # The restored diagonal under the original giant and regular priors -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original harmonic product law pays the giant atom and a single +factorial product-fibre cost. The frequency range contributes no cardinality +factor, because the diagonal key includes the frequency itself. -/ +theorem movingTemplate_harmonic_diagonal_le + (P Pg : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (cg : ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (u : TreeLeafIndex n × Fin 4 → P) (p : ℕ) + (hvg : ∀ q : Pg, V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let A := Pg × ((MovingRegularSlot n r m → P) × transferFrequencyRange (V n)) + let X := fun a : A => (a.1 : ℕ) + let y := fun a : A => a.2.1 + let v := fun a : A => (a.2.2 : ℤ) + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hPg _ a.1.property⟩ + let _ : ∀ a i, Fact (y a i : ℕ).Prime := fun a i => ⟨hP _ (y a i).property⟩ + let α := fun a : A => smoothGiantPrior Pg φ cg a.1 * + ∏ i, primeSubsetPrior P (Q i) (y a i) + let C := fun a : A => movingTemplateCoefficient (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n (4 + r) m (v a) + (movingRestoreSample n r m u (y a)) p (X a) + let θ := fun a : A => (Real.exp (smoothGiantLogNormalizer Pg φ cg) / X a) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (y a i : ℕ)) : ℝ)⁻¹ + let D := p * (∏ i, (u i : ℕ)) * outside.prod + (pivotDiagonal (fun a => X a * ∏ i, (y a i : ℕ)) v + (fun a => (α a : ℂ) * C a * + movingRegularTransform (movingOneGiantModuli (X a) (fun i => (y a i : ℕ))) + (movingOneGiantFactors (X a) (fun i => (y a i : ℕ)) greg ggiant favorable) D (v a))).re ≤ + ∑ a, α a * θ a * + ‖C a * primeProductTransform greg (D * X a) (∏ i, (y a i : ℕ)) (v a)‖ ^ 2 := by + intro A X y v instX instY α C θ D + let g := fun q : ℕ => Real.exp (smoothGiantLogNormalizer Pg φ cg) / q + have hg q : 0 ≤ g q := div_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + have hα a : 0 ≤ α a := + mul_nonneg (smoothGiantPrior_nonneg Pg φ cg hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + have hpoint a : α a ≤ g (X a) * ∏ i, primeSubsetPrior P (Q i) (y a i) := by + apply mul_le_mul_of_nonneg_right _ + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + change Real.exp (smoothGiantLogNormalizer Pg φ cg) * φ (Real.log (a.1 : ℕ) - cg) / + (a.1 : ℕ) ≤ Real.exp (smoothGiantLogNormalizer Pg φ cg) / (a.1 : ℕ) + exact div_le_div_of_nonneg_right + (mul_le_of_le_one_right (Real.exp_nonneg _) (hφ1 _)) (Nat.cast_nonneg _) + have hrow (a b : A) (hx : X a = X b) (hy : y a = y b) (hv : v a = v b) : a = b := + Prod.ext (Subtype.ext hx) (Prod.ext hy (Subtype.ext hv)) + have hc a (ha : (α a : ℂ) * C a ≠ 0) : C a ≠ 0 := right_ne_zero_of_mul ha + have hinj a (ha : (α a : ℂ) * C a ≠ 0) : Function.Injective (y a) := by + have hs := movingTemplateCoefficient_restored_support (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n r m (v a) u (y a) p (X a) (hc a ha) + intro i j hij + by_contra hne + have hh := hs.2.2.1 (show (Sum.inr i : Unit ⊕ MovingRegularSlot n r m) ≠ .inr j from + fun he => hne (Sum.inr.inj he)) + change (y a i : ℕ).Coprime (y a j : ℕ) at hh + rw [hij] at hh + exact (hP _ (y a j).property).ne_one (by simpa only [Nat.coprime_self] using hh) + have hz a (ha : (α a : ℂ) * C a ≠ 0) : v a ≠ 0 := by + intro he + apply hc a ha + simpa only [C, movingTemplateCoefficient, he] using + movingFrequencyCoefficient_zero (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F hF φ G n + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (movingTemplateSmall n (4 + r) m)) + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m))) p (X a) + have h := movingOneGiant_harmonic_diagonal_le P hP Q X + (fun a => hPg _ a.1.property) y v α C hα g hg hrow hpoint hinj hz + (fun a _ => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt (hvg a.1)) + (fun a _ i => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt (hvr (y a i))) + (fun a b _ _ i => hsep a.1 (y b i)) greg ggiant favorable D + simpa only [g, θ, Nat.cast_prod] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateIntegerNode.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateIntegerNode.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa7a7cdf9a270ed069d5dc86680901f884fb90ef --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateIntegerNode.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPrimeOffDiagonalCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateCoefficient + +namespace OAI + +/-! # The integer node on the original independent template law -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTemplateMapped_product {σ : Type*} (value : σ → ℕ) (n r m : ℕ) + (y : MovingRegularSlot n r m → σ) : + MovingSlotReversal.naturalProduct value + (flattenMovingSlots n (treeLeafMap (List.map y) n (movingTemplateSmall n r m)) ++ + flattenMovingSlots n (treeLeafMap (List.map y) n + (bulkSlotLeaves n m (movingTemplateBulk n r m)))) = ∏ i, value (y i) := by + simpa only [flattenMovingSlots_map, MovingSlotReversal.naturalProduct, + List.map_append, List.map_map, Function.comp_def] using movingTemplate_product value n r m y + +theorem movingTemplateCompensationEquiv_product {σ : Type*} (value : σ → ℕ) (n : ℕ) + (a : TreeLeafTuple (Fin 4 → σ) n) : + MovingSlotReversal.naturalProduct value (flattenMovingSlots n (movingCompensationSlots n a)) = + ∏ i, value (movingTemplateCompensationEquiv σ n a i) := by + rw [movingCompensationProduct_indexed, Fintype.prod_prod_type] + rfl + +/-- This is the full next coefficient under the original independent +compensation law, with its exact integer pivot and complete child coefficients. -/ +theorem movingTemplateCoefficient_integer_node {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (hsV : s.natAbs ≤ V (n + 1)) + (left right : MovingRegularSlot n r m → σ) (XL XR : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) + (hVL : V (n + 1) < XL) (hVR : V (n + 1) < XR) + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : 2 * pivotBound (n + 1) * childBound (n + 1) < XR * ∏ i, value (right i)) + (hRH : ∀ q, q.Prime → q ∣ XR * (∏ i, value (right i)) → V (n + 1) < q) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) : + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G (n + 1) r m s + (movingTemplatePairSample n r m left right) XL XR = + ∑ u : TreeLeafIndex n × Fin 4 → σ, + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + let LH := XL * ∏ i, value (left i) + let RH := XR * ∏ i, value (right i) + let p := reconstructedPivot (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) + if validTransferredPivot I (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) then + (φ (Real.log p - G (n + 1)) : ℂ) * + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m v.val + (movingRestoreSample n r m u left) p XL * + star (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w.val + (movingRestoreSample n r m u right) p XR) + else 0 := by + by_cases hs : s = 0 + · subst s + change movingFrequencyCoefficient value outside μ childBound pivotBound V F φ G + (n + 1) 0 _ _ XL XR = _ + rw [movingFrequencyCoefficient_zero value outside μ childBound pivotBound V F hF φ G] + simp only [zero_mul, validTransferredPivot, ne_eq, not_true_eq_false, false_and, + ite_false, Finset.sum_const_zero, mul_zero] + · + let K := fun u : TreeLeafIndex n × Fin 4 → σ => + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + let LH := XL * ∏ i, value (left i) + let RH := XR * ∏ i, value (right i) + let p := reconstructedPivot (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) + if validTransferredPivot I (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) then + (φ (Real.log p - G (n + 1)) : ℂ) * + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m v.val + (movingRestoreSample n r m u left) p XL * + star (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w.val + (movingRestoreSample n r m u right) p XR) + else 0 + change _ = ∑ u, K u + rw [← (movingTemplateCompensationEquiv σ n).sum_comp K] + rw [movingTemplateCoefficient_prime_node value outside μ childBound pivotBound V hV F hF + φ G n r m s hs hsV left right XL XR hXL hXR hVL hVR] + apply Finset.sum_congr rfl + intro a _ + have hpμ := movingTemplateCompensationEquiv_prior (μ n) n a + have hU := movingTemplateCompensationEquiv_product value n a + by_cases ha : movingCompensationPrior (μ n) n a = 0 + · simp only [K, hpμ, ha, Complex.ofReal_zero, zero_mul] + · have hc := hcomp (movingTemplateCompensationEquiv σ n a) (hpμ ▸ ha) + dsimp only [K] + rw [hpμ, Complex.ofReal_mul, mul_assoc] + apply congrArg (fun z : ℂ => (movingCompensationPrior (μ n) n a : ℂ) * z) + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro v _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro w _ + let small := (treeLeafMap (List.map left) n (movingTemplateSmall n r m), + treeLeafMap (List.map right) n (movingTemplateSmall n r m)) + let bulk := (treeLeafMap (List.map left) n (bulkSlotLeaves n m (movingTemplateBulk n r m)), + treeLeafMap (List.map right) n (bulkSlotLeaves n m (movingTemplateBulk n r m))) + have ht := movingPrimeNodeFactor_substitution value outside μ childBound pivotBound V F hF + φ G n (movingCompensationSlots n a) small bulk XL XR s v.val w.val I hI hφ hsV + (((mem_transferFrequencyRange _ _).mp v.property).trans hchild) + (((mem_transferFrequencyRange _ _).mp w.property).trans hchild) + dsimp only [small, bulk] at ht + have hCL := movingTemplateMapped_product value n r m left + have hCR := movingTemplateMapped_product value n r m right + simp only [hU, hCL, hCR] at ht + specialize ht hc.1 hgap hRH hc.2 + simp only [movingTemplateCoefficient_restored] + dsimp only [movingTopPivot] at ht ⊢ + simp only [hU, hCL, hCR, Complex.ofReal_mul, Nat.cast_prod] at ht ⊢ + split_ifs at ht ⊢ <;> simpa only [mul_assoc, mul_zero] using ht + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLeaves.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLeaves.lean new file mode 100644 index 0000000000000000000000000000000000000000..11e92c32345220b77e7df7349f9975312e12ed89 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLeaves.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplatePrior +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternBulkData + +namespace OAI + +/-! # Restoring the four compensation primes in each actual leaf -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem treeLeafTupleEquiv_append_slots {A : Type*} (n : ℕ) + (x y : TreeLeafTuple (List A) n) (j : TreeLeafIndex n) : + treeLeafTupleEquiv (List A) n (appendMovingSlotLeaves n x y) j = + treeLeafTupleEquiv (List A) n x j ++ treeLeafTupleEquiv (List A) n y j := by + induction n with + | zero => rfl + | succ n ih => cases j with + | inl j => exact ih x.1 y.1 j + | inr j => exact ih x.2 y.2 j + +theorem treeLeafTupleEquiv_compensation_slots {A : Type*} (n : ℕ) + (a : TreeLeafTuple (Fin 4 → A) n) (j : TreeLeafIndex n) : + treeLeafTupleEquiv (List A) n (movingCompensationSlots n a) j = + List.ofFn (treeLeafTupleEquiv (Fin 4 → A) n a j) := by + induction n with + | zero => rfl + | succ n ih => cases j with + | inl j => exact ih a.1 j + | inr j => exact ih a.2 j + +/-- Restoring the same compensation sample in every surviving leaf gives +exactly the small list required by the two child recursions. -/ +theorem movingRestoreSample_small_leaves {A : Type*} (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) : + treeLeafMap (List.map (movingRestoreSample n r m u y)) n (movingTemplateSmall n (4 + r) m) = + appendMovingSlotLeaves n + (movingCompensationSlots n ((treeLeafTupleEquiv (Fin 4 → A) n).symm + (fun j i => u (j, i)))) + (treeLeafMap (List.map y) n (movingTemplateSmall n r m)) := by + apply (treeLeafTupleEquiv (List A) n).injective + funext j + rw [treeLeafTupleEquiv_map, treeLeafTupleEquiv_append_slots, + treeLeafTupleEquiv_compensation_slots, Equiv.apply_symm_apply, + treeLeafTupleEquiv_map] + simp only [movingTemplateSmall, bulkSlotLeaves, Equiv.apply_symm_apply, List.map_ofFn] + rw [List.ofFn_add] + change (List.ofFn (fun i : Fin 4 => + movingRestoreSample n r m u y (j, .inl (Fin.castAdd r i)))) ++ + (List.ofFn (fun i : Fin r => + movingRestoreSample n r m u y (j, .inl (Fin.natAdd 4 i)))) = _ + simp only [movingRestoreSample_small] + rfl + +theorem movingRestoreSample_bulk_leaves {A : Type*} (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) : + treeLeafMap (List.map (movingRestoreSample n r m u y)) n + (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m)) = + treeLeafMap (List.map y) n (bulkSlotLeaves n m (movingTemplateBulk n r m)) := by + rw [bulkSlotLeaves_map, bulkSlotLeaves_map] + congr 1 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveHarmonic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveHarmonic.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8be966da4a428875483e30adfcddb9fc5dcecd8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveHarmonic.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicDiagonal +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantPrior + +namespace OAI + +/-! # The ordinary harmonic diagonal uses only nonzero regular support -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original harmonic product law pays the giant atom and a single +factorial product-fibre cost. The frequency range contributes no cardinality +factor, because the diagonal key includes the frequency itself. -/ +theorem movingTemplate_harmonic_diagonal_live + (P Pg : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (cg : ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (u : TreeLeafIndex n × Fin 4 → P) (p : ℕ) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ cg q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ i (q : P), primeSubsetPrior P (Q i) q ≠ 0 → V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ cg q ≠ 0 → + ∀ i (a : P), primeSubsetPrior P (Q i) a ≠ 0 → (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let A := Pg × ((MovingRegularSlot n r m → P) × transferFrequencyRange (V n)) + let X := fun a : A => (a.1 : ℕ) + let y := fun a : A => a.2.1 + let v := fun a : A => (a.2.2 : ℤ) + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hPg _ a.1.property⟩ + let _ : ∀ a i, Fact (y a i : ℕ).Prime := fun a i => ⟨hP _ (y a i).property⟩ + let α := fun a : A => smoothGiantPrior Pg φ cg a.1 * + ∏ i, primeSubsetPrior P (Q i) (y a i) + let C := fun a : A => movingTemplateCoefficient (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n (4 + r) m (v a) + (movingRestoreSample n r m u (y a)) p (X a) + let θ := fun a : A => (Real.exp (smoothGiantLogNormalizer Pg φ cg) / X a) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (y a i : ℕ)) : ℝ)⁻¹ + let D := p * (∏ i, (u i : ℕ)) * outside.prod + (pivotDiagonal (fun a => X a * ∏ i, (y a i : ℕ)) v + (fun a => (α a : ℂ) * C a * + movingRegularTransform (movingOneGiantModuli (X a) (fun i => (y a i : ℕ))) + (movingOneGiantFactors (X a) (fun i => (y a i : ℕ)) greg ggiant favorable) D (v a))).re ≤ + ∑ a, α a * θ a * + ‖C a * primeProductTransform greg (D * X a) (∏ i, (y a i : ℕ)) (v a)‖ ^ 2 := by + intro A X y v instX instY α C θ D + let g := fun q : ℕ => Real.exp (smoothGiantLogNormalizer Pg φ cg) / q + have hg q : 0 ≤ g q := div_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + have hα a : 0 ≤ α a := + mul_nonneg (smoothGiantPrior_nonneg Pg φ cg hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + have hpoint a : α a ≤ g (X a) * ∏ i, primeSubsetPrior P (Q i) (y a i) := by + apply mul_le_mul_of_nonneg_right _ + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + change Real.exp (smoothGiantLogNormalizer Pg φ cg) * φ (Real.log (a.1 : ℕ) - cg) / + (a.1 : ℕ) ≤ Real.exp (smoothGiantLogNormalizer Pg φ cg) / (a.1 : ℕ) + exact div_le_div_of_nonneg_right + (mul_le_of_le_one_right (Real.exp_nonneg _) (hφ1 _)) (Nat.cast_nonneg _) + have hrow (a b : A) (hx : X a = X b) (hy : y a = y b) (hv : v a = v b) : a = b := + Prod.ext (Subtype.ext hx) (Prod.ext hy (Subtype.ext hv)) + have hc a (ha : (α a : ℂ) * C a ≠ 0) : C a ≠ 0 := right_ne_zero_of_mul ha + have hinj a (ha : (α a : ℂ) * C a ≠ 0) : Function.Injective (y a) := by + have hs := movingTemplateCoefficient_restored_support (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n r m (v a) u (y a) p (X a) (hc a ha) + intro i j hij + by_contra hne + have hh := hs.2.2.1 (show (Sum.inr i : Unit ⊕ MovingRegularSlot n r m) ≠ .inr j from + fun he => hne (Sum.inr.inj he)) + change (y a i : ℕ).Coprime (y a j : ℕ) at hh + rw [hij] at hh + exact (hP _ (y a j).property).ne_one (by simpa only [Nat.coprime_self] using hh) + have hz a (ha : (α a : ℂ) * C a ≠ 0) : v a ≠ 0 := by + intro he + apply hc a ha + simpa only [C, movingTemplateCoefficient, he] using + movingFrequencyCoefficient_zero (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F hF φ G n + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (movingTemplateSmall n (4 + r) m)) + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m))) p (X a) + have hsupp (a : A) (ha : (α a : ℂ) * C a ≠ 0) : smoothGiantPrior Pg φ cg a.1 ≠ 0 := by + have ha' : α a ≠ 0 := by exact_mod_cast left_ne_zero_of_mul ha + exact left_ne_zero_of_mul ha' + have hregular (a : A) (ha : (α a : ℂ) * C a ≠ 0) (i) : + primeSubsetPrior P (Q i) (y a i) ≠ 0 := by + have ha' : α a ≠ 0 := by exact_mod_cast left_ne_zero_of_mul ha + exact Finset.prod_ne_zero_iff.mp (right_ne_zero_of_mul ha') i (Finset.mem_univ i) + have h := movingOneGiant_harmonic_diagonal_le P hP Q X + (fun a => hPg _ a.1.property) y v α C hα g hg hrow hpoint hinj hz + (fun a ha => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt (hvg a.1 (hsupp a ha))) + (fun a ha i => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt + (hvr i (y a i) (hregular a ha i))) + (fun a b ha hb i => hsep a.1 (hsupp a ha) i (y b i) (hregular b hb i)) greg ggiant favorable D + simpa only [g, θ, Nat.cast_prod] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveRaw.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveRaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..6adcd185f7fa5f11535b9d77e78c97ea6d085b21 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveRaw.lean @@ -0,0 +1,161 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullLiveTransformTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateWeightedSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullTransformTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOneGiant + +namespace OAI + +/-! # One giant-prior step with a product bound only on actual coefficient support -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance liveTemplateSum_prime {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, Fact (q j).Prime] [∀ i, Fact (p i).Prime] (i : J ⊕ I) : + Fact (Sum.elim q p i).Prime := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +local instance liveTemplateSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +/-- The support fields in the full Fourier transfer follow from the +original coefficient. Compensation retains its original independent law; +`α` contains the surviving external priors. -/ +theorem movingTemplate_prior_transfer_raw_on_live {σ A : Type} [Fintype σ] [Fintype A] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass P φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (X : A → ℕ) (hX : ∀ a, (X a).Prime) + (y : A → MovingRegularSlot n r m → σ) (v : A → ℤ) (α : A → ℂ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ a x, ggiant (X a) (-x) = conj (ggiant (X a) x)) + (N H T : ℕ) (hv : ∀ a, (v a).natAbs ≤ N) + (hH : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ), p ∈ I → ∀ a, + movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G + n r m v α X y u p a ≠ 0 → X a * (∏ i, value (y a i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p, p ∈ I → + 2 * N * H ≤ T * (p * ∏ i, value (u i))) + (hlarge : ∀ a, α a ≠ 0 → ∀ q, q.Prime → + q ∣ X a * (∏ i, value (y a i)) → T < q) : + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let _ : ∀ a i, Fact (((value ∘ y a) i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let greg := normalizedResidueFamily sets + let U := fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, value (u i) + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let _ : ∀ a i, NeZero (L a i) := fun a i => by + cases i with + | inl _ => exact ⟨(hX a).ne_zero⟩ + | inr j => exact ⟨(hvalue (y a j)).ne_zero⟩ + let gL := fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable + let Q := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantModuli (p : ℕ) (value ∘ u) + let _ : ∀ u p i, NeZero (Q u p i) := fun u p i => by + cases i with + | inl _ => exact ⟨(hP p p.property).ne_zero⟩ + | inr j => exact ⟨(hvalue (u j)).ne_zero⟩ + let gQ := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantFactors (p : ℕ) (value ∘ u) greg ggiant favorable + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + Real.exp (-smoothGiantLogNormalizer P φ (G (n + 1))) * + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, ((∏ i, μ n (u i) : ℝ) : ℂ) * + ∑ p : P, (smoothGiantPrior P φ (G (n + 1)) p : ℂ) * + ∑ a, W u p a * movingRegularTransform (Sum.elim (Q u p) (L a)) + (movingSumFactors (Q u p) (L a) (gQ u p) (gL a)) outside.prod (v a)‖ ^ 2 ≤ + (∑ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) * (U u : ℝ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + (pivotDiagonal (fun a => ∏ i, L a i) v + (movingRegularCoefficient L gL outside.prod (U u) v (W u) p)).re) + + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, (((∏ i, μ n (u i)) * (U u : ℝ) : ℝ) : ℂ) * + ∑ s ∈ transferFrequencyRange T, ∑ a, ∑ b, + if validTransferredPivot I + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) then + let p := reconstructedPivot + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) + (φ (Real.log p - G (n + 1)) : ℂ) * W u p a * conj (W u p b) * + movingRegularTransform (Sum.elim (L a) (L b)) + (movingSumFactors (L a) (L b) (gL a) (gL b)) outside.prod s + else 0‖ := by + let : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let : ∀ a, Fact (value a).Prime := fun a => ⟨hvalue a⟩ + let : ∀ a i, Fact (((value ∘ y a) i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let greg := normalizedResidueFamily sets + let U := fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, value (u i) + let Q := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantModuli (p : ℕ) (value ∘ u) + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let : ∀ (u : TreeLeafIndex n × Fin 4 → σ) (p : P) i, Fact (Q u p i).Prime := by + intro u p i + cases i with + | inl _ => exact ⟨hP p p.property⟩ + | inr j => exact ⟨hvalue (u j)⟩ + let gQ := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantFactors (p : ℕ) (value ∘ u) greg ggiant favorable + let : ∀ a i, Fact (L a i).Prime := fun a i => by + cases i <;> dsimp only [L, movingOneGiantModuli, Sum.elim, Function.comp_apply] <;> infer_instance + let : ∀ a i, NeZero (L a i) := fun a i => by infer_instance + let gL := fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + have hprod (a : A) : (∏ i, L a i) = X a * ∏ i, value (y a i) := + movingOneGiantModuli_product (X a) (value ∘ y a) + have hQprod u p : (∏ i, Q u p i) = (p : ℕ) * U u := + movingOneGiantModuli_product (p : ℕ) (value ∘ u) + have hs u p a (h : W u p a ≠ 0) := + movingTemplateTransferWeight_support value outside μ childBound pivotBound V F φ G + n r m v α X y u p a h + have hgL a i x : gL a i (-x) = conj (gL a i x) := + movingOneGiantFactors_neg (X a) (value ∘ y a) greg ggiant favorable + (hgiant a) (fun j x => by + dsimp only [greg] + rw [normalizedResidueFamily_eq] + exact normalizedResidueTransform_neg _ x) i x + have ht := smoothGiantPrior_full_transform_transfer_on_live + (Y := TreeLeafIndex n × Fin 4 → σ) (A := A) + (J := Unit ⊕ (TreeLeafIndex n × Fin 4)) (H := Unit ⊕ MovingRegularSlot n r m) P I hP hPI hI φ (G (n + 1)) hφ hpos + (fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, μ n (u i)) + (fun u => Finset.prod_nonneg (fun i _ => hμ (u i))) + (by rw [← Fintype.prod_sum]; simp only [hμmass, Finset.prod_const_one]) U + (fun u => Finset.prod_pos (fun i _ => (hvalue (u i)).pos)) Q gQ hQprod (.inl ()) + (fun u p i => match i with | .inl _ => ∅ | .inr j => sets (value (u j))) + (fun u p x => by + change ‖if favorable (p : ℕ) then complexUnitPhase (ggiant p x) else 0‖ ≤ 1 + split_ifs + · exact complexUnitPhase_norm_le _ + · simp) + (fun u p i hi => by + cases i with + | inl i => cases i; exact (hi rfl).elim + | inr j => exact normalizedResidueFamily_eq sets (value (u j))) + (fun u p i hi => by + cases i with + | inl i => cases i; exact (hi rfl).elim + | inr j => exact hsets (u j)) + (fun u p i hi => by + cases i with + | inl i => cases i; exact (hi rfl).elim + | inr j => exact hcard (u j)) (fun _ => L) (fun _ => gL) (fun _ => hgL) (fun _ => outside.prod) (fun _ => v) W + (fun u p a hw => ⟨(hs u p a hw).1, (hs u p a hw).2.1⟩) + (fun u p _ a hw => by + have h := hs u p a hw + refine ⟨h.2.2.1, ?_, h.2.2.2.2⟩ + have hc := h.2.2.2.1 + change (∏ i, L a i).Coprime (∏ i, movingOneGiantModuli p (value ∘ u) i) at hc + simpa only [L, U, movingOneGiantModuli_product, Function.comp_apply] using hc) + N H T (fun _ _ _ a _ => hv a) (fun u hu p hp a ha => (hprod a).trans_le (hH u hu p hp a ha)) + hscale (fun _ _ _ a hw q hq hd => + hlarge a (left_ne_zero_of_mul hw) q hq ((hprod a) ▸ hd)) + with_reducible exact ht + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveSymmetrization.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveSymmetrization.lean new file mode 100644 index 0000000000000000000000000000000000000000..49109e442746c3b5a2ce83d9629d523d4ee72f75 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveSymmetrization.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGroupedBulkAverage +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicGroupedEnergy +import OAI.NumberTheory.Ostmann.Construction.SelectedBulkSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicDiagonal +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantPrior + +namespace OAI + +/-! # The restored diagonal under the original giant and regular priors -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original harmonic product law pays the giant atom and a single +factorial product-fibre cost. The frequency range contributes no cardinality +factor, because the diagonal key includes the frequency itself. -/ +theorem movingTemplate_symmetrized_harmonic_diagonal_live + (P Pg : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (cg : ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (hν : ∀ j k : TreeLeafIndex n × Fin m, + primeSubsetPrior P (Q (movingTemplateBulk n r m j)) = + primeSubsetPrior P (Q (movingTemplateBulk n r m k))) + (u : TreeLeafIndex n × Fin 4 → P) (p : ℕ) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ cg q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ i (q : P), primeSubsetPrior P (Q i) q ≠ 0 → V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ cg q ≠ 0 → + ∀ i (a : P), primeSubsetPrior P (Q i) a ≠ 0 → (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let A := Pg × ((MovingRegularSlot n r m → P) × transferFrequencyRange (V n)) + let X := fun a : A => (a.1 : ℕ) + let y := fun a : A => a.2.1 + let v := fun a : A => (a.2.2 : ℤ) + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hPg _ a.1.property⟩ + let _ : ∀ a i, Fact (y a i : ℕ).Prime := fun a i => ⟨hP _ (y a i).property⟩ + let α := fun a : A => smoothGiantPrior Pg φ cg a.1 * + ∏ i, primeSubsetPrior P (Q i) (y a i) + let C := fun a : A => movingTemplateCoefficient (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n (4 + r) m (v a) + (movingRestoreSample n r m u (y a)) p (X a) + let Csym := fun a : A => mixedBulkSymmetrize n m (movingTemplateBulk n r m) + (fun _ z _ _ => C (a.1, z, a.2.2)) 0 (y a) 0 0 + let θ := fun a : A => (Real.exp (smoothGiantLogNormalizer Pg φ cg) / X a) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (y a i : ℕ)) : ℝ)⁻¹ + let D := p * (∏ i, (u i : ℕ)) * outside.prod + (pivotDiagonal (fun a => X a * ∏ i, (y a i : ℕ)) v + (fun a => (α a : ℂ) * C a * + movingRegularTransform (movingOneGiantModuli (X a) (fun i => (y a i : ℕ))) + (movingOneGiantFactors (X a) (fun i => (y a i : ℕ)) greg ggiant favorable) D (v a))).re ≤ + ∑ a, α a * θ a * + ‖Csym a * primeProductTransform greg (D * X a) (∏ i, (y a i : ℕ)) (v a)‖ ^ 2 := by + intro A X y v instX instY α C Csym θ D + let g := fun q : ℕ => Real.exp (smoothGiantLogNormalizer Pg φ cg) / q + have hg q : 0 ≤ g q := div_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + have hα a : 0 ≤ α a := + mul_nonneg (smoothGiantPrior_nonneg Pg φ cg hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + have hpoint a : α a ≤ g (X a) * ∏ i, primeSubsetPrior P (Q i) (y a i) := by + apply mul_le_mul_of_nonneg_right _ + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + change Real.exp (smoothGiantLogNormalizer Pg φ cg) * φ (Real.log (a.1 : ℕ) - cg) / + (a.1 : ℕ) ≤ Real.exp (smoothGiantLogNormalizer Pg φ cg) / (a.1 : ℕ) + exact div_le_div_of_nonneg_right + (mul_le_of_le_one_right (Real.exp_nonneg _) (hφ1 _)) (Nat.cast_nonneg _) + have hrow (a b : A) (hx : X a = X b) (hy : y a = y b) (hv : v a = v b) : a = b := + Prod.ext (Subtype.ext hx) (Prod.ext hy (Subtype.ext hv)) + have hc a (ha : (α a : ℂ) * C a ≠ 0) : C a ≠ 0 := right_ne_zero_of_mul ha + have hinjC a (ha : C a ≠ 0) : Function.Injective (y a) := by + have hs := movingTemplateCoefficient_restored_support (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n r m (v a) u (y a) p (X a) ha + intro i j hij + by_contra hne + have hh := hs.2.2.1 (show (Sum.inr i : Unit ⊕ MovingRegularSlot n r m) ≠ .inr j from + fun he => hne (Sum.inr.inj he)) + change (y a i : ℕ).Coprime (y a j : ℕ) at hh + rw [hij] at hh + exact (hP _ (y a j).property).ne_one (by simpa only [Nat.coprime_self] using hh) + have hinj a (ha : (α a : ℂ) * C a ≠ 0) := hinjC a (hc a ha) + have hnewinj a (ha : (α a : ℂ) * Csym a ≠ 0) : Function.Injective (y a) := by + obtain ⟨e, he⟩ := mixedBulkSymmetrize_ne_zero n m (movingTemplateBulk n r m) + (fun _ z _ _ => C (a.1, z, a.2.2)) 0 (y a) 0 0 (right_ne_zero_of_mul ha) + have hi := hinjC (a.1, selectedBulkSample (movingTemplateBulk n r m) e (y a), a.2.2) he + exact (selectedBulkSample_injective_iff (movingTemplateBulk n r m) e id (y a)).mp hi + have hgroup (k : ℕ × ℕ × ℤ) : + groupedCoefficient (fun a => (X a, (∏ i, (y a i : ℕ)), v a)) + (fun a => (α a : ℂ) * C a) k = + groupedCoefficient (fun a => (X a, (∏ i, (y a i : ℕ)), v a)) + (fun a => (α a : ℂ) * Csym a) k := by + exact (movingAmplitude_grouped_bulk_average P Pg n r m V + (smoothGiantPrior Pg φ cg) (fun i => primeSubsetPrior P (Q i)) hν C k).symm + have hz a (ha : (α a : ℂ) * C a ≠ 0) : v a ≠ 0 := by + intro he + apply hc a ha + simpa only [C, movingTemplateCoefficient, he] using + movingFrequencyCoefficient_zero (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F hF φ G n + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (movingTemplateSmall n (4 + r) m)) + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m))) p (X a) + have hsupp (a : A) (ha : (α a : ℂ) * C a ≠ 0) : smoothGiantPrior Pg φ cg a.1 ≠ 0 := by + have ha' : α a ≠ 0 := by exact_mod_cast left_ne_zero_of_mul ha + exact left_ne_zero_of_mul ha' + have hprior (a : A) (ha : (α a : ℂ) * C a ≠ 0) (i) : + primeSubsetPrior P (Q i) (y a i) ≠ 0 := by + have hα : α a ≠ 0 := by exact_mod_cast left_ne_zero_of_mul ha + exact Finset.prod_ne_zero_iff.mp (right_ne_zero_of_mul hα) i (Finset.mem_univ i) + have h := movingOneGiant_harmonic_grouped_diagonal_le P hP Q X + (fun a => hPg _ a.1.property) y v α C Csym hα g hg hrow hpoint hinj hz + (fun a ha => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt (hvg a.1 (hsupp a ha))) + (fun a ha i => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt + (hvr i (y a i) (hprior a ha i))) + (fun a b ha hb i => hsep a.1 (hsupp a ha) i (y b i) (hprior b hb i)) hgroup hnewinj greg ggiant favorable D + simpa only [g, θ, Nat.cast_prod] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..609908abdd14be7005bb28f65108de89d9717564 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLiveTransfer.lean @@ -0,0 +1,96 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateTransferSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullTransformTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLiveRaw + +namespace OAI + +/-! # The full giant-prior step with its actual supported product bound -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance liveFinalSum_prime {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, Fact (q j).Prime] [∀ i, Fact (p i).Prime] (i : J ⊕ I) : + Fact (Sum.elim q p i).Prime := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +local instance liveFinalSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +/-- The support fields in the full Fourier transfer follow from the +original coefficient. Compensation retains its original independent law; +`α` contains the surviving external priors. -/ +theorem movingTemplate_prior_transfer_on_live {σ A : Type} [Fintype σ] [Fintype A] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass P φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (X : A → ℕ) (hX : ∀ a, (X a).Prime) + (y : A → MovingRegularSlot n r m → σ) (v : A → ℤ) (α : A → ℂ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ a x, ggiant (X a) (-x) = conj (ggiant (X a) x)) + (N H T : ℕ) (hv : ∀ a, (v a).natAbs ≤ N) + (hH : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ), p ∈ I → ∀ a, + movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G + n r m v α X y u p a ≠ 0 → X a * (∏ i, value (y a i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p, p ∈ I → + 2 * N * H ≤ T * (p * ∏ i, value (u i))) + (hlarge : ∀ a, α a ≠ 0 → ∀ q, q.Prime → + q ∣ X a * (∏ i, value (y a i)) → T < q) : + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let _ : ∀ a i, Fact (((value ∘ y a) i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let greg := normalizedResidueFamily sets + let U := fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, value (u i) + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let _ : ∀ a i, NeZero (L a i) := fun a i => by + cases i with + | inl _ => exact ⟨(hX a).ne_zero⟩ + | inr j => exact ⟨(hvalue (y a j)).ne_zero⟩ + let gL := fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + Real.exp (-smoothGiantLogNormalizer P φ (G (n + 1))) * + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, ((∏ i, μ n (u i) : ℝ) : ℂ) * + ∑ p : P, (smoothGiantPrior P φ (G (n + 1)) p : ℂ) * + ∑ a, W u p a * movingTaggedTransform + (Sum.elim (fun b : Bool => if b then (p : ℕ) else X a) + (value ∘ movingRestoreSample n r m u (y a))) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod (v a)‖ ^ 2 ≤ + (∑ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) * (U u : ℝ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + (pivotDiagonal (fun a => ∏ i, L a i) v + (movingRegularCoefficient L gL outside.prod (U u) v (W u) p)).re) + + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, (((∏ i, μ n (u i)) * (U u : ℝ) : ℝ) : ℂ) * + ∑ s ∈ transferFrequencyRange T, ∑ a, ∑ b, + if validTransferredPivot I + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) then + let p := reconstructedPivot + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) + (φ (Real.log p - G (n + 1)) : ℂ) * W u p a * conj (W u p b) * + movingRegularTransform (Sum.elim (L a) (L b)) + (movingSumFactors (L a) (L b) (gL a) (gL b)) outside.prod s + else 0‖ := by + let greg := normalizedResidueFamily sets + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + have ht := movingTemplate_prior_transfer_raw_on_live value hvalue outside μ childBound pivotBound V F + φ G n r m P I hP hPI hI hφ hpos hμ hμmass X hX y v α sets hsets hcard ggiant favorable + hgiant N H T hv hH hscale hlarge + have hsum := movingOneGiant_restored_average value (fun z => (hvalue z).ne_zero) n r m + P (fun p => (hP p p.property).ne_zero) X (fun a => (hX a).ne_zero) y v outside.prod + greg ggiant favorable (fun u => ((∏ i, μ n (u i) : ℝ) : ℂ)) + (fun p => (smoothGiantPrior P φ (G (n + 1)) p : ℂ)) (fun u p a => W u p a) + exact (congrArg (fun z : ℂ => + Real.exp (-smoothGiantLogNormalizer P φ (G (n + 1))) * ‖z‖ ^ 2) hsum).le.trans ht + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogCorrelation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..f2b56e986b98ce90939cc0bacf1f182838d264b2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogCorrelation.lean @@ -0,0 +1,118 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalLogCoefficientPair +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedMatchedCorrelation +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateExternalMultiplier +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalBulkAction +import OAI.NumberTheory.Ostmann.Characters.MixedExternalStatistic + +namespace OAI + +/-! # The retained log weights in the original masked coefficient correlation -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem mixedExternalAverage_support_const_mul {B A : Type*} [Fintype B] [Fintype A] + (ν : B → A → ℝ) (N : ℕ) (u v a b center : ℝ) (c : ℂ) + (F H : ℤ → (B → A) → ℝ → ℝ → ℂ) + (h : ∀ y, (∏ j, ν j (y j)) ≠ 0 → ∀ s x z, F s y x z = c * H s y x z) : + mixedExternalAverage ν N u v a b center F = + c * mixedExternalAverage ν N u v a b center H := by + unfold mixedExternalAverage + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro s _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro y _ + by_cases hy : (∏ j, ν j (y j)) = 0 + · simp only [hy, Complex.ofReal_zero, zero_mul, mul_zero] + · simp_rw [h y hy, complexIntegerInterval_const_mul, complexPrimeInterval_const_mul] + ring + +theorem movingTemplate_log_correlation_eq + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n r m k : ℕ) (hn : n ≤ k) + (tier : P → ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → P → ℝ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (ν : MovingRegularSlot n r m → P → ℝ) + (hsmall : ∀ y : MovingRegularSlot n r m → P, (∏ j, ν j (y j)) ≠ 0 → ∀ j : TreeLeafIndex n × Fin r, + tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ y : MovingRegularSlot n r m → P, (∏ j, ν j (y j)) ≠ 0 → ∀ j : TreeLeafIndex n × Fin m, + tier (y (j.1, .inr j.2)) = k) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot n r m → Bool) (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) : + let slot := movingTemplateBulk n r m + let bulk := movingPatternBulkLeaves n m slot perm + let leaf := movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + g Dq Finset.univ ψ X lo hi + let coeff := fun s y x z => movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V + leaf φ G n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + let W := fun s => movingTemplateExternalMultiplier P hP n r m active outside greg s φ Jleft Jright diagonal + let wgt := fun y => ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb + (movingBulkPairedCutoffSlots n bulk j) : ℝ) : ℂ) + mixedExternalAverage ν (V n) u v a b center (fun s y x z => + (coeff s y x z * star (coeff s (selectedBulkSample slot perm y) x z)) * W s y x z) = + (logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ (2 ^ n + 2 ^ n) : ℝ) * + movingWeightedMatchedCorrelation p Subtype.val outside μ ν childBound pivotBound V f g Dq Finset.univ + ψ X lo hi φ G n (movingTemplateSmall n r m) bulk + (fun s y x z => wgt y * W s y x z) u v a b center := by + intro slot bulk leaf coeff W wgt + let plain := fun side (s : ℤ) (y : MovingRegularSlot n r m → P) (x z : ℝ) => + movingFrequencyCoefficient Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p (fun _ => f) g Dq Finset.univ ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n (movingTemplateSmall n r m)) + (treeLeafMap (List.map y) n (bulk side)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + change mixedExternalAverage ν (V n) u v a b center + (fun s y x z => (coeff s y x z * star (coeff s (selectedBulkSample slot perm y) x z)) * W s y x z) = + (logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ (2 ^ n + 2 ^ n) : ℝ) * + mixedExternalAverage ν (V n) u v a b center + (fun s y x z => (plain false s y x z * star (plain true s y x z)) * (wgt y * W s y x z)) + apply mixedExternalAverage_support_const_mul + intro y hy s x z + have hs : ∀ i ∈ flattenMovingSlots n + (treeLeafMap (List.map y) n (movingTemplateSmall n r m)), tier i ≠ k := by + intro i hi + rw [flattenMovingSlots_map] at hi + obtain ⟨j, hj, rfl⟩ := List.mem_map.mp hi + obtain ⟨j, rfl⟩ := (mem_flatten_bulkSlotLeaves n r _ j).mp hj + exact hsmall y hy j + have hb : ∀ side i, i ∈ flattenMovingSlots n + (treeLeafMap (List.map y) n (movingPatternBulkLeaves n m (movingTemplateBulk n r m) perm side)) → tier i = k := by + intro side i hi + rw [flattenMovingSlots_map] at hi + obtain ⟨j, hj, rfl⟩ := List.mem_map.mp hi + cases side + · obtain ⟨j, rfl⟩ := (mem_flatten_bulkSlotLeaves n m _ j).mp hj + exact hbulk y hy j + · obtain ⟨j, rfl⟩ := (mem_flatten_bulkSlotLeaves n m _ j).mp hj + exact hbulk y hy (perm.symm j) + have hp := movingOriginalCoefficientPair_bulk_log Subtype.val tier + (fun q : P => (hP _ q.property).pos) k outside cb cd μ hμ p (fun _ => f) g Dq Finset.univ + ψ X lo hi childBound pivotBound V φ G n s + (treeLeafMap (List.map y) n (movingTemplateSmall n r m)) + (fun side => treeLeafMap (List.map y) n (movingPatternBulkLeaves n m (movingTemplateBulk n r m) perm side)) + hn hs hb ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + dsimp only [coeff, leaf, plain, W, wgt, slot, bulk] + unfold movingTemplateCoefficient + rw [movingFrequencyCoefficient_bulk_action Subtype.val outside μ childBound pivotBound V _ φ G + n m s (movingTemplateSmall n r m) (movingTemplateBulk n r m) perm y + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ (movingTemplateSmall_not_bulk n r m)] + dsimp only at hp + have hfalse : movingPatternBulkLeaves n m (movingTemplateBulk n r m) perm false = + bulkSlotLeaves n m (movingTemplateBulk n r m) := rfl + have htrue : movingPatternBulkLeaves n m (movingTemplateBulk n r m) perm true = + bulkSlotLeaves n m (movingTemplateBulk n r m ∘ perm.symm) := rfl + rw [hfalse, htrue] at hp ⊢ + rw [hp] + simp only [movingBulkPairedCutoffSlots_map, bulkLogCutoffWeight_map, Function.comp_def] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..765f10c12ff5a71091349810ff3e251fb162cbdf --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogDiagonal.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.Ostmann.Characters.MixedExternalSupportedEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogNorm +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateMaskedSymmetrization +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkOriginalCoefficient + +namespace OAI + +/-! # Removing the retained cutoff only from the nonnegative diagonal energy -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplate_log_diagonal_le + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n r m k : ℕ) (hn : n ≤ k) + (tier : P → ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → P → ℝ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (ν : MovingRegularSlot n r m → P → ℝ) (hν : ∀ j a, 0 ≤ ν j a) + (hsmall : ∀ y : MovingRegularSlot n r m → P, (∏ j, ν j (y j)) ≠ 0 → + ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ y : MovingRegularSlot n r m → P, (∏ j, ν j (y j)) ≠ 0 → + ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) (G : ℕ → ℝ) + (active : MovingRegularSlot n r m → Bool) (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) : + let weighted := fun x s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s + let Cw := fun s y x z => movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V + weighted φ G n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + let C := fun s y x z => movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V + F φ G n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + let W := fun s => movingTemplateExternalMultiplier P hP n r m active outside greg s φ Jleft Jright diagonal + (mixedExternalAverage ν (V n) u v a b center + (fun s y x z => (‖Cw s y x z‖ ^ 2 : ℂ) * W s y x z)).re ≤ + (mixedExternalAverage ν (V n) u v a b center + (fun s y x z => (‖C s y x z‖ ^ 2 : ℂ) * W s y x z)).re := by + intro weighted Cw C W + have hw (s : ℤ) (y : MovingRegularSlot n r m → P) (x z : ℝ) : + ((W s y x z).re : ℂ) = W s y x z := + (movingTemplateExternalMultiplier_nonneg P hP n r m active outside greg s φ hφ + Jleft Jright diagonal y x z).2 + have h := mixedExternalAverage_square_mono_support ν hν (V n) u v a b center Cw C + (fun s y x z => (W s y x z).re) + (fun s y x z => (movingTemplateExternalMultiplier_nonneg P hP n r m active outside greg s φ hφ + Jleft Jright diagonal y x z).1) + (fun y hy s x z => movingTemplateCoefficient_bulk_log_norm_le Subtype.val tier k outside cb cd μ hμ + childBound pivotBound V F φ G n r m s y hn (hsmall y hy) (hbulk y hy) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊) + simpa only [hw] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogFamilyBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogFamilyBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..fed4d62a5fbf3aefce963a273fda207c91405256 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogFamilyBound.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogFamilyPatterns +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedMatchedHistories + +namespace OAI + +/-! # The actual masked energy is bounded by its original signed pattern means -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateLogFamilyMatchedCorrelation_pattern_bound + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) + (n r m : ℕ) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (active : MovingRegularSlot n r m → Bool) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → P → ℝ) (ν : MovingRegularSlot n r m → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center cb : ℝ) (hV : Monotone V) + (tlog : ℕ) (logSlots : Fin tlog → List (MovingRegularSlot n r m)) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), + Fin (N s + 1) ≃ MovingRegularSlot n r m ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let small := movingTemplateSmall n r m + let slot := movingTemplateBulk n r m + let wgt := fun (y : MovingRegularSlot n r m → P) => + ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) + let W := fun s => movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → P, + movingOriginalPatternWeight (e s) μ ν Subtype.val n (fun i => Quotient.mk'' i) + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb + ((logSlots j).map (fun i => (e s).symm (.inl i))) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable (e s) (trees t) small slot perm (fun i => Quotient.mk'' i) + P hP p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) + greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center x) x + ‖movingWeightedMatchedCorrelation p Subtype.val outside μ ν childBound pivotBound V f g Dq + Finset.univ ψ X lo hi φ G n small (movingPatternBulkLeaves n m slot perm) (fun s y x z => wgt y * W s y x z) u v a b center‖ ≤ + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ∑ s : Setoid (Bool × MovingSampleIndex n), ‖term t s‖ := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + apply (movingWeightedMatchedCorrelation_history_bound P outside n m p μ ν childBound pivotBound V + f hf g Dq ψ X lo hi φ G (movingTemplateSmall n r m) + (movingPatternBulkLeaves n m (movingTemplateBulk n r m) perm) + (fun s y x z => + ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb + (logSlots j) : ℝ) : ℂ) * + movingTemplateExternalMultiplier P hP n r m active outside greg s φ Jleft Jright diagonal y x z) u v a b center hV).trans + apply Finset.sum_le_sum + intro t _ + rw [movingTemplateLogFamilyWeightedMatchedMean_patterns P hP n r m perm _ active p μ ν g Dq greg _ + f outside childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center cb tlog logSlots N e] + exact norm_sum_le _ _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogFamilyPatterns.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogFamilyPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..7644cd502ef262be154a04f695c64e4537bf024c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogFamilyPatterns.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateExternalMultiplier +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMatchedExteriorWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkPairedCutoffs + +namespace OAI + +/-! # The signed equality-pattern expansion of the actual masked diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateLogFamilyWeightedMatchedMean_patterns + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n r m : ℕ) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (t : Bool → FrequencyTree ℤ n) (active : MovingRegularSlot n r m → Bool) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → P → ℝ) (ν : MovingRegularSlot n r m → P → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center cb : ℝ) + (tlog : ℕ) (logSlots : Fin tlog → List (MovingRegularSlot n r m)) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), + Fin (N s + 1) ≃ MovingRegularSlot n r m ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let small := movingTemplateSmall n r m + let slot := movingTemplateBulk n r m + let wgt := fun (y : MovingRegularSlot n r m → P) => + ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) + let W := movingTemplateExternalMultiplier P hP n r m active outside greg sreg φ + Jleft Jright diagonal + movingWeightedMatchedMean p Subtype.val outside μ ν childBound pivotBound f g Dq Finset.univ + ψ X lo hi φ G n t small (movingPatternBulkLeaves n m slot perm) (fun y x z => wgt y * W y x z) u v a b center = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → P, + movingOriginalPatternWeight (e s) μ ν Subtype.val n (fun i => Quotient.mk'' i) + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb + ((logSlots j).map (fun i => (e s).symm (.inl i))) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable (e s) t small slot perm (fun i => Quotient.mk'' i) + P hP p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) + greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center x) x := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + rw [movingWeightedMatchedMean_patterns p Subtype.val outside μ ν] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro x _ + unfold movingOriginalPatternWeight + congr 1 + unfold movingPatternInjectionGuard + split_ifs + · dsimp only + rw [movingWeightedMatchedKernel_mul] + have hw (x : Fin (N s + 1) → P) : + (∏ j, bulkLogCutoffWeight + (fun i => ((x ((e s).symm (.inl i)) : ℕ) : ℝ)) cb + (logSlots j)) = + ∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb + ((logSlots j).map + (fun i => (e s).symm (.inl i))) := by + simp only [bulkLogCutoffWeight_map, Function.comp_def] + rw [hw x] + congr 1 + apply movingWeightedMatchedKernel_fin (e s) t (movingTemplateSmall n r m) + (movingTemplateBulk n r m) perm (fun i => Quotient.mk'' i) P hP p g Dq + (movingPatternRegularSlots (e s) n m (movingTemplateSmall n r m) (movingTemplateBulk n r m)).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m (movingTemplateSmall n r m) (movingTemplateBulk n r m))) + greg sreg f outside childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center + intro z y + exact movingTemplateExternalMultiplier_pattern P hP n r m (e s) active outside greg sreg φ + Jleft Jright diagonal x z y + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogFamilyRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogFamilyRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..a651d6e6e07ae07f0404e82ee5da8db5eb8c0879 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogFamilyRate.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogFamilyBound +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticGoodPatternRate + +namespace OAI + +/-! # Full original matched correlation from the signed pattern budget -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateLogFamilyMatchedCorrelation_pattern_rate + (ψ : 𝓢(ℝ, ℂ)) (n k : ℕ) (hk : 0 < k) + (Cfreq Cprior gain : ℝ) (hCfreq : 0 ≤ Cfreq) (hCprior : 1 ≤ Cprior) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (r₀ : ℕ) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → primes → ℝ) (ν : MovingRegularSlot n r₀ m → primes → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (X Δ hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot n r₀ m → Bool) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (greg : ∀ q : ℕ, ZMod q → ℂ) (outside : List ℕ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center cb : ℝ) + (tlog : ℕ) (logSlots : Fin tlog → List (MovingRegularSlot n r₀ m)) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ MovingRegularSlot n r₀ m ⊕ Quotient s), + let small := movingTemplateSmall n r₀ m + let slot := movingTemplateBulk n r₀ m + let wgt := fun (y : MovingRegularSlot n r₀ m → primes) => + ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let err := Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n + (fun i => Quotient.mk'' i) + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb + ((logSlots j).map (fun i => (e s).symm (.inl i))) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable (e s) (trees t) small slot perm + (fun i => Quotient.mk'' i) primes hprimes p g Dq + (movingPatternRegularSlots (e s) n m small slot).get (fun i => active (movingPatternTemplateEquiv n r₀ m (e s) i)) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside + childBound pivotBound ψ X (Real.exp Δ) hi φ G Jleft Jright diagonal u v r w center x) x + Monotone V → f 0 = 0 → + (Sfreq.card : ℝ) ≤ Real.exp (Cfreq * m) → + (∀ s t, ‖term t s‖ ≤ + ((2 : ℝ) ^ Fintype.card (Quotient s) * + (Real.exp (Cprior * L)) ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) * + (Real.exp (-goodPatternGain n Cprior Cfreq gain * m) + err)) → + ‖movingWeightedMatchedCorrelation p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f g Dq Finset.univ ψ X (Real.exp Δ) hi φ G n small + (movingPatternBulkLeaves n m slot perm) + (fun s y x z => wgt y * movingTemplateExternalMultiplier primes hprimes n r₀ m active outside greg s + φ Jleft Jright diagonal y x z) u v r w center‖ ≤ + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + filter_upwards [arithmetic_good_pattern_rate n k hk Cprior Cfreq gain hCprior hCfreq] with L hrate + dsimp only at hrate ⊢ + intro r₀ primes hprimes p _ μ ν childBound pivotBound V f g Dq X Δ hi φ G + active perm greg outside Jleft Jright diagonal u v r w center cb tlog logSlots N e + let m := spectatorBulkCount k L + let small := movingTemplateSmall n r₀ m + let slot := movingTemplateBulk n r₀ m + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n (fun i => Quotient.mk'' i) + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb + ((logSlots j).map (fun i => (e s).symm (.inl i))) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable (e s) (trees t) small slot perm (fun i => Quotient.mk'' i) + primes hprimes p g Dq (movingPatternRegularSlots (e s) n m small slot).get (fun i => active (movingPatternTemplateEquiv n r₀ m (e s) i)) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside childBound pivotBound + ψ X (Real.exp Δ) hi φ G Jleft Jright diagonal u v r w center x) x + intro hV hf hcard hterm + have hsum := hrate Sfreq hcard (fun s t => (‖term t s‖ : ℂ)) (by + intro s t + rw [Complex.norm_real, Real.norm_of_nonneg (norm_nonneg _)] + simpa only [add_assoc] using hterm s t) + have hnonneg : 0 ≤ ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ‖term t s‖ := by positivity + simp only [← Complex.ofReal_sum, Complex.norm_real, Real.norm_of_nonneg hnonneg] at hsum + have hactual := movingTemplateLogFamilyMatchedCorrelation_pattern_bound primes hprimes outside n r₀ + (spectatorBulkCount k L) perm active p μ ν childBound pivotBound V f hf g Dq ψ X (Real.exp Δ) + hi φ G greg Jleft Jright diagonal u v r w center cb hV tlog logSlots N e + apply hactual.trans + rw [Finset.sum_comm] + exact hsum + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogMatchedBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogMatchedBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..ab8eed549d1fe7fed2696bd736f48e030acba4e1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogMatchedBound.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogMatchedPatterns +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedMatchedHistories + +namespace OAI + +/-! # The actual masked energy is bounded by its original signed pattern means -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateLogMatchedCorrelation_pattern_bound + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) + (n r m : ℕ) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (active : MovingRegularSlot n r m → Bool) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → P → ℝ) (ν : MovingRegularSlot n r m → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center cb : ℝ) (hV : Monotone V) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), + Fin (N s + 1) ≃ MovingRegularSlot n r m ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let small := movingTemplateSmall n r m + let slot := movingTemplateBulk n r m + let logSlots := movingBulkPairedCutoffSlots n (movingPatternBulkLeaves n m slot perm) + let wgt := fun (y : MovingRegularSlot n r m → P) => + ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) + let W := fun s => movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → P, + movingOriginalPatternWeight (e s) μ ν Subtype.val n (fun i => Quotient.mk'' i) + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb + ((logSlots j).map (fun i => (e s).symm (.inl i))) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable (e s) (trees t) small slot perm (fun i => Quotient.mk'' i) + P hP p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) + greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center x) x + ‖movingWeightedMatchedCorrelation p Subtype.val outside μ ν childBound pivotBound V f g Dq + Finset.univ ψ X lo hi φ G n small (movingPatternBulkLeaves n m slot perm) (fun s y x z => wgt y * W s y x z) u v a b center‖ ≤ + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ∑ s : Setoid (Bool × MovingSampleIndex n), ‖term t s‖ := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + apply (movingWeightedMatchedCorrelation_history_bound P outside n m p μ ν childBound pivotBound V + f hf g Dq ψ X lo hi φ G (movingTemplateSmall n r m) + (movingPatternBulkLeaves n m (movingTemplateBulk n r m) perm) + (fun s y x z => + ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb + (movingBulkPairedCutoffSlots n (movingPatternBulkLeaves n m (movingTemplateBulk n r m) perm) j) : ℝ) : ℂ) * + movingTemplateExternalMultiplier P hP n r m active outside greg s φ Jleft Jright diagonal y x z) u v a b center hV).trans + apply Finset.sum_le_sum + intro t _ + rw [movingTemplateLogWeightedMatchedMean_patterns P hP n r m perm _ active p μ ν g Dq greg _ + f outside childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center cb N e] + exact norm_sum_le _ _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogMatchedPatterns.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogMatchedPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..71a9c8aeab732147b9af282a0ea720b3c8485257 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogMatchedPatterns.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateExternalMultiplier +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMatchedExteriorWeight +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkPairedCutoffs + +namespace OAI + +/-! # The signed equality-pattern expansion of the actual masked diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateLogWeightedMatchedMean_patterns + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n r m : ℕ) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (t : Bool → FrequencyTree ℤ n) (active : MovingRegularSlot n r m → Bool) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → P → ℝ) (ν : MovingRegularSlot n r m → P → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center cb : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), + Fin (N s + 1) ≃ MovingRegularSlot n r m ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let small := movingTemplateSmall n r m + let slot := movingTemplateBulk n r m + let logSlots := movingBulkPairedCutoffSlots n + (movingPatternBulkLeaves n m slot perm) + let wgt := fun (y : MovingRegularSlot n r m → P) => + ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) + let W := movingTemplateExternalMultiplier P hP n r m active outside greg sreg φ + Jleft Jright diagonal + movingWeightedMatchedMean p Subtype.val outside μ ν childBound pivotBound f g Dq Finset.univ + ψ X lo hi φ G n t small (movingPatternBulkLeaves n m slot perm) (fun y x z => wgt y * W y x z) u v a b center = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → P, + movingOriginalPatternWeight (e s) μ ν Subtype.val n (fun i => Quotient.mk'' i) + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb + ((logSlots j).map (fun i => (e s).symm (.inl i))) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable (e s) t small slot perm (fun i => Quotient.mk'' i) + P hP p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) + greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center x) x := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + rw [movingWeightedMatchedMean_patterns p Subtype.val outside μ ν] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro x _ + unfold movingOriginalPatternWeight + congr 1 + unfold movingPatternInjectionGuard + split_ifs + · dsimp only + rw [movingWeightedMatchedKernel_mul] + have hw (x : Fin (N s + 1) → P) : + (∏ j, bulkLogCutoffWeight + (fun i => ((x ((e s).symm (.inl i)) : ℕ) : ℝ)) cb + (movingBulkPairedCutoffSlots n (movingPatternBulkLeaves n m (movingTemplateBulk n r m) perm) j)) = + ∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb + ((movingBulkPairedCutoffSlots n (movingPatternBulkLeaves n m (movingTemplateBulk n r m) perm) j).map + (fun i => (e s).symm (.inl i))) := by + simp only [bulkLogCutoffWeight_map, Function.comp_def] + rw [hw x] + congr 1 + apply movingWeightedMatchedKernel_fin (e s) t (movingTemplateSmall n r m) + (movingTemplateBulk n r m) perm (fun i => Quotient.mk'' i) P hP p g Dq + (movingPatternRegularSlots (e s) n m (movingTemplateSmall n r m) (movingTemplateBulk n r m)).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m (movingTemplateSmall n r m) (movingTemplateBulk n r m))) + greg sreg f outside childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center + intro z y + exact movingTemplateExternalMultiplier_pattern P hP n r m (e s) active outside greg sreg φ + Jleft Jright diagonal x z y + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogMatchedRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogMatchedRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..bd37f2594542bec317fc1afd54bab1c49891a6b6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogMatchedRate.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogMatchedBound +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticGoodPatternRate + +namespace OAI + +/-! # Full original matched correlation from the signed pattern budget -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateLogMatchedCorrelation_pattern_rate + (ψ : 𝓢(ℝ, ℂ)) (n k : ℕ) (hk : 0 < k) + (Cfreq Cprior gain : ℝ) (hCfreq : 0 ≤ Cfreq) (hCprior : 1 ≤ Cprior) : + ∀ᶠ L : ℝ in atTop, let m := spectatorBulkCount k L + ∀ (r₀ : ℕ) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → primes → ℝ) (ν : MovingRegularSlot n r₀ m → primes → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (X Δ hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (active : MovingRegularSlot n r₀ m → Bool) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (greg : ∀ q : ℕ, ZMod q → ℂ) (outside : List ℕ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v r w center cb : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ MovingRegularSlot n r₀ m ⊕ Quotient s), + let small := movingTemplateSmall n r₀ m + let slot := movingTemplateBulk n r₀ m + let logSlots := movingBulkPairedCutoffSlots n (movingPatternBulkLeaves n m slot perm) + let wgt := fun (y : MovingRegularSlot n r₀ m → primes) => + ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb (logSlots j) : ℝ) : ℂ) + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let err := Real.exp (-Real.exp ((125 / 100000 : ℝ) * L)) + + 4 * Real.exp (-Real.exp ((2 / 1000 : ℝ) * L)) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n + (fun i => Quotient.mk'' i) + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb + ((logSlots j).map (fun i => (e s).symm (.inl i))) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable (e s) (trees t) small slot perm + (fun i => Quotient.mk'' i) primes hprimes p g Dq + (movingPatternRegularSlots (e s) n m small slot).get (fun i => active (movingPatternTemplateEquiv n r₀ m (e s) i)) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside + childBound pivotBound ψ X (Real.exp Δ) hi φ G Jleft Jright diagonal u v r w center x) x + Monotone V → f 0 = 0 → + (Sfreq.card : ℝ) ≤ Real.exp (Cfreq * m) → + (∀ s t, ‖term t s‖ ≤ + ((2 : ℝ) ^ Fintype.card (Quotient s) * + (Real.exp (Cprior * L)) ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) * + (Real.exp (-goodPatternGain n Cprior Cfreq gain * m) + err)) → + ‖movingWeightedMatchedCorrelation p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound V f g Dq Finset.univ ψ X (Real.exp Δ) hi φ G n small + (movingPatternBulkLeaves n m slot perm) + (fun s y x z => wgt y * movingTemplateExternalMultiplier primes hprimes n r₀ m active outside greg s + φ Jleft Jright diagonal y x z) u v r w center‖ ≤ + Real.exp (-gain * m) + 5 * Real.exp (-Real.exp ((12 / 10000 : ℝ) * L)) := by + filter_upwards [arithmetic_good_pattern_rate n k hk Cprior Cfreq gain hCprior hCfreq] with L hrate + dsimp only at hrate ⊢ + intro r₀ primes hprimes p _ μ ν childBound pivotBound V f g Dq X Δ hi φ G + active perm greg outside Jleft Jright diagonal u v r w center cb N e + let m := spectatorBulkCount k L + let small := movingTemplateSmall n r₀ m + let slot := movingTemplateBulk n r₀ m + let logSlots := movingBulkPairedCutoffSlots n (movingPatternBulkLeaves n m slot perm) + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → primes, + movingOriginalPatternWeight (e s) μ ν (fun q : primes => (q : ℕ)) n (fun i => Quotient.mk'' i) + (fun x => ((∏ j, bulkLogCutoffWeight (fun i => ((x i : ℕ) : ℝ)) cb + ((logSlots j).map (fun i => (e s).symm (.inl i))) : ℝ) : ℂ) * + movingOriginalPatternMatchedObservable (e s) (trees t) small slot perm (fun i => Quotient.mk'' i) + primes hprimes p g Dq (movingPatternRegularSlots (e s) n m small slot).get (fun i => active (movingPatternTemplateEquiv n r₀ m (e s) i)) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) greg f outside childBound pivotBound + ψ X (Real.exp Δ) hi φ G Jleft Jright diagonal u v r w center x) x + intro hV hf hcard hterm + have hsum := hrate Sfreq hcard (fun s t => (‖term t s‖ : ℂ)) (by + intro s t + rw [Complex.norm_real, Real.norm_of_nonneg (norm_nonneg _)] + simpa only [add_assoc] using hterm s t) + have hnonneg : 0 ≤ ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ‖term t s‖ := by positivity + simp only [← Complex.ofReal_sum, Complex.norm_real, Real.norm_of_nonneg hnonneg] at hsum + have hactual := movingTemplateLogMatchedCorrelation_pattern_bound primes hprimes outside n r₀ + (spectatorBulkCount k L) perm active p μ ν childBound pivotBound V f hf g Dq ψ X (Real.exp Δ) + hi φ G greg Jleft Jright diagonal u v r w center cb hV N e + apply hactual.trans + rw [Finset.sum_comm] + exact hsum + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..b93874fefa6e682c755978df306a32a3f8c068f3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogNorm.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogProduct + +namespace OAI + +/-! # Removing a bulk cutoff only from one-branch coefficient energy -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTemplateCoefficient_bulk_log_norm_le {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → σ → ℝ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (y : MovingRegularSlot n r m → σ) (hn : n ≤ k) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (XL XR : ℕ) : + ‖movingTemplateCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n r m s y XL XR‖ ≤ + ‖movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n r m s y XL XR‖ := by + have hs : ∀ i ∈ flattenMovingSlots n + (treeLeafMap (List.map y) n (movingTemplateSmall n r m)), tier i ≠ k := by + intro i hi + rw [flattenMovingSlots_map] at hi + obtain ⟨a, ha, rfl⟩ := List.mem_map.mp hi + obtain ⟨j, rfl⟩ := (mem_flatten_bulkSlotLeaves n r _ a).mp ha + exact hsmall j + have hb : ∀ i ∈ flattenMovingSlots n + (treeLeafMap (List.map y) n (bulkSlotLeaves n m (movingTemplateBulk n r m))), tier i = k := by + intro i hi + rw [flattenMovingSlots_map] at hi + obtain ⟨a, ha, rfl⟩ := List.mem_map.mp hi + obtain ⟨j, rfl⟩ := (mem_flatten_bulkSlotLeaves n m _ a).mp ha + exact hbulk j + exact movingFrequencyCoefficient_bulk_log_norm_le value tier k outside cb cd μ hμ + childBound pivotBound V F φ G n s _ _ hn hs hb XL XR + +/-- The compensation factors are restored before applying the one-branch +norm inequality. This does not assert domination of a signed pair average. -/ +theorem movingTemplateCoefficient_restored_bulk_log_norm_le {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (k : ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → σ → ℝ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (u : TreeLeafIndex n × Fin 4 → σ) (hu : (∏ i, μ n (u i)) ≠ 0) + (y : MovingRegularSlot n r m → σ) (hn : n < k) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (XL XR : ℕ) : + ‖movingTemplateCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n (4 + r) m s (movingRestoreSample n r m u y) XL XR‖ ≤ + ‖movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m s (movingRestoreSample n r m u y) XL XR‖ := by + have hut i : tier (u i) = n := + hμ n (u i) ((Finset.prod_ne_zero_iff.mp hu) i (Finset.mem_univ i)) + apply movingTemplateCoefficient_bulk_log_norm_le value tier k outside cb cd μ hμ + childBound pivotBound V F φ G n (4 + r) m s _ hn.le _ _ XL XR + · rintro ⟨j, i⟩ + refine Fin.addCases (fun i => ?_) (fun i => ?_) i + · dsimp only + rw [movingRestoreSample_compensation n r m u y (j, i), hut] + exact hn.ne + · dsimp only + rw [movingRestoreSample_small] + exact hsmall (j, i) + · intro j + change tier (movingRestoreSample n r m u y (movingTemplateBulk n (4 + r) m j)) = k + rw [movingRestoreSample_bulk] + exact hbulk j + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..928e66f51023cc6a710d9e93cb6fec9c9246c1b8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogProduct.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingBulkLogProductLower +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateCoefficient + +namespace OAI + +/-! # The bulk cutoff bounds the full restored regular modulus -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original weighted coefficient forces the full bulk product above +its log-bin boundary before any compensation product is included. -/ +theorem movingTemplateCoefficient_bulk_log_product_lower {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (hvalue : ∀ a, 0 < value a) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (y : MovingRegularSlot n r m → σ) (hn : n ≤ k) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (XL XR : ℕ) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n r m s y XL XR ≠ 0) : + Real.exp ((2 ^ n : ℕ) * (cb - 1)) ≤ ((∏ j : TreeLeafIndex n × Fin m, value (y (j.1, .inr j.2)) : ℕ) : ℝ) := by + have hs : ∀ i ∈ flattenMovingSlots n + (treeLeafMap (List.map y) n (movingTemplateSmall n r m)), tier i ≠ k := by + intro i hi + rw [flattenMovingSlots_map] at hi + obtain ⟨a, ha, rfl⟩ := List.mem_map.mp hi + obtain ⟨j, rfl⟩ := (mem_flatten_bulkSlotLeaves n r _ a).mp ha + exact hsmall j + have hb : ∀ i ∈ flattenMovingSlots n + (bulkSlotLeaves n m (y ∘ movingTemplateBulk n r m)), tier i = k := by + intro i hi + obtain ⟨j, rfl⟩ := (mem_flatten_bulkSlotLeaves n m _ i).mp hi + exact hbulk j + unfold movingTemplateCoefficient at h + rw [bulkSlotLeaves_map] at h + have hlow := movingFrequencyCoefficient_log_product_lower value tier hvalue k outside cb cd μ hμ + childBound pivotBound V F φ G n m s _ (y ∘ movingTemplateBulk n r m) hn hs hb XL XR h + exact hlow + +/-- The original weighted coefficient forces the full bulk product above +its log-bin boundary. Small-slot primes only increase the regular modulus. -/ +theorem movingTemplateCoefficient_log_product_lower {σ : Type} [Fintype σ] + (value tier : σ → ℕ) (hvalue : ∀ a, 0 < value a) (k : ℕ) + (outside : List ℕ) (cb cd : ℝ) (μ : ℕ → σ → ℝ) + (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (y : MovingRegularSlot n r m → σ) (hn : n ≤ k) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (XL XR : ℕ) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V + (fun x s => (movingBulkLeafLogWeight value tier k outside cb cd x.data : ℂ) * F x s) + φ G n r m s y XL XR ≠ 0) : + Real.exp ((2 ^ n : ℕ) * (cb - 1)) ≤ ((∏ i, value (y i) : ℕ) : ℝ) := by + have hlow := movingTemplateCoefficient_bulk_log_product_lower value tier hvalue k outside cb cd + μ hμ childBound pivotBound V F φ G n r m s y hn hsmall hbulk XL XR h + have hsmallprod : 1 ≤ ∏ j : TreeLeafIndex n × Fin r, value (y (j.1, .inl j.2)) := + Finset.one_le_prod (fun j _ => hvalue _) + have he : (∏ i, value (y i)) = + (∏ j : TreeLeafIndex n × Fin r, value (y (j.1, .inl j.2))) * + (∏ j : TreeLeafIndex n × Fin m, value (y (j.1, .inr j.2))) := by + simp only [MovingRegularSlot, Fintype.prod_prod_type, Fintype.prod_sum_type, + Finset.prod_mul_distrib] + apply hlow.trans + rw [he] + exact_mod_cast le_mul_of_one_le_left (Nat.zero_le _) hsmallprod + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogSymmetrizedEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogSymmetrizedEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..c106c07e7496168e72503e3b5a418db7c509ff5b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateLogSymmetrizedEnergy.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogCorrelation +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLogDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateSymmetrizedNorm + +namespace OAI + +/-! # The actual retained-log symmetrized energy from diagonal and good-pair bounds -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplate_log_symmetrized_energy_bound + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n r m k : ℕ) (hm : 1 ≤ m) (hn : n ≤ k) + (tier : P → ℕ) (outside : List ℕ) (cb cd : ℝ) + (μ : ℕ → P → ℝ) (hμ : ∀ j a, μ j a ≠ 0 → tier a = j) + (ν : MovingRegularSlot n r m → P → ℝ) (hν : ∀ j a, 0 ≤ ν j a) + (hidentical : ∀ j l, ν (movingTemplateBulk n r m j) = ν (movingTemplateBulk n r m l)) + (hsmall : ∀ y : MovingRegularSlot n r m → P, (∏ j, ν j (y j)) ≠ 0 → + ∀ j : TreeLeafIndex n × Fin r, tier (y (j.1, .inl j.2)) ≠ k) + (hbulk : ∀ y : MovingRegularSlot n r m → P, (∏ j, ν j (y j)) ≠ 0 → + ∀ j : TreeLeafIndex n × Fin m, tier (y (j.1, .inr j.2)) = k) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) (G : ℕ → ℝ) + (active : MovingRegularSlot n r m → Bool) + (hactive : ∀ j, active (movingTemplateBulk n r m j) = true) + (greg : ∀ q : ℕ, ZMod q → ℂ) (Jleft Jright : ℝ) (diagonal : Bool) + (u v a b center D E : ℝ) (hD : 0 ≤ D) (hE : 0 ≤ E) + (hdiag : ‖mixedExternalAverage ν (V n) u v a b center (fun s y x z => + (‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p (fun _ => f) g Dq Finset.univ ψ X lo hi) + φ G n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) * + movingTemplateExternalMultiplier P hP n r m active outside greg s φ Jleft Jright diagonal y x z)‖ ≤ D) + (hgood : ∀ perm : Equiv.Perm (TreeLeafIndex n × Fin m), + 4 * Fintype.card (arrangementGraph m perm).ConnectedComponent ≤ 3 * Fintype.card (TreeLeafIndex n) → + let bulk := movingPatternBulkLeaves n m (movingTemplateBulk n r m) perm + let wgt := fun y => ((∏ j, bulkLogCutoffWeight (fun i => ((y i : ℕ) : ℝ)) cb + (movingBulkPairedCutoffSlots n bulk j) : ℝ) : ℂ) + ‖movingWeightedMatchedCorrelation p Subtype.val outside μ ν childBound pivotBound V f g Dq Finset.univ + ψ X lo hi φ G n (movingTemplateSmall n r m) bulk + (fun s y x z => wgt y * movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal y x z) u v a b center‖ ≤ E) : + ‖movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V + (movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + g Dq Finset.univ ψ X lo hi) φ G n r m ν active greg Jleft Jright diagonal u v a b center‖ ≤ + (((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) * + Real.exp ((2 ^ n : ℝ) * m * (-(3 / 4 : ℝ) * Real.log (2 ^ n : ℕ) + 5 / 4)) * D + E := by + let F : MovingSlotState P → ℤ → ℂ := movingOriginalLeaf Subtype.val p (fun _ => f) g Dq Finset.univ ψ X lo hi + let Fw : MovingSlotState P → ℤ → ℂ := movingOriginalLeaf Subtype.val p + (fun T s => (movingBulkLeafLogWeight Subtype.val tier k outside cb cd T : ℂ) * f s) + g Dq Finset.univ ψ X lo hi + have hleaf : Fw = fun x s => + (movingBulkLeafLogWeight Subtype.val tier k outside cb cd x.data : ℂ) * F x s := by + funext x s + exact movingOriginalLeaf_bulk_log Subtype.val tier k outside cb cd p (fun _ => f) + g Dq Finset.univ ψ X lo hi x s + rw [movingTemplateMaskedSymmetrizedEnergy_norm_eq_re P hP outside μ childBound pivotBound V + Fw φ hφ G n r m ν hν active greg Jleft Jright diagonal u v a b center] + apply movingTemplateMaskedSymmetrizedEnergy_bound P hP outside μ childBound pivotBound V Fw + φ hφ G n r m hm ν hν hidentical active hactive greg Jleft Jright diagonal u v a b center D E hD hE + · rw [hleaf] + exact (movingTemplate_log_diagonal_le P hP n r m k hn tier outside cb cd μ hμ ν hν hsmall hbulk + childBound pivotBound V F φ hφ G active greg Jleft Jright diagonal u v a b center).trans + ((Complex.re_le_norm _).trans hdiag) + · intro perm hperm + have he := movingTemplate_log_correlation_eq P hP n r m k hn tier outside cb cd μ hμ ν hsmall hbulk + p g Dq childBound pivotBound V f ψ X lo hi φ G active greg Jleft Jright diagonal u v a b center perm + rw [he, norm_mul] + have hfac : ‖((logCellProfile ((outside.map (fun p => Real.log (p : ℝ))).sum - cd) ^ + (2 ^ n + 2 ^ n) : ℝ) : ℂ)‖ ≤ 1 := by + rw [Complex.norm_real, Real.norm_of_nonneg (pow_nonneg (logCellProfile_nonneg _) _)] + exact pow_le_one₀ (logCellProfile_nonneg _) (logCellProfile_le_one _) + exact (mul_le_of_le_one_left (norm_nonneg _) hfac).trans (hgood perm hperm) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateMaskedSymmetrization.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateMaskedSymmetrization.lean new file mode 100644 index 0000000000000000000000000000000000000000..8447644c918a36b919feeed617ec45294165e958 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateMaskedSymmetrization.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNormalizedSymmetrizedEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMaskedBulkAction +import OAI.NumberTheory.Ostmann.Characters.MixedBulkSymmetrization + +namespace OAI + +/-! # Symmetrization with the actual compensation mask and original leaf coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTemplateExternalMultiplier_nonneg + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n r m : ℕ) + (active : MovingRegularSlot n r m → Bool) (outside : List ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (s : ℤ) (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) + (Jleft Jright : ℝ) (diagonal : Bool) (y : MovingRegularSlot n r m → P) (x z : ℝ) : + 0 ≤ (movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal y x z).re ∧ + ((movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal y x z).re : ℂ) = + movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal y x z := by + have hc (J t : ℝ) : 0 ≤ positiveLogCutoff φ J t := by + unfold positiveLogCutoff + split_ifs + · exact hφ _ + · exact le_rfl + let q := fun i => (y i : ℕ) + let _ : ∀ i, Fact (q i).Prime := fun i => ⟨hP _ (y i).property⟩ + let M := naturalRegularMultiplier q active s + (fun i => ((outside.prod * tupleCofactor q i : ℕ) : ZMod (q i))) + (fun i => greg (q i)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + have hM : 0 ≤ M := by + dsimp only [M, naturalRegularMultiplier] + apply Finset.prod_nonneg + intro i _ + split_ifs <;> positivity + let a := positiveLogCutoff φ Jleft (⌊Real.exp x⌋₊ : ℝ) + let b := positiveLogCutoff φ Jright (⌊Real.exp z⌋₊ : ℝ) + let d : ℝ := if diagonal then Real.exp Jright / (⌊Real.exp z⌋₊ : ℝ) else 1 + have hd : 0 ≤ d := by dsimp [d]; split_ifs <;> positivity + have heq : movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal y x z = ((a * b * d * M : ℝ) : ℂ) := by + unfold movingTemplateExternalMultiplier giantOuterWeight + dsimp only [a, b, d, M, q] + cases diagonal <;> simp only [Bool.false_eq_true, ite_false, ite_true] <;> push_cast <;> rfl + rw [heq] + simpa only [Complex.ofReal_re] using + And.intro (mul_nonneg (mul_nonneg (mul_nonneg (hc _ _) (hc _ _)) hd) hM) + (Eq.refl ((a * b * d * M : ℝ) : ℂ)) + +theorem movingTemplateMaskedSymmetrizedEnergy_bound + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) (G : ℕ → ℝ) (n r m : ℕ) (hm : 1 ≤ m) + (ν : MovingRegularSlot n r m → P → ℝ) (hν : ∀ j a, 0 ≤ ν j a) + (hidentical : ∀ j k, ν (movingTemplateBulk n r m j) = ν (movingTemplateBulk n r m k)) + (active : MovingRegularSlot n r m → Bool) + (hactive : ∀ j, active (movingTemplateBulk n r m j) = true) + (greg : ∀ q : ℕ, ZMod q → ℂ) (Jleft Jright : ℝ) (diagonal : Bool) + (u v a b center D E : ℝ) (hD : 0 ≤ D) (hE : 0 ≤ E) + (hdiag : (mixedExternalAverage ν (V n) u v a b center (fun s y x z => + (‖movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G n r m s y + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) * + movingTemplateExternalMultiplier P hP n r m active outside greg s φ Jleft Jright diagonal y x z)).re ≤ D) + (hgood : ∀ e : Equiv.Perm (TreeLeafIndex n × Fin m), + 4 * Fintype.card (arrangementGraph m e).ConnectedComponent ≤ 3 * Fintype.card (TreeLeafIndex n) → + ‖mixedExternalAverage ν (V n) u v a b center (fun s y x z => + (movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G n r m s y + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G n r m s + (selectedBulkSample (movingTemplateBulk n r m) e y) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + movingTemplateExternalMultiplier P hP n r m active outside greg s φ Jleft Jright diagonal y x z)‖ ≤ E) : + (movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G n r m + ν active greg Jleft Jright diagonal u v a b center).re ≤ + (((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) * + Real.exp ((2 ^ n : ℝ) * m * (-(3 / 4 : ℝ) * Real.log (2 ^ n : ℕ) + 5 / 4)) * D + E := by + let C := fun s y x z => movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + let W := fun s y x z => movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal y x z + have hwcast (s : ℤ) (y : MovingRegularSlot n r m → P) (x z : ℝ) : + ((W s y x z).re : ℂ) = W s y x z := + (movingTemplateExternalMultiplier_nonneg P hP n r m active outside greg s φ + hφ Jleft Jright diagonal y x z).2 + have hd : (mixedExternalAverage ν (V n) u v a b center + (fun s y x z => (‖C s y x z‖ ^ 2 : ℂ) * (W s y x z).re)).re ≤ D := by + simp_rw [hwcast] + exact hdiag + have hg (e : Equiv.Perm (TreeLeafIndex n × Fin m)) + (he : 4 * Fintype.card (arrangementGraph m e).ConnectedComponent ≤ 3 * Fintype.card (TreeLeafIndex n)) : + ‖mixedExternalAverage ν (V n) u v a b center (fun s y x z => + (C s y x z * star (C s (selectedBulkSample (movingTemplateBulk n r m) e y) x z)) * + (W s y x z).re)‖ ≤ E := by + simp_rw [hwcast] + exact hgood e he + have h := mixedBulkSymmetrize_energy_bound n m hm (movingTemplateBulk n r m) ν hν hidentical + (V n) u v a b center C (fun s y x z => (W s y x z).re) + (fun s y x z => (movingTemplateExternalMultiplier_nonneg P hP n r m active outside greg s φ + hφ Jleft Jright diagonal y x z).1) + (fun e s y x z => congrArg Complex.re (movingTemplateExternalMultiplier_bulk_action P hP + n r m active hactive outside greg s φ Jleft Jright diagonal e y x z)) D E hD hE hd hg + change (mixedExternalAverage ν (V n) u v a b center (fun s y x z => + (‖mixedBulkSymmetrize n m (movingTemplateBulk n r m) C s y x z‖ ^ 2 : ℂ) * W s y x z)).re ≤ _ + simpa only [hwcast] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateMatchedBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateMatchedBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..1cdc4ee8f7688baaa0c735a56b78a09f3197fd86 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateMatchedBound.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateMatchedPatterns +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedMatchedHistories + +namespace OAI + +/-! # The actual masked energy is bounded by its original signed pattern means -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateMatchedCorrelation_pattern_bound + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) + (n r m : ℕ) (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) (active : MovingRegularSlot n r m → Bool) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → P → ℝ) (ν : MovingRegularSlot n r m → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) (hV : Monotone V) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), + Fin (N s + 1) ≃ MovingRegularSlot n r m ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + let small := movingTemplateSmall n r m + let slot := movingTemplateBulk n r m + let W := fun s => movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal + let term := fun (t : FrequencyTree (Sfreq × Sfreq) n) (s : Setoid (Bool × MovingSampleIndex n)) => + ∑ x : Fin (N s + 1) → P, + movingOriginalPatternWeight (e s) μ ν Subtype.val n (fun i => Quotient.mk'' i) + (movingOriginalPatternMatchedObservable (e s) (trees t) small slot perm (fun i => Quotient.mk'' i) + P hP p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) + (frequencyRoot n (trees t false)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) + greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center) x + ‖movingWeightedMatchedCorrelation p Subtype.val outside μ ν childBound pivotBound V f g Dq + Finset.univ ψ X lo hi φ G n small (movingPatternBulkLeaves n m slot perm) W u v a b center‖ ≤ + ∑ t : FrequencyTree (Sfreq × Sfreq) n, ∑ s : Setoid (Bool × MovingSampleIndex n), ‖term t s‖ := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + apply (movingWeightedMatchedCorrelation_history_bound P outside n m p μ ν childBound pivotBound V + f hf g Dq ψ X lo hi φ G (movingTemplateSmall n r m) + (movingPatternBulkLeaves n m (movingTemplateBulk n r m) perm) + (fun s => movingTemplateExternalMultiplier P hP n r m active outside greg s φ + Jleft Jright diagonal) u v a b center hV).trans + apply Finset.sum_le_sum + intro t _ + rw [movingTemplateWeightedMatchedMean_patterns P hP n r m perm _ active p μ ν g Dq greg _ + f outside childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center N e] + exact norm_sum_le _ _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateMatchedPatterns.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateMatchedPatterns.lean new file mode 100644 index 0000000000000000000000000000000000000000..ccc5d3edb540dbf9bd7c60c43300ff3bdeefba85 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateMatchedPatterns.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateExternalMultiplier +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedMatchedRelabel + +namespace OAI + +/-! # The signed equality-pattern expansion of the actual masked diagonal -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingTemplateWeightedMatchedMean_patterns + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (n r m : ℕ) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (t : Bool → FrequencyTree ℤ n) (active : MovingRegularSlot n r m → Bool) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → P → ℝ) (ν : MovingRegularSlot n r m → P → ℝ) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), + Fin (N s + 1) ≃ MovingRegularSlot n r m ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + let small := movingTemplateSmall n r m + let slot := movingTemplateBulk n r m + let W := movingTemplateExternalMultiplier P hP n r m active outside greg sreg φ + Jleft Jright diagonal + movingWeightedMatchedMean p Subtype.val outside μ ν childBound pivotBound f g Dq Finset.univ + ψ X lo hi φ G n t small (movingPatternBulkLeaves n m slot perm) W u v a b center = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → P, + movingOriginalPatternWeight (e s) μ ν Subtype.val n (fun i => Quotient.mk'' i) + (movingOriginalPatternMatchedObservable (e s) t small slot perm (fun i => Quotient.mk'' i) + P hP p g Dq (movingPatternRegularSlots (e s) n m small slot).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) sreg + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m small slot)) + greg f outside childBound pivotBound ψ X lo hi φ G + Jleft Jright diagonal u v a b center) x := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + rw [movingWeightedMatchedMean_patterns p Subtype.val outside μ ν] + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro x _ + unfold movingOriginalPatternWeight + congr 1 + unfold movingPatternInjectionGuard + split_ifs + · apply movingWeightedMatchedKernel_fin (e s) t (movingTemplateSmall n r m) + (movingTemplateBulk n r m) perm (fun i => Quotient.mk'' i) P hP p g Dq + (movingPatternRegularSlots (e s) n m (movingTemplateSmall n r m) (movingTemplateBulk n r m)).get + (fun i => active (movingPatternTemplateEquiv n r m (e s) i)) + (fun x => movingRegularOther (fun i => (x i : ℕ)) outside + (movingPatternRegularSlots (e s) n m (movingTemplateSmall n r m) (movingTemplateBulk n r m))) + greg sreg f outside childBound pivotBound ψ X lo hi φ G Jleft Jright diagonal u v a b center + intro z y + exact movingTemplateExternalMultiplier_pattern P hP n r m (e s) active outside greg sreg φ + Jleft Jright diagonal x z y + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateNormalizer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateNormalizer.lean new file mode 100644 index 0000000000000000000000000000000000000000..dc106c75b5f33f3f97683fb2984428cd31b9ae84 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateNormalizer.lean @@ -0,0 +1,106 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularTemplate +import OAI.NumberTheory.Ostmann.Construction.BadMatchingHarmonicBudget + +namespace OAI + +/-! # Normalizing the actual regular template, including its small slots -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTemplate_normalizer_product_le (n r m : ℕ) + (mass : MovingRegularSlot n r m → ℝ) (L C : ℝ) (hL : 0 < L) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, Real.exp (-C * L) ≤ mass (j.1, .inl j.2)) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, L ≤ mass (j.1, .inr j.2)) : + (∏ i, (mass i)⁻¹) ≤ + Real.exp (C * L * (2 ^ n * r : ℕ)) * (L⁻¹) ^ (2 ^ n * m) := by + have hs (j : TreeLeafIndex n × Fin r) : (mass (j.1, .inl j.2))⁻¹ ≤ Real.exp (C * L) := by + have h := one_div_le_one_div_of_le (Real.exp_pos (-C * L)) (hsmall j) + simpa only [one_div, ← Real.exp_neg, neg_mul, neg_neg] using h + have hb (j : TreeLeafIndex n × Fin m) : (mass (j.1, .inr j.2))⁻¹ ≤ L⁻¹ := by + simpa only [one_div] using one_div_le_one_div_of_le hL (hbulk j) + have hsp : (∏ j : TreeLeafIndex n × Fin r, (mass (j.1, .inl j.2))⁻¹) ≤ + Real.exp (C * L) ^ (2 ^ n * r) := by + have h := Finset.prod_le_prod₀ + (fun j (_ : j ∈ (Finset.univ : Finset (TreeLeafIndex n × Fin r))) => + inv_nonneg.mpr ((Real.exp_pos _).le.trans (hsmall j))) (fun j _ => hs j) + simpa only [Finset.prod_const, Finset.card_univ, Fintype.card_prod, + card_treeLeafIndex, Fintype.card_fin] using h + have hbp : (∏ j : TreeLeafIndex n × Fin m, (mass (j.1, .inr j.2))⁻¹) ≤ + (L⁻¹) ^ (2 ^ n * m) := by + have h := Finset.prod_le_prod₀ + (fun j (_ : j ∈ (Finset.univ : Finset (TreeLeafIndex n × Fin m))) => + inv_nonneg.mpr (hL.le.trans (hbulk j))) (fun j _ => hb j) + simpa only [Finset.prod_const, Finset.card_univ, Fintype.card_prod, + card_treeLeafIndex, Fintype.card_fin] using h + have he : (∏ i, (mass i)⁻¹) = + (∏ j : TreeLeafIndex n × Fin r, (mass (j.1, .inl j.2))⁻¹) * + (∏ j : TreeLeafIndex n × Fin m, (mass (j.1, .inr j.2))⁻¹) := by + simp only [MovingRegularSlot, Fintype.prod_prod_type, Fintype.prod_sum_type, + Finset.prod_mul_distrib] + rw [he] + calc + _ ≤ Real.exp (C * L) ^ (2 ^ n * r) * (L⁻¹) ^ (2 ^ n * m) := + mul_le_mul hsp hbp + (Finset.prod_nonneg (fun j _ => inv_nonneg.mpr (hL.le.trans (hbulk j)))) + (pow_nonneg (Real.exp_nonneg _) _) + _ = _ := by rw [← Real.exp_nat_mul]; congr 2; ring + +theorem movingTemplate_factorial_normalizer_le (n r m : ℕ) + (mass : MovingRegularSlot n r m → ℝ) (L C z : ℝ) (hL : 0 < L) (hz : 0 < z) + (hsize : ((2 ^ n * (r + m) : ℕ) : ℝ) ≤ z * L) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, Real.exp (-C * L) ≤ mass (j.1, .inl j.2)) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, L ≤ mass (j.1, .inr j.2)) : + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * (∏ i, (mass i)⁻¹) ≤ + Real.exp (Real.log z * (2 ^ n * (r + m) : ℕ) + + (C * L + Real.log L) * (2 ^ n * r : ℕ)) := by + have hn := movingTemplate_normalizer_product_le n r m mass L C hL hsmall hbulk + have hf := factorial_harmonic_entropy 1 (2 ^ n * (r + m)) L z hL hz hsize + simp only [pow_one, one_mul] at hf + have hsum : 2 ^ n * (r + m) = 2 ^ n * r + 2 ^ n * m := Nat.mul_add _ _ _ + have hcancel : (L⁻¹) ^ (2 ^ n * r) * L ^ (2 ^ n * r) = 1 := by + rw [← mul_pow, inv_mul_cancel₀ hL.ne', one_pow] + rw [movingRegularSlot_card] + calc + _ ≤ ((2 ^ n * (r + m)).factorial : ℝ) * + (Real.exp (C * L * (2 ^ n * r : ℕ)) * (L⁻¹) ^ (2 ^ n * m)) := + mul_le_mul_of_nonneg_left hn (Nat.cast_nonneg _) + _ = (((2 ^ n * (r + m)).factorial : ℝ) * (L⁻¹) ^ (2 ^ n * (r + m))) * + (L ^ (2 ^ n * r) * Real.exp (C * L * (2 ^ n * r : ℕ))) := by + rw [hsum, pow_add] + symm + calc + _ = (((2 ^ n * r + 2 ^ n * m).factorial : ℝ) * + (L⁻¹) ^ (2 ^ n * m) * Real.exp (C * L * (2 ^ n * r : ℕ))) * + ((L⁻¹) ^ (2 ^ n * r) * L ^ (2 ^ n * r)) := by ring + _ = _ := by rw [hcancel]; ring + _ ≤ Real.exp (Real.log z * (2 ^ n * (r + m) : ℕ)) * + (L ^ (2 ^ n * r) * Real.exp (C * L * (2 ^ n * r : ℕ))) := + mul_le_mul_of_nonneg_right hf (mul_nonneg (pow_nonneg hL.le _) (Real.exp_nonneg _)) + _ = _ := by + rw [← Real.exp_log hL, ← Real.exp_nat_mul, ← Real.exp_add, ← Real.exp_add] + congr 1 + simp only [Real.log_exp] + ring + +theorem movingTemplate_counterpart_exponential_bound (n r m : ℕ) + (mass : MovingRegularSlot n r m → ℝ) (L C z cg Gmin cb : ℝ) + (hL : 0 < L) (hz : 0 < z) + (hsize : ((2 ^ n * (r + m) : ℕ) : ℝ) ≤ z * L) + (hsmall : ∀ j : TreeLeafIndex n × Fin r, Real.exp (-C * L) ≤ mass (j.1, .inl j.2)) + (hbulk : ∀ j : TreeLeafIndex n × Fin m, L ≤ mass (j.1, .inr j.2)) : + Real.exp (cg - Gmin - (2 ^ n : ℕ) * (cb - 1)) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * (∏ i, (mass i)⁻¹) ≤ + Real.exp (cg - Gmin - (2 ^ n : ℕ) * (cb - 1) + + Real.log z * (2 ^ n * (r + m) : ℕ) + (C * L + Real.log L) * (2 ^ n * r : ℕ)) := by + have h := mul_le_mul_of_nonneg_left + (movingTemplate_factorial_normalizer_le n r m mass L C z hL hz hsize hsmall hbulk) + (Real.exp_nonneg (cg - Gmin - (2 ^ n : ℕ) * (cb - 1))) + rw [← mul_assoc, ← Real.exp_add] at h + convert h using 1 + congr 1 + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePair.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePair.lean new file mode 100644 index 0000000000000000000000000000000000000000..38be4d574f690da7de6945af5d4c9cab6821bb08 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePair.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateProducts + +namespace OAI + +/-! # The two independent surviving regular templates -/ + +namespace Ostmann +open scoped Classical BigOperators + +def movingTemplatePairEquiv (n r m : ℕ) : + MovingRegularSlot n r m ⊕ MovingRegularSlot n r m ≃ MovingRegularSlot (n + 1) r m := + (Equiv.sumProdDistrib (TreeLeafIndex n) (TreeLeafIndex n) (Fin r ⊕ Fin m)).symm + +noncomputable def movingTemplatePairSample {A : Type*} (n r m : ℕ) + (left right : MovingRegularSlot n r m → A) : MovingRegularSlot (n + 1) r m → A := + Sum.elim left right ∘ (movingTemplatePairEquiv n r m).symm + +@[simp] theorem movingTemplatePairSample_left {A : Type*} (n r m : ℕ) + (left right : MovingRegularSlot n r m → A) (j : MovingRegularSlot n r m) : + movingTemplatePairSample n r m left right (.inl j.1, j.2) = left j := rfl + +@[simp] theorem movingTemplatePairSample_right {A : Type*} (n r m : ℕ) + (left right : MovingRegularSlot n r m → A) (j : MovingRegularSlot n r m) : + movingTemplatePairSample n r m left right (.inr j.1, j.2) = right j := rfl + +theorem movingTemplatePairSample_small {A : Type*} (n r m : ℕ) + (left right : MovingRegularSlot n r m → A) : + treeLeafMap (List.map (movingTemplatePairSample n r m left right)) (n + 1) + (movingTemplateSmall (n + 1) r m) = + (treeLeafMap (List.map left) n (movingTemplateSmall n r m), + treeLeafMap (List.map right) n (movingTemplateSmall n r m)) := by + apply (treeLeafTupleEquiv (List A) (n + 1)).injective + funext j + rw [treeLeafTupleEquiv_map] + cases j with + | inl j => + change _ = treeLeafTupleEquiv (List A) n + (treeLeafMap (List.map left) n (movingTemplateSmall n r m)) j + rw [treeLeafTupleEquiv_map] + simp only [movingTemplateSmall, bulkSlotLeaves, Equiv.apply_symm_apply, List.map_ofFn] + rfl + | inr j => + change _ = treeLeafTupleEquiv (List A) n + (treeLeafMap (List.map right) n (movingTemplateSmall n r m)) j + rw [treeLeafTupleEquiv_map] + simp only [movingTemplateSmall, bulkSlotLeaves, Equiv.apply_symm_apply, List.map_ofFn] + rfl + +theorem movingTemplatePairSample_bulk {A : Type*} (n r m : ℕ) + (left right : MovingRegularSlot n r m → A) : + treeLeafMap (List.map (movingTemplatePairSample n r m left right)) (n + 1) + (bulkSlotLeaves (n + 1) m (movingTemplateBulk (n + 1) r m)) = + (treeLeafMap (List.map left) n (bulkSlotLeaves n m (movingTemplateBulk n r m)), + treeLeafMap (List.map right) n (bulkSlotLeaves n m (movingTemplateBulk n r m))) := by + apply (treeLeafTupleEquiv (List A) (n + 1)).injective + funext j + rw [treeLeafTupleEquiv_map] + cases j with + | inl j => + change _ = treeLeafTupleEquiv (List A) n + (treeLeafMap (List.map left) n (bulkSlotLeaves n m (movingTemplateBulk n r m))) j + rw [treeLeafTupleEquiv_map] + simp only [bulkSlotLeaves, Equiv.apply_symm_apply, List.map_ofFn] + rfl + | inr j => + change _ = treeLeafTupleEquiv (List A) n + (treeLeafMap (List.map right) n (bulkSlotLeaves n m (movingTemplateBulk n r m))) j + rw [treeLeafTupleEquiv_map] + simp only [bulkSlotLeaves, Equiv.apply_symm_apply, List.map_ofFn] + rfl + +private theorem finite_prior_sum_type {J K A : Type*} + [Fintype J] [Fintype K] [Fintype A] (ν : J ⊕ K → A → ℝ) + (F : (J ⊕ K → A) → ℂ) : + (∑ x, ((∏ i, ν i (x i) : ℝ) : ℂ) * F x) = + ∑ l : J → A, ((∏ i, ν (.inl i) (l i) : ℝ) : ℂ) * + ∑ r : K → A, ((∏ i, ν (.inr i) (r i) : ℝ) : ℂ) * F (Sum.elim l r) := by + let e := Equiv.sumArrowEquivProdArrow J K A + rw [← e.symm.sum_comp (fun x => ((∏ i, ν i (x i) : ℝ) : ℂ) * F x), + Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro l _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro r _ + rw [Fintype.prod_sum_type] + simp only [e, Equiv.sumArrowEquivProdArrow_symm_apply_inl, + Equiv.sumArrowEquivProdArrow_symm_apply_inr, Complex.ofReal_mul] + exact mul_assoc _ _ _ + +/-- Pairing surviving templates preserves the independent law. The shared +compensation law stays outside this identity. -/ +theorem movingTemplatePair_average {A : Type*} [Fintype A] (n r m : ℕ) + (ν : MovingRegularSlot (n + 1) r m → A → ℝ) + (F : (MovingRegularSlot (n + 1) r m → A) → ℂ) : + (∑ x, ((∏ i, ν i (x i) : ℝ) : ℂ) * F x) = + ∑ left : MovingRegularSlot n r m → A, + ((∏ i, ν (.inl i.1, i.2) (left i) : ℝ) : ℂ) * + ∑ right : MovingRegularSlot n r m → A, + ((∏ i, ν (.inr i.1, i.2) (right i) : ℝ) : ℂ) * + F (movingTemplatePairSample n r m left right) := by + have hr := finite_prior_reindex (movingTemplatePairEquiv n r m) ν F + simp only [finite_univ_canonical] at hr ⊢ + rw [← hr] + have hs := finite_prior_sum_type (fun i => ν (movingTemplatePairEquiv n r m i)) + (fun x => F (x ∘ (movingTemplatePairEquiv n r m).symm)) + simp only [finite_univ_canonical] at hs + exact hs + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePatternMultiplier.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePatternMultiplier.lean new file mode 100644 index 0000000000000000000000000000000000000000..3a01c795f4d75c81cacd856240aa9c5382e77979 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePatternMultiplier.lean @@ -0,0 +1,46 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternTemplateEnumeration +import OAI.NumberTheory.Ostmann.Arithmetic.MovingMaskedMultiplierReindex + +namespace OAI + +/-! # The exact masked multiplier in the finite arithmetic pattern -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTemplate_pattern_multiplier {C : Type*} {N : ℕ} (n r m : ℕ) + (e : Fin (N + 1) ≃ MovingRegularSlot n r m ⊕ C) + (value : Fin (N + 1) → ℕ) (hprime : ∀ i, (value i).Prime) + (active : MovingRegularSlot n r m → Bool) (outside : List ℕ) + (g : ∀ q : ℕ, ZMod q → ℂ) (XL XR : ℕ) (s : ℤ) : + let L := movingPatternRegularSlots e n m (movingTemplateSmall n r m) (movingTemplateBulk n r m) + let p := fun i : Fin L.length => value (L.get i) + let q := fun i => value (e.symm (.inl i)) + let _ : ∀ i, Fact (p i).Prime := fun _ => ⟨hprime _⟩ + let _ : ∀ i, Fact (q i).Prime := fun _ => ⟨hprime _⟩ + naturalRegularMultiplier p (fun i => active (movingPatternTemplateEquiv n r m e i)) s + (fun i => (movingRegularOther value outside L i : ZMod (p i))) + (fun i => g (p i)) XL XR = + naturalRegularMultiplier q active s + (fun i => ((outside.prod * tupleCofactor q i : ℕ) : ZMod (q i))) + (fun i => g (q i)) XL XR := by + intro L p q ip iq + simp only [movingRegularOther_eq_cofactor, Int.cast_natCast] + let E := movingPatternTemplateEquiv n r m e + have hp : p = fun i => q (E i) := by + funext i + exact congrArg value (movingPatternTemplateEquiv_label n r m e i) + let M (v : Fin L.length → ℕ) : ℝ := + ∏ i, if active (E i) then + ‖g (v i) ((s : ZMod (v i)) * + (((outside.prod * tupleCofactor v i : ℕ) : ZMod (v i)) * + (XL : ZMod (v i)) * (XR : ZMod (v i)))⁻¹)‖ ^ 2 else 1 + simp only [naturalRegularMultiplier, div_eq_mul_inv] + change M p = _ + rw [hp] + have h := naturalRegularMultiplier_equiv E q (fun i => hprime _) active g outside.prod XL XR s + simpa only [naturalRegularMultiplier, div_eq_mul_inv, M] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrimeCore.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrimeCore.lean new file mode 100644 index 0000000000000000000000000000000000000000..ad922e02140ca341faa0ea2f9129c0699169a959 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrimeCore.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNormalizedStatistic + +namespace OAI + +/-! # The full-template Fourier amplitude is the original prime statistic -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +local instance coreSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +/-- The template amplitude used in the transfer and the core bounded by the +arithmetic estimate are identical at the actual prime giants. Every cofactor, +spectator transform, and leaf weight is evaluated at the original value. -/ +theorem movingTemplatePrimeCore_eq_full {σ I : Type} [Fintype σ] + (pSpec : I → ℕ) [∀ i, Fact (pSpec i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (pSpec i) → ℂ) (Dq : ∀ i, (ZMod (pSpec i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n r m : ℕ) (s : ℤ) (y : MovingRegularSlot n r m → σ) + (q : Bool → ℕ) [∀ b, Fact (q b).Prime] + (hprime : ∀ i, (value (y i)).Prime) + (greg ggiant : ∀ p : ℕ, ZMod p → ℂ) (favorable : ℕ → Bool) : + let _ : ∀ i, Fact ((value ∘ y) i).Prime := fun i => ⟨hprime i⟩ + movingPrimeCore pSpec value outside μ childBound pivotBound V f g Dq S ψ X lo hi φ G + n m (movingTemplateSmall n r m) (movingTemplateBulk n r m) greg ggiant favorable + s y (Real.log (q true)) (Real.log (q false)) = + movingRegularTransform (Sum.elim q (value ∘ y)) + (fun i => match i with + | .inl b => fun t => if favorable (q b) then complexUnitPhase (ggiant (q b) t) else 0 + | .inr j => greg (value (y j))) outside.prod s * + movingTemplateCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value pSpec (fun _ => f) g Dq S ψ X lo hi) φ G n r m s y + (q true) (q false) := by + let : ∀ i, Fact ((value ∘ y) i).Prime := fun i => ⟨hprime i⟩ + dsimp only + have hfull := movingTemplateCoefficient_full_transform value outside μ childBound pivotBound V + (movingOriginalLeaf value pSpec (fun _ => f) g Dq S ψ X lo hi) φ G n r m s y q hprime + greg ggiant favorable + have hphase := movingGiantPhase_regularFactor_eq value outside + (movingTemplateSmall n r m) (bulkSlotLeaves n m (movingTemplateBulk n r m)) y q + (value ∘ y) (movingTemplate_product value n r m y) greg ggiant favorable s + have hq (b : Bool) : 0 < (q b : ℝ) := Nat.cast_pos.mpr (Fact.out : (q b).Prime).pos + unfold movingPrimeCore + rw [hphase, Real.exp_log (hq true), Real.exp_log (hq false), Nat.floor_natCast, Nat.floor_natCast] + exact hfull.symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrimeStatistic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrimeStatistic.lean new file mode 100644 index 0000000000000000000000000000000000000000..cbdf9b25d6ba3c86a744cef9992b97c95404c4c7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrimeStatistic.lean @@ -0,0 +1,122 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPrimeStatisticBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingNormalizedSymmetrizedEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateEnumeration + +namespace OAI + +/-! # The prime statistic for the actual data-dependent template leaf -/ +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingTemplatePrimeStatistic + (P : Finset ℕ) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (ν : MovingRegularSlot n r m → P → ℝ) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (H : ℝ) (u v a b : ℝ) : ℂ := + primeExternalAverage ν (V n) u v a b (fun s y x z => + ((movingGiantPhase Subtype.val outside (movingTemplateSmall n r m) + (bulkSlotLeaves n m (movingTemplateBulk n r m)) ggiant favorable s y x z * + movingExternalRegularFactor Subtype.val outside (movingTemplateSmall n r m) + (bulkSlotLeaves n m (movingTemplateBulk n r m)) greg s y x z) * + movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊) * + giantOuterWeight φ H H false ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊) + +/-- The exterior factor agrees with the literal template multiplier wherever +its bulk-symmetrized coefficient is nonzero. -/ +theorem movingTemplatePrimeStatistic_energy_integrand + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (H : ℝ) (s : ℤ) + (y : MovingRegularSlot n r m → P) (x z : ℝ) : + (‖movingBulkAveragedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) * + ((giantOuterWeight φ H H false ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊) * + (‖movingExternalRegularFactor Subtype.val outside (movingTemplateSmall n r m) + (bulkSlotLeaves n m (movingTemplateBulk n r m)) greg s y x z‖ ^ 2 : ℝ)) = + (‖movingBulkAveragedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) * + movingTemplateExternalMultiplier P hP n r m (fun _ => true) outside greg s φ H H false y x z := by + by_cases hc : movingBulkAveragedTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ = 0 + · simp only [hc, norm_zero, zero_pow (by norm_num : 2 ≠ 0), Complex.ofReal_zero, zero_mul] + have hi := movingBulkAveragedTemplateCoefficient_nonzero_injective Subtype.val + (fun q : P => hP _ q.property) outside μ childBound pivotBound V F φ G n r m s y + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ hc + let q := fun i => (y i : ℕ) + let _ : ∀ i, Fact (q i).Prime := fun i => ⟨hP _ (y i).property⟩ + have hprod := movingTemplate_product Subtype.val n r m y + unfold movingTemplateExternalMultiplier + dsimp only + rw [naturalRegularMultiplier_eq_transform_norm] + simp only [ite_true] + change _ = _ * (giantOuterWeight _ _ _ _ _ _ * + (‖movingRegularTransform q (fun i => greg (q i)) + (outside.prod * ⌊Real.exp x⌋₊ * ⌊Real.exp z⌋₊) s‖ ^ 2 : ℝ)) + rw [movingRegularTransform_eq_primeProduct q hi] + unfold movingExternalRegularFactor + rw [hprod] + +theorem movingTemplatePrimeStatistic_cauchy + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) (G : ℕ → ℝ) (n r m : ℕ) + (ν : MovingRegularSlot n r m → P → ℝ) + (hν : ∀ i q, 0 ≤ ν i q) + (hidentical : ∀ j k, ν (movingTemplateBulk n r m j) = ν (movingTemplateBulk n r m k)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (H u v a b center : ℝ) : + ‖movingTemplatePrimeStatistic P outside μ childBound pivotBound V F φ G n r m ν + greg ggiant favorable H u v a b‖ ^ 2 ≤ + Real.exp (center - u) ^ 2 * + (mixedExternalAverage ν (V n) u v a b center (fun _ _ x z => + giantOuterWeight φ H H false ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)).re * + (movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G + n r m ν (fun _ => true) greg H H false u v a b center).re := by + let C := fun s y x z => movingTemplateCoefficient Subtype.val outside μ childBound pivotBound V F φ G + n r m s y ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + let R := movingExternalRegularFactor (Subtype.val : P → ℕ) outside (movingTemplateSmall n r m) + (bulkSlotLeaves n m (movingTemplateBulk n r m)) greg + let Q := movingGiantPhase (Subtype.val : P → ℕ) outside (movingTemplateSmall n r m) + (bulkSlotLeaves n m (movingTemplateBulk n r m)) ggiant favorable + let W := fun x z => giantOuterWeight φ H H false ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + have hsmall : ∀ i ∈ flattenMovingSlots n (movingTemplateSmall n r m), + i ∉ Set.range (movingTemplateBulk n r m) := movingTemplateSmall_not_bulk n r m + have hR (e s y x z) : R s (selectedBulkSample (movingTemplateBulk n r m) e y) x z = R s y x z := by + dsimp only [R, movingExternalRegularFactor] + rw [MovingSlotReversal.naturalProduct_selected_bulk Subtype.val n m + (movingTemplateSmall n r m) (movingTemplateBulk n r m) e y hsmall] + have hQ (e s y x z) : Q s (selectedBulkSample (movingTemplateBulk n r m) e y) x z = Q s y x z := + movingGiantPhase_selectedBulkSample Subtype.val outside n m (movingTemplateSmall n r m) + (movingTemplateBulk n r m) e y hsmall ggiant favorable s x z + have hQnorm (s y x z) : ‖Q s y x z‖ ≤ 1 := + movingGiantPhase_norm_le Subtype.val outside (movingTemplateSmall n r m) + (bulkSlotLeaves n m (movingTemplateBulk n r m)) ggiant favorable s y x z + have hW (x z : ℝ) : 0 ≤ (W x z).re ∧ ((W x z).re : ℂ) = W x z := by + obtain ⟨c, hc, he⟩ := giantOuterWeight_positive φ hφ H H false ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + change W x z = (c : ℂ) at he + rw [he] + exact ⟨hc, rfl⟩ + have hc := primeExternalAverage_bounded_statistic_cauchy n m (movingTemplateBulk n r m) + ν hν hidentical (V n) u v a b center C R Q hR hQ hQnorm + (fun x z => (W x z).re) (fun x z => (hW x z).1) + simp only [(hW _ _).2] at hc + have he : (mixedExternalAverage ν (V n) u v a b center (fun s y x z => + (‖mixedBulkSymmetrize n m (movingTemplateBulk n r m) C s y x z‖ ^ 2 : ℂ) * + (W x z * (‖R s y x z‖ ^ 2 : ℝ)))) = + movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G + n r m ν (fun _ => true) greg H H false u v a b center := by + unfold movingTemplateMaskedSymmetrizedEnergy + congr 1 + funext s y x z + exact movingTemplatePrimeStatistic_energy_integrand P hP outside μ childBound pivotBound V F + φ G n r m greg H s y x z + rw [he] at hc + exact hc + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrimeStatisticBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrimeStatisticBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..414be1af040e42a973f058fe35f90be010781602 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrimeStatisticBound.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplatePrimeStatistic + +namespace OAI + +/-! # The final full-cell statistic is controlled by its literal masked energy -/ +namespace Ostmann +open scoped Classical BigOperators + +theorem movingTemplatePrimeStatistic_full_cell_bound + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) + (Bφ Dφ : ℝ) (hBφ : 0 ≤ Bφ) (hDφ : 0 ≤ Dφ) + (hφnorm : ∀ x, |φ x| ≤ Bφ) (hlip : ∀ x y, |φ x - φ y| ≤ Dφ * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (G : ℕ → ℝ) (n r m : ℕ) + (ν : MovingRegularSlot n r m → P → ℝ) + (hν : ∀ i q, 0 ≤ ν i q) (hmass : ∀ i, ∑ q, ν i q = 1) + (hidentical : ∀ j k, ν (movingTemplateBulk n r m j) = ν (movingTemplateBulk n r m k)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (H : ℝ) : + ‖movingTemplatePrimeStatistic P outside μ childBound pivotBound V F φ G n r m ν + greg ggiant favorable H (H - 1) (H + 1) (H - 1) (H + 1)‖ ^ 2 ≤ + diagonalOuterMajorant Bφ Dφ false * (2 * V n + 1 : ℕ) * Real.exp 5 * + ‖movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G + n r m ν (fun _ => true) greg H H false (H - 1) (H + 1) (H - 1) (H + 1) H‖ := by + let W := fun (_ : ℤ) (_ : MovingRegularSlot n r m → P) (x z : ℝ) => + giantOuterWeight φ H H false ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + have hC := (diagonalOuterMajorant_pos Bφ Dφ false).le + have hW (s y x z) : 0 ≤ (W s y x z).re := by + obtain ⟨a, ha, he⟩ := giantOuterWeight_positive φ hφ H H false ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ + change W s y x z = (a : ℂ) at he + rw [he] + exact ha + have hWu (s y x z) : (W s y x z).re ≤ diagonalOuterMajorant Bφ Dφ false := by + apply (Complex.re_le_norm _).trans + exact (giantOuterWeight_norm φ H H Bφ Dφ hBφ hDφ hφnorm hlip hout false _ _).trans + (by unfold diagonalOuterMajorant; linarith) + have hm0 := mixedExternalAverage_re_nonneg ν hν (V n) + (H - 1) (H + 1) (H - 1) (H + 1) H W hW + have hmb := mixedExternalAverage_mass_bound ν hν hmass (V n) + (H - 1) (H + 1) (H - 1) (H + 1) H (diagonalOuterMajorant Bφ Dφ false) hC W hWu + have hmupper : (mixedExternalAverage ν (V n) + (H - 1) (H + 1) (H - 1) (H + 1) H W).re ≤ + diagonalOuterMajorant Bφ Dφ false * (2 * V n + 1 : ℕ) * Real.exp 3 := by + simpa only [show H + 1 - (H - 1) + (H + 1 - H) = 3 by ring] using hmb + have hc := movingTemplatePrimeStatistic_cauchy P hP outside μ childBound pivotBound V F + φ hφ G n r m ν hν hidentical greg ggiant favorable H + (H - 1) (H + 1) (H - 1) (H + 1) H + have he := Complex.re_le_norm (movingTemplateMaskedSymmetrizedEnergy P hP outside μ + childBound pivotBound V F φ G n r m ν (fun _ => true) greg H H false + (H - 1) (H + 1) (H - 1) (H + 1) H) + have hstep := mul_le_mul_of_nonneg_left he (mul_nonneg (sq_nonneg (Real.exp (H - (H - 1)))) hm0) + have hnext := mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_left hmupper (sq_nonneg (Real.exp (H - (H - 1))))) + (norm_nonneg (movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F + φ G n r m ν (fun _ => true) greg H H false (H - 1) (H + 1) (H - 1) (H + 1) H)) + apply hc.trans ((hstep.trans hnext).trans_eq ?_) + rw [show H - (H - 1) = 1 by ring] + have hExp : Real.exp 1 ^ 2 * Real.exp 3 = Real.exp 5 := by + rw [pow_two, ← Real.exp_add, ← Real.exp_add] + norm_num + calc + _ = (diagonalOuterMajorant Bφ Dφ false * (2 * V n + 1 : ℕ)) * + (Real.exp 1 ^ 2 * Real.exp 3) * + ‖movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G + n r m ν (fun _ => true) greg H H false (H - 1) (H + 1) (H - 1) (H + 1) H‖ := by ring + _ = _ := by rw [hExp] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrior.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrior.lean new file mode 100644 index 0000000000000000000000000000000000000000..3c67313b84f5c5873c3d1b0f1f3eea9a80cf0e8e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplatePrior.lean @@ -0,0 +1,125 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRegularTemplate +import OAI.NumberTheory.Ostmann.Construction.SelectedPrimeFubini +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleCoordinates + +namespace OAI + +/-! # The unchanged independent prime law under one template restoration -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingRestoreSample {A : Type*} (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) : + MovingRegularSlot n (4 + r) m → A := + Sum.elim u y ∘ (movingReverseTemplate n r m).symm + +@[simp] theorem movingRestoreSample_compensation {A : Type*} (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) + (i : TreeLeafIndex n × Fin 4) : + movingRestoreSample n r m u y (i.1, .inl (Fin.castAdd r i.2)) = u i := by + change Sum.elim u y ((movingReverseTemplate n r m).symm + (movingReverseTemplate n r m (.inl i))) = _ + rw [Equiv.symm_apply_apply] + rfl + +@[simp] theorem movingRestoreSample_small {A : Type*} (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) + (j : TreeLeafIndex n) (i : Fin r) : + movingRestoreSample n r m u y (j, .inl (Fin.natAdd 4 i)) = y (j, .inl i) := by + change Sum.elim u y ((movingReverseTemplate n r m).symm + (movingReverseTemplate n r m (.inr (j, .inl i)))) = _ + rw [Equiv.symm_apply_apply] + rfl + +@[simp] theorem movingRestoreSample_bulk {A : Type*} (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) + (i : TreeLeafIndex n × Fin m) : + movingRestoreSample n r m u y (movingTemplateBulk n (4 + r) m i) = + y (movingTemplateBulk n r m i) := by + rw [← movingReverseTemplate_bulk n r m i] + change Sum.elim u y ((movingReverseTemplate n r m).symm + (movingReverseTemplate n r m (.inr (movingTemplateBulk n r m i)))) = _ + rw [Equiv.symm_apply_apply] + rfl + +/-- This is literal finite Fubini; neither distinctness nor any history +support is conditioned into the prime law. -/ +theorem movingReverseTemplate_average {A : Type*} [Fintype A] (n r m : ℕ) + (ν : MovingRegularSlot n (4 + r) m → A → ℝ) + (F : (MovingRegularSlot n (4 + r) m → A) → ℂ) : + (∑ x, ((∏ i, ν i (x i) : ℝ) : ℂ) * F x) = + ∑ u : TreeLeafIndex n × Fin 4 → A, + ((∏ i, ν (movingReverseTemplate n r m (.inl i)) (u i) : ℝ) : ℂ) * + ∑ y : MovingRegularSlot n r m → A, + ((∏ i, ν (movingReverseTemplate n r m (.inr i)) (y i) : ℝ) : ℂ) * + F (movingRestoreSample n r m u y) := by + have hr := finite_prior_reindex (movingReverseTemplate n r m) ν F + simp only [finite_univ_canonical] at hr ⊢ + rw [← hr] + let e := Equiv.sumArrowEquivProdArrow (TreeLeafIndex n × Fin 4) (MovingRegularSlot n r m) A + have he := e.symm.sum_comp (fun x => + ((∏ i, ν (movingReverseTemplate n r m i) (x i) : ℝ) : ℂ) * + F (x ∘ (movingReverseTemplate n r m).symm)) + simp only [finite_univ_canonical] at he ⊢ + rw [← he] + have hs := Fintype.sum_prod_type (fun x : + (TreeLeafIndex n × Fin 4 → A) × (MovingRegularSlot n r m → A) => + ((∏ i, ν (movingReverseTemplate n r m i) (e.symm x i) : ℝ) : ℂ) * + F (e.symm x ∘ (movingReverseTemplate n r m).symm)) + simp only [finite_univ_canonical] at hs + rw [hs] + apply Finset.sum_congr rfl + intro u _ + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro y _ + have hp := Fintype.prod_sum_type (fun i : + (TreeLeafIndex n × Fin 4) ⊕ MovingRegularSlot n r m => + ν (movingReverseTemplate n r m i) (e.symm (u, y) i)) + simp only [finite_univ_canonical] at hp + rw [hp] + simp only [e, Equiv.sumArrowEquivProdArrow_symm_apply_inl, + Equiv.sumArrowEquivProdArrow_symm_apply_inr, Complex.ofReal_mul] + change _ * F (movingRestoreSample n r m u y) = _ + ring + +/-- The compensation block is sampled once, in precisely the coordinates +of `movingCompensationPrior`; the two child histories will share this block. -/ +def movingTemplateCompensationEquiv (A : Type*) (n : ℕ) : + TreeLeafTuple (Fin 4 → A) n ≃ (TreeLeafIndex n × Fin 4 → A) := + (treeLeafTupleEquiv (Fin 4 → A) n).trans (Equiv.curry (TreeLeafIndex n) (Fin 4) A).symm + +theorem movingTemplateCompensationEquiv_prior {A : Type*} + (μ : A → ℝ) (n : ℕ) (a : TreeLeafTuple (Fin 4 → A) n) : + (∏ i, μ (movingTemplateCompensationEquiv A n a i)) = movingCompensationPrior μ n a := by + rw [movingCompensationPrior_indexed, Fintype.prod_prod_type] + rfl + +theorem movingReverseTemplate_compensation_average {A : Type*} [Fintype A] (n r m : ℕ) + (ν : MovingRegularSlot n (4 + r) m → A → ℝ) (μ : A → ℝ) + (hμ : ∀ i a, ν (movingReverseTemplate n r m (.inl i)) a = μ a) + (F : (MovingRegularSlot n (4 + r) m → A) → ℂ) : + (∑ x, ((∏ i, ν i (x i) : ℝ) : ℂ) * F x) = + ∑ a : TreeLeafTuple (Fin 4 → A) n, (movingCompensationPrior μ n a : ℂ) * + ∑ y : MovingRegularSlot n r m → A, + ((∏ i, ν (movingReverseTemplate n r m (.inr i)) (y i) : ℝ) : ℂ) * + F (movingRestoreSample n r m (movingTemplateCompensationEquiv A n a) y) := by + rw [movingReverseTemplate_average] + simp_rw [hμ] + have he := (movingTemplateCompensationEquiv A n).sum_comp (fun u => + ((∏ i, μ (u i) : ℝ) : ℂ) * + ∑ y : MovingRegularSlot n r m → A, + ((∏ i, ν (movingReverseTemplate n r m (.inr i)) (y i) : ℝ) : ℂ) * + F (movingRestoreSample n r m u y)) + simp only [finite_univ_canonical] at he ⊢ + rw [← he] + apply Finset.sum_congr rfl + intro a _ + have hp := movingTemplateCompensationEquiv_prior μ n a + simp only [finite_univ_canonical] at hp + rw [hp] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateProducts.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..f58c2b073004adf89c4022c12a4db0f53afb941d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateProducts.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateLeaves +import OAI.NumberTheory.Ostmann.Arithmetic.NodeBulkProducts + +namespace OAI + +/-! # Exact moduli of the regular-slot templates -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem naturalProduct_bulkSlotLeaves {A : Type*} (value : A → ℕ) (n m : ℕ) + (slot : TreeLeafIndex n × Fin m → A) : + MovingSlotReversal.naturalProduct value (flattenMovingSlots n (bulkSlotLeaves n m slot)) = + ∏ i, value (slot i) := by + rw [movingSlotValues_flatten] + have h : movingSlotValues value n (bulkSlotLeaves n m slot) = + (treeLeafTupleEquiv ℕ n).symm (fun j => ∏ i : Fin m, value (slot (j, i))) := by + apply (treeLeafTupleEquiv ℕ n).injective + funext j + rw [movingSlotValues_indexed, Equiv.apply_symm_apply] + simp only [bulkSlotLeaves, Equiv.apply_symm_apply, MovingSlotReversal.naturalProduct, + List.map_ofFn, List.prod_ofFn] + rfl + rw [h, treeLeafProduct_indexed, Fintype.prod_prod_type] + +/-- Every regular coordinate occurs once in the small/bulk leaf lists. -/ +theorem movingTemplate_product {A : Type*} (value : A → ℕ) (n r m : ℕ) + (y : MovingRegularSlot n r m → A) : + MovingSlotReversal.naturalProduct (value ∘ y) + (flattenMovingSlots n (movingTemplateSmall n r m) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingTemplateBulk n r m))) = + ∏ i, value (y i) := by + rw [movingNaturalProduct_append] + unfold movingTemplateSmall + rw [naturalProduct_bulkSlotLeaves, naturalProduct_bulkSlotLeaves] + simp only [MovingRegularSlot, Fintype.prod_prod_type, Fintype.prod_sum_type, + Function.comp_apply, movingTemplateBulk] + rw [Finset.prod_mul_distrib] + rfl + +/-- The extracted compensation modulus is exactly the factor removed from +one child's complete regular modulus. -/ +theorem movingRestoreSample_product {A : Type*} (value : A → ℕ) (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) : + (∏ i, value (movingRestoreSample n r m u y i)) = + (∏ i, value (u i)) * ∏ i, value (y i) := by + have h := (movingReverseTemplate n r m).prod_comp + (fun i => value (movingRestoreSample n r m u y i)) + rw [Fintype.prod_sum_type] at h + simpa only [movingRestoreSample, Function.comp_apply, Equiv.symm_apply_apply, + Sum.elim_inl, Sum.elim_inr] using h.symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..6e7a699113e713c958c84882682d33aa20c1a0d6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupport.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateCoefficient +import OAI.NumberTheory.Ostmann.Arithmetic.MovingCoefficientSupport +import OAI.NumberTheory.Ostmann.Construction.GiantTransformProduct + +namespace OAI + +/-! # The literal regular template and its full Fourier factor -/ + +namespace Ostmann +open scoped Classical BigOperators + +local instance templateSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +noncomputable def movingTemplateSlotList (n r m : ℕ) : List (MovingRegularSlot n r m) := + flattenMovingSlots n (movingTemplateSmall n r m) ++ + flattenMovingSlots n (bulkSlotLeaves n m (movingTemplateBulk n r m)) + +theorem mem_movingTemplateSlotList (n r m : ℕ) (i : MovingRegularSlot n r m) : + i ∈ movingTemplateSlotList n r m := by + rcases i with ⟨j, i | i⟩ + · apply List.mem_append_left + exact (mem_flatten_bulkSlotLeaves n r _ _).mpr ⟨(j, i), rfl⟩ + · apply List.mem_append_right + exact (mem_flatten_bulkSlotLeaves n m _ _).mpr ⟨(j, i), rfl⟩ + +private theorem prime_pairwise_list_nodup (L : List ℕ) (hp : ∀ p ∈ L, p.Prime) + (h : L.Pairwise Nat.Coprime) : L.Nodup := by + induction L with + | nil => exact List.nodup_nil + | cons p L ih => + obtain ⟨hh, ht⟩ := List.pairwise_cons.mp h + refine List.nodup_cons.mpr ⟨?_, ih (fun q hq => hp q (List.mem_cons_of_mem p hq)) ht⟩ + intro hmem + have h1 : p = 1 := by simpa only [Nat.coprime_self] using hh p hmem + exact (hp p List.mem_cons_self).ne_one h1 + +/-- The support of the actual coefficient forces every prime in the full +regular template to be distinct. -/ +theorem movingTemplateCoefficient_nonzero_injective {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (y : MovingRegularSlot n r m → σ) (XL XR : ℕ) + (hprime : ∀ i, (value (y i)).Prime) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n r m s y XL XR ≠ 0) : + Function.Injective (value ∘ y) := by + have hs := (movingFrequencyCoefficient_nonzero_support value outside μ childBound pivotBound V + F φ G n s _ _ XL XR h).1 + have hr : ((movingTemplateSlotList n r m).map (value ∘ y) ++ outside).Pairwise Nat.Coprime := by + simpa only [flattenMovingSlots_map, List.map_append, List.map_map, Function.comp_def, + movingTemplateSlotList, List.tail_cons] using hs.tail.tail + have hnd : ((movingTemplateSlotList n r m).map (value ∘ y)).Nodup := by + apply prime_pairwise_list_nodup _ _ (List.pairwise_append.mp hr).1 + intro p hp + obtain ⟨i, _, rfl⟩ := List.mem_map.mp hp + exact hprime i + intro i j hij + exact List.inj_on_of_nodup_map hnd (mem_movingTemplateSlotList n r m i) + (mem_movingTemplateSlotList n r m j) hij + +/-- The two phase factors and the regular product transform combine into +exactly the full indexed Fourier transform wherever the coefficient contributes. -/ +theorem movingTemplateCoefficient_full_transform {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (y : MovingRegularSlot n r m → σ) (q : Bool → ℕ) [∀ b, Fact (q b).Prime] + (hprime : ∀ i, (value (y i)).Prime) + (greg ggiant : ∀ p : ℕ, ZMod p → ℂ) (favorable : ℕ → Bool) : + let _ : ∀ i, Fact ((value ∘ y) i).Prime := fun i => ⟨hprime i⟩ + movingRegularTransform (Sum.elim q (value ∘ y)) + (fun i => match i with + | .inl b => fun t => if favorable (q b) then complexUnitPhase (ggiant (q b) t) else 0 + | .inr j => greg (value (y j))) outside.prod s * + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n r m s y (q true) (q false) = + (giantPairPhase ggiant favorable outside.prod (∏ i, value (y i)) (q true) (q false) s * + primeProductTransform greg (outside.prod * q true * q false) (∏ i, value (y i)) s) * + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n r m s y (q true) (q false) := by + let : ∀ i, Fact ((value ∘ y) i).Prime := fun i => ⟨hprime i⟩ + dsimp only + by_cases h : movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n r m s y (q true) (q false) = 0 + · simp only [h, mul_zero] + · have he := movingRegularTransform_two_giant_phases q (value ∘ y) + (movingTemplateCoefficient_nonzero_injective value outside μ childBound pivotBound V F + φ G n r m s y (q true) (q false) hprime h) greg ggiant favorable outside.prod s + have hh := congrArg (fun z : ℂ => z * movingTemplateCoefficient value outside μ childBound pivotBound V + F φ G n r m s y (q true) (q false)) he + convert hh using 1 <;> try rfl + apply congrArg (fun z : ℂ => z * movingTemplateCoefficient value outside μ childBound pivotBound V + F φ G n r m s y (q true) (q false)) + unfold movingRegularTransform + apply Finset.prod_congr rfl + intro i _ + cases i <;> rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedHarmonic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedHarmonic.lean new file mode 100644 index 0000000000000000000000000000000000000000..5d9bb9f525042a530a390c7017c6791b6e97fa9c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedHarmonic.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicDiagonal +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantPrior + +namespace OAI + +/-! # The restored diagonal under the original giant and regular priors -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original harmonic product law pays the giant atom and a single +factorial product-fibre cost. The frequency range contributes no cardinality +factor, because the diagonal key includes the frequency itself. -/ +theorem movingTemplate_harmonic_diagonal_supported + (P Pg : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (cg : ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (u : TreeLeafIndex n × Fin 4 → P) (p : ℕ) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ cg q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ cg q ≠ 0 → ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let A := Pg × ((MovingRegularSlot n r m → P) × transferFrequencyRange (V n)) + let X := fun a : A => (a.1 : ℕ) + let y := fun a : A => a.2.1 + let v := fun a : A => (a.2.2 : ℤ) + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hPg _ a.1.property⟩ + let _ : ∀ a i, Fact (y a i : ℕ).Prime := fun a i => ⟨hP _ (y a i).property⟩ + let α := fun a : A => smoothGiantPrior Pg φ cg a.1 * + ∏ i, primeSubsetPrior P (Q i) (y a i) + let C := fun a : A => movingTemplateCoefficient (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n (4 + r) m (v a) + (movingRestoreSample n r m u (y a)) p (X a) + let θ := fun a : A => (Real.exp (smoothGiantLogNormalizer Pg φ cg) / X a) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (y a i : ℕ)) : ℝ)⁻¹ + let D := p * (∏ i, (u i : ℕ)) * outside.prod + (pivotDiagonal (fun a => X a * ∏ i, (y a i : ℕ)) v + (fun a => (α a : ℂ) * C a * + movingRegularTransform (movingOneGiantModuli (X a) (fun i => (y a i : ℕ))) + (movingOneGiantFactors (X a) (fun i => (y a i : ℕ)) greg ggiant favorable) D (v a))).re ≤ + ∑ a, α a * θ a * + ‖C a * primeProductTransform greg (D * X a) (∏ i, (y a i : ℕ)) (v a)‖ ^ 2 := by + intro A X y v instX instY α C θ D + let g := fun q : ℕ => Real.exp (smoothGiantLogNormalizer Pg φ cg) / q + have hg q : 0 ≤ g q := div_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + have hα a : 0 ≤ α a := + mul_nonneg (smoothGiantPrior_nonneg Pg φ cg hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + have hpoint a : α a ≤ g (X a) * ∏ i, primeSubsetPrior P (Q i) (y a i) := by + apply mul_le_mul_of_nonneg_right _ + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + change Real.exp (smoothGiantLogNormalizer Pg φ cg) * φ (Real.log (a.1 : ℕ) - cg) / + (a.1 : ℕ) ≤ Real.exp (smoothGiantLogNormalizer Pg φ cg) / (a.1 : ℕ) + exact div_le_div_of_nonneg_right + (mul_le_of_le_one_right (Real.exp_nonneg _) (hφ1 _)) (Nat.cast_nonneg _) + have hrow (a b : A) (hx : X a = X b) (hy : y a = y b) (hv : v a = v b) : a = b := + Prod.ext (Subtype.ext hx) (Prod.ext hy (Subtype.ext hv)) + have hc a (ha : (α a : ℂ) * C a ≠ 0) : C a ≠ 0 := right_ne_zero_of_mul ha + have hinj a (ha : (α a : ℂ) * C a ≠ 0) : Function.Injective (y a) := by + have hs := movingTemplateCoefficient_restored_support (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n r m (v a) u (y a) p (X a) (hc a ha) + intro i j hij + by_contra hne + have hh := hs.2.2.1 (show (Sum.inr i : Unit ⊕ MovingRegularSlot n r m) ≠ .inr j from + fun he => hne (Sum.inr.inj he)) + change (y a i : ℕ).Coprime (y a j : ℕ) at hh + rw [hij] at hh + exact (hP _ (y a j).property).ne_one (by simpa only [Nat.coprime_self] using hh) + have hz a (ha : (α a : ℂ) * C a ≠ 0) : v a ≠ 0 := by + intro he + apply hc a ha + simpa only [C, movingTemplateCoefficient, he] using + movingFrequencyCoefficient_zero (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F hF φ G n + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (movingTemplateSmall n (4 + r) m)) + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m))) p (X a) + have hsupp (a : A) (ha : (α a : ℂ) * C a ≠ 0) : smoothGiantPrior Pg φ cg a.1 ≠ 0 := by + have ha' : α a ≠ 0 := by exact_mod_cast left_ne_zero_of_mul ha + exact left_ne_zero_of_mul ha' + have h := movingOneGiant_harmonic_diagonal_le P hP Q X + (fun a => hPg _ a.1.property) y v α C hα g hg hrow hpoint hinj hz + (fun a ha => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt (hvg a.1 (hsupp a ha))) + (fun a _ i => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt (hvr (y a i))) + (fun a b ha _ i => hsep a.1 (hsupp a ha) (y b i)) greg ggiant favorable D + simpa only [g, θ, Nat.cast_prod] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedRaw.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedRaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..b507d06bff750df26201310948329925e7777e49 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedRaw.lean @@ -0,0 +1,159 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullSupportedTransformTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateWeightedSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullTransformTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOneGiant + +namespace OAI + +/-! # One giant-prior step with a product bound only on actual coefficient support -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance transferTemplateSum_prime {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, Fact (q j).Prime] [∀ i, Fact (p i).Prime] (i : J ⊕ I) : + Fact (Sum.elim q p i).Prime := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +local instance transferTemplateSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +/-- The support fields in the full Fourier transfer follow from the +original coefficient. Compensation retains its original independent law; +`α` contains the surviving external priors. -/ +theorem movingTemplate_prior_transfer_raw_on_support {σ A : Type} [Fintype σ] [Fintype A] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass P φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (X : A → ℕ) (hX : ∀ a, (X a).Prime) + (y : A → MovingRegularSlot n r m → σ) (v : A → ℤ) (α : A → ℂ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ a x, ggiant (X a) (-x) = conj (ggiant (X a) x)) + (N H T : ℕ) (hv : ∀ a, (v a).natAbs ≤ N) + (hH : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ), p ∈ I → ∀ a, + movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G + n r m v α X y u p a ≠ 0 → X a * (∏ i, value (y a i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p, p ∈ I → + 2 * N * H ≤ T * (p * ∏ i, value (u i))) + (hlarge : ∀ a q, q.Prime → q ∣ X a * (∏ i, value (y a i)) → T < q) : + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let _ : ∀ a i, Fact (((value ∘ y a) i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let greg := normalizedResidueFamily sets + let U := fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, value (u i) + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let _ : ∀ a i, NeZero (L a i) := fun a i => by + cases i with + | inl _ => exact ⟨(hX a).ne_zero⟩ + | inr j => exact ⟨(hvalue (y a j)).ne_zero⟩ + let gL := fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable + let Q := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantModuli (p : ℕ) (value ∘ u) + let _ : ∀ u p i, NeZero (Q u p i) := fun u p i => by + cases i with + | inl _ => exact ⟨(hP p p.property).ne_zero⟩ + | inr j => exact ⟨(hvalue (u j)).ne_zero⟩ + let gQ := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantFactors (p : ℕ) (value ∘ u) greg ggiant favorable + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + Real.exp (-smoothGiantLogNormalizer P φ (G (n + 1))) * + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, ((∏ i, μ n (u i) : ℝ) : ℂ) * + ∑ p : P, (smoothGiantPrior P φ (G (n + 1)) p : ℂ) * + ∑ a, W u p a * movingRegularTransform (Sum.elim (Q u p) (L a)) + (movingSumFactors (Q u p) (L a) (gQ u p) (gL a)) outside.prod (v a)‖ ^ 2 ≤ + (∑ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) * (U u : ℝ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + (pivotDiagonal (fun a => ∏ i, L a i) v + (movingRegularCoefficient L gL outside.prod (U u) v (W u) p)).re) + + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, (((∏ i, μ n (u i)) * (U u : ℝ) : ℝ) : ℂ) * + ∑ s ∈ transferFrequencyRange T, ∑ a, ∑ b, + if validTransferredPivot I + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) then + let p := reconstructedPivot + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) + (φ (Real.log p - G (n + 1)) : ℂ) * W u p a * conj (W u p b) * + movingRegularTransform (Sum.elim (L a) (L b)) + (movingSumFactors (L a) (L b) (gL a) (gL b)) outside.prod s + else 0‖ := by + let : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let : ∀ a, Fact (value a).Prime := fun a => ⟨hvalue a⟩ + let : ∀ a i, Fact (((value ∘ y a) i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let greg := normalizedResidueFamily sets + let U := fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, value (u i) + let Q := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantModuli (p : ℕ) (value ∘ u) + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let : ∀ (u : TreeLeafIndex n × Fin 4 → σ) (p : P) i, Fact (Q u p i).Prime := by + intro u p i + cases i with + | inl _ => exact ⟨hP p p.property⟩ + | inr j => exact ⟨hvalue (u j)⟩ + let gQ := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantFactors (p : ℕ) (value ∘ u) greg ggiant favorable + let : ∀ a i, Fact (L a i).Prime := fun a i => by + cases i <;> dsimp only [L, movingOneGiantModuli, Sum.elim, Function.comp_apply] <;> infer_instance + let : ∀ a i, NeZero (L a i) := fun a i => by infer_instance + let gL := fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + have hprod (a : A) : (∏ i, L a i) = X a * ∏ i, value (y a i) := + movingOneGiantModuli_product (X a) (value ∘ y a) + have hQprod u p : (∏ i, Q u p i) = (p : ℕ) * U u := + movingOneGiantModuli_product (p : ℕ) (value ∘ u) + have hs u p a (h : W u p a ≠ 0) := + movingTemplateTransferWeight_support value outside μ childBound pivotBound V F φ G + n r m v α X y u p a h + have hgL a i x : gL a i (-x) = conj (gL a i x) := + movingOneGiantFactors_neg (X a) (value ∘ y a) greg ggiant favorable + (hgiant a) (fun j x => by + dsimp only [greg] + rw [normalizedResidueFamily_eq] + exact normalizedResidueTransform_neg _ x) i x + have ht := smoothGiantPrior_full_transform_transfer_on_prior + (Y := TreeLeafIndex n × Fin 4 → σ) (A := A) + (J := Unit ⊕ (TreeLeafIndex n × Fin 4)) (H := Unit ⊕ MovingRegularSlot n r m) P I hP hPI hI φ (G (n + 1)) hφ hpos + (fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, μ n (u i)) + (fun u => Finset.prod_nonneg (fun i _ => hμ (u i))) + (by rw [← Fintype.prod_sum]; simp only [hμmass, Finset.prod_const_one]) U + (fun u => Finset.prod_pos (fun i _ => (hvalue (u i)).pos)) Q gQ hQprod (.inl ()) + (fun u p i => match i with | .inl _ => ∅ | .inr j => sets (value (u j))) + (fun u p x => by + change ‖if favorable (p : ℕ) then complexUnitPhase (ggiant p x) else 0‖ ≤ 1 + split_ifs + · exact complexUnitPhase_norm_le _ + · simp) + (fun u p i hi => by + cases i with + | inl i => cases i; exact (hi rfl).elim + | inr j => exact normalizedResidueFamily_eq sets (value (u j))) + (fun u p i hi => by + cases i with + | inl i => cases i; exact (hi rfl).elim + | inr j => exact hsets (u j)) + (fun u p i hi => by + cases i with + | inl i => cases i; exact (hi rfl).elim + | inr j => exact hcard (u j)) (fun _ => L) (fun _ => gL) (fun _ => hgL) (fun _ => outside.prod) (fun _ => v) W + (fun u p a hw => ⟨(hs u p a hw).1, (hs u p a hw).2.1⟩) + (fun u p _ a hw => by + have h := hs u p a hw + refine ⟨h.2.2.1, ?_, h.2.2.2.2⟩ + have hc := h.2.2.2.1 + change (∏ i, L a i).Coprime (∏ i, movingOneGiantModuli p (value ∘ u) i) at hc + simpa only [L, U, movingOneGiantModuli_product, Function.comp_apply] using hc) + N H T (fun _ _ _ a _ => hv a) (fun u hu p hp a ha => (hprod a).trans_le (hH u hu p hp a ha)) + hscale (fun _ a q hq hd => hlarge a q hq ((hprod a) ▸ hd)) + with_reducible exact ht + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedSymmetrization.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedSymmetrization.lean new file mode 100644 index 0000000000000000000000000000000000000000..3234e46cd991b058452de3a9c566f04bf32c3423 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedSymmetrization.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGroupedBulkAverage +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicGroupedEnergy +import OAI.NumberTheory.Ostmann.Construction.SelectedBulkSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicDiagonal +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantPrior + +namespace OAI + +/-! # The restored diagonal under the original giant and regular priors -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original harmonic product law pays the giant atom and a single +factorial product-fibre cost. The frequency range contributes no cardinality +factor, because the diagonal key includes the frequency itself. -/ +theorem movingTemplate_symmetrized_harmonic_diagonal_supported + (P Pg : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (cg : ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (hν : ∀ j k : TreeLeafIndex n × Fin m, + primeSubsetPrior P (Q (movingTemplateBulk n r m j)) = + primeSubsetPrior P (Q (movingTemplateBulk n r m k))) + (u : TreeLeafIndex n × Fin 4 → P) (p : ℕ) + (hvg : ∀ q : Pg, smoothGiantPrior Pg φ cg q ≠ 0 → V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, smoothGiantPrior Pg φ cg q ≠ 0 → ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let A := Pg × ((MovingRegularSlot n r m → P) × transferFrequencyRange (V n)) + let X := fun a : A => (a.1 : ℕ) + let y := fun a : A => a.2.1 + let v := fun a : A => (a.2.2 : ℤ) + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hPg _ a.1.property⟩ + let _ : ∀ a i, Fact (y a i : ℕ).Prime := fun a i => ⟨hP _ (y a i).property⟩ + let α := fun a : A => smoothGiantPrior Pg φ cg a.1 * + ∏ i, primeSubsetPrior P (Q i) (y a i) + let C := fun a : A => movingTemplateCoefficient (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n (4 + r) m (v a) + (movingRestoreSample n r m u (y a)) p (X a) + let Csym := fun a : A => mixedBulkSymmetrize n m (movingTemplateBulk n r m) + (fun _ z _ _ => C (a.1, z, a.2.2)) 0 (y a) 0 0 + let θ := fun a : A => (Real.exp (smoothGiantLogNormalizer Pg φ cg) / X a) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (y a i : ℕ)) : ℝ)⁻¹ + let D := p * (∏ i, (u i : ℕ)) * outside.prod + (pivotDiagonal (fun a => X a * ∏ i, (y a i : ℕ)) v + (fun a => (α a : ℂ) * C a * + movingRegularTransform (movingOneGiantModuli (X a) (fun i => (y a i : ℕ))) + (movingOneGiantFactors (X a) (fun i => (y a i : ℕ)) greg ggiant favorable) D (v a))).re ≤ + ∑ a, α a * θ a * + ‖Csym a * primeProductTransform greg (D * X a) (∏ i, (y a i : ℕ)) (v a)‖ ^ 2 := by + intro A X y v instX instY α C Csym θ D + let g := fun q : ℕ => Real.exp (smoothGiantLogNormalizer Pg φ cg) / q + have hg q : 0 ≤ g q := div_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + have hα a : 0 ≤ α a := + mul_nonneg (smoothGiantPrior_nonneg Pg φ cg hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + have hpoint a : α a ≤ g (X a) * ∏ i, primeSubsetPrior P (Q i) (y a i) := by + apply mul_le_mul_of_nonneg_right _ + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + change Real.exp (smoothGiantLogNormalizer Pg φ cg) * φ (Real.log (a.1 : ℕ) - cg) / + (a.1 : ℕ) ≤ Real.exp (smoothGiantLogNormalizer Pg φ cg) / (a.1 : ℕ) + exact div_le_div_of_nonneg_right + (mul_le_of_le_one_right (Real.exp_nonneg _) (hφ1 _)) (Nat.cast_nonneg _) + have hrow (a b : A) (hx : X a = X b) (hy : y a = y b) (hv : v a = v b) : a = b := + Prod.ext (Subtype.ext hx) (Prod.ext hy (Subtype.ext hv)) + have hc a (ha : (α a : ℂ) * C a ≠ 0) : C a ≠ 0 := right_ne_zero_of_mul ha + have hinjC a (ha : C a ≠ 0) : Function.Injective (y a) := by + have hs := movingTemplateCoefficient_restored_support (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n r m (v a) u (y a) p (X a) ha + intro i j hij + by_contra hne + have hh := hs.2.2.1 (show (Sum.inr i : Unit ⊕ MovingRegularSlot n r m) ≠ .inr j from + fun he => hne (Sum.inr.inj he)) + change (y a i : ℕ).Coprime (y a j : ℕ) at hh + rw [hij] at hh + exact (hP _ (y a j).property).ne_one (by simpa only [Nat.coprime_self] using hh) + have hinj a (ha : (α a : ℂ) * C a ≠ 0) := hinjC a (hc a ha) + have hnewinj a (ha : (α a : ℂ) * Csym a ≠ 0) : Function.Injective (y a) := by + obtain ⟨e, he⟩ := mixedBulkSymmetrize_ne_zero n m (movingTemplateBulk n r m) + (fun _ z _ _ => C (a.1, z, a.2.2)) 0 (y a) 0 0 (right_ne_zero_of_mul ha) + have hi := hinjC (a.1, selectedBulkSample (movingTemplateBulk n r m) e (y a), a.2.2) he + exact (selectedBulkSample_injective_iff (movingTemplateBulk n r m) e id (y a)).mp hi + have hgroup (k : ℕ × ℕ × ℤ) : + groupedCoefficient (fun a => (X a, (∏ i, (y a i : ℕ)), v a)) + (fun a => (α a : ℂ) * C a) k = + groupedCoefficient (fun a => (X a, (∏ i, (y a i : ℕ)), v a)) + (fun a => (α a : ℂ) * Csym a) k := by + exact (movingAmplitude_grouped_bulk_average P Pg n r m V + (smoothGiantPrior Pg φ cg) (fun i => primeSubsetPrior P (Q i)) hν C k).symm + have hz a (ha : (α a : ℂ) * C a ≠ 0) : v a ≠ 0 := by + intro he + apply hc a ha + simpa only [C, movingTemplateCoefficient, he] using + movingFrequencyCoefficient_zero (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F hF φ G n + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (movingTemplateSmall n (4 + r) m)) + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m))) p (X a) + have hsupp (a : A) (ha : (α a : ℂ) * C a ≠ 0) : smoothGiantPrior Pg φ cg a.1 ≠ 0 := by + have ha' : α a ≠ 0 := by exact_mod_cast left_ne_zero_of_mul ha + exact left_ne_zero_of_mul ha' + have h := movingOneGiant_harmonic_grouped_diagonal_le P hP Q X + (fun a => hPg _ a.1.property) y v α C Csym hα g hg hrow hpoint hinj hz + (fun a ha => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt (hvg a.1 (hsupp a ha))) + (fun a _ i => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt (hvr (y a i))) + (fun a b ha _ i => hsep a.1 (hsupp a ha) (y b i)) hgroup hnewinj greg ggiant favorable D + simpa only [g, θ, Nat.cast_prod] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6e0773d0678e9af2157394c9564b97adc998e59 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSupportedTransfer.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateTransferSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullTransformTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateSupportedRaw + +namespace OAI + +/-! # The full giant-prior step with its actual supported product bound -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance transferFinalSum_prime {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, Fact (q j).Prime] [∀ i, Fact (p i).Prime] (i : J ⊕ I) : + Fact (Sum.elim q p i).Prime := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +local instance transferFinalSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +/-- The support fields in the full Fourier transfer follow from the +original coefficient. Compensation retains its original independent law; +`α` contains the surviving external priors. -/ +theorem movingTemplate_prior_transfer_on_support {σ A : Type} [Fintype σ] [Fintype A] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass P φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (X : A → ℕ) (hX : ∀ a, (X a).Prime) + (y : A → MovingRegularSlot n r m → σ) (v : A → ℤ) (α : A → ℂ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ a x, ggiant (X a) (-x) = conj (ggiant (X a) x)) + (N H T : ℕ) (hv : ∀ a, (v a).natAbs ≤ N) + (hH : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → + ∀ (p : ℕ), p ∈ I → ∀ a, + movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G + n r m v α X y u p a ≠ 0 → X a * (∏ i, value (y a i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p, p ∈ I → + 2 * N * H ≤ T * (p * ∏ i, value (u i))) + (hlarge : ∀ a q, q.Prime → q ∣ X a * (∏ i, value (y a i)) → T < q) : + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let _ : ∀ a i, Fact (((value ∘ y a) i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let greg := normalizedResidueFamily sets + let U := fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, value (u i) + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let _ : ∀ a i, NeZero (L a i) := fun a i => by + cases i with + | inl _ => exact ⟨(hX a).ne_zero⟩ + | inr j => exact ⟨(hvalue (y a j)).ne_zero⟩ + let gL := fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + Real.exp (-smoothGiantLogNormalizer P φ (G (n + 1))) * + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, ((∏ i, μ n (u i) : ℝ) : ℂ) * + ∑ p : P, (smoothGiantPrior P φ (G (n + 1)) p : ℂ) * + ∑ a, W u p a * movingTaggedTransform + (Sum.elim (fun b : Bool => if b then (p : ℕ) else X a) + (value ∘ movingRestoreSample n r m u (y a))) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod (v a)‖ ^ 2 ≤ + (∑ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) * (U u : ℝ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + (pivotDiagonal (fun a => ∏ i, L a i) v + (movingRegularCoefficient L gL outside.prod (U u) v (W u) p)).re) + + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, (((∏ i, μ n (u i)) * (U u : ℝ) : ℝ) : ℂ) * + ∑ s ∈ transferFrequencyRange T, ∑ a, ∑ b, + if validTransferredPivot I + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) then + let p := reconstructedPivot + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) + (φ (Real.log p - G (n + 1)) : ℂ) * W u p a * conj (W u p b) * + movingRegularTransform (Sum.elim (L a) (L b)) + (movingSumFactors (L a) (L b) (gL a) (gL b)) outside.prod s + else 0‖ := by + let greg := normalizedResidueFamily sets + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + have ht := movingTemplate_prior_transfer_raw_on_support value hvalue outside μ childBound pivotBound V F + φ G n r m P I hP hPI hI hφ hpos hμ hμmass X hX y v α sets hsets hcard ggiant favorable + hgiant N H T hv hH hscale hlarge + have hsum := movingOneGiant_restored_average value (fun z => (hvalue z).ne_zero) n r m + P (fun p => (hP p p.property).ne_zero) X (fun a => (hX a).ne_zero) y v outside.prod + greg ggiant favorable (fun u => ((∏ i, μ n (u i) : ℝ) : ℂ)) + (fun p => (smoothGiantPrior P φ (G (n + 1)) p : ℂ)) (fun u p a => W u p a) + exact (congrArg (fun z : ℂ => + Real.exp (-smoothGiantLogNormalizer P φ (G (n + 1))) * ‖z‖ ^ 2) hsum).le.trans ht + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSymmetrizedDiagonal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSymmetrizedDiagonal.lean new file mode 100644 index 0000000000000000000000000000000000000000..4d9aa83aa022752f25378c09f65f13f9ca3fea0e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSymmetrizedDiagonal.lean @@ -0,0 +1,113 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateDiagonal +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGroupedBulkAverage +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicGroupedEnergy +import OAI.NumberTheory.Ostmann.Construction.SelectedBulkSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingHarmonicDiagonal +import OAI.NumberTheory.Ostmann.Construction.SmoothGiantPrior + +namespace OAI + +/-! # The restored diagonal under the original giant and regular priors -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The original harmonic product law pays the giant atom and a single +factorial product-fibre cost. The frequency range contributes no cardinality +factor, because the diagonal key includes the frequency itself. -/ +theorem movingTemplate_symmetrized_harmonic_diagonal_le + (P Pg : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPg : ∀ p ∈ Pg, p.Prime) + (outside : List ℕ) (μ : ℕ → P → ℝ) (childBound pivotBound V : ℕ → ℕ) + (F : MovingSlotState P → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (hφ0 : ∀ x, 0 ≤ φ x) (hφ1 : ∀ x, φ x ≤ 1) (G : ℕ → ℝ) + (cg : ℝ) + (n r m : ℕ) (Q : MovingRegularSlot n r m → Finset ℕ) + (hν : ∀ j k : TreeLeafIndex n × Fin m, + primeSubsetPrior P (Q (movingTemplateBulk n r m j)) = + primeSubsetPrior P (Q (movingTemplateBulk n r m k))) + (u : TreeLeafIndex n × Fin 4 → P) (p : ℕ) + (hvg : ∀ q : Pg, V n < (q : ℕ)) (hvr : ∀ q : P, V n < (q : ℕ)) + (hsep : ∀ q : Pg, ∀ a : P, (q : ℕ) ≠ (a : ℕ)) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + let A := Pg × ((MovingRegularSlot n r m → P) × transferFrequencyRange (V n)) + let X := fun a : A => (a.1 : ℕ) + let y := fun a : A => a.2.1 + let v := fun a : A => (a.2.2 : ℤ) + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hPg _ a.1.property⟩ + let _ : ∀ a i, Fact (y a i : ℕ).Prime := fun a i => ⟨hP _ (y a i).property⟩ + let α := fun a : A => smoothGiantPrior Pg φ cg a.1 * + ∏ i, primeSubsetPrior P (Q i) (y a i) + let C := fun a : A => movingTemplateCoefficient (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n (4 + r) m (v a) + (movingRestoreSample n r m u (y a)) p (X a) + let Csym := fun a : A => mixedBulkSymmetrize n m (movingTemplateBulk n r m) + (fun _ z _ _ => C (a.1, z, a.2.2)) 0 (y a) 0 0 + let θ := fun a : A => (Real.exp (smoothGiantLogNormalizer Pg φ cg) / X a) * + ((Fintype.card (MovingRegularSlot n r m)).factorial : ℝ) * + (∏ i, (∑ q ∈ Q i, (q : ℝ)⁻¹)⁻¹) * ((∏ i, (y a i : ℕ)) : ℝ)⁻¹ + let D := p * (∏ i, (u i : ℕ)) * outside.prod + (pivotDiagonal (fun a => X a * ∏ i, (y a i : ℕ)) v + (fun a => (α a : ℂ) * C a * + movingRegularTransform (movingOneGiantModuli (X a) (fun i => (y a i : ℕ))) + (movingOneGiantFactors (X a) (fun i => (y a i : ℕ)) greg ggiant favorable) D (v a))).re ≤ + ∑ a, α a * θ a * + ‖Csym a * primeProductTransform greg (D * X a) (∏ i, (y a i : ℕ)) (v a)‖ ^ 2 := by + intro A X y v instX instY α C Csym θ D + let g := fun q : ℕ => Real.exp (smoothGiantLogNormalizer Pg φ cg) / q + have hg q : 0 ≤ g q := div_nonneg (Real.exp_nonneg _) (Nat.cast_nonneg _) + have hα a : 0 ≤ α a := + mul_nonneg (smoothGiantPrior_nonneg Pg φ cg hφ0 a.1) + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + have hpoint a : α a ≤ g (X a) * ∏ i, primeSubsetPrior P (Q i) (y a i) := by + apply mul_le_mul_of_nonneg_right _ + (Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (Q i) (y a i))) + change Real.exp (smoothGiantLogNormalizer Pg φ cg) * φ (Real.log (a.1 : ℕ) - cg) / + (a.1 : ℕ) ≤ Real.exp (smoothGiantLogNormalizer Pg φ cg) / (a.1 : ℕ) + exact div_le_div_of_nonneg_right + (mul_le_of_le_one_right (Real.exp_nonneg _) (hφ1 _)) (Nat.cast_nonneg _) + have hrow (a b : A) (hx : X a = X b) (hy : y a = y b) (hv : v a = v b) : a = b := + Prod.ext (Subtype.ext hx) (Prod.ext hy (Subtype.ext hv)) + have hc a (ha : (α a : ℂ) * C a ≠ 0) : C a ≠ 0 := right_ne_zero_of_mul ha + have hinjC a (ha : C a ≠ 0) : Function.Injective (y a) := by + have hs := movingTemplateCoefficient_restored_support (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F φ G n r m (v a) u (y a) p (X a) ha + intro i j hij + by_contra hne + have hh := hs.2.2.1 (show (Sum.inr i : Unit ⊕ MovingRegularSlot n r m) ≠ .inr j from + fun he => hne (Sum.inr.inj he)) + change (y a i : ℕ).Coprime (y a j : ℕ) at hh + rw [hij] at hh + exact (hP _ (y a j).property).ne_one (by simpa only [Nat.coprime_self] using hh) + have hinj a (ha : (α a : ℂ) * C a ≠ 0) := hinjC a (hc a ha) + have hnewinj a (ha : (α a : ℂ) * Csym a ≠ 0) : Function.Injective (y a) := by + obtain ⟨e, he⟩ := mixedBulkSymmetrize_ne_zero n m (movingTemplateBulk n r m) + (fun _ z _ _ => C (a.1, z, a.2.2)) 0 (y a) 0 0 (right_ne_zero_of_mul ha) + have hi := hinjC (a.1, selectedBulkSample (movingTemplateBulk n r m) e (y a), a.2.2) he + exact (selectedBulkSample_injective_iff (movingTemplateBulk n r m) e id (y a)).mp hi + have hgroup (k : ℕ × ℕ × ℤ) : + groupedCoefficient (fun a => (X a, (∏ i, (y a i : ℕ)), v a)) + (fun a => (α a : ℂ) * C a) k = + groupedCoefficient (fun a => (X a, (∏ i, (y a i : ℕ)), v a)) + (fun a => (α a : ℂ) * Csym a) k := by + exact (movingAmplitude_grouped_bulk_average P Pg n r m V + (smoothGiantPrior Pg φ cg) (fun i => primeSubsetPrior P (Q i)) hν C k).symm + have hz a (ha : (α a : ℂ) * C a ≠ 0) : v a ≠ 0 := by + intro he + apply hc a ha + simpa only [C, movingTemplateCoefficient, he] using + movingFrequencyCoefficient_zero (fun q : P => (q : ℕ)) outside μ + childBound pivotBound V F hF φ G n + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (movingTemplateSmall n (4 + r) m)) + (treeLeafMap (List.map (movingRestoreSample n r m u (y a))) n + (bulkSlotLeaves n m (movingTemplateBulk n (4 + r) m))) p (X a) + have h := movingOneGiant_harmonic_grouped_diagonal_le P hP Q X + (fun a => hPg _ a.1.property) y v α C Csym hα g hg hrow hpoint hinj hz + (fun a _ => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt (hvg a.1)) + (fun a _ i => ((mem_transferFrequencyRange _ _).mp a.2.2.property).trans_lt (hvr (y a i))) + (fun a b _ _ i => hsep a.1 (y b i)) hgroup hnewinj greg ggiant favorable D + simpa only [g, θ, Nat.cast_prod] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSymmetrizedNorm.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSymmetrizedNorm.lean new file mode 100644 index 0000000000000000000000000000000000000000..6fae381329595fdf9801a089fe144131b5be692c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateSymmetrizedNorm.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateMaskedSymmetrization +import OAI.NumberTheory.Ostmann.Characters.MixedExternalMass + +namespace OAI + +/-! # The masked symmetrized energy is a nonnegative real number -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem mixedExternalAverage_norm_eq_re {B A : Type*} [Fintype B] [Fintype A] + (ν : B → A → ℝ) (hν : ∀ j a, 0 ≤ ν j a) (N : ℕ) (u v a b center : ℝ) + (F : ℤ → (B → A) → ℝ → ℝ → ℂ) + (hreal : ∀ s y x z, (F s y x z).im = 0) + (hpos : ∀ s y x z, 0 ≤ (F s y x z).re) : + ‖mixedExternalAverage ν N u v a b center F‖ = + (mixedExternalAverage ν N u v a b center F).re := by + have hi : (mixedExternalAverage ν N u v a b center F).im = 0 := by + simp only [mixedExternalAverage_finite, Complex.im_sum, Complex.mul_im, + Complex.ofReal_re, Complex.ofReal_im, zero_mul, add_zero, hreal, mul_zero, + Finset.sum_const_zero] + have hr : (((mixedExternalAverage ν N u v a b center F).re : ℝ) : ℂ) = + mixedExternalAverage ν N u v a b center F := by + apply Complex.ext <;> simp only [Complex.ofReal_re, Complex.ofReal_im, hi] + rw [← hr, Complex.norm_real, Real.norm_of_nonneg + (mixedExternalAverage_re_nonneg ν hν N u v a b center F hpos)] + rfl + +theorem movingTemplateMaskedSymmetrizedEnergy_norm_eq_re + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (outside : List ℕ) (μ : ℕ → P → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState P → ℤ → ℂ) + (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) (G : ℕ → ℝ) (n r m : ℕ) + (ν : MovingRegularSlot n r m → P → ℝ) (hν : ∀ j a, 0 ≤ ν j a) + (active : MovingRegularSlot n r m → Bool) (greg : ∀ q : ℕ, ZMod q → ℂ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) : + ‖movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G n r m + ν active greg Jleft Jright diagonal u v a b center‖ = + (movingTemplateMaskedSymmetrizedEnergy P hP outside μ childBound pivotBound V F φ G n r m + ν active greg Jleft Jright diagonal u v a b center).re := by + unfold movingTemplateMaskedSymmetrizedEnergy + apply mixedExternalAverage_norm_eq_re ν hν + · intro s y x z + have h := (movingTemplateExternalMultiplier_nonneg P hP n r m active outside greg s φ + hφ Jleft Jright diagonal y x z).2 + rw [← h] + simp only [← Complex.ofReal_pow, ← Complex.ofReal_mul, Complex.ofReal_im] + · intro s y x z + have h := movingTemplateExternalMultiplier_nonneg P hP n r m active outside greg s φ + hφ Jleft Jright diagonal y x z + rw [← h.2] + simp only [← Complex.ofReal_pow, ← Complex.ofReal_mul, Complex.ofReal_re] + exact mul_nonneg (sq_nonneg _) h.1 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3866464914830947c499d079ead7f925ebfe0f5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateTransfer.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateTransferSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullTransformTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateTransferRaw + +namespace OAI + +/-! # One giant-prior step for the original restored coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance transferFinalSum_prime {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, Fact (q j).Prime] [∀ i, Fact (p i).Prime] (i : J ⊕ I) : + Fact (Sum.elim q p i).Prime := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +local instance transferFinalSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +/-- The support fields in the full Fourier transfer follow from the +original coefficient. Compensation retains its original independent law; +`α` contains the surviving external priors. -/ +theorem movingTemplate_prior_transfer {σ A : Type} [Fintype σ] [Fintype A] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass P φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (X : A → ℕ) (hX : ∀ a, (X a).Prime) + (y : A → MovingRegularSlot n r m → σ) (v : A → ℤ) (α : A → ℂ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ a x, ggiant (X a) (-x) = conj (ggiant (X a) x)) + (N H T : ℕ) (hv : ∀ a, (v a).natAbs ≤ N) + (hH : ∀ a, X a * (∏ i, value (y a i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p, p ∈ I → + 2 * N * H ≤ T * (p * ∏ i, value (u i))) + (hlarge : ∀ a q, q.Prime → q ∣ X a * (∏ i, value (y a i)) → T < q) : + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let _ : ∀ a i, Fact (((value ∘ y a) i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let greg := normalizedResidueFamily sets + let U := fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, value (u i) + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let _ : ∀ a i, NeZero (L a i) := fun a i => by + cases i with + | inl _ => exact ⟨(hX a).ne_zero⟩ + | inr j => exact ⟨(hvalue (y a j)).ne_zero⟩ + let gL := fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + Real.exp (-smoothGiantLogNormalizer P φ (G (n + 1))) * + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, ((∏ i, μ n (u i) : ℝ) : ℂ) * + ∑ p : P, (smoothGiantPrior P φ (G (n + 1)) p : ℂ) * + ∑ a, W u p a * movingTaggedTransform + (Sum.elim (fun b : Bool => if b then (p : ℕ) else X a) + (value ∘ movingRestoreSample n r m u (y a))) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod (v a)‖ ^ 2 ≤ + (∑ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) * (U u : ℝ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + (pivotDiagonal (fun a => ∏ i, L a i) v + (movingRegularCoefficient L gL outside.prod (U u) v (W u) p)).re) + + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, (((∏ i, μ n (u i)) * (U u : ℝ) : ℝ) : ℂ) * + ∑ s ∈ transferFrequencyRange T, ∑ a, ∑ b, + if validTransferredPivot I + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) then + let p := reconstructedPivot + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) + (φ (Real.log p - G (n + 1)) : ℂ) * W u p a * conj (W u p b) * + movingRegularTransform (Sum.elim (L a) (L b)) + (movingSumFactors (L a) (L b) (gL a) (gL b)) outside.prod s + else 0‖ := by + let greg := normalizedResidueFamily sets + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + have ht := movingTemplate_prior_transfer_raw value hvalue outside μ childBound pivotBound V F + φ G n r m P I hP hPI hI hφ hpos hμ hμmass X hX y v α sets hsets hcard ggiant favorable + hgiant N H T hv hH hscale hlarge + have hsum := movingOneGiant_restored_average value (fun z => (hvalue z).ne_zero) n r m + P (fun p => (hP p p.property).ne_zero) X (fun a => (hX a).ne_zero) y v outside.prod + greg ggiant favorable (fun u => ((∏ i, μ n (u i) : ℝ) : ℂ)) + (fun p => (smoothGiantPrior P φ (G (n + 1)) p : ℂ)) (fun u p a => W u p a) + exact (congrArg (fun z : ℂ => + Real.exp (-smoothGiantLogNormalizer P φ (G (n + 1))) * ‖z‖ ^ 2) hsum).le.trans ht + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateTransferRaw.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateTransferRaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d4ad0cf31e9e5e3a301c7bf050b8ba47fdc284d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateTransferRaw.lean @@ -0,0 +1,155 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateWeightedSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingFullTransformTransfer +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOneGiant + +namespace OAI + +/-! # One giant-prior step for the original restored coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +local instance transferTemplateSum_prime {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, Fact (q j).Prime] [∀ i, Fact (p i).Prime] (i : J ⊕ I) : + Fact (Sum.elim q p i).Prime := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +local instance transferTemplateSum_neZero {J I : Type*} (q : J → ℕ) (p : I → ℕ) + [∀ j, NeZero (q j)] [∀ i, NeZero (p i)] (i : J ⊕ I) : + NeZero (Sum.elim q p i) := by + cases i <;> dsimp only [Sum.elim] <;> infer_instance + +/-- The support fields in the full Fourier transfer follow from the +original coefficient. Compensation retains its original independent law; +`α` contains the surviving external priors. -/ +theorem movingTemplate_prior_transfer_raw {σ A : Type} [Fintype σ] [Fintype A] + (value : σ → ℕ) (hvalue : ∀ a, (value a).Prime) + (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (P I : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) (hPI : P ⊆ I) + (hI : ∀ p ∈ I, 0 < p) (hφ : ∀ x, 0 ≤ φ x) + (hpos : 0 < smoothGiantMass P φ (G (n + 1))) + (hμ : ∀ a, 0 ≤ μ n a) (hμmass : ∑ a, μ n a = 1) + (X : A → ℕ) (hX : ∀ a, (X a).Prime) + (y : A → MovingRegularSlot n r m → σ) (v : A → ℤ) (α : A → ℂ) + (sets : ∀ q : ℕ, Finset (ZMod q)) + (hsets : ∀ a, (sets (value a)).Nonempty) + (hcard : ∀ a, (sets (value a)).card < value a) + (ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) + (hgiant : ∀ a x, ggiant (X a) (-x) = conj (ggiant (X a) x)) + (N H T : ℕ) (hv : ∀ a, (v a).natAbs ≤ N) + (hH : ∀ a, X a * (∏ i, value (y a i)) ≤ H) + (hscale : ∀ (u : TreeLeafIndex n × Fin 4 → σ), (∏ i, μ n (u i)) ≠ 0 → ∀ p, p ∈ I → + 2 * N * H ≤ T * (p * ∏ i, value (u i))) + (hlarge : ∀ a q, q.Prime → q ∣ X a * (∏ i, value (y a i)) → T < q) : + let _ : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let _ : ∀ a i, Fact (((value ∘ y a) i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let greg := normalizedResidueFamily sets + let U := fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, value (u i) + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let _ : ∀ a i, NeZero (L a i) := fun a i => by + cases i with + | inl _ => exact ⟨(hX a).ne_zero⟩ + | inr j => exact ⟨(hvalue (y a j)).ne_zero⟩ + let gL := fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable + let Q := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantModuli (p : ℕ) (value ∘ u) + let _ : ∀ u p i, NeZero (Q u p i) := fun u p i => by + cases i with + | inl _ => exact ⟨(hP p p.property).ne_zero⟩ + | inr j => exact ⟨(hvalue (u j)).ne_zero⟩ + let gQ := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantFactors (p : ℕ) (value ∘ u) greg ggiant favorable + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + Real.exp (-smoothGiantLogNormalizer P φ (G (n + 1))) * + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, ((∏ i, μ n (u i) : ℝ) : ℂ) * + ∑ p : P, (smoothGiantPrior P φ (G (n + 1)) p : ℂ) * + ∑ a, W u p a * movingRegularTransform (Sum.elim (Q u p) (L a)) + (movingSumFactors (Q u p) (L a) (gQ u p) (gL a)) outside.prod (v a)‖ ^ 2 ≤ + (∑ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) * (U u : ℝ) * + ∑ p ∈ I, φ (Real.log p - G (n + 1)) * + (pivotDiagonal (fun a => ∏ i, L a i) v + (movingRegularCoefficient L gL outside.prod (U u) v (W u) p)).re) + + ‖∑ u : TreeLeafIndex n × Fin 4 → σ, (((∏ i, μ n (u i)) * (U u : ℝ) : ℝ) : ℂ) * + ∑ s ∈ transferFrequencyRange T, ∑ a, ∑ b, + if validTransferredPivot I + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) then + let p := reconstructedPivot + (v a * (∏ i, L b i) - v b * (∏ i, L a i)) (s * U u) + (φ (Real.log p - G (n + 1)) : ℂ) * W u p a * conj (W u p b) * + movingRegularTransform (Sum.elim (L a) (L b)) + (movingSumFactors (L a) (L b) (gL a) (gL b)) outside.prod s + else 0‖ := by + let : ∀ a, Fact (X a).Prime := fun a => ⟨hX a⟩ + let : ∀ a, Fact (value a).Prime := fun a => ⟨hvalue a⟩ + let : ∀ a i, Fact (((value ∘ y a) i)).Prime := fun a i => ⟨hvalue (y a i)⟩ + let greg := normalizedResidueFamily sets + let U := fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, value (u i) + let Q := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantModuli (p : ℕ) (value ∘ u) + let L := fun a => movingOneGiantModuli (X a) (value ∘ y a) + let : ∀ (u : TreeLeafIndex n × Fin 4 → σ) (p : P) i, Fact (Q u p i).Prime := by + intro u p i + cases i with + | inl _ => exact ⟨hP p p.property⟩ + | inr j => exact ⟨hvalue (u j)⟩ + let gQ := fun (u : TreeLeafIndex n × Fin 4 → σ) (p : P) => + movingOneGiantFactors (p : ℕ) (value ∘ u) greg ggiant favorable + let : ∀ a i, Fact (L a i).Prime := fun a i => by + cases i <;> dsimp only [L, movingOneGiantModuli, Sum.elim, Function.comp_apply] <;> infer_instance + let : ∀ a i, NeZero (L a i) := fun a i => by infer_instance + let gL := fun a => movingOneGiantFactors (X a) (value ∘ y a) greg ggiant favorable + let W := movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m v α X y + have hprod (a : A) : (∏ i, L a i) = X a * ∏ i, value (y a i) := + movingOneGiantModuli_product (X a) (value ∘ y a) + have hQprod u p : (∏ i, Q u p i) = (p : ℕ) * U u := + movingOneGiantModuli_product (p : ℕ) (value ∘ u) + have hs u p a (h : W u p a ≠ 0) := + movingTemplateTransferWeight_support value outside μ childBound pivotBound V F φ G + n r m v α X y u p a h + have hgL a i x : gL a i (-x) = conj (gL a i x) := + movingOneGiantFactors_neg (X a) (value ∘ y a) greg ggiant favorable + (hgiant a) (fun j x => by + dsimp only [greg] + rw [normalizedResidueFamily_eq] + exact normalizedResidueTransform_neg _ x) i x + have ht := smoothGiantPrior_full_transform_transfer + (Y := TreeLeafIndex n × Fin 4 → σ) (A := A) + (J := Unit ⊕ (TreeLeafIndex n × Fin 4)) (H := Unit ⊕ MovingRegularSlot n r m) P I hP hPI hI φ (G (n + 1)) hφ hpos + (fun u : TreeLeafIndex n × Fin 4 → σ => ∏ i, μ n (u i)) + (fun u => Finset.prod_nonneg (fun i _ => hμ (u i))) + (by rw [← Fintype.prod_sum]; simp only [hμmass, Finset.prod_const_one]) U + (fun u => Finset.prod_pos (fun i _ => (hvalue (u i)).pos)) Q gQ hQprod (.inl ()) + (fun u p i => match i with | .inl _ => ∅ | .inr j => sets (value (u j))) + (fun u p x => by + change ‖if favorable (p : ℕ) then complexUnitPhase (ggiant p x) else 0‖ ≤ 1 + split_ifs + · exact complexUnitPhase_norm_le _ + · simp) + (fun u p i hi => by + cases i with + | inl i => cases i; exact (hi rfl).elim + | inr j => exact normalizedResidueFamily_eq sets (value (u j))) + (fun u p i hi => by + cases i with + | inl i => cases i; exact (hi rfl).elim + | inr j => exact hsets (u j)) + (fun u p i hi => by + cases i with + | inl i => cases i; exact (hi rfl).elim + | inr j => exact hcard (u j)) (fun _ => L) (fun _ => gL) (fun _ => hgL) (fun _ => outside.prod) (fun _ => v) W + (fun u p a hw => ⟨(hs u p a hw).1, (hs u p a hw).2.1⟩) + (fun u p _ a hw => by + have h := hs u p a hw + refine ⟨h.2.2.1, ?_, h.2.2.2.2⟩ + have hc := h.2.2.2.1 + change (∏ i, L a i).Coprime (∏ i, movingOneGiantModuli p (value ∘ u) i) at hc + simpa only [L, U, movingOneGiantModuli_product, Function.comp_apply] using hc) + N H T (fun _ _ _ a _ => hv a) (fun _ _ _ a _ => (hprod a).trans_le (hH a)) + hscale (fun _ a q hq hd => hlarge a q hq ((hprod a) ▸ hd)) + with_reducible exact ht + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateTransferSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateTransferSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..7062afb437680e83bcc5a39234f3cf78e876f7ba --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateTransferSupport.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPairedTransform +import OAI.NumberTheory.Ostmann.Arithmetic.MovingChildListSupport + +namespace OAI + +/-! # Transfer support derived from nonzero original template coefficients -/ + +namespace Ostmann +open scoped Classical BigOperators + +private theorem indexed_coprime_of_list {I : Type*} (p : I → ℕ) (L : List I) + (hcover : ∀ i, i ∈ L) (h : (L.map p).Pairwise Nat.Coprime) : + Pairwise (fun i j => (p i).Coprime (p j)) := by + have h' : L.Pairwise (fun i j => i ≠ j → (p i).Coprime (p j)) := + (List.pairwise_map.mp h).imp (fun {i j} hij (_ : i ≠ j) => hij) + have hflip : L.Pairwise (flip (fun i j => i ≠ j → (p i).Coprime (p j))) := + h'.imp (fun {i j} hij (hji : j ≠ i) => (hij hji.symm).symm) + intro i j hij + exact h'.forall_of_forall_of_flip (fun a _ haa => (haa rfl).elim) hflip + (hcover i) (hcover j) hij + +/-- The complete current Fourier slots inherit pairwise and outside +coprimality directly from the support of their coefficient. -/ +theorem movingTemplateCoefficient_transfer_support {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (y : MovingRegularSlot n r m → σ) (q : Bool → ℕ) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n r m s y (q true) (q false) ≠ 0) : + Pairwise (fun i j => (Sum.elim q (value ∘ y) i).Coprime (Sum.elim q (value ∘ y) j)) ∧ + ∀ i, outside.prod.Coprime (Sum.elim q (value ∘ y) i) := by + let L : List (Bool ⊕ MovingRegularSlot n r m) := + [.inl true, .inl false] ++ (movingTemplateSlotList n r m).map Sum.inr + let p := Sum.elim q (value ∘ y) + have hcover : ∀ i, i ∈ L := by + intro i + cases i with + | inl b => cases b <;> simp [L] + | inr i => exact List.mem_append_right _ (List.mem_map.mpr + ⟨i, mem_movingTemplateSlotList n r m i, rfl⟩) + have hs := (movingFrequencyCoefficient_nonzero_support value outside μ childBound + pivotBound V F φ G n s _ _ (q true) (q false) h).1 + have hs' : (L.map p ++ outside).Pairwise Nat.Coprime := by + simpa only [L, p, List.map_append, List.map_cons, List.map_nil, List.map_map, + List.cons_append, List.nil_append, Sum.elim_inl, Sum.elim_inr, + movingTemplateSlotList, flattenMovingSlots_map, Function.comp_def] using hs + obtain ⟨hp, _, ho⟩ := List.pairwise_append.mp hs' + refine ⟨indexed_coprime_of_list p L hcover hp, ?_⟩ + intro i + apply Nat.coprime_list_prod_left_iff.mpr + intro d hd + exact (ho (p i) (List.mem_map.mpr ⟨i, hcover i, rfl⟩) d hd).symm + +/-- Restrict the full support to the two pieces of a restored child. +This supplies the exact support fields of the giant transfer. -/ +theorem movingTemplateCoefficient_restored_support {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (u : TreeLeafIndex n × Fin 4 → σ) (y : MovingRegularSlot n r m → σ) + (p X : ℕ) + (h : movingTemplateCoefficient value outside μ childBound pivotBound V F φ G + n (4 + r) m s (movingRestoreSample n r m u y) p X ≠ 0) : + let Q := Sum.elim (fun _ : Unit => p) (value ∘ u) + let L := Sum.elim (fun _ : Unit => X) (value ∘ y) + Pairwise (fun i j => (Q i).Coprime (Q j)) ∧ + (∀ i, outside.prod.Coprime (Q i)) ∧ + Pairwise (fun i j => (L i).Coprime (L j)) ∧ + (∏ i, L i).Coprime (∏ i, Q i) ∧ + (∀ i, outside.prod.Coprime (L i)) := by + let q : Bool → ℕ := fun b => if b then p else X + have hs := movingTemplateCoefficient_transfer_support value outside μ childBound pivotBound V + F φ G n (4 + r) m s (movingRestoreSample n r m u y) q h + have he := movingTransferSlotEquiv_values value n r m u y p X + let f := Sum.elim (Sum.elim (fun _ : Unit => p) (value ∘ u)) + (Sum.elim (fun _ : Unit => X) (value ∘ y)) + have hp : Pairwise (fun i j => (f i).Coprime (f j)) := by + intro i j hij + have hx := hs.1 ((movingTransferSlotEquiv n r m).injective.ne hij) + change (Sum.elim q (value ∘ movingRestoreSample n r m u y) + (movingTransferSlotEquiv n r m i)).Coprime + (Sum.elim q (value ∘ movingRestoreSample n r m u y) + (movingTransferSlotEquiv n r m j)) at hx + rw [congrFun he i, congrFun he j] at hx + exact hx + have hd : ∀ i, outside.prod.Coprime (f i) := by + intro i + have hx := hs.2 (movingTransferSlotEquiv n r m i) + rw [congrFun he i] at hx + exact hx + dsimp only + refine ⟨?_, ?_, ?_, ?_, ?_⟩ + · intro i j hij + exact hp (fun he => hij (Sum.inl.inj he)) + · intro i + exact hd (.inl i) + · intro i j hij + exact hp (fun he => hij (Sum.inr.inj he)) + · apply Nat.coprime_prod_left_iff.mpr + intro i _ + apply Nat.coprime_prod_right_iff.mpr + intro j _ + exact hp (Sum.inr_ne_inl) + · intro i + exact hd (.inr i) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateWeightedSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateWeightedSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..9953ff3d9296e43eb85d2f6af155485f0fc0633b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTemplateWeightedSupport.lean @@ -0,0 +1,41 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateTransferSupport + +namespace OAI + +/-! # The original external weight multiplying a restored coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingTemplateTransferWeight {σ A : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (v : A → ℤ) (α : A → ℂ) (X : A → ℕ) + (y : A → MovingRegularSlot n r m → σ) + (u : TreeLeafIndex n × Fin 4 → σ) (p : ℕ) (a : A) : ℂ := + α a * movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m + (v a) (movingRestoreSample n r m u (y a)) p (X a) + +theorem movingTemplateTransferWeight_support {σ A : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (F : MovingSlotState σ → ℤ → ℂ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) + (v : A → ℤ) (α : A → ℂ) (X : A → ℕ) + (y : A → MovingRegularSlot n r m → σ) + (u : TreeLeafIndex n × Fin 4 → σ) (p : ℕ) (a : A) + (h : movingTemplateTransferWeight value outside μ childBound pivotBound V F φ G n r m + v α X y u p a ≠ 0) : + let Q := Sum.elim (fun _ : Unit => p) (value ∘ u) + let L := Sum.elim (fun _ : Unit => X a) (value ∘ y a) + Pairwise (fun i j => (Q i).Coprime (Q j)) ∧ + (∀ i, outside.prod.Coprime (Q i)) ∧ + Pairwise (fun i j => (L i).Coprime (L j)) ∧ + (∏ i, L i).Coprime (∏ i, Q i) ∧ + (∀ i, outside.prod.Coprime (L i)) := + movingTemplateCoefficient_restored_support value outside μ childBound pivotBound V F φ G + n r m (v a) u (y a) p (X a) (right_ne_zero_of_mul h) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTopCells.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTopCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..a957bba6203e2132a97b473d8d35d4c304ac3a4b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTopCells.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSupportCells + +namespace OAI + +/-! # Actual top-giant residue cells for the moving arithmetic support -/ + +namespace Ostmann +open scoped Classical + +theorem MovingSlotData.formulaNodes_frequencies {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (L R : HistoryFormula Bool) : + ∀ f ∈ T.formulaNodes value hvalue childBound pivotBound hf L R, + f.guard.right ≠ 0 ∧ f.guard.root ≠ 0 := by + induction T generalizing L R with + | leaf s regular => simp [formulaNodes] + | node s CL CR u left right ihL ihR => + intro f hmem + rcases List.mem_cons.mp hmem with h | h + · subst f + exact ⟨hf.2.2.root, hf.1⟩ + · rcases List.mem_append.mp h with h | h + · exact ihL hf.2.1 _ _ f h + · exact ihR hf.2.2 _ _ f h + +def topGiantInput (XL XR : ℕ) (b : Bool) : ℤ := if b then XR else XL + +/-- The period depends only on the fixed small data and frequencies. -/ +noncomputable def movingTopPeriod {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) : ℕ := + movingArithmeticPeriod (T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true)) + +theorem movingTopPeriod_pos {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) : + 0 < movingTopPeriod value hvalue childBound pivotBound T hf := + movingArithmeticPeriod_pos _ (T.formulaNodes_frequencies value hvalue childBound pivotBound hf _ _) + +noncomputable def movingTopRootCuts {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR : ℕ) : Finset ℝ := + movingArithmeticRootCuts + (T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true)) + (topGiantInput 0 XR) false + +/-- With the other giant fixed, the original arithmetic support is constant +on the constructed residue and root cells. This also covers empty depth. -/ +theorem moving_top_support_cells {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XL YL XR : ℕ) + (hres : (XL : ℤ) ≡ (YL : ℤ) [ZMOD movingTopPeriod value hvalue childBound pivotBound T hf]) + (hcell : rootCellCode (movingTopRootCuts value hvalue childBound pivotBound T hf XR) (XL : ℝ) = + rootCellCode (movingTopRootCuts value hvalue childBound pivotBound T hf XR) (YL : ℝ)) : + T.ArithmeticSupport value childBound pivotBound XL XR ↔ + T.ArithmeticSupport value childBound pivotBound YL XR := by + let nodes := T.formulaNodes value hvalue childBound pivotBound hf (.prime false) (.prime true) + let a := topGiantInput 0 XR + have hin (Z : ℕ) : movingGiantUpdate a false (Z : ℤ) = topGiantInput Z XR := by + funext b + cases b <;> simp [movingGiantUpdate, Function.update, a, topGiantInput] + have hmod : ∀ i, movingGiantUpdate a false (XL : ℤ) i ≡ + movingGiantUpdate a false (YL : ℤ) i [ZMOD movingArithmeticPeriod nodes] := by + intro i + rw [hin, hin] + cases i + · exact hres + · exact Int.ModEq.refl _ + have hh := movingFormulaNodes_holds_invariant nodes a false XL YL hmod hcell + rw [hin, hin] at hh + have hleft := T.formulaNodes_iff value hvalue childBound pivotBound hf XL XR + (.prime false) (.prime true) (topGiantInput XL XR) + (by simp [topGiantInput]) (by simp [topGiantInput]) + have hright := T.formulaNodes_iff value hvalue childBound pivotBound hf YL XR + (.prime false) (.prime true) (topGiantInput YL XR) + (by simp [topGiantInput]) (by simp [topGiantInput]) + exact hleft.symm.trans (hh.trans hright) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransferSlots.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransferSlots.lean new file mode 100644 index 0000000000000000000000000000000000000000..78ed9e45dd9d4342246b4bf37dbed87feb3d4b60 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransferSlots.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplatePrimeCore +import OAI.NumberTheory.Ostmann.Characters.PermutedAdditiveCancellation + +namespace OAI + +/-! # Reindexing the original pivot, compensation, and surviving slots -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- Reindexing changes neither the cofactor nor its local transform. -/ +theorem movingRegularTransform_equiv {I J : Type*} [Fintype I] [Fintype J] + (e : I ≃ J) (p : J → ℕ) [∀ j, NeZero (p j)] + (g : ∀ j, ZMod (p j) → ℂ) (D : ℕ) (s : ℤ) : + let _ : ∀ i, NeZero (p (e i)) := fun _i => inferInstance + movingRegularTransform (fun i => p (e i)) (fun i => g (e i)) D s = + movingRegularTransform p g D s := by + dsimp only + unfold movingRegularTransform + simp_rw [tupleCofactor_equiv e p (fun j => NeZero.ne (p j))] + exact e.prod_comp (fun j => g j ((s : ZMod (p j)) * + ((D * tupleCofactor p j : ℕ) : ZMod (p j))⁻¹)) + +/-- The first block is the removed giant and compensation. The second is +one surviving giant and its remaining regular slots. -/ +def movingTransferSlotEquiv (n r m : ℕ) : + ((Unit ⊕ (TreeLeafIndex n × Fin 4)) ⊕ (Unit ⊕ MovingRegularSlot n r m)) ≃ + (Bool ⊕ MovingRegularSlot n (4 + r) m) where + toFun + | .inl (.inl _) => .inl true + | .inl (.inr i) => .inr (movingReverseTemplate n r m (.inl i)) + | .inr (.inl _) => .inl false + | .inr (.inr i) => .inr (movingReverseTemplate n r m (.inr i)) + invFun + | .inl true => .inl (.inl ()) + | .inl false => .inr (.inl ()) + | .inr j => match (movingReverseTemplate n r m).symm j with + | .inl i => .inl (.inr i) + | .inr i => .inr (.inr i) + left_inv := by + intro i + rcases i with ((u | i) | (u | i)) + · cases u; rfl + · change (match (movingReverseTemplate n r m).symm (movingReverseTemplate n r m (.inl i)) with + | .inl j => Sum.inl (Sum.inr j) + | .inr j => Sum.inr (Sum.inr j)) = _ + rw [Equiv.symm_apply_apply] + · cases u; rfl + · change (match (movingReverseTemplate n r m).symm (movingReverseTemplate n r m (.inr i)) with + | .inl j => Sum.inl (Sum.inr j) + | .inr j => Sum.inr (Sum.inr j)) = _ + rw [Equiv.symm_apply_apply] + right_inv := by + intro i + rcases i with (b | j) + · cases b <;> rfl + · have h := (movingReverseTemplate n r m).apply_symm_apply j + cases he : (movingReverseTemplate n r m).symm j with + | inl k => + simp only [he] at h ⊢ + exact congrArg Sum.inr h + | inr k => + simp only [he] at h ⊢ + exact congrArg Sum.inr h + +@[simp] theorem movingTransferSlotEquiv_pivot (n r m : ℕ) : + movingTransferSlotEquiv n r m (.inl (.inl ())) = .inl true := rfl + +@[simp] theorem movingTransferSlotEquiv_old_giant (n r m : ℕ) : + movingTransferSlotEquiv n r m (.inr (.inl ())) = .inl false := rfl + +/-- The reindexing inserts precisely the same sampled compensation vector +which appears in the two child coefficients. -/ +theorem movingTransferSlotEquiv_values {A : Type*} (value : A → ℕ) (n r m : ℕ) + (u : TreeLeafIndex n × Fin 4 → A) (y : MovingRegularSlot n r m → A) (XL XR : ℕ) : + (fun i => Sum.elim (fun b => if b then XL else XR) + (value ∘ movingRestoreSample n r m u y) (movingTransferSlotEquiv n r m i)) = + Sum.elim (Sum.elim (fun _ : Unit => XL) (value ∘ u)) + (Sum.elim (fun _ : Unit => XR) (value ∘ y)) := by + funext i + rcases i with ((j | j) | (j | j)) + · rfl + · change value (movingRestoreSample n r m u y (movingReverseTemplate n r m (.inl j))) = value (u j) + simp only [movingRestoreSample, Function.comp_apply, Equiv.symm_apply_apply, Sum.elim_inl] + · rfl + · change value (movingRestoreSample n r m u y (movingReverseTemplate n r m (.inr j))) = value (y j) + simp only [movingRestoreSample, Function.comp_apply, Equiv.symm_apply_apply, Sum.elim_inr] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransferSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransferSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..ce809da3674872e456e3cdd90aef097aa67598e4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransferSupport.lean @@ -0,0 +1,167 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRootReconstruction +import OAI.NumberTheory.Ostmann.Construction.TransferOutputSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSmallFrequencyUnits + +namespace OAI + +/-! # Support inherited by the reconstructed giant-only transfer -/ + +namespace Ostmann +open scoped Classical + +/-- The integer quotient satisfies the full rigidity guard. Its frequency +unit is derived from prime sizes, rather than assumed as a new transfer input. -/ +theorem moving_reconstructed_node_valid {σ : Type*} + (value : σ → ℕ) (childBound pivotBound : ℕ → ℕ) + (x : MovingSlotState σ) (I : Finset ℕ) (s v w : ℤ) (V : ℕ) + (hI : ∀ p ∈ I, 0 < p) + (h : validTransferredPivot I + (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) + (s * x.compensation value)) + (hV : s.natAbs ≤ V) + (hlarge : ∀ q, q.Prime → q ∣ x.rightProduct value → V < q) + (hpivot : ∀ p ∈ I, p * x.compensation value ≤ pivotBound x.depth) + (hv : v.natAbs ≤ childBound x.depth) (hw : w.natAbs ≤ childBound x.depth) + (hgap : 2 * pivotBound x.depth * childBound x.depth < x.rightProduct value) + (hunit : ∀ p ∈ I, (p * x.compensation value).Coprime w.natAbs) : + let p := reconstructedPivot + (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) + (s * x.compensation value) + ValidTransferNode (movingSlotSystem value childBound pivotBound) x s v w + (p * x.compensation value) ∧ 0 < x.compensation value := by + dsimp only + let p := reconstructedPivot + (v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ)) + (s * x.compensation value) + have hs : s ≠ 0 := left_ne_zero_of_mul h.1 + have hU : 0 < x.compensation value := Nat.pos_of_ne_zero (by + intro hz + exact h.1 (by simp only [hz, Nat.cast_zero, mul_zero])) + have hR := large_prime_factors_coprime_frequency (x.rightProduct value) s hs + (fun q hq hd => hV.trans_lt (hlarge q hq hd)) + have hRu : IsCoprime s (x.rightProduct value : ℤ) := by + simpa only [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast] + using hR.symm + have he := validTransferredPivot_equation I _ _ h + refine ⟨⟨hs, hRu, ?_, Nat.mul_pos (hI p h.2.2.2) hU, + hpivot p h.2.2.2, hv, hw, hgap, hunit p h.2.2.2⟩, hU⟩ + change v * (x.rightProduct value : ℤ) - w * (x.leftProduct value : ℤ) = + s * ((p * x.compensation value : ℕ) : ℤ) + rw [Nat.cast_mul] + calc + _ = (s * (x.compensation value : ℤ)) * (p : ℤ) := he + _ = _ := by ring + +/-- The two branch priors already supply their internal and outside tests. +The only new pairwise requirement is the cross-product coprimality. -/ +theorem pairwise_coprime_merge_shared (A B Y : List ℕ) + (hA : (A ++ Y).Pairwise Nat.Coprime) + (hB : (B ++ Y).Pairwise Nat.Coprime) (hAB : A.prod.Coprime B.prod) : + (A ++ B ++ Y).Pairwise Nat.Coprime := by + obtain ⟨hAA, hYY, hAY⟩ := List.pairwise_append.mp hA + obtain ⟨hBB, _, hBY⟩ := List.pairwise_append.mp hB + apply List.pairwise_append.mpr + refine ⟨List.pairwise_append.mpr ⟨hAA, hBB, ?_⟩, hYY, ?_⟩ + · intro a ha b hb + exact (Nat.coprime_list_prod_right_iff.mp + (Nat.coprime_list_prod_left_iff.mp hAB a ha)) b hb + · intro a ha y hy + rcases List.mem_append.mp ha with ha | ha + · exact hAY a ha y hy + · exact hBY a ha y hy + +/-- The root's pairwise test follows from the two old branch supports and +the nonzero transfer equation, since every shared prime is too large to +divide the new frequency. -/ +theorem moving_transferred_current_pairwise {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) {n : ℕ} + (s : ℤ) (CL CR u : List σ) (l r : MovingSlotData σ n) (XL XR P : ℕ) + (hs : s ≠ 0) (v w : ℤ) + (hrel : v * ((XR * MovingSlotReversal.naturalProduct value CR : ℕ) : ℤ) - + w * ((XL * MovingSlotReversal.naturalProduct value CL : ℕ) : ℤ) = s * P) + (hleft : ((XL :: CL.map value) ++ outside).Pairwise Nat.Coprime) + (hright : ((XR :: CR.map value) ++ outside).Pairwise Nat.Coprime) + (hsmall : ∀ q, q.Prime → q ∣ XL * MovingSlotReversal.naturalProduct value CL → + q ∣ XR * MovingSlotReversal.naturalProduct value CR → s.natAbs < q) + (hunit : (XL * MovingSlotReversal.naturalProduct value CL).Coprime P) : + ((MovingSlotData.node s CL CR u l r).currentSlots value XL XR ++ outside).Pairwise + Nat.Coprime := by + have hLR := transferred_products_coprime + (XL * MovingSlotReversal.naturalProduct value CL) + (XR * MovingSlotReversal.naturalProduct value CR) v w s P hs hrel hsmall + (common_prime_pivot_unit P _ _ hunit) + have hp := pairwise_coprime_merge_shared (XL :: CL.map value) (XR :: CR.map value) + outside hleft hright (by simpa only [List.prod_cons, MovingSlotReversal.naturalProduct] + using hLR) + have he : ((XL :: CL.map value) ++ (XR :: CR.map value) ++ outside).Perm + ((MovingSlotData.node s CL CR u l r).currentSlots value XL XR ++ outside) := by + apply List.perm_iff_count.mpr + intro a + simp only [MovingSlotData.currentSlots, MovingSlotData.regularSlots, List.map_append, + List.count_cons, List.count_append] + omega + exact (he.pairwise_iff (R := Nat.Coprime) (fun h => h.symm)).mp hp + +/-- All current giant tests, including descendant frequencies, follow from +pairwise support and the same large-prime separation used at the root. -/ +theorem moving_local_support_of_large {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) {n : ℕ} + (T : MovingSlotData σ n) (XL XR : ℕ) + (hp : (T.currentSlots value XL XR ++ outside).Pairwise Nat.Coprime) + (hf : T.Frequencies (fun s => s ≠ 0 ∧ + ∀ q, q.Prime → q ∣ XL * XR → s.natAbs < q)) : + movingLocalSupport value outside ⟨n, T, XL, XR⟩ := by + have cast_coprime {a b : ℕ} (h : a.Coprime b) : IsCoprime (a : ℤ) (b : ℤ) := by + exact Int.isCoprime_iff_gcd_eq_one.mpr (by simpa only [Int.gcd_natCast_natCast] using h) + have giant_frequency (X : ℕ) (hX : X ∣ XL * XR) : + IsCoprime (X : ℤ) T.frequencyProduct := by + apply (T.frequencies_isCoprime (X : ℤ)).mp + apply hf.mono + intro s hs + have hu := large_prime_factors_coprime_frequency X s hs.1 + (fun q hq hqd => hs.2 q hq (hqd.trans hX)) + simpa only [Int.isCoprime_iff_gcd_eq_one, Int.gcd_def, Int.natAbs_natCast] using hu + have hXL := giant_frequency XL (dvd_mul_right XL XR) + have hXR := giant_frequency XR (dvd_mul_left XR XL) + have hpair := hp + change (XL :: XR :: (T.regularSlots.map value ++ outside)).Pairwise Nat.Coprime at hpair + obtain ⟨hL, htail⟩ := List.pairwise_cons.mp hpair + obtain ⟨hR, _⟩ := List.pairwise_cons.mp htail + have hLreg : XL.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) := by + apply Nat.coprime_list_prod_right_iff.mpr + intro a ha + exact hL a (List.mem_cons_of_mem XR (List.mem_append_left outside ha)) + have hRreg : XR.Coprime (MovingSlotReversal.naturalProduct value T.regularSlots) := by + apply Nat.coprime_list_prod_right_iff.mpr + intro a ha + exact hR a (List.mem_append_left outside ha) + have hLout : XL.Coprime outside.prod := Nat.coprime_list_prod_right_iff.mpr + (fun a ha => hL a (List.mem_cons_of_mem XR (List.mem_append_right _ ha))) + have hRout : XR.Coprime outside.prod := Nat.coprime_list_prod_right_iff.mpr + (fun a ha => hR a (List.mem_append_right _ ha)) + exact ⟨hp, hXL, hXR, cast_coprime hLreg, cast_coprime hRreg, + cast_coprime hLout, cast_coprime hRout⟩ + +/-- In the transfer application the surviving top giants are actual primes. +All the additional descendant-frequency tests are therefore automatic. -/ +theorem moving_local_support_prime_giants {σ : Type*} + (value : σ → ℕ) (outside : List ℕ) {n : ℕ} + (T : MovingSlotData σ n) (XL XR V : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) (hVL : V < XL) (hVR : V < XR) + (hp : (T.currentSlots value XL XR ++ outside).Pairwise Nat.Coprime) + (hf : T.Frequencies (fun s => s ≠ 0 ∧ s.natAbs ≤ V)) : + movingLocalSupport value outside ⟨n, T, XL, XR⟩ := by + apply moving_local_support_of_large value outside T XL XR hp + apply hf.mono + intro s hs + refine ⟨hs.1, ?_⟩ + intro q hq hd + rcases hq.dvd_mul.mp hd with hd | hd + · have he : q = XL := ((Nat.dvd_prime hXL).mp hd).resolve_left hq.ne_one + exact he ▸ hs.2.trans_lt hVL + · have he : q = XR := ((Nat.dvd_prime hXR).mp hd).resolve_left hq.ne_one + exact he ▸ hs.2.trans_lt hVR + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransferTransform.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransferTransform.lean new file mode 100644 index 0000000000000000000000000000000000000000..c8a9ab83f1e2e871e22a5e75b7b06cda865f0f14 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransferTransform.lean @@ -0,0 +1,81 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTransferSlots + +namespace OAI + +/-! # The full Fourier transform in the actual transfer slot order -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- A common formula for regular factors and the two marked giant phases. +Using the modulus as an explicit argument makes reindexing independent of +presentation of the dependent residue types. -/ +noncomputable def movingTaggedTransform {I : Type*} [Fintype I] + (p : I → ℕ) (giant : I → Bool) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (D : ℕ) (s : ℤ) : ℂ := + ∏ i, (if giant i then + (fun t => if favorable (p i) then complexUnitPhase (ggiant (p i) t) else 0) + else greg (p i)) + ((s : ZMod (p i)) * ((D * tupleCofactor p i : ℕ) : ZMod (p i))⁻¹) + +theorem movingTaggedTransform_equiv {I J : Type*} [Fintype I] [Fintype J] + (e : I ≃ J) (p : J → ℕ) (hp : ∀ j, p j ≠ 0) (giant : J → Bool) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (D : ℕ) (s : ℤ) : + movingTaggedTransform (p ∘ e) (giant ∘ e) greg ggiant favorable D s = + movingTaggedTransform p giant greg ggiant favorable D s := by + unfold movingTaggedTransform + dsimp only [Function.comp_def] + simp_rw [tupleCofactor_equiv e p hp] + exact e.prod_comp (fun j => (if giant j then + (fun t => if favorable (p j) then complexUnitPhase (ggiant (p j) t) else 0) + else greg (p j)) + ((s : ZMod (p j)) * ((D * tupleCofactor p j : ℕ) : ZMod (p j))⁻¹)) + +/-- Restoring a compensation sample places precisely the extracted giant +and its compensation factors before the surviving giant and regular factors. -/ +theorem movingTaggedTransform_restored {A : Type*} (value : A → ℕ) + (n r m : ℕ) (u : TreeLeafIndex n × Fin 4 → A) + (y : MovingRegularSlot n r m → A) (XL XR : ℕ) + (hXL : XL ≠ 0) (hXR : XR ≠ 0) + (hu : ∀ i, value (u i) ≠ 0) (hy : ∀ i, value (y i) ≠ 0) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) (D : ℕ) (s : ℤ) : + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then XL else XR) + (value ∘ movingRestoreSample n r m u y)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable D s = + movingTaggedTransform + (Sum.elim (Sum.elim (fun _ : Unit => XL) (value ∘ u)) + (Sum.elim (fun _ : Unit => XR) (value ∘ y))) + (Sum.elim (Sum.elim (fun _ : Unit => true) (fun _ => false)) + (Sum.elim (fun _ : Unit => true) (fun _ => false))) greg ggiant favorable D s := by + let p : Bool ⊕ MovingRegularSlot n (4 + r) m → ℕ := + Sum.elim (fun b : Bool => if b then XL else XR) + (value ∘ movingRestoreSample n r m u y) + let t : Bool ⊕ MovingRegularSlot n (4 + r) m → Bool := + Sum.elim (fun _ => true) (fun _ => false) + have hp : ∀ i, p i ≠ 0 := by + intro i + rcases i with (b | i) + · cases b <;> assumption + · change value (movingRestoreSample n r m u y i) ≠ 0 + unfold movingRestoreSample + dsimp only [Function.comp_apply] + cases he : (movingReverseTemplate n r m).symm i with + | inl j => exact hu j + | inr j => exact hy j + have ht : t ∘ movingTransferSlotEquiv n r m = + Sum.elim (Sum.elim (fun _ : Unit => true) (fun _ => false)) + (Sum.elim (fun _ : Unit => true) (fun _ => false)) := by + funext i + rcases i with ((i | i) | (i | i)) <;> rfl + have he := movingTaggedTransform_equiv (movingTransferSlotEquiv n r m) p hp t + greg ggiant favorable D s + rw [ht] at he + have hv := movingTransferSlotEquiv_values value n r m u y XL XR + change p ∘ movingTransferSlotEquiv n r m = _ at hv + rw [hv] at he + exact he.symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransformedIntegerNode.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransformedIntegerNode.lean new file mode 100644 index 0000000000000000000000000000000000000000..28b4f578f42bbd2d8428bb6e11622c77bae56882 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingTransformedIntegerNode.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingTemplateIntegerNode +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOneGiant + +namespace OAI + +/-! # The integer off-diagonal with the full surviving Fourier factor -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The exact node identity retains both giant phases and every regular +Fourier factor. The right side is the off-diagonal in the giant transfer. -/ +theorem movingTemplateCoefficient_transformed_integer_node {σ : Type} [Fintype σ] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (hV : Monotone V) + (F : MovingSlotState σ → ℤ → ℂ) (hF : ∀ x, F x 0 = 0) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (n r m : ℕ) (s : ℤ) + (hsV : s.natAbs ≤ V (n + 1)) + (left right : MovingRegularSlot n r m → σ) (XL XR : ℕ) + (hXL : XL.Prime) (hXR : XR.Prime) + (hVL : V (n + 1) < XL) (hVR : V (n + 1) < XR) + (I : Finset ℕ) (hI : ∀ p ∈ I, 0 < p) + (hφ : ∀ p : ℕ, 0 < p → φ (Real.log p - G (n + 1)) ≠ 0 → p ∈ I) + (hchild : V n ≤ childBound (n + 1)) + (hgap : 2 * pivotBound (n + 1) * childBound (n + 1) < XR * ∏ i, value (right i)) + (hRH : ∀ q, q.Prime → q ∣ XR * (∏ i, value (right i)) → V (n + 1) < q) + (hcomp : ∀ u : TreeLeafIndex n × Fin 4 → σ, (∏ i, μ n (u i)) ≠ 0 → + (∀ p ∈ I, p * (∏ i, value (u i)) ≤ pivotBound (n + 1)) ∧ + (∀ q, q.Prime → q ∣ ∏ i, value (u i) → childBound (n + 1) < q)) + (hleft : ∀ i, value (left i) ≠ 0) (hright : ∀ i, value (right i) ≠ 0) + (greg ggiant : ∀ q : ℕ, ZMod q → ℂ) (favorable : ℕ → Bool) : + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G (n + 1) r m s + (movingTemplatePairSample n r m left right) XL XR * + movingTaggedTransform + (Sum.elim (fun b : Bool => if b then XL else XR) + (value ∘ movingTemplatePairSample n r m left right)) + (Sum.elim (fun _ => true) (fun _ => false)) greg ggiant favorable outside.prod s = + ∑ u : TreeLeafIndex n × Fin 4 → σ, + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * + ∑ v : transferFrequencyRange (V n), ∑ w : transferFrequencyRange (V n), + let LH := XL * ∏ i, value (left i) + let RH := XR * ∏ i, value (right i) + let p := reconstructedPivot (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) + if validTransferredPivot I (v.val * RH - w.val * LH) (s * ∏ i, value (u i)) then + (φ (Real.log p - G (n + 1)) : ℂ) * + movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m v.val + (movingRestoreSample n r m u left) p XL * + star (movingTemplateCoefficient value outside μ childBound pivotBound V F φ G n (4 + r) m w.val + (movingRestoreSample n r m u right) p XR) * + movingTaggedTransform + (Sum.elim (movingOneGiantModuli XL (value ∘ left)) + (movingOneGiantModuli XR (value ∘ right))) + (Sum.elim (Sum.elim (fun _ : Unit => true) (fun _ => false)) + (Sum.elim (fun _ : Unit => true) (fun _ => false))) + greg ggiant favorable outside.prod s + else 0 := by + have hn := movingTemplateCoefficient_integer_node value outside μ childBound pivotBound V hV + F hF φ G n r m s hsV left right XL XR hXL hXR hVL hVR I hI hφ hchild hgap hRH hcomp + have ht := movingTaggedTransform_paired value n r m left right XL XR + hXL.ne_zero hXR.ne_zero hleft hright greg ggiant favorable outside.prod s + rw [hn, Finset.sum_mul] + apply Finset.sum_congr rfl + intro u _ + rw [mul_assoc, Finset.sum_mul] + apply congrArg (fun z : ℂ => + (((∏ i, μ n (u i)) * ((∏ i, value (u i)) : ℝ) : ℝ) : ℂ) * z) + apply Finset.sum_congr rfl + intro v _ + rw [Finset.sum_mul] + apply Finset.sum_congr rfl + intro w _ + dsimp only + split_ifs + · congr 1 + exact ht.symm + · exact zero_mul _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingUnitPeriodBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingUnitPeriodBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..88dbe82bd59b9e35c8c4edbe4d0a6b1931902007 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingUnitPeriodBound.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSignedUnits +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSamplePeriod + +namespace OAI + +/-! # Size of the full giant-unit period, including regular and outside slots -/ + +namespace Ostmann +open scoped Classical + +/-- Bounds the current regular product at every actual state of the tree. -/ +def MovingSlotData.RegularBound {σ : Type*} (value : σ → ℕ) (B : ℕ) : + {n : ℕ} → MovingSlotData σ n → Prop + | _, T@(.leaf _ _) => MovingSlotReversal.naturalProduct value T.regularSlots ≤ B + | _, T@(.node _ _ _ _ left right) => + MovingSlotReversal.naturalProduct value T.regularSlots ≤ B ∧ + left.RegularBound value B ∧ right.RegularBound value B + +def movingGiantUnitExponent : ℕ → ℕ + | 0 => 3 + | n + 1 => (2 ^ (n + 2) - 1) + 4 + 2 * movingGiantUnitExponent n + +theorem MovingSlotData.frequencyProduct_bound {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) (B : ℕ) + (hfreq : T.Frequencies (fun s => s.natAbs ≤ B)) : + T.frequencyProduct.natAbs ≤ B ^ (2 ^ (n + 1) - 1) := by + induction T with + | leaf s regular => simpa [frequencyProduct, Frequencies] using hfreq + | @node n s CL CR u left right ihL ihR => + have he : 1 + (2 ^ (n + 1) - 1) + (2 ^ (n + 1) - 1) = 2 ^ (n + 1 + 1) - 1 := by + have hp : 1 ≤ 2 ^ (n + 1) := Nat.one_le_pow _ _ (by omega) + rw [pow_succ] + omega + simp only [frequencyProduct, Int.natAbs_mul] + calc + _ ≤ B * B ^ (2 ^ (n + 1) - 1) * B ^ (2 ^ (n + 1) - 1) := + Nat.mul_le_mul (Nat.mul_le_mul hfreq.1 (ihL hfreq.2.1)) (ihR hfreq.2.2) + _ = B ^ (1 + (2 ^ (n + 1) - 1) + (2 ^ (n + 1) - 1)) := by + simp only [pow_add, pow_one] + _ = _ := congrArg (B ^ ·) he + +theorem MovingSlotData.frequencyProduct_ne_zero {σ : Type*} {n : ℕ} + (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) : T.frequencyProduct ≠ 0 := by + induction T with + | leaf => exact hf + | node s CL CR u left right ihL ihR => + exact mul_ne_zero (mul_ne_zero hf.1 (ihL hf.2.1)) (ihR hf.2.2) + +theorem movingGiantUnitPeriod_ne_zero {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (outside : List ℕ) (hout : outside.prod ≠ 0) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) : + movingGiantUnitPeriod value outside T ≠ 0 := by + induction T with + | leaf s regular => + exact mul_ne_zero (mul_ne_zero hf (by exact_mod_cast + MovingSlotReversal.naturalProduct_ne_zero value hvalue regular)) (by exact_mod_cast hout) + | node s CL CR u left right ihL ihR => + apply mul_ne_zero + · apply mul_ne_zero + · apply mul_ne_zero + · exact mul_ne_zero (mul_ne_zero + (MovingSlotData.frequencyProduct_ne_zero _ hf) + (by exact_mod_cast MovingSlotReversal.naturalProduct_ne_zero value hvalue (CL ++ CR))) + (by exact_mod_cast hout) + · exact mul_ne_zero hf.1 (by exact_mod_cast MovingSlotReversal.naturalProduct_ne_zero value hvalue u) + · exact ihL hf.2.1 + · exact ihR hf.2.2 + +theorem movingGiantUnitPeriod_bound {σ : Type*} (value : σ → ℕ) (outside : List ℕ) + {n : ℕ} (T : MovingSlotData σ n) (B : ℕ) + (hfreq : T.Frequencies (fun s => s.natAbs ≤ B)) + (hcomp : T.CompensationBound value B) (hregular : T.RegularBound value B) + (hout : outside.prod ≤ B) : + (movingGiantUnitPeriod value outside T).natAbs ≤ B ^ movingGiantUnitExponent n := by + induction T with + | leaf s regular => + simp only [movingGiantUnitPeriod, MovingSlotData.frequencyProduct, Int.natAbs_mul, Int.natAbs_natCast] + have h := Nat.mul_le_mul (Nat.mul_le_mul hfreq hregular) hout + simpa [movingGiantUnitExponent, pow_succ] using h + | @node n s CL CR u left right ihL ihR => + have hfp := MovingSlotData.frequencyProduct_bound (MovingSlotData.node s CL CR u left right) B hfreq + have hl := ihL hfreq.2.1 hcomp.2.1 hregular.2.1 + have hr := ihR hfreq.2.2 hcomp.2.2 hregular.2.2 + simp only [movingGiantUnitPeriod, Int.natAbs_mul, Int.natAbs_natCast] + calc + _ ≤ (B ^ (2 ^ (n + 2) - 1) * B * B) * (B * B) * + B ^ movingGiantUnitExponent n * B ^ movingGiantUnitExponent n := + Nat.mul_le_mul (Nat.mul_le_mul (Nat.mul_le_mul + (Nat.mul_le_mul (Nat.mul_le_mul hfp hregular.1) hout) + (Nat.mul_le_mul hfreq.1 hcomp.1)) hl) hr + _ = B ^ movingGiantUnitExponent (n + 1) := by + rw [movingGiantUnitExponent, two_mul] + simp only [pow_add] + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingUnitSampleBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingUnitSampleBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..983d7003a0c632ab6605ddc9531188565919137e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingUnitSampleBound.lean @@ -0,0 +1,113 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingUnitPeriodBound +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSmallFrequencyUnits + +namespace OAI + +/-! # The actual sampled regular lists in the full unit-period estimate -/ + +namespace Ostmann +open scoped Classical + +def MovingSlotData.RegularLengthLE {σ : Type*} (D : ℕ) : + {n : ℕ} → MovingSlotData σ n → Prop + | _, T@(.leaf _ _) => T.regularSlots.length ≤ D + | _, T@(.node _ _ _ _ left right) => + T.regularSlots.length ≤ D ∧ left.RegularLengthLE D ∧ right.RegularLengthLE D + +theorem MovingSlotData.RegularLengthLE.mono {σ : Type*} {n D E : ℕ} + {T : MovingSlotData σ n} (h : T.RegularLengthLE D) (hDE : D ≤ E) : + T.RegularLengthLE E := by + induction T with + | leaf => exact h.trans hDE + | node s CL CR U left right ihL ihR => + exact ⟨h.1.trans hDE, ihL h.2.1, ihR h.2.2⟩ + +theorem buildMovingSlotData_regular_length {σ : Type*} (n : ℕ) (t : FrequencyTree ℤ n) + (small bulk : TreeLeafTuple (List σ) n) (samples : MovingSampleSlots σ n) + (A B : ℕ) (hsmall : MovingLeafLengthLE n small A) (hbulk : MovingLeafLengthLE n bulk B) : + (buildMovingSlotData n t small bulk samples).RegularLengthLE (2 ^ n * (A + B + 4 * n)) := by + induction samples generalizing A B with + | leaf => + simpa only [buildMovingSlotData, MovingSlotData.RegularLengthLE, MovingSlotData.regularSlots, + flattenMovingSlots, List.length_append, pow_zero, Nat.mul_zero, Nat.add_zero, one_mul] using + Nat.add_le_add hsmall hbulk + | @node n samples left right ihL ihR => + have hleft := ihL t.2.1 (appendMovingSlotLeaves n (movingCompensationSlots n samples) small.1) + bulk.1 (4 + A) B (moving_append_length_le n _ _ 4 A + (moving_compensation_length n samples) hsmall.1) hbulk.1 + have hright := ihR t.2.2 (appendMovingSlotLeaves n (movingCompensationSlots n samples) small.2) + bulk.2 (4 + A) B (moving_append_length_le n _ _ 4 A + (moving_compensation_length n samples) hsmall.2) hbulk.2 + have hD : 2 ^ n * (4 + A + B + 4 * n) ≤ 2 ^ (n + 1) * (A + B + 4 * (n + 1)) := by + rw [show 4 + A + B + 4 * n = A + B + 4 * (n + 1) by omega] + exact Nat.mul_le_mul_right _ (Nat.pow_le_pow_right (by omega) (by omega)) + refine ⟨?_, hleft.mono hD, hright.mono hD⟩ + have hp := (buildMovingSlotData_regular_perm (n + 1) t small bulk (.node samples left right)).length_eq + change (buildMovingSlotData (n + 1) t small bulk (.node samples left right)).regularSlots.length ≤ _ + rw [hp, List.length_append] + have hs := moving_flatten_length_le (n + 1) small A hsmall + have hb := moving_flatten_length_le (n + 1) bulk B hbulk + exact (Nat.add_le_add hs hb).trans (by + rw [← Nat.mul_add] + exact Nat.mul_le_mul_left _ (by omega)) + +theorem MovingSlotData.RegularLengthLE.product_bound {σ : Type*} {n D : ℕ} + (T : MovingSlotData σ n) (hT : T.RegularLengthLE D) (value : σ → ℕ) + (P : ℕ) (hP : 1 ≤ P) (hvalue : ∀ i, value i ≤ P) : + T.RegularBound value (P ^ D) := by + induction T with + | leaf s regular => + exact (movingNaturalProduct_le_pow value P hvalue regular).trans (Nat.pow_le_pow_right hP hT) + | node s CL CR U left right ihL ihR => + exact ⟨(movingNaturalProduct_le_pow value P hvalue (CL ++ CR)).trans + (Nat.pow_le_pow_right hP hT.1), ihL hT.2.1, ihR hT.2.2⟩ + +theorem MovingSlotData.RegularBound.mono {σ : Type*} {n B C : ℕ} + (T : MovingSlotData σ n) (value : σ → ℕ) (h : T.RegularBound value B) (hBC : B ≤ C) : + T.RegularBound value C := by + induction T with + | leaf => exact h.trans hBC + | node s CL CR U left right ihL ihR => exact ⟨h.1.trans hBC, ihL h.2.1, ihR h.2.2⟩ + +/-- A concrete upper bound retaining the number of original small and bulk +slots. Compensation contributes exactly four labels per bottom leaf per level. -/ +theorem movingSample_unitPeriod_bound {σ : Type*} (value : σ → ℕ) + (P V : ℕ) (hP : 1 ≤ P) (hV : 1 ≤ V) (hvalue : ∀ i, value i ≤ P) + (outside : List ℕ) (hout : 1 ≤ outside.prod) + (n : ℕ) (t : FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List σ) n) + (samples : MovingSampleSlots σ n) (A B : ℕ) + (hsmall : MovingLeafLengthLE n small A) (hbulk : MovingLeafLengthLE n bulk B) + (hfreq : (buildMovingSlotData n t small bulk samples).Frequencies (fun s => s.natAbs ≤ V)) : + (movingGiantUnitPeriod value outside (buildMovingSlotData n t small bulk samples)).natAbs ≤ + (V * P ^ (2 ^ n * (A + B + 4 * n) + 4 * 2 ^ n) * outside.prod) ^ movingGiantUnitExponent n := by + let D := 2 ^ n * (A + B + 4 * n) + let K := V * P ^ (D + 4 * 2 ^ n) * outside.prod + have hp : 1 ≤ P ^ (D + 4 * 2 ^ n) := Nat.one_le_pow _ _ hP + have hvK : V ≤ K := by + change V ≤ V * P ^ (D + 4 * 2 ^ n) * outside.prod + calc + V = V * 1 * 1 := by simp + _ ≤ _ := Nat.mul_le_mul (Nat.mul_le_mul_left V hp) hout + have hpK : P ^ (D + 4 * 2 ^ n) ≤ K := by + change P ^ (D + 4 * 2 ^ n) ≤ V * P ^ (D + 4 * 2 ^ n) * outside.prod + calc + _ = 1 * P ^ (D + 4 * 2 ^ n) * 1 := by simp + _ ≤ _ := Nat.mul_le_mul (Nat.mul_le_mul_right _ hV) hout + have hoK : outside.prod ≤ K := by + change outside.prod ≤ V * P ^ (D + 4 * 2 ^ n) * outside.prod + calc + _ = (1 * 1) * outside.prod := by simp + _ ≤ _ := Nat.mul_le_mul_right _ (Nat.mul_le_mul hV hp) + have hD : P ^ D ≤ K := (Nat.pow_le_pow_right hP (Nat.le_add_right _ _)).trans hpK + have hc : P ^ (4 * 2 ^ n) ≤ K := + (Nat.pow_le_pow_right hP (Nat.le_add_left _ _)).trans hpK + exact movingGiantUnitPeriod_bound value outside _ K + (hfreq.mono (fun _ hs => hs.trans hvK)) + ((buildMovingSlotData_compensation_bound value P hP hvalue n t small bulk samples).mono value hc) + (MovingSlotData.RegularBound.mono _ value + (MovingSlotData.RegularLengthLE.product_bound _ + (buildMovingSlotData_regular_length n t small bulk samples A B hsmall hbulk) value P hP hvalue) hD) hoK + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..735765516a4a9a7fdbc3b9e7947c36bda1adecc4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalEnergy.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedDiagonalMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalDiagonalEnergy + +namespace OAI + +/-! # Exact expansion of the coefficient square with its exterior mask retained -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingWeightedDiagonalEnergy {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small bulk : TreeLeafTuple (List B) n) + (W : ℤ → (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) : ℂ := + ∑ s : transferFrequencyRange (V n), ∑ y : B → σ, ((∏ b, ν b (y b) : ℝ) : ℂ) * + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n bulk) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) * + W s.val y x z)) + +theorem movingWeightedDiagonalEnergy_eq {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small bulk : TreeLeafTuple (List B) n) + (W : ℤ → (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) : + movingWeightedDiagonalEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n small bulk W u v r w center = + ∑ s : transferFrequencyRange (V n), ∑ a : MovingDescendantFrequencyIndex V n, + ∑ b : MovingDescendantFrequencyIndex V n, + movingWeightedDiagonalMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n (fun side => if side then movingRootedFrequencyTree V n s.val b + else movingRootedFrequencyTree V n s.val a) + small bulk (W s.val) u v r w center := by + unfold movingWeightedDiagonalEnergy + apply Finset.sum_congr rfl + intro s _ + have heq (y : B → σ) (x z : ℝ) : + (‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n bulk) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) = + ∑ a : MovingDescendantFrequencyIndex V n, ∑ b : MovingDescendantFrequencyIndex V n, + movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (movingRootedFrequencyTree V n s.val a) + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n bulk) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (movingRootedFrequencyTree V n s.val b) + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n bulk) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊) := by + rw [movingFrequencyCoefficient_original, Complex.star_def, ← Complex.mul_conj'] + simp only [map_sum, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + simp_rw [heq, Finset.sum_mul, complexIntegerInterval_sum, complexPrimeInterval_sum, + Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + rw [Finset.sum_comm] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalHistories.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalHistories.lean new file mode 100644 index 0000000000000000000000000000000000000000..bbdf19d0986b7019de952066ca47227f343c8cd5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalHistories.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedDiagonalEnergy + +namespace OAI + +/-! # The original paired frequency histories with the exterior multiplier retained -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingWeightedDiagonalEnergy_history_bound {B : Type} [Fintype B] + (primes : Finset ℕ) (outside : List ℕ) + (n m : ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small bulk : TreeLeafTuple (List B) n) + (W : ℤ → (B → primes) → ℝ → ℝ → ℂ) + (u v r w center : ℝ) (hV : Monotone V) : + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + ‖movingWeightedDiagonalEnergy p Subtype.val outside μ ν childBound pivotBound V f g Dq + Finset.univ ψ X lo hi φ G n small bulk W u v r w center‖ ≤ + ∑ t : FrequencyTree (Sfreq × Sfreq) n, + ‖movingWeightedDiagonalMean p Subtype.val outside μ ν childBound pivotBound f g Dq + Finset.univ ψ X lo hi φ G n (trees t) small bulk + (W (frequencyRoot n (trees t false))) u v r w center‖ := by + dsimp only + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let M := fun a b : FrequencyTree ℤ n => + movingWeightedDiagonalMean p (fun q : primes => (q : ℕ)) outside μ ν childBound pivotBound + f g Dq Finset.univ ψ X lo hi φ G n (fun side => if side then b else a) + small bulk (W (frequencyRoot n a)) u v r w center + have hzL (a : ScheduledFrequencyIndex V n) (t : FrequencyTree ℤ n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M (scheduledFrequencyHistory V n a) t = 0 := + movingWeightedDiagonalMean_zero_frequency p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f hf g Dq Finset.univ ψ X lo hi φ G n _ small + bulk (W _) u v r w center false ha + have hzR (t : FrequencyTree ℤ n) (a : ScheduledFrequencyIndex V n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M t (scheduledFrequencyHistory V n a) = 0 := + movingWeightedDiagonalMean_zero_frequency p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f hf g Dq Finset.univ ψ X lo hi φ G n _ small + bulk (W _) u v r w center true ha + have hs := same_root_scheduled_pair_sum_le V n + (fun a b => ‖M (scheduledFrequencyHistory V n a) (scheduledFrequencyHistory V n b)‖) + (fun _ _ => norm_nonneg _) + have hh (a : transferFrequencyRange (V n)) (b : MovingDescendantFrequencyIndex V n) : + scheduledFrequencyHistory V n ((scheduledFrequencyRootEquiv V n).symm (a, b)) = + movingRootedFrequencyTree V n a.val b := by + rw [scheduledFrequencyRootEquiv_history, Equiv.apply_symm_apply] + simp_rw [hh] at hs + have he := paired_scheduled_history_sum_le V hV n (fun a b => ‖M a b‖) + (fun _ _ => norm_nonneg _) (fun a t ha => by rw [hzL a t ha, norm_zero]) + (fun t a ha => by rw [hzR t a ha, norm_zero]) + rw [movingWeightedDiagonalEnergy_eq] + apply le_trans _ (hs.trans (he.trans ?_)) + · apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro a _ + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro b _ + have hb := norm_sum_le (Finset.univ : Finset (MovingDescendantFrequencyIndex V n)) + (fun c => movingWeightedDiagonalMean p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f g Dq Finset.univ ψ X lo hi φ G n + (fun side => if side then movingRootedFrequencyTree V n a.val c + else movingRootedFrequencyTree V n a.val b) + small bulk (W a.val) u v r w center) + simpa only [M, frequencyRoot_movingRootedFrequencyTree] using hb + · apply Finset.sum_le_sum + intro t _ + let trees := fun side => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + have htrees : (fun side => if side then trees true else trees false) = trees := by + funext side + cases side <;> rfl + dsimp only [M] + rw [htrees] + split_ifs + · exact le_rfl + · exact norm_nonneg _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalMean.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..0a18185901d241837a43cc8264a4e2bb0c9ec04e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalMean.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSampleDiagonalExpansion +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalPatternMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternDiagonalProduct +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternPrimeRelabel + +namespace OAI + +/-! # Equality patterns with a retained external Fourier multiplier -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingWeightedDiagonalKernel {σ I B : Type*} {n : ℕ} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (W : (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) + (y : B → σ) (a : MovingSampleSlots σ n × MovingSampleSlots σ n) : ℂ := + let H := fun b XL XR => + let T := buildMovingSlotData n (t b) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n bulk) (if b then a.2 else a.1) + movingSupportedWeight value outside T XL XR + (movingOriginalGiantWeight q value childBound pivotBound (fun _ => f) + (fun _ _ _ _ => 1) g Dq S ψ X lo hi φ G T (t b) XL XR) + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (H false ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (H true ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + W y x z)) + +/-- Both history averages and the external law are the original ones. -/ +noncomputable def movingWeightedDiagonalMean {σ I B : Type*} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (W : (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) : ℂ := + ∑ y : B → σ, ((∏ b, ν b (y b) : ℝ) : ℂ) * + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t false) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n bulk) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t true) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n bulk) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + W y x z)) + +theorem movingWeightedDiagonalMean_patterns {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (W : (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + movingWeightedDiagonalMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n t small bulk W u v r w center = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → σ, + movingOriginalPatternWeight (e s) μ ν value n (fun i => Quotient.mk'' i) + (fun x => movingWeightedDiagonalKernel q value outside childBound pivotBound f g Dq S + ψ X lo hi φ G t small bulk W u v r w center + (fun b => x ((e s).symm (.inl b))) + ((movingSamplePairCoordinates σ n).symm + (fun i => x ((e s).symm (.inr (Quotient.mk'' i)))))) x := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + let H := movingWeightedDiagonalKernel q value outside childBound pivotBound f g Dq S + ψ X lo hi φ G t small bulk W u v r w center + have hpair (y : B → σ) : + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t false) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n bulk) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t true) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n bulk) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + W y x z)) = + ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ a : {a : Quotient s → σ // Function.Injective a}, + (internalPatternWeight (fun i => Quotient.mk'' i) + (fun i => μ (movingSampleTier i.2)) value a.val : ℂ) * + H y ((movingSamplePairCoordinates σ n).symm (fun i => a.val (Quotient.mk'' i))) := by + simp_rw [movingOriginalSampleAverage_compensated] + exact movingCompensatedAverage_diagonal_patterns μ value n _ _ _ u v r w center + unfold movingWeightedDiagonalMean + simp_rw [hpair] + exact moving_external_pattern_mean μ ν value n H N e + +theorem movingWeightedDiagonalMean_zero_frequency {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small bulk : TreeLeafTuple (List B) n) + (W : (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) + (side : Bool) (hzero : ¬ ∀ s ∈ allFrequencyList n (t side), s ≠ 0) : + movingWeightedDiagonalMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n t small bulk W u v r w center = 0 := by + have hz := movingOriginalSampleAverage_zero_frequency q value outside μ childBound pivotBound + (fun _ => f) (fun _ _ => hf) g Dq S ψ X lo hi φ G n (t side) + unfold movingWeightedDiagonalMean + cases side <;> + simp_rw [hz _ _ _ _ hzero] <;> + simp only [star_zero, zero_mul, mul_zero, complexPrimeInterval, complexIntegerInterval, + Finset.sum_const_zero, ite_self] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalRelabel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cbd11bebb89b2da41c6e0ca0becd3f255f26a63 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedDiagonalRelabel.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedDiagonalMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalDiagonalPatterns + +namespace OAI + +/-! # Relabeling the retained exterior multiplier into arithmetic coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingPatternExternalMultiplier {J : Type*} [Fintype J] {N : ℕ} + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (reg : J → Fin (N + 1)) (active : J → Bool) + (other : (Fin (N + 1) → primes) → J → ℤ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) (φ : ℝ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (x : Fin (N + 1) → primes) (z y : ℝ) : ℂ := + let q := fun j => (x (reg j) : ℕ) + let _ : ∀ j, Fact (q j).Prime := fun j => ⟨hprimes _ (x (reg j)).property⟩ + (giantOuterWeight φ Jleft Jright diagonal ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ : ℂ) * + (naturalRegularMultiplier q active sreg (fun j => (other x j : ZMod (q j))) + (fun j => greg (q j)) ⌊Real.exp z⌋₊ ⌊Real.exp y⌋₊ : ℝ) + +theorem movingWeightedDiagonalKernel_fin {B C J : Type*} [Fintype J] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (reg : J → Fin (N + 1)) (active : J → Bool) + (other : (Fin (N + 1) → primes) → J → ℤ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (W : (B → primes) → ℝ → ℝ → ℂ) + (x : Fin (N + 1) → primes) + (hW : ∀ z y, W (fun j => x (e.symm (.inl j))) z y = + movingPatternExternalMultiplier primes hprimes reg active other greg sreg φ + Jleft Jright diagonal x z y) : + movingWeightedDiagonalKernel p (fun q : primes => (q : ℕ)) outside + childBound pivotBound f g Dq Finset.univ ψ X lo hi φ G t small + (bulkSlotLeaves n m slot) W u v a b center + (fun j => x (e.symm (.inl j))) + ((movingSamplePairCoordinates primes n).symm + (fun i => x (e.symm (.inr (pattern i))))) = + movingOriginalPatternDiagonalObservable e t small slot pattern primes hprimes p g Dq + reg active sreg other greg f outside childBound pivotBound + ψ X lo hi φ G Jleft Jright diagonal u v a b center x := by + have heval (side : Bool) : + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern side).map x = + buildMovingSlotData n (t side) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n small) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n (bulkSlotLeaves n m slot)) + (movingPatternSamples primes n (fun i => x (e.symm (.inr (pattern i)))) side) := by + have hbulk : movingPatternBulkLeaves n m slot (Equiv.refl _) = + fun _ => bulkSlotLeaves n m slot := by + funext b + cases b <;> rfl + rw [movingPatternFinBulkData, hbulk] + exact movingPatternFinData_evaluate e t (fun _ => small) + (fun _ => bulkSlotLeaves n m slot) pattern x side + have hterm (side : Bool) (XL XR : ℕ) : + let T := buildMovingSlotData n (t side) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n small) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n (bulkSlotLeaves n m slot)) + (movingPatternSamples primes n (fun i => x (e.symm (.inr (pattern i)))) side) + movingSupportedWeight (fun q : primes => (q : ℕ)) outside T XL XR + (movingOriginalGiantWeight p (fun q : primes => (q : ℕ)) childBound pivotBound + (fun _ => f) (fun _ _ _ _ => 1) g Dq Finset.univ ψ X lo hi φ G T (t side) XL XR) = + movingSupportedWeight (fun i => (x i : ℕ)) outside + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern side) XL XR + (movingOriginalGiantWeight p (fun i => (x i : ℕ)) childBound pivotBound + (fun _ => f) (fun _ _ _ _ => 1) g Dq Finset.univ ψ X lo hi φ G + (movingPatternFinBulkData e n m t (fun _ => small) slot (Equiv.refl _) pattern side) + (t side) XL XR) := by + dsimp only + rw [← heval side, movingOriginalGiantWeight_map, movingSupportedWeight_map] + rfl + unfold movingOriginalPatternDiagonalObservable + unfold movingWeightedDiagonalKernel + dsimp only + rw [← movingPatternSamples_pair] + dsimp only + apply congrArg (complexPrimeInterval 1 0 a b) + funext y + apply congrArg (complexIntegerInterval 1 0 u v center) + funext z + simp only [Bool.false_eq_true, ite_false, ite_true] + rw [hterm false, hterm true] + rw [hW z y] + unfold movingPatternExternalMultiplier movingOriginalSupportedOuterPair + dsimp only + exact (mul_assoc _ _ _).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedEnergyPartition.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedEnergyPartition.lean new file mode 100644 index 0000000000000000000000000000000000000000..a8cab2a38428601ec034fdebf0983fd6a9246ed5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedEnergyPartition.lean @@ -0,0 +1,34 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedDiagonalEnergy +import OAI.NumberTheory.Ostmann.Characters.MixedExternalPartition + +namespace OAI + +/-! # Four unit rectangles for the original weighted diagonal energy -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingWeightedDiagonalEnergy_full_cell_bound {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small bulk : TreeLeafTuple (List B) n) + (W : ℤ → (B → σ) → ℝ → ℝ → ℂ) (H J center E : ℝ) + (h : ∀ i j : Bool, ‖movingWeightedDiagonalEnergy q value outside μ ν + childBound pivotBound V f g Dq S ψ X lo hi φ G n small bulk W + (if i then H else H - 1) ((if i then H else H - 1) + 1) + (if j then J else J - 1) ((if j then J else J - 1) + 1) center‖ ≤ E) : + ‖movingWeightedDiagonalEnergy q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n small bulk W (H - 1) (H + 1) (J - 1) (J + 1) center‖ ≤ 4 * E := by + exact mixedExternalAverage_full_cell_bound ν (V n) H J center E + (fun s y x z => + (‖movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n bulk) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊‖ ^ 2 : ℂ) * W s y x z) h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedCorrelation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedCorrelation.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b43d1c23946e354224077be81d35ad0d578e3fc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedCorrelation.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedMatchedMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalDiagonalEnergy + +namespace OAI + +/-! # The full original correlation of two matched bulk assignments -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingWeightedMatchedCorrelation {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (W : ℤ → (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) : ℂ := + ∑ s : transferFrequencyRange (V n), ∑ y : B → σ, ((∏ b, ν b (y b) : ℝ) : ℂ) * + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk false)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk true)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + W s.val y x z)) + +theorem movingWeightedMatchedCorrelation_eq {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (W : ℤ → (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) : + movingWeightedMatchedCorrelation q value outside μ ν childBound pivotBound V f g Dq S + ψ X lo hi φ G n small bulk W u v r w center = + ∑ s : transferFrequencyRange (V n), ∑ a : MovingDescendantFrequencyIndex V n, + ∑ b : MovingDescendantFrequencyIndex V n, + movingWeightedMatchedMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n (fun side => if side then movingRootedFrequencyTree V n s.val b + else movingRootedFrequencyTree V n s.val a) + small bulk (W s.val) u v r w center := by + unfold movingWeightedMatchedCorrelation + apply Finset.sum_congr rfl + intro s _ + have heq (y : B → σ) (x z : ℝ) : + (movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk false)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingFrequencyCoefficient value outside μ childBound pivotBound V + (movingOriginalLeaf value q (fun _ => f) g Dq S ψ X lo hi) φ G n s.val + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk true)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) = + ∑ a : MovingDescendantFrequencyIndex V n, ∑ b : MovingDescendantFrequencyIndex V n, + movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (movingRootedFrequencyTree V n s.val a) + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk false)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (movingRootedFrequencyTree V n s.val b) + (treeLeafMap (List.map y) n small) (treeLeafMap (List.map y) n (bulk true)) + ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊) := by + simp only [movingFrequencyCoefficient_original, star_sum, Finset.sum_mul, Finset.mul_sum] + rw [Finset.sum_comm] + simp_rw [heq, Finset.sum_mul, complexIntegerInterval_sum, complexPrimeInterval_sum, + Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro a _ + rw [Finset.sum_comm] + rfl + +theorem movingWeightedMatchedMean_zero_frequency {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (W : (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) + (side : Bool) (hzero : ¬ ∀ s ∈ allFrequencyList n (t side), s ≠ 0) : + movingWeightedMatchedMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n t small bulk W u v r w center = 0 := by + have hz := movingOriginalSampleAverage_zero_frequency q value outside μ childBound pivotBound + (fun _ => f) (fun _ _ => hf) g Dq S ψ X lo hi φ G n (t side) + unfold movingWeightedMatchedMean + cases side <;> + simp_rw [hz _ _ _ _ hzero] <;> + simp only [star_zero, zero_mul, mul_zero, complexPrimeInterval, complexIntegerInterval, + Finset.sum_const_zero, ite_self] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedHistories.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedHistories.lean new file mode 100644 index 0000000000000000000000000000000000000000..5b36e81980f5bafd2726bb30b60a6344611c6cbb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedHistories.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedMatchedCorrelation + +namespace OAI + +/-! # The original paired frequency histories with the exterior multiplier retained -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingWeightedMatchedCorrelation_history_bound {B : Type} [Fintype B] + (primes : Finset ℕ) (outside : List ℕ) + (n m : ℕ) (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (μ : ℕ → primes → ℝ) (ν : B → primes → ℝ) + (childBound pivotBound V : ℕ → ℕ) (f : ℤ → ℂ) (hf : f 0 = 0) + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (W : ℤ → (B → primes) → ℝ → ℝ → ℂ) + (u v r w center : ℝ) (hV : Monotone V) : + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let trees := fun (t : FrequencyTree (Sfreq × Sfreq) n) side => + frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + ‖movingWeightedMatchedCorrelation p Subtype.val outside μ ν childBound pivotBound V f g Dq + Finset.univ ψ X lo hi φ G n small bulk W u v r w center‖ ≤ + ∑ t : FrequencyTree (Sfreq × Sfreq) n, + ‖movingWeightedMatchedMean p Subtype.val outside μ ν childBound pivotBound f g Dq + Finset.univ ψ X lo hi φ G n (trees t) small bulk + (W (frequencyRoot n (trees t false))) u v r w center‖ := by + dsimp only + let Sfreq := (transferFrequencyRange (V n)).erase 0 + let M := fun a b : FrequencyTree ℤ n => + movingWeightedMatchedMean p (fun q : primes => (q : ℕ)) outside μ ν childBound pivotBound + f g Dq Finset.univ ψ X lo hi φ G n (fun side => if side then b else a) + small bulk (W (frequencyRoot n a)) u v r w center + have hzL (a : ScheduledFrequencyIndex V n) (t : FrequencyTree ℤ n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M (scheduledFrequencyHistory V n a) t = 0 := + movingWeightedMatchedMean_zero_frequency p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f hf g Dq Finset.univ ψ X lo hi φ G n _ small + bulk (W _) u v r w center false ha + have hzR (t : FrequencyTree ℤ n) (a : ScheduledFrequencyIndex V n) + (ha : ¬ ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) : + M t (scheduledFrequencyHistory V n a) = 0 := + movingWeightedMatchedMean_zero_frequency p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f hf g Dq Finset.univ ψ X lo hi φ G n _ small + bulk (W _) u v r w center true ha + have hs := same_root_scheduled_pair_sum_le V n + (fun a b => ‖M (scheduledFrequencyHistory V n a) (scheduledFrequencyHistory V n b)‖) + (fun _ _ => norm_nonneg _) + have hh (a : transferFrequencyRange (V n)) (b : MovingDescendantFrequencyIndex V n) : + scheduledFrequencyHistory V n ((scheduledFrequencyRootEquiv V n).symm (a, b)) = + movingRootedFrequencyTree V n a.val b := by + rw [scheduledFrequencyRootEquiv_history, Equiv.apply_symm_apply] + simp_rw [hh] at hs + have he := paired_scheduled_history_sum_le V hV n (fun a b => ‖M a b‖) + (fun _ _ => norm_nonneg _) (fun a t ha => by rw [hzL a t ha, norm_zero]) + (fun t a ha => by rw [hzR t a ha, norm_zero]) + rw [movingWeightedMatchedCorrelation_eq] + apply le_trans _ (hs.trans (he.trans ?_)) + · apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro a _ + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro b _ + have hb := norm_sum_le (Finset.univ : Finset (MovingDescendantFrequencyIndex V n)) + (fun c => movingWeightedMatchedMean p (fun q : primes => (q : ℕ)) outside μ ν + childBound pivotBound f g Dq Finset.univ ψ X lo hi φ G n + (fun side => if side then movingRootedFrequencyTree V n a.val c + else movingRootedFrequencyTree V n a.val b) + small bulk (W a.val) u v r w center) + simpa only [M, frequencyRoot_movingRootedFrequencyTree] using hb + · apply Finset.sum_le_sum + intro t _ + let trees := fun side => frequencyTreeMap Subtype.val n (frequencyPairProjection Sfreq n side t) + have htrees : (fun side => if side then trees true else trees false) = trees := by + funext side + cases side <;> rfl + dsimp only [M] + rw [htrees] + split_ifs + · exact le_rfl + · exact norm_nonneg _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedMean.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedMean.lean new file mode 100644 index 0000000000000000000000000000000000000000..be24b1a5136c61aafd3c0e5db59a562ff420a646 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedMean.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingOriginalDiagonalMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMatchedProduct + +namespace OAI + +/-! # The original matched-history mean and its exact equality patterns -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingWeightedMatchedKernel {σ I B : Type*} {n : ℕ} + (q : I → ℕ) [∀ i, Fact (q i).Prime] (value : σ → ℕ) (outside : List ℕ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (W : (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) + (y : B → σ) (a : MovingSampleSlots σ n × MovingSampleSlots σ n) : ℂ := + let H := fun b XL XR => + let T := buildMovingSlotData n (t b) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulk b)) (if b then a.2 else a.1) + movingSupportedWeight value outside T XL XR + (movingOriginalGiantWeight q value childBound pivotBound (fun _ => f) + (fun _ _ _ _ => 1) g Dq S ψ X lo hi φ G T (t b) XL XR) + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (H false ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (H true ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + W y x z)) + +/-- Both history averages and the external law are the original ones. -/ +noncomputable def movingWeightedMatchedMean {σ I B : Type*} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (W : (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) : ℂ := + ∑ y : B → σ, ((∏ b, ν b (y b) : ℝ) : ℂ) * + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t false) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulk false)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t true) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulk true)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + W y x z)) + +theorem movingWeightedMatchedMean_patterns {σ I B : Type} + [Fintype σ] [Fintype B] (q : I → ℕ) [∀ i, Fact (q i).Prime] + (value : σ → ℕ) (outside : List ℕ) (μ : ℕ → σ → ℝ) (ν : B → σ → ℝ) + (childBound pivotBound : ℕ → ℕ) (f : ℤ → ℂ) + (g : ∀ i, ZMod (q i) → ℂ) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (n : ℕ) (t : Bool → FrequencyTree ℤ n) (small : TreeLeafTuple (List B) n) (bulk : Bool → TreeLeafTuple (List B) n) + (W : (B → σ) → ℝ → ℝ → ℂ) (u v r w center : ℝ) + (N : Setoid (Bool × MovingSampleIndex n) → ℕ) + (e : ∀ s : Setoid (Bool × MovingSampleIndex n), Fin (N s + 1) ≃ B ⊕ Quotient s) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + movingWeightedMatchedMean q value outside μ ν childBound pivotBound f g Dq S + ψ X lo hi φ G n t small bulk W u v r w center = + ∑ s : Setoid (Bool × MovingSampleIndex n), ∑ x : Fin (N s + 1) → σ, + movingOriginalPatternWeight (e s) μ ν value n (fun i => Quotient.mk'' i) + (fun x => movingWeightedMatchedKernel q value outside childBound pivotBound f g Dq S + ψ X lo hi φ G t small bulk W u v r w center + (fun b => x ((e s).symm (.inl b))) + ((movingSamplePairCoordinates σ n).symm + (fun i => x ((e s).symm (.inr (Quotient.mk'' i)))))) x := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + dsimp only + let H := movingWeightedMatchedKernel q value outside childBound pivotBound f g Dq S + ψ X lo hi φ G t small bulk W u v r w center + have hpair (y : B → σ) : + complexPrimeInterval 1 0 r w (fun z => complexIntegerInterval 1 0 u v center (fun x => + (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t false) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulk false)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊ * + star (movingOriginalSampleAverage q value outside μ childBound pivotBound (fun _ => f) + g Dq S ψ X lo hi φ G n (t true) (treeLeafMap (List.map y) n small) + (treeLeafMap (List.map y) n (bulk true)) ⌊Real.exp x⌋₊ ⌊Real.exp z⌋₊)) * + W y x z)) = + ∑ s : Setoid (Bool × MovingSampleIndex n), + ∑ a : {a : Quotient s → σ // Function.Injective a}, + (internalPatternWeight (fun i => Quotient.mk'' i) + (fun i => μ (movingSampleTier i.2)) value a.val : ℂ) * + H y ((movingSamplePairCoordinates σ n).symm (fun i => a.val (Quotient.mk'' i))) := by + simp_rw [movingOriginalSampleAverage_compensated] + exact movingCompensatedAverage_diagonal_patterns μ value n _ _ _ u v r w center + unfold movingWeightedMatchedMean + simp_rw [hpair] + exact moving_external_pattern_mean μ ν value n H N e + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedRelabel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedRelabel.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1c2300c16f6b77f8ec0c6f693c96852de2d373d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWeightedMatchedRelabel.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedMatchedMean +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWeightedDiagonalRelabel +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternMatchedObservable + +namespace OAI + +/-! # The masked correlation of two bulk assignments in pattern coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +theorem movingWeightedMatchedKernel_fin {B C J : Type*} [Fintype J] {N n m : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (t : Bool → FrequencyTree ℤ n) + (small : TreeLeafTuple (List B) n) (slot : (TreeLeafIndex n × Fin m) ↪ B) + (perm : Equiv.Perm (TreeLeafIndex n × Fin m)) + (pattern : Bool × MovingSampleIndex n → C) + (primes : Finset ℕ) (hprimes : ∀ p ∈ primes, p.Prime) + (p : Fin m → ℕ) [∀ i, Fact (p i).Prime] + (g : ∀ i, ZMod (p i) → ℂ) (Dq : ∀ i, (ZMod (p i))ˣ) + (reg : J → Fin (N + 1)) (active : J → Bool) + (other : (Fin (N + 1) → primes) → J → ℤ) + (greg : ∀ q : ℕ, ZMod q → ℂ) (sreg : ℤ) + (f : ℤ → ℂ) (outside : List ℕ) (childBound pivotBound : ℕ → ℕ) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (Jleft Jright : ℝ) (diagonal : Bool) (u v a b center : ℝ) + (W : (B → primes) → ℝ → ℝ → ℂ) + (x : Fin (N + 1) → primes) + (hW : ∀ z y, W (fun j => x (e.symm (.inl j))) z y = + movingPatternExternalMultiplier primes hprimes reg active other greg sreg φ + Jleft Jright diagonal x z y) : + movingWeightedMatchedKernel p (fun q : primes => (q : ℕ)) outside + childBound pivotBound f g Dq Finset.univ ψ X lo hi φ G t small + (movingPatternBulkLeaves n m slot perm) W u v a b center + (fun j => x (e.symm (.inl j))) + ((movingSamplePairCoordinates primes n).symm + (fun i => x (e.symm (.inr (pattern i))))) = + movingOriginalPatternMatchedObservable e t small slot perm pattern primes hprimes p g Dq + reg active sreg other greg f outside childBound pivotBound + ψ X lo hi φ G Jleft Jright diagonal u v a b center x := by + have heval (side : Bool) : + (movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern side).map x = + buildMovingSlotData n (t side) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n small) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n (movingPatternBulkLeaves n m slot perm side)) + (movingPatternSamples primes n (fun i => x (e.symm (.inr (pattern i)))) side) := by + exact movingPatternFinData_evaluate e t (fun _ => small) + (movingPatternBulkLeaves n m slot perm) pattern x side + have hterm (side : Bool) (XL XR : ℕ) : + let T := buildMovingSlotData n (t side) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n small) + (treeLeafMap (List.map (fun j => x (e.symm (.inl j)))) n (movingPatternBulkLeaves n m slot perm side)) + (movingPatternSamples primes n (fun i => x (e.symm (.inr (pattern i)))) side) + movingSupportedWeight (fun q : primes => (q : ℕ)) outside T XL XR + (movingOriginalGiantWeight p (fun q : primes => (q : ℕ)) childBound pivotBound + (fun _ => f) (fun _ _ _ _ => 1) g Dq Finset.univ ψ X lo hi φ G T (t side) XL XR) = + movingSupportedWeight (fun i => (x i : ℕ)) outside + (movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern side) XL XR + (movingOriginalGiantWeight p (fun i => (x i : ℕ)) childBound pivotBound + (fun _ => f) (fun _ _ _ _ => 1) g Dq Finset.univ ψ X lo hi φ G + (movingPatternFinBulkData e n m t (fun _ => small) slot perm pattern side) + (t side) XL XR) := by + dsimp only + rw [← heval side, movingOriginalGiantWeight_map, movingSupportedWeight_map] + rfl + unfold movingOriginalPatternMatchedObservable + unfold movingWeightedMatchedKernel + dsimp only + rw [← movingPatternSamples_pair] + dsimp only + apply congrArg (complexPrimeInterval 1 0 a b) + funext y + apply congrArg (complexIntegerInterval 1 0 u v center) + funext z + simp only [Bool.false_eq_true, ite_false, ite_true] + rw [hterm false, hterm true] + rw [hW z y] + unfold movingPatternExternalMultiplier movingOriginalSupportedOuterPair + dsimp only + exact (mul_assoc _ _ _).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWindowCells.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWindowCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..ced5b3d81982d56856d6412901d3d37e10983254 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWindowCells.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingScalarWindows +import OAI.NumberTheory.Ostmann.Arithmetic.MovingArithmeticCells + +namespace OAI + +/-! # Sharp terminal windows have explicit polynomial root cells -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def movingWindowPolynomials {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (L R : Polynomial ℝ) (X lo hi : ℝ) + (i : TreeLeafIndex n × Bool) : Polynomial ℝ := + if i.2 then Polynomial.C hi - movingLeafNormalizedPolynomial value T L R X i.1 + else movingLeafNormalizedPolynomial value T L R X i.1 - Polynomial.C lo + +noncomputable def movingWindowRootCuts {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (L R : Polynomial ℝ) (X lo hi : ℝ) : Finset ℝ := + polynomialRootCuts (movingWindowPolynomials value T L R X lo hi) + +theorem movingWindowPolynomials_mem_iff {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (L R : Polynomial ℝ) (X lo hi z : ℝ) : + (∀ i, (movingLeafNormalizedPolynomial value T L R X i).eval z ∈ Set.Icc lo hi) ↔ + ∀ i, 0 ≤ (movingWindowPolynomials value T L R X lo hi i).eval z := by + constructor + · intro h i + cases hb : i.2 + · simpa only [movingWindowPolynomials, hb, Bool.false_eq_true, ite_false, + Polynomial.eval_sub, Polynomial.eval_C, sub_nonneg] using (h i.1).1 + · simpa only [movingWindowPolynomials, hb, ite_true, + Polynomial.eval_sub, Polynomial.eval_C, sub_nonneg] using (h i.1).2 + · intro h i + constructor + · simpa only [movingWindowPolynomials, Bool.false_eq_true, ite_false, + Polynomial.eval_sub, Polynomial.eval_C, sub_nonneg] using h (i, false) + · simpa only [movingWindowPolynomials, ite_true, + Polynomial.eval_sub, Polynomial.eval_C, sub_nonneg] using h (i, true) + +theorem movingWindowRootCuts_card {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (L R : Polynomial ℝ) (X lo hi : ℝ) + (hL : L.natDegree ≤ 1) (hR : R.natDegree ≤ 1) : + (movingWindowRootCuts value T L R X lo hi).card ≤ 4 * 2 ^ n := by + have hp (i : TreeLeafIndex n) : (movingLeafNormalizedPolynomial value T L R X i).natDegree ≤ 2 := by + apply Polynomial.natDegree_mul_le.trans + simpa only [Polynomial.natDegree_C, zero_add, mul_one] using T.leafPolynomials_degree value L R 1 hL hR i + have hdeg (i : TreeLeafIndex n × Bool) : + (movingWindowPolynomials value T L R X lo hi i).natDegree ≤ 2 := by + unfold movingWindowPolynomials + split_ifs + · exact (Polynomial.natDegree_sub_le _ _).trans (max_le (by simp) (hp i.1)) + · exact (Polynomial.natDegree_sub_le _ _).trans (max_le (hp i.1) (by simp)) + apply (polynomialRootCuts_card _).trans + calc + _ ≤ ∑ _i : TreeLeafIndex n × Bool, 2 := Finset.sum_le_sum (fun i _ => hdeg i) + _ = _ := by simp only [Finset.sum_const, Finset.card_univ, Fintype.card_prod, + Fintype.card_bool, card_treeLeafIndex, smul_eq_mul]; omega + +theorem movingPolynomialWindows_of_rootCell {σ : Type*} (value : σ → ℕ) {n : ℕ} + (T : MovingSlotData σ n) (L R : Polynomial ℝ) (X lo hi x y : ℝ) + (S : Finset ℝ) (hS : movingWindowRootCuts value T L R X lo hi ⊆ S) + (hcode : rootCellCode S x = rootCellCode S y) : + (∀ i, (movingLeafNormalizedPolynomial value T L R X i).eval x ∈ Set.Icc lo hi) ↔ + (∀ i, (movingLeafNormalizedPolynomial value T L R X i).eval y ∈ Set.Icc lo hi) := by + rw [movingWindowPolynomials_mem_iff, movingWindowPolynomials_mem_iff] + apply forall_congr' + intro i + apply polynomial_nonneg_iff_of_root_cell _ S _ hcode + intro r hr + exact hS (Finset.mem_biUnion.mpr ⟨i, Finset.mem_univ _, Multiset.mem_toFinset.mpr hr⟩) + +theorem movingNaturalWindows_of_rootCell {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (XR XL YL : ℕ) (X lo hi : ℝ) (S : Finset ℝ) + (hS : movingWindowRootCuts value T Polynomial.X (Polynomial.C XR) X lo hi ⊆ S) + (hcode : rootCellCode S (XL : ℝ) = rootCellCode S (YL : ℝ)) + (hX : T.Integral value XL XR) (hY : T.Integral value YL XR) : + (∀ i, (T.leafModuli value XL XR i : ℝ) / X ∈ Set.Icc lo hi) ↔ + (∀ i, (T.leafModuli value YL XR i : ℝ) / X ∈ Set.Icc lo hi) := by + have h := movingPolynomialWindows_of_rootCell value T Polynomial.X (Polynomial.C XR) + X lo hi XL YL S hS hcode + have hx (i : TreeLeafIndex n) : + (movingLeafNormalizedPolynomial value T Polynomial.X (Polynomial.C XR) X i).eval (XL : ℝ) = + (T.leafModuli value XL XR i : ℝ) / X := by + rw [movingLeafNormalizedPolynomial_eval, T.leafPolynomials_eval value hvalue hf XL XR hX + _ _ _ (by simp) (by simp)] + have hy (i : TreeLeafIndex n) : + (movingLeafNormalizedPolynomial value T Polynomial.X (Polynomial.C XR) X i).eval (YL : ℝ) = + (T.leafModuli value YL XR i : ℝ) / X := by + rw [movingLeafNormalizedPolynomial_eval, T.leafPolynomials_eval value hvalue hf YL XR hY + _ _ _ (by simp) (by simp)] + simpa only [hx, hy] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWindowedSpectators.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWindowedSpectators.lean new file mode 100644 index 0000000000000000000000000000000000000000..3ac61fc32c7e56f5ac030e4049a5d13a237f720e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/MovingWindowedSpectators.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingWindowCells +import OAI.NumberTheory.Ostmann.ZeroDensity.MovingFullSmoothZero +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSpectatorCells + +namespace OAI + +/-! # The complete nonsmooth factor of the original moving coefficient -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap + +noncomputable def movingWindowedSpectatorWeight {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : ℂ := + movingUnrestrictedWeight value (movingWindowLeaf value X lo hi (movingDataLeaf F)) + (movingDataExtra E) T XL XR * ∏ i ∈ S, movingSlotSpectator value (g i) (D i) T XL XR + +theorem movingWindowedSpectatorWeight_norm {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (B : I → ℝ) (hB : ∀ i ∈ S, 0 ≤ B i) (hg : ∀ i ∈ S, ∀ z, ‖g i z‖ ≤ B i) + {n : ℕ} (T : MovingSlotData σ n) (XL XR : ℕ) : + ‖movingWindowedSpectatorWeight q value F E X lo hi g D S T XL XR‖ ≤ + ‖movingDataWeight F E T‖ * ∏ i ∈ S, B i ^ (2 ^ n) := by + rw [movingWindowedSpectatorWeight, norm_mul] + have hscalar : ‖movingUnrestrictedWeight value + (movingWindowLeaf value X lo hi (movingDataLeaf F)) (movingDataExtra E) T XL XR‖ ≤ + ‖movingDataWeight F E T‖ := by + rw [movingUnrestrictedWeight_data_window] + split_ifs + · exact le_rfl + · simpa only [norm_zero] using norm_nonneg (movingDataWeight F E T) + exact mul_le_mul hscalar (movingSpectatorProduct_norm q value g D S B hB hg T XL XR) + (norm_nonneg _) (norm_nonneg _) + +theorem movingWindowedSpectatorWeight_cells {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (X lo hi : ℝ) (g : ∀ i, ZMod (q i) → ℂ) (D : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) (XR M XL YL : ℕ) + (hM : ∀ i ∈ S, (q i : ℤ) * movingSpectatorDenominator value T ∣ (M : ℤ)) + (roots : Finset ℝ) + (hroots : movingWindowRootCuts value T Polynomial.X (Polynomial.C XR) X lo hi ⊆ roots) + (hX : T.Integral value XL XR) (hY : T.Integral value YL XR) + (hres : (XL : ℤ) ≡ (YL : ℤ) [ZMOD M]) + (hcode : rootCellCode roots (XL : ℝ) = rootCellCode roots (YL : ℝ)) : + movingWindowedSpectatorWeight q value F E X lo hi g D S T XL XR = + movingWindowedSpectatorWeight q value F E X lo hi g D S T YL XR := by + unfold movingWindowedSpectatorWeight + rw [movingUnrestrictedWeight_data_window, movingUnrestrictedWeight_data_window] + have hwin := movingNaturalWindows_of_rootCell value hvalue T hf XR XL YL X lo hi roots hroots hcode hX hY + simp only [hwin] + rw [movingSpectatorProduct_modEq q value hvalue g D S T hf M XL XR YL hM hX hY hres] + +/-- This identity includes all original arithmetic guards, terminal windows, +smooth factors, compensation weights, and spectators. -/ +theorem moving_complete_coefficient_factor {σ I : Type*} (q : I → ℕ) + [∀ i, Fact (q i).Prime] (value : σ → ℕ) (hvalue : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) + (F : {n : ℕ} → MovingSlotData σ n → ℤ → ℂ) + (E : {n : ℕ} → MovingSlotData σ n → ℤ → ℤ → ℤ → ℝ) + (g : ∀ i, ZMod (q i) → ℂ) (hg : ∀ i, g i 0 = 0) (Dq : ∀ i, (ZMod (q i))ˣ) (S : Finset I) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + {n : ℕ} (T : MovingSlotData σ n) (t : FrequencyTree ℤ n) (hT : T.Follows t) + (hf : T.Frequencies (· ≠ 0)) (XL XR : ℕ) : + recursiveTransferWeight (movingSlotSystem value childBound pivotBound) + (fun x s => (movingWindowLeaf value X lo hi (movingDataLeaf F) x s * + movingFourierLeaf value ψ X x s) * + ∏ i ∈ S, spectatorHistoryLeaf (movingSlotModulus value) (g i) (Dq i) x s) + (movingSlotCutoff value childBound pivotBound + (movingPhiExtra value childBound pivotBound (movingDataExtra E) φ G)) n ⟨n, T, XL, XR⟩ t = + (movingArithmeticIndicator value childBound pivotBound T XL XR * + movingWindowedSpectatorWeight q value F E X lo hi g Dq S T XL XR) * + smoothPolynomialWeight (movingSmoothPolynomialFactors value T Polynomial.X (Polynomial.C XR) + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) XL := by + rw [moving_full_smooth_spectator_of_zero q value hvalue childBound pivotBound + (movingDataLeaf F) (movingDataExtra E) g hg Dq S ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout + T t hT hf XL XR Polynomial.X (Polynomial.C XR) XL (by simp) (by simp)] + rw [movingSlotWeight_indicator_factor value hvalue childBound pivotBound + (movingWindowLeaf value X lo hi (movingDataLeaf F)) (movingDataExtra E) T t hT hf XL XR] + unfold movingWindowedSpectatorWeight + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/NaturalHistoryEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/NaturalHistoryEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..0824ca36d0206666d3724093a157a626d25917f9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/NaturalHistoryEnergy.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.Ostmann.Construction.NaturalFixedPivotEnergy +import OAI.NumberTheory.Ostmann.Construction.UniformFixedPivotHistoryEnergy + +namespace OAI + +/-! # The actual rounded character cutoff in the fixed-pivot energy -/ +namespace Ostmann +open Filter +open scoped Classical BigOperators SchwartzMap FourierTransform + +theorem uniform_constituent_natural_history_energy (n : ℕ) + (ψ : 𝓢(ℝ, ℂ)) (C₀ K d ε : ℝ) (hd : 0 ≤ d) (hε : 0 < ε) + (hψ : SchwartzMap.seminorm ℝ 0 0 (𝓕 ψ : 𝓢(ℝ, ℂ)) ≤ Real.exp K) : + ∀ᶠ m : ℝ in atTop, + ∀ {I : Type*} [Fintype I] (role : I → CopyScheduleRole) (size : I → ℕ) + (childBound pivotBound : ℕ → ℕ) + (ranges : (j : ℕ) → List (ScheduleAtomRange role j)) + (i : Σ a, Fin (size a)) (_hi : role i.1 = .word) + (_hu : ∀ k < n, ∀ a b, role a = .pivot k → role b = .pivot k → a = b) + (p : I) (_hp : role p = .pivot n) (_hunique : ∀ j, role j = .pivot n → j = p) + (X lo upper : ℝ) (M : ℕ) + (P : Finset ℕ) (cells : (Σ a, Fin (size a)) → Finset ℕ), + (∀ p ∈ P, p.Prime ∧ naturalTransferCutoff (d * m) m n < p) → + 0 < X → 1 < X * lo → Real.exp (d * m - C₀) ≤ lo → + (∀ j, cells j ⊆ P) → (∀ j, (∑ p ∈ cells j, (p : ℝ)⁻¹) ≠ 0) → + ∀ h J : ℕ, + naturalTransferCutoff (d * m) m n ^ ((2 ^ (n + 1) - 1) * (n + 2)) ≤ 2 ^ h → + (∀ p ∈ cells i, 2 ^ h ≤ p ∧ p < 2 ^ (h + J)) → + ∀ a C₁ L : ℝ, 0 < a → 1 ≤ L → + a ≤ ∑ p ∈ cells i, (p : ℝ)⁻¹ → (J : ℝ) ≤ Real.exp (C₁ * L) → + constituentHistoryEnergy role size n P cells childBound pivotBound ranges + (scheduleFourierLeaf role ψ X lo upper) + (scheduledFrequencyHistory (naturalTransferCutoff (d * m) m) n) M ≤ + Real.exp ((C₁ + max (Real.log (3 / a)) 0) * (2 ^ n : ℕ) * L + ε * m) := by + filter_upwards [uniform_constituent_natural_fixedPivot_energy n ψ C₀ K d ε hd hε hψ] + with m hm + intro I instI role size childBound pivotBound ranges i hi hu p hp hunique X lo upper M P cells + hP hX hXlo hlo hsub hmass h J hsmall hrange a C₁ L ha hL hcell hJ + have he := hm role size childBound pivotBound ranges i hi hu X lo upper M P cells + hP hX hXlo hlo hsub hmass h J hsmall hrange a C₁ L ha hL hcell hJ + have hf := constituent_fixedPivot_prior_fubini role size n M p hp hunique P + (fun j => primeSubsetPrior P (cells (copyScheduleOrigin n j.val))) + (fun j => primeSubsetPrior_mass P _ (hsub _) (hmass _)) + (fun t v => ‖fullAtomTransferWeight role childBound pivotBound ranges + (scheduleFourierLeaf role ψ X lo upper) n v + (scheduledFrequencyHistory (naturalTransferCutoff (d * m) m) n t)‖ ^ 2) + have hbound := (le_of_eq hf.symm).trans he + simp only [enumeratedPartitionEquiv_rest, Sum.elim_inl, Sum.elim_inr] at hbound + apply le_trans (le_of_eq ?_) hbound + unfold constituentHistoryEnergy + apply Finset.sum_congr rfl + intro u _ + congr 1 + rw [Finset.sum_comm] + simp only [← Finset.mul_sum] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/NaturalMatchingEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/NaturalMatchingEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..45ccd02f13808da2b8f3be07b2d13e9f2b42dc92 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/NaturalMatchingEnergy.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.Ostmann.Construction.ConstituentEnergyMarginal +import OAI.NumberTheory.Ostmann.Construction.NaturalFixedPivotEnergy + +namespace OAI + +/-! # The literal diagonal history energy at the rounded cutoffs -/ + +namespace Ostmann +open Filter +open scoped BigOperators Classical SchwartzMap FourierTransform + +theorem uniform_natural_constituentHistoryEnergy_bound (n : ℕ) + (ψ : 𝓢(ℝ, ℂ)) (C₀ K d ε : ℝ) (hd : 0 ≤ d) (hε : 0 < ε) + (hψ : SchwartzMap.seminorm ℝ 0 0 (𝓕 ψ : 𝓢(ℝ, ℂ)) ≤ Real.exp K) : + ∀ᶠ m : ℝ in atTop, + ∀ {I : Type*} [Fintype I], + ∀ (role : I → CopyScheduleRole) (size : I → ℕ) + (childBound pivotBound : ℕ → ℕ) + (ranges : (j : ℕ) → List (ScheduleAtomRange role j)) + (i : Σ a, Fin (size a)) (_hi : role i.1 = .word) + (_hu : ∀ k < n, ∀ a b, role a = .pivot k → role b = .pivot k → a = b) + (pivot : I) (_hpivot : role pivot = .pivot n) + (_hunique : ∀ j, role j = .pivot n → j = pivot), + ∀ X lo upper : ℝ, ∀ M : ℕ, + ∀ P : Finset ℕ, ∀ cells : (Σ a, Fin (size a)) → Finset ℕ, + (∀ p ∈ P, p.Prime ∧ naturalTransferCutoff (d * m) m n < p) → + 0 < X → 1 < X * lo → Real.exp (d * m - C₀) ≤ lo → + (∀ j, cells j ⊆ P) → (∀ j, (∑ p ∈ cells j, (p : ℝ)⁻¹) ≠ 0) → + ∀ h J : ℕ, + naturalTransferCutoff (d * m) m n ^ ((2 ^ (n + 1) - 1) * (n + 2)) ≤ 2 ^ h → + (∀ p ∈ cells i, 2 ^ h ≤ p ∧ p < 2 ^ (h + J)) → + ∀ a C₁ L : ℝ, 0 < a → 1 ≤ L → + a ≤ ∑ p ∈ cells i, (p : ℝ)⁻¹ → (J : ℝ) ≤ Real.exp (C₁ * L) → + constituentHistoryEnergy role size n P cells childBound pivotBound ranges + (scheduleFourierLeaf role ψ X lo upper) + (scheduledFrequencyHistory (naturalTransferCutoff (d * m) m) n) M ≤ + Real.exp ((C₁ + max (Real.log (3 / a)) 0) * (2 ^ n : ℕ) * L + ε * m) := by + filter_upwards [uniform_constituent_natural_fixedPivot_energy n ψ C₀ K d ε hd hε hψ] with m hm + intro I instI role size childBound pivotBound ranges i hi hu pivot hpivot hunique X lo upper M P cells hP hX hXlo hlo hsub hmass h J hsmall hrange a C₁ L ha hL hcell hJ + rw [constituentHistoryEnergy_eq_fixedPivot role size n M P cells hsub hmass + pivot hpivot hunique] + exact hm role size childBound pivotBound ranges i hi hu X lo upper M P cells hP hX hXlo hlo hsub hmass h J hsmall hrange + a C₁ L ha hL hcell hJ + +theorem natural_constituentHistoryEnergy_bound {I : Type*} [Fintype I] + (role : I → CopyScheduleRole) (size : I → ℕ) + (childBound pivotBound : ℕ → ℕ) + (ranges : (j : ℕ) → List (ScheduleAtomRange role j)) + (i : Σ a, Fin (size a)) (hi : role i.1 = .word) (n : ℕ) + (hu : ∀ k < n, ∀ a b, role a = .pivot k → role b = .pivot k → a = b) + (pivot : I) (hpivot : role pivot = .pivot n) + (hunique : ∀ j, role j = .pivot n → j = pivot) + (ψ : 𝓢(ℝ, ℂ)) (C₀ K d ε : ℝ) (hd : 0 ≤ d) (hε : 0 < ε) + (hψ : SchwartzMap.seminorm ℝ 0 0 (𝓕 ψ : 𝓢(ℝ, ℂ)) ≤ Real.exp K) : + ∀ᶠ m : ℝ in atTop, ∀ X lo upper : ℝ, ∀ M : ℕ, + ∀ P : Finset ℕ, ∀ cells : (Σ a, Fin (size a)) → Finset ℕ, + (∀ p ∈ P, p.Prime ∧ naturalTransferCutoff (d * m) m n < p) → + 0 < X → 1 < X * lo → Real.exp (d * m - C₀) ≤ lo → + (∀ j, cells j ⊆ P) → (∀ j, (∑ p ∈ cells j, (p : ℝ)⁻¹) ≠ 0) → + ∀ h J : ℕ, + naturalTransferCutoff (d * m) m n ^ ((2 ^ (n + 1) - 1) * (n + 2)) ≤ 2 ^ h → + (∀ p ∈ cells i, 2 ^ h ≤ p ∧ p < 2 ^ (h + J)) → + ∀ a C₁ L : ℝ, 0 < a → 1 ≤ L → + a ≤ ∑ p ∈ cells i, (p : ℝ)⁻¹ → (J : ℝ) ≤ Real.exp (C₁ * L) → + constituentHistoryEnergy role size n P cells childBound pivotBound ranges + (scheduleFourierLeaf role ψ X lo upper) + (scheduledFrequencyHistory (naturalTransferCutoff (d * m) m) n) M ≤ + Real.exp ((C₁ + max (Real.log (3 / a)) 0) * (2 ^ n : ℕ) * L + ε * m) := by + filter_upwards [uniform_natural_constituentHistoryEnergy_bound n ψ C₀ K d ε hd hε hψ] + with m hm + exact hm role size childBound pivotBound ranges i hi hu pivot hpivot hunique + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/NaturalScheduleEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/NaturalScheduleEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..4123685b7868c941d434788c9d6a3b4c0cfc71ba --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/NaturalScheduleEnergy.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Construction.ConstituentScheduledEnergy +import OAI.NumberTheory.Ostmann.Construction.RoundedEnergyCutoffs + +namespace OAI + +/-! # The sharp energy rate at the manuscript's actual rounded cutoffs -/ + +namespace Ostmann +open Filter +open scoped BigOperators Classical SchwartzMap FourierTransform + +theorem constituent_natural_schedule_energy {I : Type*} [Fintype I] + (role : I → CopyScheduleRole) (size : I → ℕ) + (childBound pivotBound : ℕ → ℕ) + (ranges : (j : ℕ) → List (ScheduleAtomRange role j)) + (i : Σ a, Fin (size a)) (hi : role i.1 = .word) (n : ℕ) + (hu : ∀ k < n, ∀ a b, role a = .pivot k → role b = .pivot k → a = b) + (ψ : 𝓢(ℝ, ℂ)) (C₀ K d ε : ℝ) (hd : 0 ≤ d) (hε : 0 < ε) + (hψ : SchwartzMap.seminorm ℝ 0 0 (𝓕 ψ : 𝓢(ℝ, ℂ)) ≤ Real.exp K) : + ∀ᶠ m : ℝ in atTop, ∀ X lo upper : ℝ, + ∀ P : Finset ℕ, ∀ cells : (Σ a, Fin (size a)) → Finset ℕ, + (∀ p ∈ P, p.Prime ∧ naturalTransferCutoff (d * m) m n < p) → + 0 < X → 1 < X * lo → Real.exp (d * m - C₀) ≤ lo → + (∀ j, cells j ⊆ P) → (∀ j, (∑ p ∈ cells j, (p : ℝ)⁻¹) ≠ 0) → + ∀ h J : ℕ, + naturalTransferCutoff (d * m) m n ^ ((2 ^ (n + 1) - 1) * (n + 2)) ≤ 2 ^ h → + (∀ p ∈ cells i, 2 ^ h ≤ p ∧ p < 2 ^ (h + J)) → + ∀ a C₁ L : ℝ, 0 < a → 1 ≤ L → + a ≤ ∑ p ∈ cells i, (p : ℝ)⁻¹ → (J : ℝ) ≤ Real.exp (C₁ * L) → + (∑ j : ScheduledFrequencyIndex (naturalTransferCutoff (d * m) m) n, + ∑ q : SurvivingConstituent role size n → P, + scheduledPrimePrior (fun j : Σ a, Fin (size a) => role j.1) n + (fun j => primeSubsetPrior P (cells j)) q * + ‖fullAtomTransferWeight role childBound pivotBound ranges + (scheduleFourierLeaf role ψ X lo upper) n + (fun a => ((scheduleConstituentWord role size n a).map (fun v => (q v : ℕ))).prod) + (scheduledFrequencyHistory (naturalTransferCutoff (d * m) m) n j)‖ ^ 2) ≤ + Real.exp ((C₁ + max (Real.log (3 / a)) 0) * (2 ^ n : ℕ) * L + ε * m) := by + let C := (2 : ℝ) ^ n * d + 1 + have hC : 0 ≤ C := by dsimp [C]; positivity + have hrate := constituent_scheduled_square_rate role size childBound pivotBound ranges i hi n hu + ψ C₀ K C (ε / 4) hC (by positivity) hψ + have hrate' := (tendsto_id.const_mul_atTop (by norm_num : (0 : ℝ) < 4)).eventually hrate + filter_upwards [hrate', eventual_rounded_frequency_card n d hd, eventually_ge_atTop (0 : ℝ)] + with m hm hc hm0 + intro X lo upper P cells hP hX hXlo hlo hsub hmass h J hsmall hrange a C₁ L ha hL hcell hJ + let V := naturalTransferCutoff (d * m) m + have hV : Monotone V := naturalTransferCutoff_monotone _ _ (mul_nonneg hd hm0) + have hN : (V n : ℝ) ≤ Real.exp (C * (4 * m)) := by + have hn := hc n le_rfl + have hnat : (V n : ℝ) ≤ ((transferFrequencyRange (V n)).card : ℝ) := by + rw [card_transferFrequencyRange] + push_cast + linarith [show (0 : ℝ) ≤ (V n : ℝ) from Nat.cast_nonneg _] + exact hnat.trans (hn.trans (Real.exp_le_exp.mpr (by + change C * m ≤ C * (4 * m) + have h4 : m ≤ 4 * m := by linarith + exact mul_le_mul_of_nonneg_left h4 hC))) + have hv0 : (V 0 : ℝ) ≤ Real.exp (d * m + Real.sqrt (4 * m)) := rounded_bottom_frequency_bound _ _ + have hmod (t : FrequencyTree ((transferFrequencyRange (V n)).erase 0) n) : + historyFrequencyModulus ((transferFrequencyRange (V n)).erase 0) n n t ≤ 2 ^ h := by + apply (historyFrequencyModulus_le _ (V n) _ n n t).trans hsmall + intro s hs + exact (mem_transferFrequencyRange _ _).mp (Finset.mem_erase.mp hs).2 + have hb := hm V (d * m) X lo upper P cells hV hN hv0 hP hX hXlo hlo hsub hmass + h J hmod hrange a C₁ L ha hL hcell hJ + have he : ε / 4 * (4 * m) = ε * m := by ring + simpa only [id_eq, he, V] using hb + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/NodeBulkProducts.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/NodeBulkProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9a4a05f9dcb79f0f08cb0373948182f3f91214a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/NodeBulkProducts.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.Ostmann.Construction.ScheduledPreorderNodes +import OAI.NumberTheory.Ostmann.Construction.ScaledWordLeaves +import OAI.NumberTheory.Ostmann.Characters.TreeSplitResidues + +namespace OAI + +/-! # Preorder child products of the selected original prime leaves -/ + +namespace Ostmann +open scoped BigOperators + +theorem treeLeafProduct_indexed {G : Type*} [CommMonoid G] + (n : ℕ) (x : TreeLeafIndex n → G) : + treeLeafProduct n ((treeLeafTupleEquiv G n).symm x) = ∏ i, x i := by + induction n with + | zero => + change Unit → G at x + change x () = ∏ i : Unit, x i + exact (Fintype.prod_subsingleton x ()).symm + | succ n ih => + change (TreeLeafIndex n ⊕ TreeLeafIndex n) → G at x + change treeLeafProduct n ((treeLeafTupleEquiv G n).symm (fun i => x (.inl i))) * + treeLeafProduct n ((treeLeafTupleEquiv G n).symm (fun i => x (.inr i))) = _ + rw [ih, ih] + change _ = ∏ i : TreeLeafIndex n ⊕ TreeLeafIndex n, x i + exact (Fintype.prod_sum_type x).symm + +def childProductsAtPath {G : Type*} [CommMonoid G] : + (n : ℕ) → TreeLeafTuple G n → List Bool → G × G + | 0, _, _ => (1, 1) + | n + 1, x, [] => (treeLeafProduct n x.1, treeLeafProduct n x.2) + | n + 1, x, b :: path => + if b then childProductsAtPath n x.2 path else childProductsAtPath n x.1 path + +theorem actualChildProducts_get_path {G : Type*} [CommMonoid G] + (n : ℕ) (x : TreeLeafTuple G n) (path : List Bool) (hp : path.length < n) : + (actualChildProducts n x).getD (nodePathIndex n path) (1, 1) = + childProductsAtPath n x path := by + induction n generalizing path with + | zero => simp at hp + | succ n ih => + cases path with + | nil => rfl + | cons b path => + have hp' : path.length < n := by simpa using hp + have hidx := nodePathIndex_lt n path hp' + have hpow := Nat.one_le_two_pow (n := n) + cases b + · simp only [nodePathIndex, Bool.false_eq_true, ite_false, actualChildProducts] + rw [show 1 + nodePathIndex n path = nodePathIndex n path + 1 by omega, + List.getD_cons_succ, List.getD_append _ _ _ _ (by + rw [actualChildProducts_length]; exact hidx)] + exact ih _ path hp' + · simp only [nodePathIndex, ite_true, actualChildProducts] + rw [show 2 ^ n + nodePathIndex n path = (2 ^ n - 1 + nodePathIndex n path) + 1 by omega, + List.getD_cons_succ, List.getD_append_right _ _ _ _ (by + rw [actualChildProducts_length]; omega), actualChildProducts_length] + rw [show 2 ^ n - 1 + nodePathIndex n path - (2 ^ n - 1) = nodePathIndex n path by omega] + exact ih _ path hp' + +theorem childProductsAtPath_descend {G : Type*} [CommMonoid G] + (n : ℕ) (path : List Bool) (x : TreeLeafIndex (n + 1 + path.length) → G) : + childProductsAtPath (n + 1 + path.length) + ((treeLeafTupleEquiv G (n + 1 + path.length)).symm x) path = + (∏ i : TreeLeafIndex n, descendLeafValues path.length (n + 1) (reversePathOfList path) x (.inl i), + ∏ i : TreeLeafIndex n, descendLeafValues path.length (n + 1) (reversePathOfList path) x (.inr i)) := by + induction path with + | nil => + change (treeLeafProduct n ((treeLeafTupleEquiv G n).symm (fun i => x (.inl i))), + treeLeafProduct n ((treeLeafTupleEquiv G n).symm (fun i => x (.inr i)))) = _ + rw [treeLeafProduct_indexed, treeLeafProduct_indexed] + rfl + | cons b path ih => + cases b + · change childProductsAtPath (n + 1 + path.length) + ((treeLeafTupleEquiv G (n + 1 + path.length)).symm (fun i => x (.inl i))) path = _ + rw [ih] + rfl + · change childProductsAtPath (n + 1 + path.length) + ((treeLeafTupleEquiv G (n + 1 + path.length)).symm (fun i => x (.inr i))) path = _ + rw [ih] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/NonbulkHarmonicBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/NonbulkHarmonicBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..a878a7db807e9521d58a0767d9ed9ae65ac37ae2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/NonbulkHarmonicBudget.lean @@ -0,0 +1,124 @@ +import OAI.NumberTheory.Ostmann.Construction.SurvivingSlotCount +import OAI.NumberTheory.Ostmann.Construction.SpectatorBulkScale + +namespace OAI + +/-! # The nonbulk normalization costs only its actual surviving slots -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +noncomputable def nonbulkCombinatorialCost (n B : ℕ) : ℝ := + (((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) * (2 ^ n * B).factorial + +theorem nonbulkCombinatorialCost_pos (n B : ℕ) : 0 < nonbulkCombinatorialCost n B := by + unfold nonbulkCombinatorialCost + positivity + +theorem eventual_nonbulk_depth_budget (c ε : ℝ) (hc : 0 ≤ c) (hε : 0 < ε) : + ∀ᶠ k : ℕ in atTop, 4 * c * (4 * (k : ℝ) + 8) ≤ ε * (k : ℝ) ^ 4 := by + have hlarge : ∀ᶠ k : ℕ in atTop, 32 * c / ε ≤ (k : ℝ) := + tendsto_natCast_atTop_atTop.eventually (eventually_ge_atTop _) + filter_upwards [hlarge, eventually_ge_atTop (2 : ℕ)] with k hk hk2 + have hk0 : (0 : ℝ) ≤ k := Nat.cast_nonneg _ + have hk2' : (2 : ℝ) ≤ k := by exact_mod_cast hk2 + have hεk : 32 * c ≤ ε * k := by + have h := (div_le_iff₀ hε).mp hk + nlinarith + have hp : (k : ℝ) ^ 2 ≤ (k : ℝ) ^ 4 := + pow_le_pow_right₀ (by linarith) (by omega) + calc + _ ≤ 32 * c * k := by nlinarith + _ ≤ ε * (k : ℝ) ^ 2 := by nlinarith [mul_le_mul_of_nonneg_right hεk hk0] + _ ≤ _ := mul_le_mul_of_nonneg_left hp hε.le + +theorem scheduled_nonbulk_harmonic_bound {I : Type*} [Fintype I] + (role : I → CopyScheduleRole) (n m B : ℕ) + (word : Fin m ≃ {i : I // role i = .word}) + (hB : Fintype.card {i : I // role i ≠ .word} ≤ B) + (mass : CopyScheduleH role n → ℝ) (c L : ℝ) (hcL : 0 ≤ c * L) + (hmass : ∀ h : ScheduledNonbulkH role n, Real.exp (-c * L) ≤ mass h.val) : + (((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) * + (Fintype.card (ScheduledNonbulkH role n)).factorial * + (∏ h : ScheduledNonbulkH role n, (mass h.val)⁻¹) ≤ + nonbulkCombinatorialCost n B * Real.exp (c * L * (2 ^ n * B : ℕ)) := by + have hN : Fintype.card (ScheduledNonbulkH role n) ≤ 2 ^ n * B := + (scheduledNonbulkH_card_sharp role n m word).trans (Nat.mul_le_mul_left _ hB) + have hf : ((Fintype.card (ScheduledNonbulkH role n)).factorial : ℝ) ≤ + (2 ^ n * B).factorial := by exact_mod_cast Nat.factorial_le hN + have hp : (∏ h : ScheduledNonbulkH role n, (mass h.val)⁻¹) ≤ + Real.exp (c * L * (2 ^ n * B : ℕ)) := by + calc + _ ≤ ∏ _h : ScheduledNonbulkH role n, Real.exp (c * L) := by + apply Finset.prod_le_prod₀ + · intro h _ + exact inv_nonneg.mpr ((Real.exp_pos _).le.trans (hmass h)) + · intro h _ + have he := one_div_le_one_div_of_le (Real.exp_pos (-c * L)) (hmass h) + simpa only [one_div, show -c * L = -(c * L) by ring, Real.exp_neg, + inv_inv] using he + _ = Real.exp (c * L * Fintype.card (ScheduledNonbulkH role n)) := by + simp only [Finset.prod_const, Finset.card_univ, ← Real.exp_nat_mul] + congr 1 + ring + _ ≤ _ := Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_left (by exact_mod_cast hN) hcL) + unfold nonbulkCombinatorialCost + exact mul_le_mul (mul_le_mul_of_nonneg_left hf (by positivity)) hp + (Finset.prod_nonneg (fun h _ => inv_nonneg.mpr ((Real.exp_pos _).le.trans (hmass h)))) + (by positivity) + +/-- The threshold is uniform in the growing slot type and word count. -/ +theorem eventual_nonbulk_cost (n B k : ℕ) (hk : 0 < k) (c ε : ℝ) + (_hc : 0 ≤ c) (hε : 0 < ε) (hbudget : 4 * c * B ≤ ε * (k : ℝ) ^ 4) : + ∀ᶠ L : ℝ in atTop, + nonbulkCombinatorialCost n B * Real.exp (c * L * (2 ^ n * B : ℕ)) ≤ + Real.exp (ε * (2 ^ n : ℕ) * (spectatorBulkCount k L : ℝ)) := by + let F := nonbulkCombinatorialCost n B + let r : ℝ := (2 ^ n : ℕ) + have hr : 0 < r := by dsimp [r]; positivity + have hF : 0 < F := nonbulkCombinatorialCost_pos n B + have hk4 : 0 < (k : ℝ) ^ 4 := by positivity + have ht := (spectatorBulkCount_tendsto k hk).eventually + (eventually_ge_atTop (2 * Real.log F / (ε * r))) + filter_upwards [ht, eventually_ge_atTop (4 / (k : ℝ) ^ 4), + eventually_ge_atTop (0 : ℝ)] with L hL hscale hL0 + have hscale' : 4 ≤ (k : ℝ) ^ 4 * L := by + simpa only [mul_comm L] using (div_le_iff₀ hk4).mp hscale + have hhalf := spectatorBulkCount_half k L hscale' + have hc : c * L * (2 ^ n * B : ℕ) ≤ + ε / 2 * r * (spectatorBulkCount k L : ℝ) := by + have hb := mul_le_mul_of_nonneg_right hbudget hL0 + have hb' := mul_le_mul_of_nonneg_left hb hr.le + have hm := mul_le_mul_of_nonneg_left hhalf (mul_nonneg hε.le hr.le) + dsimp only [r] at hm hb' ⊢ + push_cast at hm hb' ⊢ + nlinarith + have hlog : Real.log F ≤ ε / 2 * r * (spectatorBulkCount k L : ℝ) := by + have hh := (div_le_iff₀ (mul_pos hε hr)).mp hL + nlinarith + change F * _ ≤ _ + rw [← Real.exp_log hF, ← Real.exp_add] + exact Real.exp_le_exp.mpr (by linarith) + +theorem eventual_scheduled_nonbulk_cost (n B k : ℕ) (hk : 0 < k) (c ε : ℝ) + (hc : 0 ≤ c) (hε : 0 < ε) (hbudget : 4 * c * B ≤ ε * (k : ℝ) ^ 4) : + ∀ᶠ L : ℝ in atTop, ∀ {I : Type*} [Fintype I], + ∀ (role : I → CopyScheduleRole) + (_word : Fin (spectatorBulkCount k L) ≃ {i : I // role i = .word}), + Fintype.card {i : I // role i ≠ .word} ≤ B → + ∀ mass : CopyScheduleH role n → ℝ, + (∀ h : ScheduledNonbulkH role n, Real.exp (-c * L) ≤ mass h.val) → + (((2 ^ n + 1) * (2 ^ n) ^ (2 * 2 ^ n) : ℕ) : ℝ) * + (Fintype.card (ScheduledNonbulkH role n)).factorial * + (∏ h : ScheduledNonbulkH role n, (mass h.val)⁻¹) ≤ + Real.exp (ε * (2 ^ n : ℕ) * (spectatorBulkCount k L : ℝ)) := by + filter_upwards [eventual_nonbulk_cost n B k hk c ε hc hε hbudget, + eventually_ge_atTop (0 : ℝ)] with L hcost hL + intro I instI role word hB mass hmass + exact (scheduled_nonbulk_harmonic_bound role n (spectatorBulkCount k L) B word hB + mass c L (mul_nonneg hc hL) hmass).trans hcost + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/OccurrencePermutation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/OccurrencePermutation.lean new file mode 100644 index 0000000000000000000000000000000000000000..69bdc1e7927f0632efc2810c72360f0f2d307c79 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/OccurrencePermutation.lean @@ -0,0 +1,48 @@ +import Mathlib + +namespace OAI + +namespace Ostmann.Arithmetic.OccurrencePermutation + +theorem exists_occurrence_equiv {A : Type*} {xs ys : List A} (h : xs.Perm ys) : + ∃e : Fin xs.length ≃ Fin ys.length, ∀i,ys.get (e i)=xs.get i := by + classical + induction h with + | nil => exact ⟨Equiv.refl _,fun i => Fin.elim0 i⟩ + | @cons a xs ys h ih => + obtain ⟨e,he⟩ := ih + let e' := ((finSuccEquiv xs.length).trans (Equiv.optionCongr e)).trans + (finSuccEquiv ys.length).symm + refine ⟨e',?_⟩ + intro i + refine Fin.cases ?_ (fun j => ?_) i + · simp [e'] + · simpa [e'] using he j + | swap a b xs => + refine ⟨Equiv.swap 0 1,?_⟩ + intro i + refine Fin.cases ?_ (fun j => ?_) i + · simp + · refine Fin.cases ?_ (fun k => ?_) j + · simp + · have h0 : k.succ.succ ≠ (0 : Fin (xs.length+2)) := Fin.succ_ne_zero _ + have h1 : k.succ.succ ≠ (1 : Fin (xs.length+2)) := by + intro he + have hv := congrArg Fin.val he + norm_num [Fin.val_succ,Fin.val_one] at hv + simp [Equiv.swap_apply_def,h0,h1] + | trans h1 h2 ih1 ih2 => + obtain ⟨e,he⟩ := ih1 + obtain ⟨f,hf⟩ := ih2 + exact ⟨e.trans f,fun i => (hf (e i)).trans (he i)⟩ + +noncomputable def indexEquiv {A : Type*} {xs ys : List A} (h : xs.Perm ys) : + Fin xs.length ≃ Fin ys.length := Classical.choose (exists_occurrence_equiv h) + +theorem get_indexEquiv {A : Type*} {xs ys : List A} (h : xs.Perm ys) + (i : Fin xs.length) : ys.get (indexEquiv h i)=xs.get i := + Classical.choose_spec (exists_occurrence_equiv h) i + +end Ostmann.Arithmetic.OccurrencePermutation + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/OneSidedGraphFactor.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/OneSidedGraphFactor.lean new file mode 100644 index 0000000000000000000000000000000000000000..8a3f51f0c12ef02966ff54ee0049f2ac98429048 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/OneSidedGraphFactor.lean @@ -0,0 +1,90 @@ +import OAI.NumberTheory.Ostmann.Construction.DirectedPrimePhase + +namespace OAI + +/-! # Separating a one-sided graph edge from the bounded unary factors -/ + +namespace Ostmann + +open scoped BigOperators + +def twoVertexLabels {J : Type*} (fixed : J → ℕ) (q p : ℕ) : Bool ⊕ J → ℕ + | .inl true => q + | .inl false => p + | .inr j => fixed j + +noncomputable def finiteEdgeWeight {I : Type*} [Fintype I] + (E : I → I → ℕ → ℕ → ℂ) (ν : I → ℕ → ℂ) (v : I → ℕ) : ℂ := + ∏ i, ν i (v i) * ∏ j, E i j (v i) (v j) + +noncomputable def fixedGraphFactor {J : Type*} [Fintype J] + (E : (Bool ⊕ J) → (Bool ⊕ J) → ℕ → ℕ → ℂ) + (ν : (Bool ⊕ J) → ℕ → ℂ) (fixed : J → ℕ) : ℂ := + ∏ i, ν (.inr i) (fixed i) * ∏ j, E (.inr i) (.inr j) (fixed i) (fixed j) + +noncomputable def longGraphFactor {J : Type*} [Fintype J] + (E : (Bool ⊕ J) → (Bool ⊕ J) → ℕ → ℕ → ℂ) + (ν : (Bool ⊕ J) → ℕ → ℂ) (fixed : J → ℕ) (p : ℕ) : ℂ := + ν (.inl false) p * (∏ j, E (.inl false) (.inr j) p (fixed j)) * + ∏ i, E (.inr i) (.inl false) (fixed i) p + +noncomputable def shortGraphFactor {J : Type*} [Fintype J] + (E : (Bool ⊕ J) → (Bool ⊕ J) → ℕ → ℕ → ℂ) + (ν : (Bool ⊕ J) → ℕ → ℂ) (fixed : J → ℕ) (q : ℕ) : ℂ := + ν (.inl true) q * (∏ j, E (.inl true) (.inr j) q (fixed j)) * + (∏ i, E (.inr i) (.inl true) (fixed i) q) * fixedGraphFactor E ν fixed + +theorem one_sided_graph_factorization {J : Type*} [Fintype J] + (E : (Bool ⊕ J) → (Bool ⊕ J) → ℕ → ℕ → ℂ) + (ν : (Bool ⊕ J) → ℕ → ℂ) (fixed : J → ℕ) (q p : ℕ) + (hself : E (.inl true) (.inl true) q q = 1 ∧ E (.inl false) (.inl false) p p = 1) + (hreverse : E (.inl false) (.inl true) p q = 1) : + finiteEdgeWeight E ν (twoVertexLabels fixed q p) = + longGraphFactor E ν fixed p * shortGraphFactor E ν fixed q * E (.inl true) (.inl false) q p := by + simp only [finiteEdgeWeight, Fintype.prod_sum_type, Fintype.prod_bool, twoVertexLabels, + hself.1, hself.2, hreverse, one_mul, mul_one] + simp only [longGraphFactor, shortGraphFactor, fixedGraphFactor] + simp only [Finset.prod_mul_distrib] + ring + +private theorem norm_mul_le_one' (x y : ℂ) (hx : ‖x‖ ≤ 1) (hy : ‖y‖ ≤ 1) : ‖x * y‖ ≤ 1 := by + rw [norm_mul] + exact (mul_le_mul hx hy (norm_nonneg _) (by norm_num)).trans_eq (one_mul 1) + +private theorem norm_prod_le_one' {I : Type*} [Fintype I] (f : I → ℂ) + (hf : ∀ i, ‖f i‖ ≤ 1) : ‖∏ i, f i‖ ≤ 1 := by + rw [norm_prod] + exact Finset.prod_le_one₀ (fun _ _ => norm_nonneg _) (fun i _ => hf i) + +theorem fixedGraphFactor_norm {J : Type*} [Fintype J] + (E : (Bool ⊕ J) → (Bool ⊕ J) → ℕ → ℕ → ℂ) + (ν : (Bool ⊕ J) → ℕ → ℂ) (fixed : J → ℕ) + (hE : ∀ i j x y, ‖E i j x y‖ ≤ 1) (hν : ∀ i x, ‖ν i x‖ ≤ 1) : + ‖fixedGraphFactor E ν fixed‖ ≤ 1 := by + apply norm_prod_le_one' + intro i + exact norm_mul_le_one' _ _ (hν _ _) (norm_prod_le_one' _ (fun j => hE _ _ _ _)) + +theorem longGraphFactor_norm {J : Type*} [Fintype J] + (E : (Bool ⊕ J) → (Bool ⊕ J) → ℕ → ℕ → ℂ) + (ν : (Bool ⊕ J) → ℕ → ℂ) (fixed : J → ℕ) + (hE : ∀ i j x y, ‖E i j x y‖ ≤ 1) (hν : ∀ i x, ‖ν i x‖ ≤ 1) (p : ℕ) : + ‖longGraphFactor E ν fixed p‖ ≤ 1 := by + apply norm_mul_le_one' + · exact norm_mul_le_one' _ _ (hν _ _) (norm_prod_le_one' _ (fun j => hE _ _ _ _)) + · exact norm_prod_le_one' _ (fun i => hE _ _ _ _) + +theorem shortGraphFactor_norm {J : Type*} [Fintype J] + (E : (Bool ⊕ J) → (Bool ⊕ J) → ℕ → ℕ → ℂ) + (ν : (Bool ⊕ J) → ℕ → ℂ) (fixed : J → ℕ) + (hE : ∀ i j x y, ‖E i j x y‖ ≤ 1) (hν : ∀ i x, ‖ν i x‖ ≤ 1) (q : ℕ) : + ‖shortGraphFactor E ν fixed q‖ ≤ 1 := by + apply norm_mul_le_one' + · apply norm_mul_le_one' + · exact norm_mul_le_one' _ _ (hν _ _) (norm_prod_le_one' _ (fun j => hE _ _ _ _)) + · exact norm_prod_le_one' _ (fun i => hE _ _ _ _) + · exact fixedGraphFactor_norm E ν fixed hE hν + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/OpenCellIntegerComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/OpenCellIntegerComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..4e82a9ae6d2aa9c8c018eb7b76067f93a03c06ca --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/OpenCellIntegerComparison.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ContinuousIntegerComparison + +namespace OAI + +/-! # Open integer cells retain their endpoint atoms -/ + +namespace Ostmann +open MeasureTheory +open scoped BigOperators Classical + +theorem complexIntegerInterval_open_cell_bound (q a : ℕ) (u v G : ℝ) + (W w : ℝ → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hbound : ∀ y ∈ Set.Ioc u v, ‖W y - w y‖ ≤ B) + (heq : ∀ y ∈ Set.Ioo u v, W y = w y) : + ‖complexIntegerInterval q a u v G W - complexIntegerInterval q a u v G w‖ ≤ + B * Real.exp (-G) := by + let T := Finset.Ioc ⌊Real.exp u⌋₊ ⌊Real.exp v⌋₊ + let S : Finset ℕ := {⌊Real.exp v⌋₊} + have hC : 0 ≤ B * Real.exp (-G) := mul_nonneg hB (Real.exp_pos _).le + have hatom (n : ℕ) : ‖(integerResidueAtom q a G n : ℂ)‖ ≤ Real.exp (-G) := by + rw [Complex.norm_real, Real.norm_eq_abs, abs_of_nonneg (integerResidueAtom_nonneg q a G n)] + unfold integerResidueAtom + split_ifs + · exact le_rfl + · exact (Real.exp_pos _).le + have hpoint (n : ℕ) (hn : n ∈ T) : + ‖(W (Real.log n) - w (Real.log n)) * (integerResidueAtom q a G n : ℂ)‖ ≤ + if n ∈ S then B * Real.exp (-G) else 0 := by + by_cases hS : n ∈ S + · rw [ite_eq_left hS, norm_mul] + exact mul_le_mul (hbound _ (log_mem_of_mem_exp_interval hn)) (hatom n) (norm_nonneg _) hB + · rw [ite_eq_right hS] + have hlog := log_mem_of_mem_exp_interval hn + have hn0 : (0 : ℝ) < n := by + have : 0 < n := lt_of_le_of_lt (Nat.zero_le _) (Finset.mem_Ioc.mp hn).1 + exact_mod_cast this + have hne : Real.log n ≠ v := by + intro hv + apply hS + simp only [S, Finset.mem_singleton] + rw [← hv, Real.exp_log hn0, Nat.floor_natCast] + rw [heq _ ⟨hlog.1, lt_of_le_of_ne hlog.2 hne⟩, sub_self, zero_mul, norm_zero] + have he : complexIntegerInterval q a u v G W - complexIntegerInterval q a u v G w = + ∑ n ∈ T, (W (Real.log n) - w (Real.log n)) * (integerResidueAtom q a G n : ℂ) := by + simp only [complexIntegerInterval, ← Finset.sum_sub_distrib, T, sub_mul] + rw [he] + calc + _ ≤ ∑ n ∈ T, ‖(W (Real.log n) - w (Real.log n)) * (integerResidueAtom q a G n : ℂ)‖ := + norm_sum_le _ _ + _ ≤ ∑ n ∈ T, if n ∈ S then B * Real.exp (-G) else 0 := Finset.sum_le_sum hpoint + _ = ((T.filter (· ∈ S)).card : ℝ) * (B * Real.exp (-G)) := by + rw [← Finset.sum_filter] + simp + _ ≤ (S.card : ℝ) * (B * Real.exp (-G)) := by + apply mul_le_mul_of_nonneg_right _ hC + exact_mod_cast Finset.card_le_card (show T.filter (· ∈ S) ⊆ S from + fun _ h => (Finset.mem_filter.mp h).2) + _ = _ := by simp [S] + +theorem open_cell_integer_comparison (q a : ℕ) (hq : 0 < q) (u v G : ℝ) (huv : u ≤ v) + (W w : ℝ → ℂ) (hwc : ContinuousOn w (Set.Icc u v)) (V B : ℝ) + (hV : ∀ s : ℕ → ℝ, Monotone s → ∀ N, s 0 = u → s N = v → + discreteVariation (fun j => w (s j)) N ≤ V) + (hB : 0 ≤ B) (hbound : ∀ y ∈ Set.Ioc u v, ‖W y - w y‖ ≤ B) + (heq : ∀ y ∈ Set.Ioo u v, W y = w y) : + ‖complexIntegerInterval q a u v G W - + ∫ y in Set.Ioc u v, w y * (integerLogDensity q G y : ℂ)‖ ≤ + V * (2 * Real.exp (-G)) + B * Real.exp (-G) := by + have h1 := complexIntegerInterval_open_cell_bound q a u v G W w B hB hbound heq + have h2 := continuous_integer_comparison q a hq u v G huv w hwc V hV + exact (norm_sub_le_norm_sub_add_norm_sub _ (complexIntegerInterval q a u v G w) _).trans + (by linarith) + +theorem piecewise_integer_comparison (q a : ℕ) (hq : 0 < q) (G : ℝ) + (s : ℕ → ℝ) (hs : Monotone s) (N : ℕ) + (W : ℝ → ℂ) (w : ℕ → ℝ → ℂ) (V B : ℕ → ℝ) + (hwc : ∀ j < N, ContinuousOn (w j) (Set.Icc (s j) (s (j + 1)))) + (hV : ∀ j < N, ∀ r : ℕ → ℝ, Monotone r → ∀ M, + r 0 = s j → r M = s (j + 1) → discreteVariation (fun k => w j (r k)) M ≤ V j) + (hB : ∀ j < N, 0 ≤ B j) + (hbound : ∀ j < N, ∀ y ∈ Set.Ioc (s j) (s (j + 1)), ‖W y - w j y‖ ≤ B j) + (heq : ∀ j < N, ∀ y ∈ Set.Ioo (s j) (s (j + 1)), W y = w j y) : + ‖complexIntegerInterval q a (s 0) (s N) G W - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + w j y * (integerLogDensity q G y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, (V j * (2 * Real.exp (-G)) + B j * Real.exp (-G)) := by + rw [← complexIntegerInterval_partition q a G s hs W N, ← Finset.sum_sub_distrib] + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro j hj + have hjN : j < N := Finset.mem_range.mp hj + exact open_cell_integer_comparison q a hq _ _ G (hs (Nat.le_succ _)) + W (w j) (hwc j hjN) (V j) (B j) (hV j hjN) (hB j hjN) (hbound j hjN) (heq j hjN) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/OpenCellPrimeComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/OpenCellPrimeComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cb445a49963bb4201bf00a4dee8c337dfa85e9c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/OpenCellPrimeComparison.lean @@ -0,0 +1,86 @@ +import OAI.NumberTheory.Ostmann.Construction.PrimeExceptionalPoints +import OAI.NumberTheory.Ostmann.Arithmetic.ContinuousPrimeComparison + +namespace OAI + +/-! # Prime comparison on open root cells, with boundary atoms retained -/ + +namespace Ostmann +open scoped BigOperators Classical +open MeasureTheory + +theorem complexPrimeInterval_open_cell_bound (q a : ℕ) (u v : ℝ) + (W w : ℝ → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hbound : ∀ y ∈ Set.Ioc u v, ‖W y - w y‖ ≤ B) + (heq : ∀ y ∈ Set.Ioo u v, W y = w y) : + ‖complexPrimeInterval q a u v W - complexPrimeInterval q a u v w‖ ≤ + B * Real.exp (-u) := by + have h := complexPrimeInterval_exceptional_bound q a u v W w {⌊Real.exp v⌋₊} B hB + (fun p hp _ _ => hbound _ (log_mem_of_mem_exp_interval hp)) (by + intro p hp hprime _ hnot + have hlog := log_mem_of_mem_exp_interval hp + have hp0 : (0 : ℝ) < p := by exact_mod_cast hprime.pos + have hne : Real.log p ≠ v := by + intro he + apply hnot + simp only [Finset.mem_singleton] + rw [← he, Real.exp_log hp0, Nat.floor_natCast] + exact heq _ ⟨hlog.1, lt_of_le_of_ne hlog.2 hne⟩) + simpa only [Finset.card_singleton, Nat.cast_one, one_mul] using h + +/-- A cell's interior uses its continuous smooth factor; the right endpoint +is accounted for by its prime atom, even when it is an arithmetic root. -/ +theorem PublishedProgressionInput.open_cell_prime_comparison (P : PublishedProgressionInput) + {Q q a : ℕ} (hQ : 2 ≤ Q) (hq : 1 ≤ q) (hqQ : q ≤ Q) (ha : a.Coprime q) + (u v : ℝ) (hu : 1 ≤ u) (huv : u ≤ v) (hshort : v ≤ u + 1) + (W w : ℝ → ℂ) (hwc : ContinuousOn w (Set.Icc u v)) (V B : ℝ) + (hV : ∀ s : ℕ → ℝ, Monotone s → ∀ N, s 0 = u → s N = v → + discreteVariation (fun j => w (s j)) N ≤ V) + (hB : 0 ≤ B) (hbound : ∀ y ∈ Set.Ioc u v, ‖W y - w y‖ ≤ B) + (heq : ∀ y ∈ Set.Ioo u v, W y = w y) : + ‖complexPrimeInterval q a u v W - + ∫ y in Set.Ioc u v, w y * (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + V * (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt u) + + Real.exp (-P.kappa * u / Real.log (4 * (Q : ℝ)))) + B * Real.exp (-u) := by + have h1 := complexPrimeInterval_open_cell_bound q a u v W w B hB hbound heq + have h2 := P.continuous_prime_comparison hQ hq hqQ ha u v hu huv hshort w hwc V hV + exact (norm_sub_le_norm_sub_add_norm_sub _ (complexPrimeInterval q a u v w) _).trans + (by linarith) + +/-- Sum the actual prime weights over the constructed root partition. The +ideal term is the sum of its continuous cell integrals with the Page factor. -/ +theorem PublishedProgressionInput.piecewise_prime_comparison (P : PublishedProgressionInput) + {Q q a : ℕ} (hQ : 2 ≤ Q) (hq : 1 ≤ q) (hqQ : q ≤ Q) (ha : a.Coprime q) + (s : ℕ → ℝ) (hs : Monotone s) (N : ℕ) (hs0 : 1 ≤ s 0) (hshort : s N ≤ s 0 + 1) + (W : ℝ → ℂ) (w : ℕ → ℝ → ℂ) (V B : ℕ → ℝ) + (hwc : ∀ j < N, ContinuousOn (w j) (Set.Icc (s j) (s (j + 1)))) + (hV : ∀ j < N, ∀ r : ℕ → ℝ, Monotone r → ∀ M, + r 0 = s j → r M = s (j + 1) → discreteVariation (fun k => w j (r k)) M ≤ V j) + (hB : ∀ j < N, 0 ≤ B j) + (hbound : ∀ j < N, ∀ y ∈ Set.Ioc (s j) (s (j + 1)), ‖W y - w j y‖ ≤ B j) + (heq : ∀ j < N, ∀ y ∈ Set.Ioo (s j) (s (j + 1)), W y = w j y) : + ‖complexPrimeInterval q a (s 0) (s N) W - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + w j y * (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, (V j * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ)))) + B j * Real.exp (-(s j))) := by + rw [← complexPrimeInterval_partition q a s hs W N, ← Finset.sum_sub_distrib] + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro j hj + have hjN : j < N := Finset.mem_range.mp hj + apply P.open_cell_prime_comparison hQ hq hqQ ha _ _ + (hs0.trans (hs (Nat.zero_le _))) (hs (Nat.le_succ _)) + · have h1 := hs (by omega : j + 1 ≤ N) + have h0 := hs (Nat.zero_le j) + linarith + · exact hwc j hjN + · exact hV j hjN + · exact hB j hjN + · exact hbound j hjN + · exact heq j hjN + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyActualBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyActualBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..6c927551122bba6aaecfa0856b17ce71c2df2e81 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyActualBudget.lean @@ -0,0 +1,91 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PairedFrequencyActualBudgetEnvelope + +namespace OAI + +noncomputable section +open Filter +open scoped BigOperators +namespace Ostmann.Arithmetic.PairedFrequencyActualBudget +open Conclusion Characters + +def actualBudget (C D ε δ Bs BD Bz : ℝ) (k : ℕ) (L : ℝ) (l : ℕ) : ℝ := + FrequencyTreeSum.budget (pairedRanges Bs BD Bz k L l) + (PairedFrequencyTreeSum.nodeBudget C D ε δ (addressBound Bs BD Bz k L l)) l [] + +theorem actualBudget_le_exp {C D ε δ Bs BD Bz : ℝ} + (hC : 0 ≤ C) (hD : 0 < D) (hε : 0 ≤ ε) (hδ : 0 ≤ δ) + (hBs : 0 ≤ Bs) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) + {k : ℕ} (hk : 0 < k) (L : ℝ) (hm : 1 ≤ bulkSize k L) + {l : ℕ} (hl : l ≤ k) : + actualBudget C D ε δ Bs BD Bz k L l ≤ + Real.exp ((2:ℝ)^l*(2*initialGap Bs k L+2*Real.sqrt (bulkSize k L)+2*Real.log 2)+ + ((2:ℝ)^l-1)*nodeExponent C D ε δ (scaleLinearConstant Bs BD Bz k) (bulkSize k L)) := by + apply budget_exp_bound (N:=l) + · intro p + have hlog : 0 ≤ Real.log (addressBound Bs BD Bz k L l p) := + Real.log_nonneg (by exact_mod_cast addressBound_pos hBs hBD hBz hk L l p) + unfold PairedFrequencyTreeSum.nodeBudget + positivity + · intro p + exact nodeBudget_le_exp hC hD hε hδ (scaleLinearConstant_pos Bs BD Bz k).le + (by exact_mod_cast hm) _ (addressBound_pos hBs hBD hBz hk L l) + (addressBound_le_exp Bs BD Bz k L l hl hm) p + · exact paired_leaf_card_le Bs BD Bz k L l + · simp + +theorem scalar_envelope_le {h H gap C d m : ℝ} + (hh : h ≤ H) (hC : 0 ≤ C) (hd : 0 ≤ d) (hm : 0 ≤ m) : + h*(2*gap+2*Real.sqrt m+2*Real.log 2)+(h-1)*(C+d*m+6*Real.sqrt m) ≤ + 2*h*gap+(H*d)*m+8*H*Real.sqrt m+H*(C+2*Real.log 2) := by + have hlog : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + have hn := mul_le_mul_of_nonneg_right (show h-1 ≤ H by linarith) + (show 0 ≤ C+d*m+6*Real.sqrt m by positivity) + have hr := mul_le_mul_of_nonneg_right hh + (show 0 ≤ 2*Real.sqrt m+2*Real.log 2 by positivity) + nlinarith + +theorem exists_eventually_actualBudget_le {Bs BD Bz : ℝ} + (hBs : 0 ≤ Bs) (hBD : 0 ≤ BD) (hBz : 0 ≤ Bz) + {k : ℕ} (hk : 0 < k) {ρ : ℝ} (hρ : 0 < ρ) : + ∃ ε δ : ℝ, 0 < ε ∧ 0 < δ ∧ + ∀ C D : ℝ, 0 ≤ C → 0 < D → + ∀ᶠ L : ℝ in atTop, ∀ l ≤ k, + actualBudget C D ε δ Bs BD Bz k L l ≤ + Real.exp (2*(2:ℝ)^l*initialGap Bs k L+ρ*(bulkSize k L:ℝ)) := by + let A := scaleLinearConstant Bs BD Bz k + let H : ℝ := 2^k + let ε := ρ/(8*H*A) + have hA : 0 < A := scaleLinearConstant_pos Bs BD Bz k + have hH : 0 < H := by dsimp [H]; positivity + have he : 0 < ε := div_pos hρ (by positivity) + refine ⟨ε,ε,he,he,?_⟩ + intro C D hC hD + have hcoef : H*((2*ε+2*ε)*A)=ρ/2 := by + dsimp [ε] + field_simp + ring + have habs := (bulkSize_tendsto_atTop hk).eventually + (HistoryFrequencyBudget.eventually_const_sqrt_le (8*H) + (H*(nodeConstant C D A+2*Real.log 2)) (ρ/2) (by positivity)) + have hm := (bulkSize_tendsto_atTop hk).eventually (eventually_ge_atTop (1:ℝ)) + filter_upwards [habs,hm] with L habs hm + intro l hl + have hmN : 1 ≤ bulkSize k L := by exact_mod_cast hm + have hh : (2:ℝ)^l ≤ H := pow_le_pow_right₀ (by norm_num) hl + have hb := actualBudget_le_exp hC hD he.le he.le hBs hBD hBz hk L hmN hl + apply hb.trans + apply Real.exp_le_exp.mpr + change (2:ℝ)^l*(2*initialGap Bs k L+2*Real.sqrt (bulkSize k L)+2*Real.log 2)+ + ((2:ℝ)^l-1)*(nodeConstant C D A+(2*ε+2*ε)*A*(bulkSize k L:ℝ)+ + 6*Real.sqrt (bulkSize k L)) ≤ _ + have hs := scalar_envelope_le (gap:=initialGap Bs k L) + (m:=(bulkSize k L:ℝ)) hh (nodeConstant_nonneg (C:=C) (D:=D) hA.le) + (show 0 ≤ (2*ε+2*ε)*A by positivity) (Nat.cast_nonneg _) + rw [hcoef] at hs + nlinarith + +end Ostmann.Arithmetic.PairedFrequencyActualBudget + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyActualBudgetBasic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyActualBudgetBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..27232cc19fccf6a4787ec047e15dd1b1153f9cf9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyActualBudgetBasic.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.HistorySmoothWeightScaleNumerics +import OAI.NumberTheory.Ostmann.Arithmetic.PairedFrequencyTreeSumCount +import OAI.NumberTheory.Ostmann.Characters.HistoryFrequencyBudgetAbsorption +import OAI.NumberTheory.Ostmann.Conclusion.FinalRateAbsorptionBasic + +namespace OAI + +noncomputable section +open scoped BigOperators +namespace Ostmann.Arithmetic.PairedFrequencyActualBudget +open Conclusion Characters + +def addressBound (Bs BD Bz : ℝ) (k : ℕ) (L : ℝ) (l : ℕ) (p : List Bool) : ℕ := + frequencyBound Bs BD Bz k L (l-p.length) + +def pairedRanges (Bs BD Bz : ℝ) (k : ℕ) (L : ℝ) (l : ℕ) + (p : List Bool) : Finset (ℤ × ℤ) := + let S := HistoryFrequencyBudget.signedRange (addressBound Bs BD Bz k L l p) + S ×ˢ S + +theorem mem_pairedRanges (Bs BD Bz : ℝ) (k : ℕ) (L : ℝ) (l : ℕ) + (p : List Bool) (s : ℤ × ℤ) : + s∈pairedRanges Bs BD Bz k L l p ↔ + (s.1≠0 ∧ s.1.natAbs≤addressBound Bs BD Bz k L l p) ∧ + (s.2≠0 ∧ s.2.natAbs≤addressBound Bs BD Bz k L l p) := by + simp [pairedRanges,HistoryFrequencyBudget.mem_signedRange] + +@[simp] theorem pairedRanges_card (Bs BD Bz : ℝ) (k : ℕ) (L : ℝ) (l : ℕ) + (p : List Bool) : + (pairedRanges Bs BD Bz k L l p).card=(2*addressBound Bs BD Bz k L l p)^2 := by + simp [pairedRanges,HistoryFrequencyBudget.signedRange_card,pow_two] + +theorem addressBound_pos {Bs BD Bz : ℝ} (hBs : 0≤Bs) (hBD : 0≤BD) (hBz : 0≤Bz) + {k : ℕ} (hk : 0 exact Nat.cast_nonneg _ + | succ j ih => exact mul_nonneg (mul_nonneg (hC p) (ih _)) (ih _) + induction j generalizing p with + | zero => simpa only [FrequencyTreeSum.budget,pow_zero,one_mul,sub_self,zero_mul,add_zero] + using hleaf p (by omega) + | succ j ih => + have hl := ih (false::p) (by simp only [List.length_cons]; omega) + have hr := ih (true::p) (by simp only [List.length_cons]; omega) + calc + _≤Real.exp B*Real.exp ((2:ℝ)^j*A+((2:ℝ)^j-1)*B)* + Real.exp ((2:ℝ)^j*A+((2:ℝ)^j-1)*B) := + mul_le_mul (mul_le_mul (hnode p) hl (hn _ _) (Real.exp_pos _).le) + hr (hn _ _) (by positivity) + _=_ := by rw [←Real.exp_add,←Real.exp_add]; congr 1; rw [pow_succ]; ring + +end Ostmann.Arithmetic.PairedFrequencyActualBudget + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyActualBudgetEnvelope.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyActualBudgetEnvelope.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a10f6e8170377770c8481dea25dc29889ad8105 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyActualBudgetEnvelope.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PairedFrequencyActualBudgetBasic + +namespace OAI + +noncomputable section +open scoped BigOperators +namespace Ostmann.Arithmetic.PairedFrequencyActualBudget +open Conclusion Characters + +def nodeConstant (C D A : ℝ) : ℝ := Real.log (max (4*C*D^2) 1*(1+A)^3) + +def nodeExponent (C D ε δ A m : ℝ) : ℝ := + nodeConstant C D A+(2*δ+2*ε)*A*m+6*Real.sqrt m + +theorem nodeConstant_nonneg {C D A : ℝ} (hA : 0 ≤ A) : 0 ≤ nodeConstant C D A := by + apply Real.log_nonneg + have hp : (1:ℝ) ≤ (1+A)^3 := one_le_pow₀ (by linarith) + exact one_le_mul_of_one_le_of_one_le (le_max_right _ _) hp + +private theorem self_le_exp_two_sqrt {m : ℝ} (hm : 0 < m) : + m ≤ Real.exp (2*Real.sqrt m) := by + have hl := Real.log_le_rpow_div hm.le (by norm_num : (0:ℝ)<1/2) + rw [←Real.sqrt_eq_rpow] at hl + have he := Real.exp_le_exp.mpr hl + rw [Real.exp_log hm] at he + convert he using 1 + congr 1 + ring + +theorem nodeBudget_le_exp {C D ε δ A m : ℝ} (_hC : 0 ≤ C) (_hD : 0 defaultData Q + | _+1,p,x,[] => + ⟨x.1.val.1,x.1.val.2,(root S x.2.1).1,(root S x.2.2).1, + (root S x.2.1).2,(root S x.2.2).2, + (hdiv p x.1.val x.1.property).1,(hdiv p x.1.val x.1.property).2⟩ + | _+1,_,x,false::q => assignmentDataForward x.2.1 q + | _+1,_,x,true::q => assignmentDataForward x.2.2 q + +def assignmentData {k : ℕ} {p : List Bool} (x : Assignment S k p) + (q : List Bool) : FrequencyExposure.Data Q := + assignmentDataForward S hdiv x q.reverse + +theorem assignmentData_left {k : ℕ} {p : List Bool} (x : Assignment S (k+1) p) + (q : List Bool) : + assignmentData S hdiv x (q ++ [false]) = assignmentData S hdiv x.2.1 q := by + simp [assignmentData, List.reverse_append, assignmentDataForward] + +theorem assignmentData_right {k : ℕ} {p : List Bool} (x : Assignment S (k+1) p) + (q : List Bool) : + assignmentData S hdiv x (q ++ [true]) = assignmentData S hdiv x.2.2 q := by + simp [assignmentData, List.reverse_append, assignmentDataForward] + +theorem budget_eq_weight_shift (C : NNReal) (ε : ℝ) {k : ℕ} {p : List Bool} + (x : Assignment S k p) (d : List Bool → FrequencyExposure.Data Q) (r : List Bool) + (hd : ∀ q, d (q ++ r) = assignmentData S hdiv x q) : + ((FrequencyExposure.budget C ε d k r).value : ℝ) = + weight S (factor (C : ℝ) ε) x := by + induction k generalizing p r with + | zero => rfl + | succ k ih => + have hleft : ∀ q, d (q ++ false :: r) = assignmentData S hdiv x.2.1 q := by + intro q + calc + _ = d ((q ++ [false]) ++ r) := by simp only [List.append_assoc, List.cons_append, List.nil_append] + _ = assignmentData S hdiv x (q ++ [false]) := hd _ + _ = _ := assignmentData_left S hdiv x q + have hright : ∀ q, d (q ++ true :: r) = assignmentData S hdiv x.2.2 q := by + intro q + calc + _ = d ((q ++ [true]) ++ r) := by simp only [List.append_assoc, List.cons_append, List.nil_append] + _ = assignmentData S hdiv x (q ++ [true]) := hd _ + _ = _ := assignmentData_right S hdiv x q + have hroot : d r = assignmentData S hdiv x [] := by simpa using hd [] + change ((C : ℝ) * (FrequencyExposure.reducedPair (d r) : ℝ) ^ (ε - 1)) * + ((FrequencyExposure.budget C ε d k (false :: r)).value : ℝ) * + ((FrequencyExposure.budget C ε d k (true :: r)).value : ℝ) = _ + rw [ih x.2.1 (false :: r) hleft, ih x.2.2 (true :: r) hright, hroot] + rfl + +theorem budget_eq_weight (C : NNReal) (ε : ℝ) {k : ℕ} {p : List Bool} + (x : Assignment S k p) : + ((FrequencyExposure.budget C ε (assignmentData S hdiv x) k []).value : ℝ) = + weight S (factor (C : ℝ) ε) x := + budget_eq_weight_shift S hdiv C ε x _ [] (fun q => by rw [List.append_nil]) + +end Ostmann.Arithmetic.PairedFrequencyTreeSum + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyTreeSumLocal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyTreeSumLocal.lean new file mode 100644 index 0000000000000000000000000000000000000000..167eec1b1c7521929bc3196ae4035b5234990bfd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedFrequencyTreeSumLocal.lean @@ -0,0 +1,122 @@ +import Mathlib.Analysis.SpecialFunctions.Pow.Real +import OAI.NumberTheory.Ostmann.Arithmetic.FrequencyLCM +import OAI.NumberTheory.Ostmann.Characters.FrequencyHarmonic + +namespace OAI + +noncomputable section +open scoped BigOperators +namespace Ostmann.Arithmetic.PairedFrequencyTreeSum +open FrequencyMultiplicity + +theorem reduced_sum_le (v w : ℤ) (hv : v ≠ 0) (S : Finset ℤ) (V : ℕ) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V) (f : ℕ → ℝ) (hf : ∀ a, 0 ≤ f a) : + ∑ s ∈ S, f (reducedModulus v w s) ≤ + (2 * ((v.natAbs.gcd w.natAbs).divisors.card : ℝ)) * ∑ a ∈ Finset.Icc 1 V, f a := by + have hmap : ∀ s ∈ S, reducedModulus v w s ∈ Finset.Icc 1 V := + fun s hs => Characters.reducedModulus_mem_Icc v w s (hS s hs).1 V (hS s hs).2 + calc + _ = ∑ a ∈ Finset.Icc 1 V, ∑ s ∈ S with reducedModulus v w s = a, f a := + (Finset.sum_fiberwise_of_maps_to' hmap f).symm + _ ≤ ∑ a ∈ Finset.Icc 1 V, (2 * ((v.natAbs.gcd w.natAbs).divisors.card : ℝ)) * f a := by + apply Finset.sum_le_sum + intro a ha + simp only [Finset.sum_const, nsmul_eq_mul] + apply mul_le_mul_of_nonneg_right _ (hf a) + exact_mod_cast reduced_fiber_card v w hv S a + _ = _ := (Finset.mul_sum _ _ _).symm + +def modulus (s v w : ℤ × ℤ) : ℕ := + (reducedModulus v.1 w.1 s.1).lcm (reducedModulus v.2 w.2 s.2) + +theorem paired_reduced_sum_le (S : Finset (ℤ × ℤ)) (V : ℕ) + (hS : ∀ s ∈ S, (s.1 ≠ 0 ∧ s.1.natAbs ≤ V) ∧ (s.2 ≠ 0 ∧ s.2.natAbs ≤ V)) + (v w : ℤ × ℤ) (hv : v.1 ≠ 0 ∧ v.2 ≠ 0) + (f : ℕ → ℕ → ℝ) (hf : ∀ a b, 0 ≤ f a b) : + ∑ s ∈ S, f (reducedModulus v.1 w.1 s.1) (reducedModulus v.2 w.2 s.2) ≤ + 4 * ((v.1.natAbs.gcd w.1.natAbs).divisors.card : ℝ) * + ((v.2.natAbs.gcd w.2.natAbs).divisors.card : ℝ) * + ∑ a ∈ Finset.Icc 1 V, ∑ b ∈ Finset.Icc 1 V, f a b := by + let A := S.image Prod.fst + let B := S.image Prod.snd + have hA : ∀ s ∈ A, s ≠ 0 ∧ s.natAbs ≤ V := by + intro s hs + obtain ⟨z,hz,rfl⟩ := Finset.mem_image.mp hs + exact (hS z hz).1 + have hB : ∀ s ∈ B, s ≠ 0 ∧ s.natAbs ≤ V := by + intro s hs + obtain ⟨z,hz,rfl⟩ := Finset.mem_image.mp hs + exact (hS z hz).2 + have hsub : S ⊆ A ×ˢ B := fun z hz => Finset.mem_product.mpr + ⟨Finset.mem_image.mpr ⟨z,hz,rfl⟩, Finset.mem_image.mpr ⟨z,hz,rfl⟩⟩ + calc + _ ≤ ∑ s ∈ A ×ˢ B, f (reducedModulus v.1 w.1 s.1) (reducedModulus v.2 w.2 s.2) := + Finset.sum_le_sum_of_subset_of_nonneg hsub (fun _ _ _ => hf _ _) + _ = ∑ s ∈ A, ∑ t ∈ B, f (reducedModulus v.1 w.1 s) (reducedModulus v.2 w.2 t) := + Finset.sum_product _ _ _ + _ ≤ ∑ s ∈ A, (2 * ((v.2.natAbs.gcd w.2.natAbs).divisors.card : ℝ)) * + ∑ b ∈ Finset.Icc 1 V, f (reducedModulus v.1 w.1 s) b := by + apply Finset.sum_le_sum + intro s hs + exact reduced_sum_le v.2 w.2 hv.2 B V hB (f (reducedModulus v.1 w.1 s)) (hf _) + _ = (2 * ((v.2.natAbs.gcd w.2.natAbs).divisors.card : ℝ)) * + ∑ s ∈ A, ∑ b ∈ Finset.Icc 1 V, f (reducedModulus v.1 w.1 s) b := by rw [Finset.mul_sum] + _ ≤ (2 * ((v.2.natAbs.gcd w.2.natAbs).divisors.card : ℝ)) * + ((2 * ((v.1.natAbs.gcd w.1.natAbs).divisors.card : ℝ)) * + ∑ a ∈ Finset.Icc 1 V, ∑ b ∈ Finset.Icc 1 V, f a b) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact reduced_sum_le v.1 w.1 hv.1 A V hA (fun a => ∑ b ∈ Finset.Icc 1 V, f a b) + (fun a => Finset.sum_nonneg (fun b _ => hf a b)) + _ = _ := by ring + +theorem lcm_rpow_le {V a b : ℕ} (ha : a ∈ Finset.Icc 1 V) + (hb : b ∈ Finset.Icc 1 V) {ε : ℝ} (hε : 0 ≤ ε) : + ((a.lcm b : ℕ) : ℝ) ^ (ε - 1) ≤ (V : ℝ) ^ (2 * ε) * ((a.lcm b : ℕ) : ℝ)⁻¹ := by + have hl : 0 < ((a.lcm b : ℕ) : ℝ) := by + exact_mod_cast Nat.lcm_pos (Finset.mem_Icc.mp ha).1 (Finset.mem_Icc.mp hb).1 + have hle : ((a.lcm b : ℕ) : ℝ) ≤ (V : ℝ) ^ 2 := by + have hn : a.lcm b ≤ V * V := (Nat.lcm_le_mul (Finset.mem_Icc.mp ha).1 + (Finset.mem_Icc.mp hb).1).trans (Nat.mul_le_mul (Finset.mem_Icc.mp ha).2 + (Finset.mem_Icc.mp hb).2) + simpa only [pow_two] using (show ((a.lcm b : ℕ) : ℝ) ≤ (V : ℝ) * V by exact_mod_cast hn) + calc + _ = ((a.lcm b : ℕ) : ℝ) ^ ε * ((a.lcm b : ℕ) : ℝ)⁻¹ := by + rw [Real.rpow_sub hl, Real.rpow_one, div_eq_mul_inv] + _ ≤ ((V : ℝ) ^ 2) ^ ε * ((a.lcm b : ℕ) : ℝ)⁻¹ := + mul_le_mul_of_nonneg_right (Real.rpow_le_rpow hl.le hle hε) (by positivity) + _ = _ := by + rw [← Real.rpow_natCast (V : ℝ) 2, ← Real.rpow_mul (Nat.cast_nonneg V)] + norm_num + +theorem local_sum_le (S : Finset (ℤ × ℤ)) (V : ℕ) + (hS : ∀ s ∈ S, (s.1 ≠ 0 ∧ s.1.natAbs ≤ V) ∧ (s.2 ≠ 0 ∧ s.2.natAbs ≤ V)) + (v w : ℤ × ℤ) (hv : v.1 ≠ 0 ∧ v.2 ≠ 0) {ε : ℝ} (hε : 0 ≤ ε) : + ∑ s ∈ S, (modulus s v w : ℝ) ^ (ε - 1) ≤ + 4 * ((v.1.natAbs.gcd w.1.natAbs).divisors.card : ℝ) * + ((v.2.natAbs.gcd w.2.natAbs).divisors.card : ℝ) * + (V : ℝ) ^ (2 * ε) * (1 + Real.log V) ^ 3 := by + apply (paired_reduced_sum_le S V hS v w hv + (fun a b => ((a.lcm b : ℕ) : ℝ) ^ (ε - 1)) (fun a b => by positivity)).trans + have hsum : (∑ a ∈ Finset.Icc 1 V, ∑ b ∈ Finset.Icc 1 V, + ((a.lcm b : ℕ) : ℝ) ^ (ε - 1)) ≤ (V : ℝ) ^ (2 * ε) * (1 + Real.log V) ^ 3 := by + calc + _ ≤ ∑ a ∈ Finset.Icc 1 V, ∑ b ∈ Finset.Icc 1 V, + (V : ℝ) ^ (2 * ε) * ((a.lcm b : ℕ) : ℝ)⁻¹ := by + apply Finset.sum_le_sum + intro a ha + exact Finset.sum_le_sum (fun b hb => lcm_rpow_le ha hb hε) + _ = (V : ℝ) ^ (2 * ε) * (∑ a ∈ Finset.Icc 1 V, ∑ b ∈ Finset.Icc 1 V, + ((a.lcm b : ℕ) : ℝ)⁻¹) := by simp only [Finset.mul_sum] + _ ≤ _ := mul_le_mul_of_nonneg_left (FrequencyLCM.reciprocal_lcm_sum_le_log V) (by positivity) + calc + _ ≤ (4 * ((v.1.natAbs.gcd w.1.natAbs).divisors.card : ℝ) * + ((v.2.natAbs.gcd w.2.natAbs).divisors.card : ℝ)) * + ((V : ℝ) ^ (2 * ε) * (1 + Real.log V) ^ 3) := + mul_le_mul_of_nonneg_left hsum (by positivity) + _ = _ := by ring + +end Ostmann.Arithmetic.PairedFrequencyTreeSum + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedScheduledNormBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedScheduledNormBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff9975a493784ee59e1a2e53bbc7ca1d4d73c9cc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedScheduledNormBound.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PairedScheduledSum +import OAI.NumberTheory.Ostmann.Arithmetic.PatternFrequencyNormSum + +namespace OAI + +/-! # The original two scheduled frequency sums satisfy the arithmetic budget -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem paired_scheduled_frequency_budget (V : ℕ → ℕ) (hV : Monotone V) (n : ℕ) + (D K err : ℝ) (hD : 0 ≤ D) (hK : 0 ≤ K) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ V n ^ 2 → (q.divisors.card : ℝ) ≤ D) + (F : FrequencyTree ℤ n → FrequencyTree ℤ n → ℝ) + (hF : ∀ a b, 0 ≤ F a b) + (hzeroL : ∀ a : ScheduledFrequencyIndex V n, ∀ t, + ¬(∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) → + F (scheduledFrequencyHistory V n a) t = 0) + (hzeroR : ∀ t, ∀ a : ScheduledFrequencyIndex V n, + ¬(∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) → + F t (scheduledFrequencyHistory V n a) = 0) + (hpoint : ∀ t : FrequencyTree (((transferFrequencyRange (V n)).erase 0) × + ((transferFrequencyRange (V n)).erase 0)) n, + F (frequencyTreeMap Subtype.val n + (frequencyPairProjection ((transferFrequencyRange (V n)).erase 0) n false t)) + (frequencyTreeMap Subtype.val n + (frequencyPairProjection ((transferFrequencyRange (V n)).erase 0) n true t)) ≤ + err + K * (frequencyLeafWeight (pairedFrequencyLeaf ((transferFrequencyRange (V n)).erase 0) + (V 0)) n t * ((frequencySplitList ((transferFrequencyRange (V n)).erase 0) n t).map + (pairFrequencySupportBound D)).prod)) : + (∑ a : ScheduledFrequencyIndex V n, ∑ b : ScheduledFrequencyIndex V n, + F (scheduledFrequencyHistory V n a) (scheduledFrequencyHistory V n b)) ≤ + (Fintype.card (FrequencyTree (((transferFrequencyRange (V n)).erase 0) × + ((transferFrequencyRange (V n)).erase 0)) n) : ℝ) * err + + K * ((8 * D ^ 4 * (1 + Real.log (V n)) ^ 3) ^ (2 ^ n - 1) * + (2 * (V 0 : ℝ)) ^ (2 * 2 ^ n)) := by + let S := (transferFrequencyRange (V n)).erase 0 + let H := fun t : FrequencyTree (S × S) n => + F (frequencyTreeMap Subtype.val n (frequencyPairProjection S n false t)) + (frequencyTreeMap Subtype.val n (frequencyPairProjection S n true t)) + have hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ V n := by + intro s hs + exact ⟨(Finset.mem_erase.mp hs).1, (mem_transferFrequencyRange _ _).mp (Finset.mem_erase.mp hs).2⟩ + have hbudget := paired_frequency_norm_sum_le S n (V n) (V 0) D K err hD hK hS hdiv + (fun t => (H t : ℂ)) (fun t => by + rw [Complex.norm_real, Real.norm_of_nonneg (hF _ _)] + exact hpoint t) + have hsum0 : 0 ≤ ∑ t : FrequencyTree (S × S) n, H t := Finset.sum_nonneg (fun _ _ => hF _ _) + rw [← Complex.ofReal_sum, Complex.norm_real, Real.norm_of_nonneg hsum0] at hbudget + apply (paired_scheduled_history_sum_le V hV n F hF hzeroL hzeroR).trans + apply le_trans _ hbudget + apply Finset.sum_le_sum + intro t _ + split_ifs with hcut + · exact le_rfl + · exact hF _ _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedScheduledSum.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedScheduledSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ca82414fcca4659b59cf162f52a67cc9e6e524a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PairedScheduledSum.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.Ostmann.Construction.PairedScheduledHistory + +namespace OAI + +/-! # Extending both scheduled frequency sums with their bottom cutoffs intact -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem paired_scheduled_history_sum_le (V : ℕ → ℕ) (hV : Monotone V) (n : ℕ) + (F : FrequencyTree ℤ n → FrequencyTree ℤ n → ℝ) + (hF : ∀ a b, 0 ≤ F a b) + (hzeroL : ∀ a : ScheduledFrequencyIndex V n, ∀ t, + ¬(∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) → + F (scheduledFrequencyHistory V n a) t = 0) + (hzeroR : ∀ t, ∀ a : ScheduledFrequencyIndex V n, + ¬(∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0) → + F t (scheduledFrequencyHistory V n a) = 0) : + (∑ a : ScheduledFrequencyIndex V n, ∑ b : ScheduledFrequencyIndex V n, + F (scheduledFrequencyHistory V n a) (scheduledFrequencyHistory V n b)) ≤ + ∑ t : FrequencyTree (((transferFrequencyRange (V n)).erase 0) × + ((transferFrequencyRange (V n)).erase 0)) n, + if frequencyLeafWeight (pairedFrequencyLeaf ((transferFrequencyRange (V n)).erase 0) + (V 0)) n t = 1 then + F (frequencyTreeMap Subtype.val n + (frequencyPairProjection ((transferFrequencyRange (V n)).erase 0) n false t)) + (frequencyTreeMap Subtype.val n + (frequencyPairProjection ((transferFrequencyRange (V n)).erase 0) n true t)) + else 0 := by + let p := fun a : ScheduledFrequencyIndex V n => + ∀ s ∈ allFrequencyList n (scheduledFrequencyHistory V n a), s ≠ 0 + have hr (t : FrequencyTree ℤ n) : + (∑ b : ScheduledFrequencyIndex V n, F t (scheduledFrequencyHistory V n b)) = + ∑ b : NonzeroScheduledHistory V n, F t (scheduledFrequencyHistory V n b.val) := by + have h := Fintype.sum_subtype_add_sum_subtype p (fun b => F t (scheduledFrequencyHistory V n b)) + have hz : (∑ b : {b // ¬p b}, F t (scheduledFrequencyHistory V n b.val)) = 0 := + Finset.sum_eq_zero (fun b _ => hzeroR t b.val b.property) + rw [hz, add_zero] at h + exact h.symm + have hl : + (∑ a : ScheduledFrequencyIndex V n, ∑ b : NonzeroScheduledHistory V n, + F (scheduledFrequencyHistory V n a) (scheduledFrequencyHistory V n b.val)) = + ∑ a : NonzeroScheduledHistory V n, ∑ b : NonzeroScheduledHistory V n, + F (scheduledFrequencyHistory V n a.val) (scheduledFrequencyHistory V n b.val) := by + have h := Fintype.sum_subtype_add_sum_subtype p (fun a => + ∑ b : NonzeroScheduledHistory V n, + F (scheduledFrequencyHistory V n a) (scheduledFrequencyHistory V n b.val)) + have hz : (∑ a : {a // ¬p a}, ∑ b : NonzeroScheduledHistory V n, + F (scheduledFrequencyHistory V n a.val) (scheduledFrequencyHistory V n b.val)) = 0 := by + apply Finset.sum_eq_zero + intro a _ + exact Finset.sum_eq_zero (fun b _ => hzeroL a.val _ a.property) + rw [hz, add_zero] at h + exact h.symm + let e := pairedScheduledHistoryEmbedding V hV n + let G := fun t : FrequencyTree (((transferFrequencyRange (V n)).erase 0) × + ((transferFrequencyRange (V n)).erase 0)) n => + if frequencyLeafWeight (pairedFrequencyLeaf ((transferFrequencyRange (V n)).erase 0) + (V 0)) n t = 1 then + F (frequencyTreeMap Subtype.val n + (frequencyPairProjection ((transferFrequencyRange (V n)).erase 0) n false t)) + (frequencyTreeMap Subtype.val n + (frequencyPairProjection ((transferFrequencyRange (V n)).erase 0) n true t)) + else 0 + have he (a : NonzeroScheduledHistory V n × NonzeroScheduledHistory V n) : + G (e a) = F (scheduledFrequencyHistory V n a.1.val) (scheduledFrequencyHistory V n a.2.val) := by + dsimp only [G, e] + rw [pairedScheduledHistoryEmbedding_leaf, ite_eq_left rfl, + pairedScheduledHistoryEmbedding_projection, pairedScheduledHistoryEmbedding_projection] + rfl + calc + _ = ∑ a : NonzeroScheduledHistory V n × NonzeroScheduledHistory V n, + F (scheduledFrequencyHistory V n a.1.val) (scheduledFrequencyHistory V n a.2.val) := by + simp_rw [hr] + rw [hl, Fintype.sum_prod_type] + _ = ∑ a : NonzeroScheduledHistory V n × NonzeroScheduledHistory V n, G (e a) := by + exact Finset.sum_congr rfl (fun a _ => (he a).symm) + _ ≤ ∑ t, G t := by + rw [← Finset.sum_map] + exact Finset.sum_le_sum_of_subset_of_nonneg (Finset.subset_univ _) (by + intro t _ _ + dsimp only [G] + split_ifs + · exact hF _ _ + · exact le_rfl) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PatternFrequencyNormSum.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PatternFrequencyNormSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..72c90968875299179333da52f24d4368b14dc6c1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PatternFrequencyNormSum.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternUniformBudget +import OAI.NumberTheory.Ostmann.Arithmetic.VariableModulusSupport + +namespace OAI + +/-! # Summing the arithmetic norm over frequencies and internal patterns -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The two-history norm retains every node's reduced-modulus bound. Only +the negligible comparison errors are multiplied by the full history count. -/ +theorem paired_frequency_norm_sum_le (S : Finset ℤ) (n N V : ℕ) + (D K err : ℝ) (hD : 0 ≤ D) (hK : 0 ≤ K) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) + (R : FrequencyTree (S × S) n → ℂ) + (hR : ∀ t, ‖R t‖ ≤ err + K * + (frequencyLeafWeight (pairedFrequencyLeaf S V) n t * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod)) : + ‖∑ t, R t‖ ≤ (Fintype.card (FrequencyTree (S × S) n) : ℝ) * err + + K * ((8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) * + (2 * (V : ℝ)) ^ (2 * 2 ^ n)) := by + have hsum := arithmetic_frequency_tree_sum_le S N V D hD hS + (gcd_frequency_divisor_bound S N D hS hdiv) n + calc + _ ≤ ∑ t, (err + K * frequencyTreeWeight + (pairedFrequencyKernel S D) (pairedFrequencyLeaf S V) n t) := by + apply norm_sum_le_of_le + intro t _ + simpa only [frequencyTreeWeight_eq_splitList, mul_comm] using hR t + _ = (Fintype.card (FrequencyTree (S × S) n) : ℝ) * err + + K * ∑ t, frequencyTreeWeight (pairedFrequencyKernel S D) (pairedFrequencyLeaf S V) n t := by + rw [Finset.sum_add_distrib, ← Finset.mul_sum, Finset.sum_const, + Finset.card_univ, nsmul_eq_mul] + _ ≤ _ := add_le_add le_rfl (mul_le_mul_of_nonneg_left hsum hK) + +/-- The same retained frequency sum survives summing every equality pattern +of the original internal prime samples. -/ +theorem pattern_frequency_norm_sum_le (S : Finset ℤ) (n N V : ℕ) + (D E K err : ℝ) (hD : 0 ≤ D) (hE : 0 ≤ E) (hK : 0 ≤ K) (herr : 0 ≤ err) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + ∀ R : Setoid (Bool × MovingSampleIndex n) → FrequencyTree (S × S) n → ℂ, + (∀ s t, ‖R s t‖ ≤ + ((2 : ℝ) ^ Fintype.card (Quotient s) * E ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) * + (err + K * (frequencyLeafWeight (pairedFrequencyLeaf S V) n t * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod))) → + ‖∑ s, ∑ t, R s t‖ ≤ + ((2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) * (max 2 E) ^ (4 * n * 2 ^ n)) * + ((Fintype.card (FrequencyTree (S × S) n) : ℝ) * err + + K * ((8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) * + (2 * (V : ℝ)) ^ (2 * 2 ^ n))) := by + dsimp only + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + intro R hR + let T : ℝ := (Fintype.card (FrequencyTree (S × S) n) : ℝ) * err + + K * ((8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) * + (2 * (V : ℝ)) ^ (2 * 2 ^ n)) + have hlog := Real.log_natCast_nonneg N + have hT : 0 ≤ T := by dsimp only [T]; positivity + have hs (s : Setoid (Bool × MovingSampleIndex n)) : + ‖∑ t, R s t‖ ≤ T * ((2 : ℝ) ^ Fintype.card (Quotient s) * + E ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) := by + let κ : ℝ := (2 : ℝ) ^ Fintype.card (Quotient s) * + E ^ (4 * n * 2 ^ n - Fintype.card (Quotient s)) + have hκ : 0 ≤ κ := mul_nonneg (by positivity) (pow_nonneg hE _) + have h := paired_frequency_norm_sum_le S n N V D (κ * K) (κ * err) hD + (mul_nonneg hκ hK) hS hdiv (R s) (fun t => by + simpa only [κ, mul_add, mul_assoc] using hR s t) + exact h.trans_eq (by dsimp only [T]; ring) + have h := movingPattern_error_sum_le n E T hE hT (fun s => ∑ t, R s t) hs + exact h.trans_eq (by ring) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicGraphCancellation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicGraphCancellation.lean new file mode 100644 index 0000000000000000000000000000000000000000..744cf0468eb547cae50fa8352a72bdc5d52a69a9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicGraphCancellation.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.ZeroDensity.DirichletGraphFactor +import OAI.NumberTheory.Ostmann.Arithmetic.HarmonicPeriodicBound + +namespace OAI + +/-! # Graph cancellation with the retained frequency residue conditions -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem harmonic_periodic_graph_bound {J : Type*} [Fintype J] + (χ : (Bool ⊕ J) → ∀ p : ℕ, DirichletCharacter ℂ p) + (b : (Bool ⊕ J) → (Bool ⊕ J) → ℤ) + (unary : (Bool ⊕ J) → ℕ → ℂ) (fixed : J → ℕ) + (hunary : ∀ i x, ‖unary i x‖ ≤ 1) + (hself : b (.inl true) (.inl true) = 0 ∧ b (.inl false) (.inl false) = 0) + (hreverse : b (.inl false) (.inl true) = 0) + (P Q : Finset ℕ) (hprime : ∀ q ∈ Q, q.Prime) + (hnonprincipal : ∀ q ∈ Q, χ (.inl true) q ^ b (.inl true) (.inl false) ≠ 1) + (a M K : ℕ) (ha : 0 < a) (hM : ∀ q : Q, M.Coprime (q : ℕ)) + (gate : Q → ZMod M → ℂ) (hgate : ∀ q z, ‖gate q z‖ ≤ 1) + (hlow : ∀ p ∈ P, a ≤ p) (hhigh : ∀ p ∈ P, p < a + K * M) + (b₀ : ℝ) (hb₀ : 0 < b₀) (hbQ : ∀ q ∈ Q, b₀ ≤ (q : ℝ)) + (hPmass : 0 < ∑ p ∈ P, (p : ℝ)⁻¹) (hQmass : 0 < ∑ q ∈ Q, (q : ℝ)⁻¹) + {n t : ℕ} (F : Q → Fin n → ClippedPolynomialFactor) + (H : Q → Fin t → Polynomial ℝ) (keep : Q → (Fin t → Bool) → Bool) + (B : ℝ) (R Bq : ℕ) (hB : 0 ≤ B) + (hbudget : ∀ q, smoothPolynomialBudget (F q) ≤ B) + (hcomplexity : ∀ q, polynomialWeightComplexity (F q) (H q) ≤ R) + (hBq : ∀ q : Q, (q : ℕ) ≤ Bq) : + ‖∑ p : P, (primeSubsetPrior P P p : ℂ) * + ∑ q : Q, (primeSubsetPrior Q Q q : ℂ) * + (finiteEdgeWeight (dirichletGraphEdge χ b) unary + (twoVertexLabels fixed (q : ℕ) (p : ℕ)) * + (gate q ((p : ℕ) : ZMod M) * polynomialAmplitude (F q) (H q) (keep q) (p : ℝ)))‖ ^ 2 ≤ + (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (((∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ * b₀⁻¹) * (((K * M : ℕ) : ℝ) / a * B ^ 2) + + (M : ℝ) * ((3 ^ (2 * R) : ℕ) * (2 * (a : ℝ)⁻¹ * B ^ 2)) * (Bq : ℝ) ^ 2) := by + have hQne : Q.Nonempty := by + by_contra h + have he : Q = ∅ := Finset.not_nonempty_iff_eq_empty.mp h + simp only [he, Finset.sum_empty] at hQmass + exact (lt_irrefl (0 : ℝ)) hQmass + obtain ⟨q₀, hq₀⟩ := hQne + have hforward : b (.inl true) (.inl false) ≠ 0 := by + intro h + have hh := hnonprincipal q₀ hq₀ + simp only [h, zpow_zero, ne_eq, not_true_eq_false] at hh + obtain ⟨U, V, hU, hV, hfactor⟩ := dirichlet_one_sided_graph_factorization + χ b unary fixed hunary hself hreverse hforward + have hb := harmonic_periodic_polynomial_one_sided_bound P Q hprime + (fun q => χ (.inl true) q ^ b (.inl true) (.inl false)) + (fun q => hnonprincipal q q.property) a M K ha hM gate hgate hlow hhigh b₀ hb₀ hbQ hPmass hQmass + F H keep B R Bq hB hbudget hcomplexity hBq + (fun p => U p) (fun q => V q) (fun p => hU p) (fun q => hV q) + have he : (∑ p : P, (primeSubsetPrior P P p : ℂ) * + ∑ q : Q, (primeSubsetPrior Q Q q : ℂ) * + (finiteEdgeWeight (dirichletGraphEdge χ b) unary + (twoVertexLabels fixed (q : ℕ) (p : ℕ)) * + (gate q ((p : ℕ) : ZMod M) * polynomialAmplitude (F q) (H q) (keep q) (p : ℝ)))) = + ∑ p : P, (primeSubsetPrior P P p : ℂ) * + (U p * ∑ q : Q, (primeSubsetPrior Q Q q : ℂ) * V q * + ((χ (.inl true) q ^ b (.inl true) (.inl false)) ((p : ℕ) : ZMod (q : ℕ)) * + (gate q ((p : ℕ) : ZMod M) * polynomialAmplitude (F q) (H q) (keep q) (p : ℝ)))) := by + apply Finset.sum_congr rfl + intro p _ + congr 1 + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro q _ + rw [hfactor] + ring + rw [he] + exact hb + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicIntervalPhase.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicIntervalPhase.lean new file mode 100644 index 0000000000000000000000000000000000000000..736b48d6722cf5c08b2168b8b494285b9e32a8ce --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicIntervalPhase.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.Ostmann.ZeroDensity.OriginalDensityCorrelation + +namespace OAI + +/-! # The periodic phase estimate on a translated integer interval -/ + +namespace Ostmann + +open scoped BigOperators + +theorem weighted_periodic_linear_shift_bound (q : ℕ) [NeZero q] + (f : ZMod q → ℂ) (A α : ℝ) (hA : 0 ≤ A) + (hf : ∀ u, ‖additiveFourier f u‖ ≤ A) (w : ℕ → ℂ) (M N : ℕ) : + ‖∑ n ∈ Finset.range N, w n * + (f ((n + M : ℕ) : ZMod q) * realAdditivePhase α ^ (n + M))‖ ≤ + discreteVariation w N * (2 * A * ((N : ℝ) + q * (1 + Real.log q))) := by + have ht (u : ZMod q) : ‖additiveFourier (fun x => f (x + (M : ZMod q))) u‖ ≤ A := by + rw [additiveFourier_add_right, norm_mul] + have hc : ‖ZMod.stdAddChar ((M : ZMod q) * u)‖ = 1 := by simp [ZMod.stdAddChar_apply] + rw [hc, one_mul] + exact hf u + have heq : (∑ n ∈ Finset.range N, w n * + (f ((n + M : ℕ) : ZMod q) * realAdditivePhase α ^ (n + M))) = + realAdditivePhase α ^ M * ∑ n ∈ Finset.range N, w n * + ((fun x : ZMod q => f (x + (M : ZMod q))) (n : ZMod q) * realAdditivePhase α ^ n) := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro n hn + rw [pow_add, Nat.cast_add] + ring + rw [heq, norm_mul, norm_pow, norm_realAdditivePhase, one_pow, one_mul] + exact weighted_periodic_linear_phase_bound q _ A α hA ht w N + +theorem periodic_grid_cost_le_square (q : ℕ) [NeZero q] : + (q : ℝ) * (1 + Real.log q) ≤ (q : ℝ) ^ 2 := by + have hq : (0 : ℝ) < q := by exact_mod_cast Nat.pos_of_ne_zero (NeZero.ne q) + have hl := Real.log_le_sub_one_of_pos hq + nlinarith + +theorem weighted_periodic_linear_shift_long_bound (q : ℕ) [NeZero q] + (f : ZMod q → ℂ) (A α : ℝ) (hA : 0 ≤ A) + (hf : ∀ u, ‖additiveFourier f u‖ ≤ A) (w : ℕ → ℂ) (M N : ℕ) + (hN : q ^ 2 ≤ N) : + ‖∑ n ∈ Finset.range N, w n * + (f ((n + M : ℕ) : ZMod q) * realAdditivePhase α ^ (n + M))‖ ≤ + discreteVariation w N * (4 * A * N) := by + apply (weighted_periodic_linear_shift_bound q f A α hA hf w M N).trans + apply mul_le_mul_of_nonneg_left _ (by unfold discreteVariation; positivity) + have hN' : (q : ℝ) ^ 2 ≤ N := by exact_mod_cast hN + have hg := periodic_grid_cost_le_square q + nlinarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicResidueSum.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicResidueSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..f3b0cb7093e92165f475b4a979bda5e9dc31f9ee --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicResidueSum.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.Ostmann.Construction.IntegerIntervalDistribution + +namespace OAI + +/-! # A positive periodic sum over a finite interval -/ + +namespace Ostmann + +open scoped BigOperators + +theorem periodic_residue_sum_le (q W : ℕ) [NeZero q] + (F : ZMod q → ℝ) (hF : ∀ x, 0 ≤ F x) : + (∑ n ∈ Finset.Ioc 0 W, F (n : ZMod q)) ≤ + ((W : ℝ) / q + 1) * ∑ x : ZMod q, F x := by + classical + have hmaps (n : ℕ) (_ : n ∈ Finset.Ioc 0 W) : + (n : ZMod q) ∈ (Finset.univ : Finset (ZMod q)) := Finset.mem_univ _ + rw [← Finset.sum_fiberwise_of_maps_to hmaps, Finset.mul_sum] + apply Finset.sum_le_sum + intro x hx + have heq : ((Finset.Ioc 0 W).filter (fun n : ℕ => (n : ZMod q) = x)) = + (Finset.Ioc 0 W).filter (fun n => Nat.ModEq q n x.val) := by + ext n + have hc : (n : ZMod q) = x ↔ Nat.ModEq q n x.val := by + calc + _ ↔ (n : ZMod q) = (x.val : ZMod q) := by rw [ZMod.natCast_zmod_val] + _ ↔ _ := ZMod.natCast_eq_natCast_iff n x.val q + simp only [Finset.mem_filter, hc] + have hb := integer_interval_residue_error 0 W q x.val (Nat.zero_le _) + (Nat.pos_of_ne_zero (NeZero.ne q)) + have hcard : (((Finset.Ioc 0 W).filter (fun n : ℕ => (n : ZMod q) = x)).card : ℝ) ≤ + (W : ℝ) / q + 1 := by + rw [heq] + have hh := (abs_le.mp hb).2 + simp only [Nat.cast_zero, sub_zero] at hh + linarith + calc + _ = (((Finset.Ioc 0 W).filter (fun n : ℕ => (n : ZMod q) = x)).card : ℝ) * F x := by + calc + _ = ∑ _n ∈ (Finset.Ioc 0 W).filter (fun n : ℕ => (n : ZMod q) = x), F x := by + apply Finset.sum_congr rfl + intro n hn + rw [(Finset.mem_filter.mp hn).2] + _ = _ := by simp + _ ≤ _ := mul_le_mul_of_nonneg_right hcard (hF x) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicWeightPoisson.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicWeightPoisson.lean new file mode 100644 index 0000000000000000000000000000000000000000..aa20674afb1a1423ce8b538e0447f9977298d1bb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PeriodicWeightPoisson.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.QuadraticCenter.AmplificationMean +import OAI.NumberTheory.Ostmann.Construction.PhysicalAmplification + +namespace OAI + +/-! # Poisson summation gives the exact total amplification weight -/ + +namespace Ostmann + +open scoped BigOperators FourierTransform SchwartzMap + +theorem scaled_periodic_poisson {N : ℕ} [NeZero N] + (F : ZMod N → ℂ) (ψ : 𝓢(ℝ, ℂ)) (X : ℝ) (hX : 0 < X) : + (∑' n : ℤ, F (n : ZMod N) * ψ ((n : ℝ) / X)) = + (X : ℂ) * ∑' n : ℤ, 𝓕 ψ ((n : ℝ) * X / N) * additiveFourier F (-(n : ZMod N)) := by + have hN : (0 : ℝ) < N := by exact_mod_cast NeZero.pos N + have ha : 0 < (N : ℝ) / X := div_pos hN hX + have hp := integer_poisson_transform (positiveDilate ψ ((N : ℝ) / X) ha) F + have harg (n : ℤ) : (N : ℝ) / X * ((n : ℝ) / N) = n / X := by field_simp + have hfreq (n : ℤ) : (n : ℝ) / ((N : ℝ) / X) = n * X / N := by rw [div_div_eq_mul_div] + simp_rw [positiveDilate_apply, harg, positiveDilate_fourier, hfreq] at hp + rw [hp] + simp_rw [← tsum_mul_left] + apply tsum_congr + intro n + have hNC : (N : ℂ) ≠ 0 := by exact_mod_cast NeZero.ne N + push_cast + field_simp + +theorem periodic_poisson_single_frequency {N : ℕ} [NeZero N] + (F : ZMod N → ℂ) (ψ : 𝓢(ℝ, ℂ)) (X H : ℝ) (hX : 0 < X) + (hmean : additiveFourier F 0 = 1) (hH : H < X / N) + (hsupp : ∀ x : ℝ, H < |x| → 𝓕 ψ x = 0) : + (∑' n : ℤ, F (n : ZMod N) * ψ ((n : ℝ) / X)) = (X : ℂ) * 𝓕 ψ 0 := by + rw [scaled_periodic_poisson F ψ X hX] + have hn (n : ℤ) (hne : n ≠ 0) : + 𝓕 ψ ((n : ℝ) * X / N) * additiveFourier F (-(n : ZMod N)) = 0 := by + have habs : (1 : ℝ) ≤ |(n : ℝ)| := by + exact_mod_cast (show (1 : ℤ) ≤ |n| by have hh := abs_pos.mpr hne; omega) + have hN : (0 : ℝ) < N := by exact_mod_cast NeZero.pos N + have hlarge : H < |(n : ℝ) * X / N| := by + rw [abs_div, abs_mul, abs_of_pos hX, abs_of_pos hN] + have hb := mul_le_mul_of_nonneg_right habs (div_nonneg hX.le hN.le) + have he : |(n : ℝ)| * X / N = |(n : ℝ)| * (X / N) := by ring + rw [he] + exact hH.trans_le (by simpa only [one_mul] using hb) + rw [hsupp _ hlarge, zero_mul] + rw [tsum_eq_single 0 hn] + simp [hmean] + +/-- Exact form of the total-weight identity for the manuscript's original +positive periodic weight. -/ +theorem amplification_total_weight (Q : Finset ℕ) (hQ : ∀ p ∈ Q, p.Prime) + (D : ∀ p : ℕ, Finset (ZMod p)) (ψ : 𝓢(ℝ, ℂ)) (X H : ℝ) (hX : 0 < X) + (hH : H < X / Q.toList.prod) (hsupp : ∀ x : ℝ, H < |x| → 𝓕 ψ x = 0) : + (∑' n : ℤ, physicalWeight Q D ψ X n) = X * (𝓕 ψ 0).re := by + let : NeZero Q.toList.prod := ⟨(prime_list_prod_pos _ (primeSet_list_prime Q hQ)).ne'⟩ + have hp := periodic_poisson_single_frequency (amplificationCRT Q hQ D) ψ X H hX + (amplificationCRT_mean_one Q hQ D) hH hsupp + have hsc : Summable (fun n : ℤ => amplificationCRT Q hQ D (n : ZMod Q.toList.prod) * ψ ((n : ℝ) / X)) := by + have hsn : Summable (fun n : ℤ => ‖ψ ((n : ℝ) / X)‖) := by + simpa only [positiveDilate_apply, div_eq_mul_inv, mul_comm] using + schwartz_int_norm_summable (positiveDilate ψ X⁻¹ (inv_pos.mpr hX)) + apply Summable.of_norm_bounded (hsn.mul_left ((17 / 16 : ℝ) ^ Q.card)) + intro n + rw [amplificationCRT_intCast, norm_mul, Complex.norm_real, Real.norm_eq_abs, + abs_of_pos (amplificationWeight_pos Q hQ D n)] + exact mul_le_mul_of_nonneg_right (amplificationWeight_le Q hQ D n) (norm_nonneg _) + have hre := congrArg Complex.reCLM hp + rw [Complex.reCLM.map_tsum hsc] at hre + simpa only [amplificationCRT_intCast, Complex.reCLM_apply, Complex.mul_re, Complex.ofReal_re, + Complex.ofReal_im, zero_mul, sub_zero, physicalWeight, mul_comm] using hre + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..0883ddfdf3f0f9c18efa0225d89b0e30dc47d60a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparison.lean @@ -0,0 +1,43 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PermutationDiagramComparisonProducts +import OAI.NumberTheory.Ostmann.Tree.TreeComparison + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PermutationDiagramComparison +open scoped BigOperators ComplexConjugate +open Ostmann.FiniteField +open ResidueHaar +variable {p depth m : ℕ} [Fact p.Prime] + +def slotCorrelation (σ : Equiv.Perm (Fin (2^depth) × Fin m)) + (T1 T2 : Tree.Diagram (ZMod p) depth) (g : ZMod p → ℂ) : ℂ := + average (fun samples : Fin (2^depth) × Fin m → (ZMod p)ˣ => + T1.value g (slotLeaves σ samples).1 * conj (T2.value g (slotLeaves σ samples).2)) + +theorem slotCorrelation_eq_diagramCorrelation (σ : Equiv.Perm (Fin (2^depth) × Fin m)) + (hm : 0 < m) (T1 T2 : Tree.Diagram (ZMod p) depth) (g : ZMod p → ℂ) : + slotCorrelation σ T1 T2 g = Tree.diagramCorrelation + (TreePermutationHaar.leftPartition σ) (TreePermutationHaar.rightPartition σ hm) T1 T2 g := by + have hh := TreePermutationHaar.tree_products_uniform (F:=ZMod p) σ hm + (fun x => T1.value g x.val.1 * conj (T2.value g x.val.2)) + change average (fun samples => + T1.value g (TreePermutationHaar.leafPairEquiv (PermutationHaar.products σ samples)).1 * + conj (T2.value g (TreePermutationHaar.leafPairEquiv (PermutationHaar.products σ samples)).2)) = _ at hh + simp only [←slotLeaves_eq_leafPairEquiv] at hh + exact hh + +theorem slotCorrelation_good_bound (σ : Equiv.Perm (Fin (2^depth) × Fin m)) + (hm : 0 < m) (T1 T2 : Tree.Diagram (ZMod p) depth) (hp : 3≤p) (hd : 2≤depth) + (hgood : 4*TreePermutationHaar.blocks σ≤3*2^depth) + (g : ZMod p → ℂ) (hg0 : g 0=0) (hg : l2Sq g≤1) : + ‖slotCorrelation σ T1 T2 g‖≤Tree.treeComparisonConstant (depth-2)* + ((correlationBound g:ℝ)+(p:ℝ)^(-(1/4:ℝ))) := by + rw [slotCorrelation_eq_diagramCorrelation σ hm] + exact Tree.tree_comparison_of_two_le _ _ T1 T2 hp hd hgood g hg0 hg + +end Ostmann.Arithmetic.PermutationDiagramComparison + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparisonActual.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparisonActual.lean new file mode 100644 index 0000000000000000000000000000000000000000..dba6d0731e5dbdf499f40bbcd0666f7b08743141 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparisonActual.lean @@ -0,0 +1,31 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PermutationDiagramComparisonUniversal +import OAI.NumberTheory.Ostmann.Conclusion.LowLevelBadPairs + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PermutationDiagramComparison +open Ostmann.FiniteField +variable {p depth m : ℕ} [Fact p.Prime] + +theorem slotCorrelation_transfer_good_bound (σ : Equiv.Perm (Fin (2^depth) × Fin m)) + (hm : 0 < m) (T1 T2 : Tree.Diagram (ZMod p) depth) (hp : 3≤p) + (hgood : ¬Conclusion.TransferBadArrangement σ) + (g : ZMod p → ℂ) (hg0 : g 0=0) (hg : l2Sq g≤1) : + ‖slotCorrelation σ T1 T2 g‖≤Tree.treeComparisonConstant (depth-2)* + ((correlationBound g:ℝ)+(p:ℝ)^(-(1/4:ℝ))) := by + have hh : ¬(2^depth≤2) ∧ ¬Conclusion.BadArrangement σ := not_or.mp hgood + have hd : 2≤depth := by + by_contra h + have he : depth=0 ∨ depth=1 := by omega + rcases he with rfl | rfl <;> norm_num at hh + apply slotCorrelation_good_bound σ hm T1 T2 hp hd + · exact Nat.le_of_not_gt hh.2 + · exact hg0 + · exact hg + +end Ostmann.Arithmetic.PermutationDiagramComparison + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparisonProducts.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparisonProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..fea1a6ef63867ff05a7208210f8c60c348b504f3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparisonProducts.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.TreePermutationHaar + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PermutationDiagramComparison +open scoped BigOperators + +variable {r m depth : ℕ} {G : Type*} [CommGroup G] + +private theorem row_filter_product (samples : Fin r × Fin m → G) (a : Fin r) : + (∏ x : Fin r, ∏ i : Fin m, if x=a then samples (x,i) else 1)=∏i,samples (a,i) := by + classical + calc + _ = ∏ x : Fin r, if x=a then ∏i : Fin m,samples (x,i) else 1 := by + apply Finset.prod_congr rfl + intro x hx + by_cases h : x=a <;> simp only [h,ite_true,ite_false,Finset.prod_const_one] + _ = _ := by simp + +theorem products_left (σ : Equiv.Perm (Fin r × Fin m)) + (samples : Fin r × Fin m → G) (a : Fin r) : + (PermutationHaar.products σ samples).1 a = ∏ i,samples (a,i) := by + classical + simp only [PermutationHaar.products,BipartiteHaar.slotProducts,IncidenceHaar.fiberProduct, + MonoidHom.coe_mk,OneHom.coe_mk,Finset.prod_filter,Fintype.prod_prod_type] + exact row_filter_product samples a + +theorem products_right (σ : Equiv.Perm (Fin r × Fin m)) + (samples : Fin r × Fin m → G) (a : Fin r) : + (PermutationHaar.products σ samples).2 a = ∏ i,samples (σ.symm (a,i)) := by + classical + change (∏ e ∈ Finset.univ.filter (fun e => (σ e).1=a),samples e)=_ + rw [Finset.prod_filter] + have hh := Equiv.prod_comp σ (fun e => if e.1=a then samples (σ.symm e) else 1) + simp only [Equiv.symm_apply_apply] at hh + rw [hh] + rw [Fintype.prod_prod_type] + exact row_filter_product (samples ∘ σ.symm) a + +variable {F : Type*} [Field F] + +def slotLeaves (σ : Equiv.Perm (Fin (2^depth) × Fin m)) + (samples : Fin (2^depth) × Fin m → Fˣ) : + (Tree.Leaves depth → Fˣ) × (Tree.Leaves depth → Fˣ) := + (fun path => ∏i,samples (TreePermutationHaar.leafIndex depth path,i), + fun path => ∏i,samples (σ.symm (TreePermutationHaar.leafIndex depth path,i))) + +theorem slotLeaves_eq_leafPairEquiv (σ : Equiv.Perm (Fin (2^depth) × Fin m)) + (samples : Fin (2^depth) × Fin m → Fˣ) : + slotLeaves σ samples = TreePermutationHaar.leafPairEquiv + (PermutationHaar.products σ samples) := by + apply Prod.ext <;> funext path + · exact (products_left σ samples _).symm + · exact (products_right σ samples _).symm + +end Ostmann.Arithmetic.PermutationDiagramComparison + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparisonUniversal.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparisonUniversal.lean new file mode 100644 index 0000000000000000000000000000000000000000..284447350ba2c528f3bf3c10813285d85138420d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationDiagramComparisonUniversal.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PermutationDiagramComparison + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PermutationDiagramComparison +open scoped BigOperators ComplexConjugate +open Ostmann.FiniteField Ostmann.Tree ResidueHaar +variable {p depth m : ℕ} [Fact p.Prime] + +theorem diagramCorrelation_cauchy_sq {b : ℕ} (P Q : LeafPartition depth b) + (T1 T2 : Diagram (ZMod p) depth) (g : ZMod p → ℂ) : + ‖diagramCorrelation P Q T1 T2 g‖^2≤ + Density.average (fun M => ‖T1.value g M‖^2)* + Density.average (fun M => ‖T2.value g M‖^2) := by + have hh := coupled_cauchy_sq (labelProducts (U:=(ZMod p)ˣ) P.label) (labelProducts Q.label) + (labelProducts_surjective P.label P.onto) (labelProducts_surjective Q.label Q.onto) + (T1.value g) (T2.value g) + have he := average_equiv (coupledLeavesEquiv (p:=p) P Q) + (fun x : CoupledLeaves (p:=p) P Q => T1.value g x.val.1*conj (T2.value g x.val.2)) + change average (fun x : coupledGroup (labelProducts P.label) (labelProducts Q.label) => + T1.value g x.val.1*conj (T2.value g x.val.2))=diagramCorrelation P Q T1 T2 g at he + rw [he] at hh + simp only [real_average_fintype_congr _ + (inferInstance : Fintype (Leaves depth → (ZMod p)ˣ))] at hh + exact hh + +theorem slotCorrelation_universal_bound (σ : Equiv.Perm (Fin (2^depth) × Fin m)) + (hm : 0 < m) (T1 T2 : Diagram (ZMod p) depth) (hp : 3≤p) + (g : ZMod p → ℂ) (hg : l2Sq g≤1) : + ‖slotCorrelation σ T1 T2 g‖≤(3:ℝ)^(2^depth) := by + rw [slotCorrelation_eq_diagramCorrelation σ hm] + have hc := diagramCorrelation_cauchy_sq + (TreePermutationHaar.leftPartition σ) (TreePermutationHaar.rightPartition σ hm) T1 T2 g + have h1 := Density.diagram_l2_bound T1 hp g hg + have h2 := Density.diagram_l2_bound T2 hp g hg + have hn2 : 0≤Density.average (fun M => ‖T2.value g M‖^2) := by + unfold Density.average + positivity + have hh := mul_le_mul h1 h2 hn2 (by positivity : (0:ℝ)≤3^(2^depth)) + have hsq : ‖diagramCorrelation (TreePermutationHaar.leftPartition σ) + (TreePermutationHaar.rightPartition σ hm) T1 T2 g‖^2≤((3:ℝ)^(2^depth))^2 := by + simpa only [pow_two] using hc.trans hh + have hn := norm_nonneg (diagramCorrelation (TreePermutationHaar.leftPartition σ) + (TreePermutationHaar.rightPartition σ hm) T1 T2 g) + have hb : (0:ℝ)≤3^(2^depth) := by positivity + nlinarith + +end Ostmann.Arithmetic.PermutationDiagramComparison + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationHaar.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationHaar.lean new file mode 100644 index 0000000000000000000000000000000000000000..090b14a6ecfb17a820ddadc0f7d41349a761f26b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationHaar.lean @@ -0,0 +1,127 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.BipartiteHaar +import OAI.NumberTheory.Ostmann.Conclusion.OverlapComponents + +namespace OAI + +noncomputable section +open scoped BigOperators +namespace Ostmann.Arithmetic.PermutationHaar +open IncidenceHaar + +variable {r m : ℕ} {G : Type*} [CommGroup G] + +abbrev source (_σ : Equiv.Perm (Fin r × Fin m)) (e : Fin r × Fin m) : Fin r ⊕ Fin r := + Sum.inl e.1 +abbrev target (σ : Equiv.Perm (Fin r × Fin m)) (e : Fin r × Fin m) : Fin r ⊕ Fin r := + Sum.inr (σ e).1 + +theorem edge_path (σ : Equiv.Perm (Fin r × Fin m)) (e : Fin r × Fin m) : + Relation.EqvGen (edgeRelation (source σ) (target σ)) + (Sum.inl e.1) (Sum.inr (σ e).1) := + Relation.EqvGen.rel _ _ ⟨e,rfl,rfl⟩ + +theorem left_path (σ : Equiv.Perm (Fin r × Fin m)) {a b : Fin r} + (h : Conclusion.leftComponent σ a = Conclusion.leftComponent σ b) : + Relation.EqvGen (edgeRelation (source σ) (target σ)) (Sum.inl a) (Sum.inl b) := by + have hp : Relation.EqvGen (Conclusion.overlapRelation σ) a b := Quotient.exact h + clear h + induction hp with + | rel a b h => + obtain ⟨u,v,h⟩ := h + have hright := edge_path σ (b,v) + rw [← h] at hright + exact Relation.EqvGen.trans _ _ _ (edge_path σ (a,u)) + (Relation.EqvGen.symm _ _ hright) + | refl a => exact Relation.EqvGen.refl _ + | symm a b h ih => exact Relation.EqvGen.symm _ _ ih + | trans a b c h₁ h₂ ih₁ ih₂ => exact Relation.EqvGen.trans _ _ _ ih₁ ih₂ + +def label (σ : Equiv.Perm (Fin r × Fin m)) (hm : 0 < m) : + Fin r ⊕ Fin r → Conclusion.OverlapComponent σ := + Sum.elim (Conclusion.leftComponent σ) (Conclusion.rightComponent σ hm) + +def root (σ : Equiv.Perm (Fin r × Fin m)) (c : Conclusion.OverlapComponent σ) : + Fin r ⊕ Fin r := Sum.inl c.out + +theorem label_root (σ : Equiv.Perm (Fin r × Fin m)) (hm : 0 < m) + (c : Conclusion.OverlapComponent σ) : label σ hm (root σ c) = c := Quotient.out_eq c + +theorem path_root (σ : Equiv.Perm (Fin r × Fin m)) (hm : 0 < m) + (v : Fin r ⊕ Fin r) : + Relation.EqvGen (edgeRelation (source σ) (target σ)) v (root σ (label σ hm v)) := by + cases v with + | inl a => + exact left_path σ (Quotient.out_eq (Conclusion.leftComponent σ a)).symm + | inr b => + let e := σ.symm (b,⟨0,hm⟩) + have he : Relation.EqvGen (edgeRelation (source σ) (target σ)) + (Sum.inl e.1) (Sum.inr b) := by simpa [e] using edge_path σ e + exact Relation.EqvGen.trans _ _ _ (Relation.EqvGen.symm _ _ he) + (left_path σ (Quotient.out_eq (Conclusion.leftComponent σ e.1)).symm) + +def coupled (σ : Equiv.Perm (Fin r × Fin m)) (hm : 0 < m) : + Subgroup ((Fin r → G) × (Fin r → G)) where + carrier := {x | ∀ c : Conclusion.OverlapComponent σ, + fiberProduct (Conclusion.leftComponent σ) c x.1 = + fiberProduct (Conclusion.rightComponent σ hm) c x.2} + one_mem' := by intro c; simp + mul_mem' hx hy := by intro c; simp only [Prod.fst_mul,Prod.snd_mul,map_mul,hx c,hy c] + inv_mem' hx := by intro c; simp only [Prod.fst_inv,Prod.snd_inv,map_inv,hx c] + +def products (σ : Equiv.Perm (Fin r × Fin m)) : + (Fin r × Fin m → G) →* ((Fin r → G) × (Fin r → G)) := + BipartiteHaar.slotProducts Prod.fst (fun e => (σ e).1) + +theorem products_range (σ : Equiv.Perm (Fin r × Fin m)) (hm : 0 < m) : + (products (G:=G) σ).range = coupled σ hm := by + ext x + constructor + · rintro ⟨y,rfl⟩ + intro c + have h := fiberProduct_boundary (source σ) (target σ) (label σ hm) + (Conclusion.slot_component σ hm) c y + rw [← BipartiteHaar.signed_slotProducts] at h + change fiberProduct (Sum.elim (Conclusion.leftComponent σ) + (Conclusion.rightComponent σ hm)) c + (BipartiteHaar.signedEquiv (products σ y)) = 1 at h + rw [BipartiteHaar.fiberProduct_signed,div_eq_one] at h + exact h + · intro hx + have hb : BipartiteHaar.signedEquiv x ∈ (boundary (source σ) (target σ)).range := by + apply mem_range_of_component_products (source σ) (target σ) (label σ hm) + (root σ) (label_root σ hm) (path_root σ hm) + intro c + change fiberProduct (Sum.elim (Conclusion.leftComponent σ) + (Conclusion.rightComponent σ hm)) c (BipartiteHaar.signedEquiv x) = 1 + rw [BipartiteHaar.fiberProduct_signed,div_eq_one] + exact hx c + obtain ⟨y,hy⟩ := hb + refine ⟨y,BipartiteHaar.signedEquiv.injective ?_⟩ + exact (BipartiteHaar.signed_slotProducts _ _ y).trans hy + +def toCoupled (σ : Equiv.Perm (Fin r × Fin m)) (hm : 0 < m) : + (Fin r × Fin m → G) →* coupled (G:=G) σ hm := + (products σ).codRestrict (coupled σ hm) (fun x => by + rw [← products_range] + exact ⟨x,rfl⟩) + +theorem toCoupled_surjective (σ : Equiv.Perm (Fin r × Fin m)) (hm : 0 < m) : + Function.Surjective (toCoupled (G:=G) σ hm) := by + intro x + have hx : x.val ∈ (products σ).range := by rw [products_range]; exact x.property + obtain ⟨y,hy⟩ := hx + exact ⟨y,Subtype.ext hy⟩ + +instance coupledFintype [Fintype G] (σ : Equiv.Perm (Fin r × Fin m)) (hm : 0 < m) : + Fintype (coupled (G:=G) σ hm) := Fintype.ofFinite _ + +theorem products_uniform [Fintype G] (σ : Equiv.Perm (Fin r × Fin m)) (hm : 0 < m) + (F : coupled (G:=G) σ hm → ℂ) : + ResidueHaar.average (fun x => F (toCoupled σ hm x)) = ResidueHaar.average F := + GroupHaarImage.average_surjective _ (toCoupled_surjective σ hm) F + +end Ostmann.Arithmetic.PermutationHaar + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationHaarConvention.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationHaarConvention.lean new file mode 100644 index 0000000000000000000000000000000000000000..281f714274cc4a20704185d70a88b7fb2790ac21 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PermutationHaarConvention.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.CanonicalHistoryLeafBulkHaar +import OAI.NumberTheory.Ostmann.Construction.DiagonalBadPairInversionComponents + +namespace OAI + +open Erdos970 + +noncomputable section +namespace Ostmann.Arithmetic.PermutationHaarConvention +open Conclusion + +def rowConjugate {r m : ℕ} (e : Equiv.Perm (Fin r)) + (σ : Equiv.Perm (Fin r × Fin m)) : Equiv.Perm (Fin r × Fin m) := + (e.prodCongr (Equiv.refl (Fin m))).trans + (σ.trans (e.prodCongr (Equiv.refl (Fin m))).symm) + +theorem overlapRelation_rowConjugate {r m : ℕ} (e : Equiv.Perm (Fin r)) + (σ : Equiv.Perm (Fin r × Fin m)) (a b : Fin r) : + overlapRelation (rowConjugate e σ) a b ↔ overlapRelation σ (e a) (e b) := by + change (∃ u v : Fin m, e.symm (σ (e a,u)).1 = e.symm (σ (e b,v)).1) ↔ _ + exact exists_congr fun u => exists_congr fun v => e.symm.injective.eq_iff + +private theorem eqvGen_map {A B : Type*} {R : A → A → Prop} {S : B → B → Prop} + (f : A → B) (hf : ∀ a b, R a b → S (f a) (f b)) + {a b : A} (h : Relation.EqvGen R a b) : Relation.EqvGen S (f a) (f b) := by + induction h with + | rel a b h => exact .rel _ _ (hf a b h) + | refl a => exact .refl _ + | symm a b h ih => exact .symm _ _ ih + | trans a b c h₁ h₂ ih₁ ih₂ => exact .trans _ _ _ ih₁ ih₂ + +theorem overlapClosure_rowConjugate {r m : ℕ} (e : Equiv.Perm (Fin r)) + (σ : Equiv.Perm (Fin r × Fin m)) (a b : Fin r) : + Relation.EqvGen (overlapRelation (rowConjugate e σ)) a b ↔ + Relation.EqvGen (overlapRelation σ) (e a) (e b) := by + constructor + · exact eqvGen_map e (fun u v => (overlapRelation_rowConjugate e σ u v).mp) + · intro h + have hh := eqvGen_map e.symm (fun u v huv => + (overlapRelation_rowConjugate e σ (e.symm u) (e.symm v)).mpr + (by simpa only [Equiv.apply_symm_apply] using huv)) h + simpa only [Equiv.symm_apply_apply] using hh + +def rowComponentEquiv {r m : ℕ} (e : Equiv.Perm (Fin r)) + (σ : Equiv.Perm (Fin r × Fin m)) : + OverlapComponent (rowConjugate e σ) ≃ OverlapComponent σ := + Quotient.congr e (overlapClosure_rowConjugate e σ) + +theorem overlapComponent_card_rowConjugate {r m : ℕ} (e : Equiv.Perm (Fin r)) + (σ : Equiv.Perm (Fin r × Fin m)) : + Fintype.card (OverlapComponent (rowConjugate e σ)) = + Fintype.card (OverlapComponent σ) := Fintype.card_congr (rowComponentEquiv e σ) + +theorem haarPermutation_blocks {l m : ℕ} (σ : Equiv.Perm (Fin (2^l) × Fin m)) : + TreePermutationHaar.blocks (CanonicalHistoryLeafBulk.haarPermutation σ) = + TreePermutationHaar.blocks σ := by + change Fintype.card (OverlapComponent + (rowConjugate (CanonicalHistoryLeafBulk.addressChange l) σ.symm)) = _ + rw [overlapComponent_card_rowConjugate,overlapComponent_card_symm] + +@[simp] theorem haarPermutation_badArrangement_iff {l m : ℕ} + (σ : Equiv.Perm (Fin (2^l) × Fin m)) : + BadArrangement (CanonicalHistoryLeafBulk.haarPermutation σ) ↔ BadArrangement σ := by + unfold BadArrangement + rw [show Fintype.card (OverlapComponent (CanonicalHistoryLeafBulk.haarPermutation σ)) = + Fintype.card (OverlapComponent σ) from haarPermutation_blocks σ] + +@[simp] theorem haarPermutation_transferBadArrangement_iff {l m : ℕ} + (σ : Equiv.Perm (Fin (2^l) × Fin m)) : + TransferBadArrangement (CanonicalHistoryLeafBulk.haarPermutation σ) ↔ TransferBadArrangement σ := by + simp only [TransferBadArrangement,haarPermutation_badArrangement_iff] + +theorem haarPermutation_good {l m : ℕ} (σ : Equiv.Perm (Fin (2^l) × Fin m)) + (h : ¬ TransferBadArrangement σ) : + ¬ TransferBadArrangement (CanonicalHistoryLeafBulk.haarPermutation σ) := + h ∘ (haarPermutation_transferBadArrangement_iff σ).mp + +end Ostmann.Arithmetic.PermutationHaarConvention + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagMass.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee68dce370209a0bf763dfef0c1540b141a85e33 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagMass.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialFlagReplacementWeighted +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialRootMass + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PolynomialFlagMass +open scoped BigOperators +open MvPolynomial ProductExpectation PolynomialFlagReplacement + +theorem divisibility_probability_le {n : ℕ} (P : MvPolynomial (Fin n) ℤ) (hP : P ≠ 0) + (S : Fin n → Finset ℤ) (μ : Fin n → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (α β H C Cnu : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hH : 0 ≤ H) + (hC : 0 ≤ C) (hCnu : 0 ≤ Cnu) + (hμ : ∀i a,a∈S i → 0 ≤ μ i a) (hmass : ∀i,∑a∈S i,μ i a ≤ C) + (hatom : ∀i a,a∈S i → μ i a ≤ α) + (hprime : ∀b∈B,b.Prime) (hνmass : ∑b∈B,ν b ≤ Cnu) + (hνatom : ∀b∈B,ν b ≤ β) + (hsize : ∀x,(∀i,x i∈S i) → eval x P ≠ 0 → Real.log |((eval x P:ℤ):ℝ)| ≤ H) : + expectation S μ (fun x => ∑b∈B,ν b*divisibilityIndicator P x b) ≤ + (P.totalDegree:ℝ)*α*C^(n-1)*Cnu+β*(H/Real.log 2)*C^n := by + have hlog2 : 0 < Real.log (2:ℝ) := Real.log_pos (by norm_num) + have hfiber (x : Fin n → ℤ) (hx : ∀i,x i∈S i) : + (∑b∈B,ν b*divisibilityIndicator P x b) ≤ + Cnu*(if eval x P=0 then 1 else 0)+β*(H/Real.log 2) := by + by_cases hz : eval x P=0 + · simp only [divisibilityIndicator,hz,dvd_zero,ite_true,mul_one] + exact hνmass.trans (le_add_of_nonneg_right (mul_nonneg hβ (div_nonneg hH hlog2.le))) + · simp only [hz,ite_false,mul_zero,zero_add] + have hN : (eval x P).natAbs ≠ 0 := by simpa only [Int.natAbs_ne_zero] using hz + have hd := AccidentalDivisibility.weighted_prime_divisors (eval x P).natAbs hN B ν hβ hνatom + have he : (∑b∈B,ν b*divisibilityIndicator P x b)= + ∑b∈B with b.Prime ∧ b ∣ (eval x P).natAbs,ν b := by + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro b hb + simp only [divisibilityIndicator,Int.natCast_dvd,hprime b hb,true_and] + split_ifs <;> simp + rw [he] + apply hd.trans + apply mul_le_mul_of_nonneg_left _ hβ + apply div_le_div_of_nonneg_right _ hlog2.le + simpa only [Nat.cast_natAbs,Int.cast_abs] using hsize x hx hz + calc + _ ≤ expectation S μ (fun x => Cnu*(if eval x P=0 then 1 else 0)+β*(H/Real.log 2)) := + expectation_mono_support S μ hμ hfiber + _ = Cnu*expectation S μ (fun x => if eval x P=0 then 1 else 0)+ + expectation S μ (fun _ => β*(H/Real.log 2)) := by + rw [ProductExpectation.add,expectation_const_mul] + _ ≤ Cnu*((P.totalDegree:ℝ)*α*C^(n-1))+β*(H/Real.log 2)*C^n := add_le_add + (mul_le_mul_of_nonneg_left + (PolynomialRootMass.weighted_zero_bound P hP S μ α C hα hC hμ hmass hatom) hCnu) + (PolynomialRootMass.expectation_const_le S μ hμ hmass (by positivity)) + _ = _ := by ring + +theorem weighted_restricted_flag_error_le {n : ℕ} (P : MvPolynomial (Fin n) ℤ) (hP : P ≠ 0) + (S : Fin n → Finset ℤ) (μ : Fin n → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (α β H A C Cnu : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hH : 0 ≤ H) (hA : 0 ≤ A) + (hC : 0 ≤ C) (hCnu : 0 ≤ Cnu) + (hμ : ∀i a,a∈S i → 0 ≤ μ i a) (hmass : ∀i,∑a∈S i,μ i a ≤ C) + (hatom : ∀i a,a∈S i → μ i a ≤ α) + (hprime : ∀b∈B,b.Prime) (hν : ∀b∈B,0 ≤ ν b) (hνmass : ∑b∈B,ν b ≤ Cnu) + (hνatom : ∀b∈B,ν b ≤ β) + (hsize : ∀x,(∀i,x i∈S i) → eval x P ≠ 0 → Real.log |((eval x P:ℤ):ℝ)| ≤ H) + (r : (Fin n → ℤ) → ℕ → Bool) (w : (Fin n → ℤ) → ℕ → ℝ) + (hw : ∀x,(∀i,x i∈S i) → ∀b∈B,0 ≤ w x b ∧ w x b ≤ A) : + expectation S μ (fun x => ∑b∈B,ν b*(if r x b then w x b*flagError P x b else 0)) ≤ + A*((P.totalDegree:ℝ)*α*C^(n-1)*Cnu+β*(H/Real.log 2)*C^n) := by + have he : expectation S μ (fun x => ∑b∈B,ν b*(if r x b then w x b*flagError P x b else 0)) ≤ + expectation S μ (fun x => A*(∑b∈B,ν b*divisibilityIndicator P x b)) := by + apply expectation_mono_support S μ hμ + intro x hx + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro b hb + have hp : (if r x b then w x b*flagError P x b else 0) ≤ A*divisibilityIndicator P x b := by + rw [flagError_of_ne_zero P hP] + split_ifs + · exact mul_le_mul_of_nonneg_right (hw x hx b hb).2 (indicator_nonneg P x b) + · exact mul_nonneg hA (indicator_nonneg P x b) + have hh := mul_le_mul_of_nonneg_left hp (hν b hb) + simpa only [mul_assoc,mul_left_comm] using hh + rw [expectation_const_mul] at he + exact he.trans (mul_le_mul_of_nonneg_left + (divisibility_probability_le P hP S μ B ν α β H C Cnu hα hβ hH hC hCnu hμ hmass hatom + hprime hνmass hνatom hsize) hA) + +end Ostmann.Arithmetic.PolynomialFlagMass + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacement.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..7322ad6d22768e1ff9f2d3a04d2c45d46cbb3dfa --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacement.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialFlagReplacementExpectation + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PolynomialFlagReplacement +open scoped BigOperators +open MvPolynomial ProductExpectation + +def divisibilityIndicator {n : ℕ} (P : MvPolynomial (Fin n) ℤ) (x : Fin n → ℤ) (b : ℕ) : ℝ := + if (b:ℤ) ∣ eval x P then 1 else 0 + +def flagError {n : ℕ} (P : MvPolynomial (Fin n) ℤ) (x : Fin n → ℤ) (b : ℕ) : ℝ := + |divisibilityIndicator P x b - if P=0 then 1 else 0| + +@[simp] theorem zero_polynomial_flag {n : ℕ} (x : Fin n → ℤ) (b : ℕ) : + divisibilityIndicator (0 : MvPolynomial (Fin n) ℤ) x b=1 := by + simp [divisibilityIndicator] + +@[simp] theorem zero_polynomial_error {n : ℕ} (x : Fin n → ℤ) (b : ℕ) : + flagError (0 : MvPolynomial (Fin n) ℤ) x b=0 := by simp [flagError] + +lemma indicator_nonneg {n : ℕ} (P : MvPolynomial (Fin n) ℤ) (x : Fin n → ℤ) (b : ℕ) : + 0 ≤ divisibilityIndicator P x b := by unfold divisibilityIndicator; split_ifs <;> norm_num + +lemma flagError_of_ne_zero {n : ℕ} (P : MvPolynomial (Fin n) ℤ) (hP : P≠0) + (x : Fin n → ℤ) (b : ℕ) : flagError P x b=divisibilityIndicator P x b := by + simp only [flagError,hP,ite_false,sub_zero,abs_of_nonneg (indicator_nonneg P x b)] + +theorem divisibility_probability_le {n : ℕ} (P : MvPolynomial (Fin n) ℤ) (hP : P≠0) + (S : Fin n → Finset ℤ) (μ : Fin n → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (α β H : ℝ) (hα : 0≤α) (hβ : 0≤β) (hH : 0≤H) + (hμ : ∀ i a, a∈S i → 0≤μ i a) (hmass : ∀ i, ∑ a∈S i, μ i a=1) + (hatom : ∀ i a, a∈S i → μ i a≤α) + (hprime : ∀ b∈B, b.Prime) (hνmass : ∑ b∈B,ν b=1) + (hνatom : ∀ b∈B,ν b≤β) + (hsize : ∀ x, (∀ i,x i∈S i) → eval x P≠0 → Real.log |((eval x P:ℤ):ℝ)|≤H) : + expectation S μ (fun x => ∑ b∈B,ν b*divisibilityIndicator P x b) ≤ + (P.totalDegree:ℝ)*α + β*(H/Real.log 2) := by + have hlog2 : 0 simp + rw [he] + apply hd.trans + apply mul_le_mul_of_nonneg_left _ hβ + apply div_le_div_of_nonneg_right _ hlog2.le + simpa only [Nat.cast_natAbs,Int.cast_abs] using hsize x hx hz + calc + _ ≤ expectation S μ (fun x => (if eval x P=0 then 1 else 0)+β*(H/Real.log 2)) := + expectation_mono_support S μ hμ hfiber + _ = expectation S μ (fun x => if eval x P=0 then 1 else 0)+β*(H/Real.log 2) := by + rw [ProductExpectation.add,ProductExpectation.const S μ hmass] + _ ≤ _ := add_le_add (PolynomialRootProbability.weighted_zero_bound P hP S μ α hα hμ hmass hatom) le_rfl + +theorem identity_replacement_exact {n : ℕ} (S : Fin n → Finset ℤ) (μ : Fin n → ℤ → ℝ) + (B : Finset ℕ) (ν : ℕ → ℝ) : + expectation S μ (fun x => ∑ b∈B,ν b*flagError (0 : MvPolynomial (Fin n) ℤ) x b)=0 := by + simp only [zero_polynomial_error,mul_zero,Finset.sum_const_zero,expectation_zero] + +end Ostmann.Arithmetic.PolynomialFlagReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementExpectation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementExpectation.lean new file mode 100644 index 0000000000000000000000000000000000000000..9f4be3afa86e9d6bb9923e8aae8184f5b079f2a5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementExpectation.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialRootProbability + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PolynomialFlagReplacement +open scoped BigOperators +open ProductExpectation + +theorem expectation_mono_support {K : Type*} : + ∀ {n : ℕ} (S : Fin n → Finset K) (μ : Fin n → K → ℝ) + (_hμ : ∀ i a, a ∈ S i → 0 ≤ μ i a) {f g : (Fin n → K) → ℝ} + (_hfg : ∀ x, (∀ i, x i ∈ S i) → f x ≤ g x), expectation S μ f ≤ expectation S μ g + | 0,_,_,_,_,_,hfg => hfg _ (fun i => Fin.elim0 i) + | n+1,S,μ,hμ,f,g,hfg => by + apply expectation_mono_support (Fin.tail S) (Fin.tail μ) (fun i => hμ i.succ) + intro x hx + apply Finset.sum_le_sum + intro a ha + apply mul_le_mul_of_nonneg_left _ (hμ 0 a ha) + apply hfg + intro i + exact Fin.cases ha (fun j => hx j) i + +lemma expectation_zero {K : Type*} : ∀ {n : ℕ} (S : Fin n → Finset K) (μ : Fin n → K → ℝ), + expectation S μ (fun _ => 0)=0 + | 0,_,_ => rfl + | n+1,S,μ => by + simp only [expectation,mul_zero,Finset.sum_const_zero] + exact expectation_zero _ _ + +lemma expectation_nonneg {K : Type*} {n : ℕ} (S : Fin n → Finset K) (μ : Fin n → K → ℝ) + (hμ : ∀ i a, a ∈ S i → 0 ≤ μ i a) (f : (Fin n → K) → ℝ) + (hf : ∀ x, (∀ i, x i ∈ S i) → 0 ≤ f x) : 0 ≤ expectation S μ f := by + simpa only [expectation_zero] using expectation_mono_support S μ hμ hf + +lemma expectation_const_mul {K : Type*} : + ∀ {n : ℕ} (S : Fin n → Finset K) (μ : Fin n → K → ℝ) + (c : ℝ) (f : (Fin n → K) → ℝ), + expectation S μ (fun x => c*f x)=c*expectation S μ f + | 0,_,_,_,_ => rfl + | n+1,S,μ,c,f => by + simp only [expectation,show ∀ a y : ℝ, a*(c*y)=c*(a*y) from fun _ _ => by ring,← Finset.mul_sum] + exact expectation_const_mul _ _ _ _ + +lemma expectation_finset_sum {K J : Type*} [DecidableEq J] {n : ℕ} + (S : Fin n → Finset K) (μ : Fin n → K → ℝ) (F : Finset J) + (f : J → (Fin n → K) → ℝ) : + expectation S μ (fun x => ∑ j ∈ F, f j x) = ∑ j ∈ F, expectation S μ (f j) := by + induction F using Finset.induction_on with + | empty => simp only [Finset.sum_empty,expectation_zero] + | @insert j F hj ih => + simp only [Finset.sum_insert hj,ProductExpectation.add,ih] + +end Ostmann.Arithmetic.PolynomialFlagReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementFinite.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementFinite.lean new file mode 100644 index 0000000000000000000000000000000000000000..f8eef4e3bff208b77110924d2883143f0e192bb6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementFinite.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialFlagReplacementFiniteReindex + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PolynomialFlagReplacementFinite +open scoped BigOperators +open MvPolynomial + +theorem weighted_restricted_flag_error_le {ι : Type*} [Fintype ι] [DecidableEq ι] + (P : MvPolynomial ι ℤ) (hP : P≠0) + (S : ι → Finset ℤ) (μ : ι → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (α β H A : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hH : 0 ≤ H) (hA : 0 ≤ A) + (hμ : ∀i a,a∈S i → 0 ≤ μ i a) (hmass : ∀i,∑a∈S i,μ i a=1) + (hatom : ∀i a,a∈S i → μ i a ≤ α) + (hprime : ∀b∈B,b.Prime) (hν : ∀b∈B,0 ≤ ν b) (hνmass : ∑b∈B,ν b=1) + (hνatom : ∀b∈B,ν b ≤ β) + (hsize : ∀x,(∀i,x i∈S i) → eval x P≠0 → Real.log |((eval x P:ℤ):ℝ)| ≤ H) + (r : (ι → ℤ) → ℕ → Bool) (w : (ι → ℤ) → ℕ → ℝ) + (hw : ∀x,(∀i,x i∈S i) → ∀b∈B,0 ≤ w x b ∧ w x b ≤ A) : + (∑x∈Fintype.piFinset S,(∏i,μ i (x i))* + (∑b∈B,ν b*(if r x b then w x b*flagError P x b else 0))) ≤ + A*((P.totalDegree:ℝ)*α+β*(H/Real.log 2)) := by + classical + let e := Fintype.equivFin ι + have hsupport (x : Fin (Fintype.card ι) → ℤ) + (hx : ∀j,x j∈S (e.symm j)) : ∀i,(x ∘ e) i∈S i := by + intro i + simpa only [Function.comp_apply,e.symm_apply_apply] using hx (e i) + have hsize' (x : Fin (Fintype.card ι) → ℤ) (hx : ∀j,x j∈S (e.symm j)) + (hne : eval x (rename e P)≠0) : Real.log |((eval x (rename e P):ℤ):ℝ)| ≤ H := by + simpa only [eval_rename_equiv] using hsize (x ∘ e) (hsupport x hx) + (by simpa only [eval_rename_equiv] using hne) + have hh := PolynomialFlagReplacement.weighted_restricted_flag_error_le + (rename e P) (rename_ne_zero e hP) (fun j => S (e.symm j)) (fun j => μ (e.symm j)) + B ν α β H A hα hβ hH hA (fun j a ha => hμ (e.symm j) a ha) + (fun j => hmass (e.symm j)) (fun j a ha => hatom (e.symm j) a ha) + hprime hν hνmass hνatom hsize' (fun x => r (x ∘ e)) (fun x => w (x ∘ e)) + (fun x hx b hb => hw (x ∘ e) (hsupport x hx) b hb) + have heflag (x : Fin (Fintype.card ι) → ℤ) (b : ℕ) : + PolynomialFlagReplacement.flagError (rename e P) x b=flagError P (x ∘ e) b := by + rw [fin_flagError_eq,flagError_rename_equiv] + simp_rw [heflag] at hh + rw [totalDegree_rename_equiv] at hh + rw [expectation_reindex_eq_product_sum e S μ + (fun x => ∑b∈B,ν b*(if r x b then w x b*flagError P x b else 0))] at hh + exact hh + +theorem identity_replacement_exact {ι : Type*} [Fintype ι] [DecidableEq ι] + (S : ι → Finset ℤ) (μ : ι → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (r : (ι → ℤ) → ℕ → Bool) (w : (ι → ℤ) → ℕ → ℝ) : + (∑x∈Fintype.piFinset S,(∏i,μ i (x i))* + (∑b∈B,ν b*(if r x b then w x b*flagError (0 : MvPolynomial ι ℤ) x b else 0)))=0 := by + simp only [zero_polynomial_error,mul_zero,ite_self,Finset.sum_const_zero] + +end Ostmann.Arithmetic.PolynomialFlagReplacementFinite + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementFiniteFamily.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementFiniteFamily.lean new file mode 100644 index 0000000000000000000000000000000000000000..fde8a78e562203cf3e9ee660da126fa2de5450fa --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementFiniteFamily.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialFlagReplacementFinite + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PolynomialFlagReplacementFinite +open scoped BigOperators +open MvPolynomial + +theorem weighted_restricted_flag_error_le_all {ι : Type*} [Fintype ι] [DecidableEq ι] + (P : MvPolynomial ι ℤ) + (S : ι → Finset ℤ) (μ : ι → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (α β H A : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hH : 0 ≤ H) (hA : 0 ≤ A) + (hμ : ∀i a,a∈S i → 0 ≤ μ i a) (hmass : ∀i,∑a∈S i,μ i a=1) + (hatom : ∀i a,a∈S i → μ i a ≤ α) + (hprime : ∀b∈B,b.Prime) (hν : ∀b∈B,0 ≤ ν b) (hνmass : ∑b∈B,ν b=1) + (hνatom : ∀b∈B,ν b ≤ β) + (hsize : ∀x,(∀i,x i∈S i) → eval x P≠0 → Real.log |((eval x P:ℤ):ℝ)| ≤ H) + (r : (ι → ℤ) → ℕ → Bool) (w : (ι → ℤ) → ℕ → ℝ) + (hw : ∀x,(∀i,x i∈S i) → ∀b∈B,0 ≤ w x b ∧ w x b ≤ A) : + (∑x∈Fintype.piFinset S,(∏i,μ i (x i))* + (∑b∈B,ν b*(if r x b then w x b*flagError P x b else 0))) ≤ + A*((P.totalDegree:ℝ)*α+β*(H/Real.log 2)) := by + classical + by_cases hP : P=0 + · subst P + rw [identity_replacement_exact] + have hlog : 0 ≤ Real.log (2:ℝ) := (Real.log_pos (by norm_num : (1:ℝ) < 2)).le + positivity + · exact weighted_restricted_flag_error_le P hP S μ B ν α β H A hα hβ hH hA + hμ hmass hatom hprime hν hνmass hνatom hsize r w hw + +theorem product_prior_sum_comm {ι κ : Type*} [Fintype ι] [DecidableEq ι] + (S : ι → Finset ℤ) (μ : ι → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (D : Finset κ) (f : κ → (ι → ℤ) → ℕ → ℝ) : + (∑x∈Fintype.piFinset S,(∏i,μ i (x i))*(∑b∈B,ν b*(∑j∈D,f j x b))) = + ∑j∈D,∑x∈Fintype.piFinset S,(∏i,μ i (x i))*(∑b∈B,ν b*f j x b) := by + simp_rw [Finset.mul_sum] + calc + _ = ∑x∈Fintype.piFinset S,∑j∈D,∑b∈B,(∏i,μ i (x i))*(ν b*f j x b) := by + apply Finset.sum_congr rfl + intro x hx + exact Finset.sum_comm + _ = _ := Finset.sum_comm + +theorem family_weighted_restricted_flag_error_le {ι κ : Type*} [Fintype ι] [DecidableEq ι] + (D : Finset κ) (P : κ → MvPolynomial ι ℤ) + (S : ι → Finset ℤ) (μ : ι → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (α β H A : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hH : 0 ≤ H) (hA : 0 ≤ A) + (hμ : ∀i a,a∈S i → 0 ≤ μ i a) (hmass : ∀i,∑a∈S i,μ i a=1) + (hatom : ∀i a,a∈S i → μ i a ≤ α) + (hprime : ∀b∈B,b.Prime) (hν : ∀b∈B,0 ≤ ν b) (hνmass : ∑b∈B,ν b=1) + (hνatom : ∀b∈B,ν b ≤ β) + (hsize : ∀j∈D,∀x,(∀i,x i∈S i) → eval x (P j)≠0 → Real.log |((eval x (P j):ℤ):ℝ)| ≤ H) + (r : (ι → ℤ) → ℕ → Bool) (w : (ι → ℤ) → ℕ → ℝ) + (hw : ∀x,(∀i,x i∈S i) → ∀b∈B,0 ≤ w x b ∧ w x b ≤ A) : + (∑x∈Fintype.piFinset S,(∏i,μ i (x i))* + (∑b∈B,ν b*(if r x b then w x b*(∑j∈D,flagError (P j) x b) else 0))) ≤ + A*(∑j∈D,(((P j).totalDegree:ℝ)*α+β*(H/Real.log 2))) := by + classical + have hi (x : ι → ℤ) (b : ℕ) : + (if r x b then w x b*(∑j∈D,flagError (P j) x b) else 0) = + ∑j∈D,(if r x b then w x b*flagError (P j) x b else 0) := by + split_ifs <;> simp only [Finset.mul_sum,Finset.sum_const_zero] + simp_rw [hi] + rw [product_prior_sum_comm,Finset.mul_sum] + apply Finset.sum_le_sum + intro j hj + exact weighted_restricted_flag_error_le_all (P j) S μ B ν α β H A hα hβ hH hA + hμ hmass hatom hprime hν hνmass hνatom (hsize j hj) r w hw + +end Ostmann.Arithmetic.PolynomialFlagReplacementFinite + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementFiniteReindex.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementFiniteReindex.lean new file mode 100644 index 0000000000000000000000000000000000000000..d611b71867a76858382b89e4e83dfe1d5f86323a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementFiniteReindex.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialFlagReplacementWeighted +import OAI.NumberTheory.Ostmann.Arithmetic.ProductExpectationFinite + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PolynomialFlagReplacementFinite +open scoped BigOperators +open MvPolynomial + +def divisibilityIndicator {ι : Type*} (P : MvPolynomial ι ℤ) (x : ι → ℤ) (b : ℕ) : ℝ := + if (b:ℤ) ∣ eval x P then 1 else 0 + +def flagError {ι : Type*} (P : MvPolynomial ι ℤ) (x : ι → ℤ) (b : ℕ) : ℝ := by + classical + exact |divisibilityIndicator P x b-if P=0 then 1 else 0| + +@[simp] theorem zero_polynomial_flag {ι : Type*} (x : ι → ℤ) (b : ℕ) : + divisibilityIndicator (0 : MvPolynomial ι ℤ) x b=1 := by + simp [divisibilityIndicator] + +@[simp] theorem zero_polynomial_error {ι : Type*} (x : ι → ℤ) (b : ℕ) : + flagError (0 : MvPolynomial ι ℤ) x b=0 := by simp [flagError] + +theorem flagError_nonneg {ι : Type*} (P : MvPolynomial ι ℤ) (x : ι → ℤ) (b : ℕ) : + 0 ≤ flagError P x b := abs_nonneg _ + +theorem totalDegree_rename_equiv {ι κ : Type*} (e : ι ≃ κ) (P : MvPolynomial ι ℤ) : + (rename e P).totalDegree=P.totalDegree := totalDegree_renameEquiv e P + +theorem rename_ne_zero {ι κ : Type*} (e : ι ≃ κ) {P : MvPolynomial ι ℤ} (hP : P≠0) : + rename e P≠0 := by + exact fun h => hP ((rename_eq_zero_iff_of_injective P e.injective).mp h) + +@[simp] theorem eval_rename_equiv {ι κ : Type*} (e : ι ≃ κ) (P : MvPolynomial ι ℤ) + (x : κ → ℤ) : eval x (rename e P)=eval (x ∘ e) P := eval_rename e x P + +@[simp] theorem divisibilityIndicator_rename_equiv {ι κ : Type*} (e : ι ≃ κ) + (P : MvPolynomial ι ℤ) (x : κ → ℤ) (b : ℕ) : + divisibilityIndicator (rename e P) x b=divisibilityIndicator P (x ∘ e) b := by + simp only [divisibilityIndicator,eval_rename_equiv] + +@[simp] theorem flagError_rename_equiv {ι κ : Type*} (e : ι ≃ κ) + (P : MvPolynomial ι ℤ) (x : κ → ℤ) (b : ℕ) : + flagError (rename e P) x b=flagError P (x ∘ e) b := by + classical + by_cases hP : P=0 + · subst P + simp only [map_zero,zero_polynomial_error] + · simp only [flagError,divisibilityIndicator_rename_equiv,hP,rename_ne_zero e hP,ite_false] + +theorem fin_flagError_eq {n : ℕ} (P : MvPolynomial (Fin n) ℤ) (x : Fin n → ℤ) (b : ℕ) : + PolynomialFlagReplacement.flagError P x b=flagError P x b := by + classical + by_cases hP : P=0 + · subst P + rw [PolynomialFlagReplacement.zero_polynomial_error,zero_polynomial_error] + · by_cases hd : (b:ℤ) ∣ eval x P + · simp only [PolynomialFlagReplacement.flagError,flagError, + PolynomialFlagReplacement.divisibilityIndicator,divisibilityIndicator,hP,hd,ite_true,ite_false] + · simp only [PolynomialFlagReplacement.flagError,flagError, + PolynomialFlagReplacement.divisibilityIndicator,divisibilityIndicator,hP,hd,ite_false] + +theorem product_sum_reindex {ι κ K : Type*} [Fintype ι] [Fintype κ] [DecidableEq ι] [DecidableEq κ] + (e : ι ≃ κ) (S : ι → Finset K) (μ : ι → K → ℝ) (f : (ι → K) → ℝ) : + (∑ x ∈ Fintype.piFinset (fun j => S (e.symm j)), + (∏j,μ (e.symm j) (x j))*f (x ∘ e)) = + ∑ x ∈ Fintype.piFinset S,(∏i,μ i (x i))*f x := by + classical + apply Finset.sum_bij (fun x _ => x ∘ e) + · intro x hx + apply Fintype.mem_piFinset.mpr + intro i + simpa only [Function.comp_apply,e.symm_apply_apply] using Fintype.mem_piFinset.mp hx (e i) + · intro x hx y hy hxy + funext j + have hh := congrFun hxy (e.symm j) + simpa only [Function.comp_apply,e.apply_symm_apply] using hh + · intro y hy + refine ⟨y ∘ e.symm,?_,?_⟩ + · exact Fintype.mem_piFinset.mpr (fun j => Fintype.mem_piFinset.mp hy (e.symm j)) + · funext i + simp only [Function.comp_apply,e.symm_apply_apply] + · intro x hx + congr 1 + exact Fintype.prod_equiv e.symm _ _ (fun j => by simp only [Function.comp_apply,e.apply_symm_apply]) + +theorem expectation_reindex_eq_product_sum {ι K : Type*} [Fintype ι] [DecidableEq ι] {n : ℕ} + (e : ι ≃ Fin n) (S : ι → Finset K) (μ : ι → K → ℝ) (f : (ι → K) → ℝ) : + ProductExpectation.expectation (fun j => S (e.symm j)) (fun j => μ (e.symm j)) + (fun x => f (x ∘ e)) = ∑ x ∈ Fintype.piFinset S,(∏i,μ i (x i))*f x := by + rw [ProductExpectation.eq_product_sum] + exact product_sum_reindex e S μ f + +end Ostmann.Arithmetic.PolynomialFlagReplacementFinite + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementUnnormalized.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementUnnormalized.lean new file mode 100644 index 0000000000000000000000000000000000000000..bef796e3fcfd3e21f949eac13a1950964b4b1baa --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementUnnormalized.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialFlagReplacementFiniteFamily +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialFlagReplacementUnnormalizedFinite + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PolynomialFlagReplacementUnnormalized +open scoped BigOperators +open MvPolynomial PolynomialFlagReplacementFinite + +theorem weighted_restricted_flag_error_le_all {ι : Type*} [Fintype ι] [DecidableEq ι] + (P : MvPolynomial ι ℤ) + (S : ι → Finset ℤ) (μ : ι → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (α β H A C Cnu : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hH : 0 ≤ H) (hA : 0 ≤ A) + (hC : 0 ≤ C) (hCnu : 0 ≤ Cnu) + (hμ : ∀i a,a∈S i → 0 ≤ μ i a) (hmass : ∀i,∑a∈S i,μ i a ≤ C) + (hatom : ∀i a,a∈S i → μ i a ≤ α) + (hprime : ∀b∈B,b.Prime) (hν : ∀b∈B,0 ≤ ν b) (hνmass : ∑b∈B,ν b ≤ Cnu) + (hνatom : ∀b∈B,ν b ≤ β) + (hsize : ∀x,(∀i,x i∈S i) → eval x P≠0 → Real.log |((eval x P:ℤ):ℝ)| ≤ H) + (r : (ι → ℤ) → ℕ → Bool) (w : (ι → ℤ) → ℕ → ℝ) + (hw : ∀x,(∀i,x i∈S i) → ∀b∈B,0 ≤ w x b ∧ w x b ≤ A) : + (∑x∈Fintype.piFinset S,(∏i,μ i (x i))* + (∑b∈B,ν b*(if r x b then w x b*flagError P x b else 0))) ≤ + A*((P.totalDegree:ℝ)*α*C^(Fintype.card ι-1)*Cnu+β*(H/Real.log 2)*C^Fintype.card ι) := by + classical + by_cases hP : P=0 + · subst P + rw [identity_replacement_exact] + have hlog : 0 ≤ Real.log (2:ℝ) := (Real.log_pos (by norm_num : (1:ℝ) < 2)).le + positivity + · exact weighted_restricted_flag_error_le P hP S μ B ν α β H A C Cnu hα hβ hH hA hC hCnu + hμ hmass hatom hprime hν hνmass hνatom hsize r w hw + +theorem family_weighted_restricted_flag_error_le {ι κ : Type*} [Fintype ι] [DecidableEq ι] + (D : Finset κ) (P : κ → MvPolynomial ι ℤ) + (S : ι → Finset ℤ) (μ : ι → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (α β H A C Cnu : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hH : 0 ≤ H) (hA : 0 ≤ A) + (hC : 0 ≤ C) (hCnu : 0 ≤ Cnu) + (hμ : ∀i a,a∈S i → 0 ≤ μ i a) (hmass : ∀i,∑a∈S i,μ i a ≤ C) + (hatom : ∀i a,a∈S i → μ i a ≤ α) + (hprime : ∀b∈B,b.Prime) (hν : ∀b∈B,0 ≤ ν b) (hνmass : ∑b∈B,ν b ≤ Cnu) + (hνatom : ∀b∈B,ν b ≤ β) + (hsize : ∀j∈D,∀x,(∀i,x i∈S i) → eval x (P j)≠0 → Real.log |((eval x (P j):ℤ):ℝ)| ≤ H) + (r : (ι → ℤ) → ℕ → Bool) (w : (ι → ℤ) → ℕ → ℝ) + (hw : ∀x,(∀i,x i∈S i) → ∀b∈B,0 ≤ w x b ∧ w x b ≤ A) : + (∑x∈Fintype.piFinset S,(∏i,μ i (x i))* + (∑b∈B,ν b*(if r x b then w x b*(∑j∈D,flagError (P j) x b) else 0))) ≤ + A*(∑j∈D,(((P j).totalDegree:ℝ)*α*C^(Fintype.card ι-1)*Cnu+β*(H/Real.log 2)*C^Fintype.card ι)) := by + classical + have hi (x : ι → ℤ) (b : ℕ) : + (if r x b then w x b*(∑j∈D,flagError (P j) x b) else 0) = + ∑j∈D,(if r x b then w x b*flagError (P j) x b else 0) := by + split_ifs <;> simp only [Finset.mul_sum,Finset.sum_const_zero] + simp_rw [hi] + rw [product_prior_sum_comm,Finset.mul_sum] + apply Finset.sum_le_sum + intro j hj + exact weighted_restricted_flag_error_le_all (P j) S μ B ν α β H A C Cnu hα hβ hH hA hC hCnu + hμ hmass hatom hprime hν hνmass hνatom (hsize j hj) r w hw + +end Ostmann.Arithmetic.PolynomialFlagReplacementUnnormalized + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementUnnormalizedFinite.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementUnnormalizedFinite.lean new file mode 100644 index 0000000000000000000000000000000000000000..6619f386be19049bdda88b23d5b78520d2a1a2bb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementUnnormalizedFinite.lean @@ -0,0 +1,55 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialFlagMass +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialFlagReplacementFiniteReindex + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PolynomialFlagReplacementUnnormalized +open scoped BigOperators +open MvPolynomial PolynomialFlagReplacementFinite + +theorem weighted_restricted_flag_error_le {ι : Type*} [Fintype ι] [DecidableEq ι] + (P : MvPolynomial ι ℤ) (hP : P≠0) + (S : ι → Finset ℤ) (μ : ι → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (α β H A C Cnu : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hH : 0 ≤ H) (hA : 0 ≤ A) + (hC : 0 ≤ C) (hCnu : 0 ≤ Cnu) + (hμ : ∀i a,a∈S i → 0 ≤ μ i a) (hmass : ∀i,∑a∈S i,μ i a ≤ C) + (hatom : ∀i a,a∈S i → μ i a ≤ α) + (hprime : ∀b∈B,b.Prime) (hν : ∀b∈B,0 ≤ ν b) (hνmass : ∑b∈B,ν b ≤ Cnu) + (hνatom : ∀b∈B,ν b ≤ β) + (hsize : ∀x,(∀i,x i∈S i) → eval x P≠0 → Real.log |((eval x P:ℤ):ℝ)| ≤ H) + (r : (ι → ℤ) → ℕ → Bool) (w : (ι → ℤ) → ℕ → ℝ) + (hw : ∀x,(∀i,x i∈S i) → ∀b∈B,0 ≤ w x b ∧ w x b ≤ A) : + (∑x∈Fintype.piFinset S,(∏i,μ i (x i))* + (∑b∈B,ν b*(if r x b then w x b*flagError P x b else 0))) ≤ + A*((P.totalDegree:ℝ)*α*C^(Fintype.card ι-1)*Cnu+β*(H/Real.log 2)*C^Fintype.card ι) := by + classical + let e := Fintype.equivFin ι + have hsupport (x : Fin (Fintype.card ι) → ℤ) + (hx : ∀j,x j∈S (e.symm j)) : ∀i,(x ∘ e) i∈S i := by + intro i + simpa only [Function.comp_apply,e.symm_apply_apply] using hx (e i) + have hsize' (x : Fin (Fintype.card ι) → ℤ) (hx : ∀j,x j∈S (e.symm j)) + (hne : eval x (rename e P)≠0) : Real.log |((eval x (rename e P):ℤ):ℝ)| ≤ H := by + simpa only [eval_rename_equiv] using hsize (x ∘ e) (hsupport x hx) + (by simpa only [eval_rename_equiv] using hne) + have hh := PolynomialFlagMass.weighted_restricted_flag_error_le + (rename e P) (rename_ne_zero e hP) (fun j => S (e.symm j)) (fun j => μ (e.symm j)) + B ν α β H A C Cnu hα hβ hH hA hC hCnu (fun j a ha => hμ (e.symm j) a ha) + (fun j => hmass (e.symm j)) (fun j a ha => hatom (e.symm j) a ha) + hprime hν hνmass hνatom hsize' (fun x => r (x ∘ e)) (fun x => w (x ∘ e)) + (fun x hx b hb => hw (x ∘ e) (hsupport x hx) b hb) + have heflag (x : Fin (Fintype.card ι) → ℤ) (b : ℕ) : + PolynomialFlagReplacement.flagError (rename e P) x b=flagError P (x ∘ e) b := by + rw [fin_flagError_eq,flagError_rename_equiv] + simp_rw [heflag] at hh + rw [totalDegree_rename_equiv] at hh + rw [expectation_reindex_eq_product_sum e S μ + (fun x => ∑b∈B,ν b*(if r x b then w x b*flagError P x b else 0))] at hh + exact hh + +end Ostmann.Arithmetic.PolynomialFlagReplacementUnnormalized + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementWeighted.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementWeighted.lean new file mode 100644 index 0000000000000000000000000000000000000000..6a0689e418da28a4b15f6e89c8c1d1c1d0fa3f80 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialFlagReplacementWeighted.lean @@ -0,0 +1,45 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialFlagReplacement + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PolynomialFlagReplacement +open scoped BigOperators +open MvPolynomial ProductExpectation + +theorem weighted_restricted_flag_error_le {n : ℕ} (P : MvPolynomial (Fin n) ℤ) (hP : P≠0) + (S : Fin n → Finset ℤ) (μ : Fin n → ℤ → ℝ) (B : Finset ℕ) (ν : ℕ → ℝ) + (α β H A : ℝ) (hα : 0≤α) (hβ : 0≤β) (hH : 0≤H) (hA : 0≤A) + (hμ : ∀ i a, a∈S i → 0≤μ i a) (hmass : ∀ i, ∑ a∈S i, μ i a=1) + (hatom : ∀ i a, a∈S i → μ i a≤α) + (hprime : ∀ b∈B, b.Prime) (hν : ∀ b∈B,0≤ν b) (hνmass : ∑ b∈B,ν b=1) + (hνatom : ∀ b∈B,ν b≤β) + (hsize : ∀ x, (∀ i,x i∈S i) → eval x P≠0 → Real.log |((eval x P:ℤ):ℝ)|≤H) + (r : (Fin n → ℤ) → ℕ → Bool) (w : (Fin n → ℤ) → ℕ → ℝ) + (hw : ∀ x, (∀ i,x i∈S i) → ∀ b∈B,0≤w x b ∧ w x b≤A) : + expectation S μ (fun x => ∑ b∈B,ν b*(if r x b then w x b*flagError P x b else 0)) ≤ + A*((P.totalDegree:ℝ)*α+β*(H/Real.log 2)) := by + have he : expectation S μ (fun x => ∑ b∈B,ν b*(if r x b then w x b*flagError P x b else 0)) ≤ + expectation S μ (fun x => A*(∑ b∈B,ν b*divisibilityIndicator P x b)) := by + apply expectation_mono_support S μ hμ + intro x hx + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro b hb + have hp : (if r x b then w x b*flagError P x b else 0) ≤ A*divisibilityIndicator P x b := by + rw [flagError_of_ne_zero P hP] + split_ifs + · exact mul_le_mul_of_nonneg_right (hw x hx b hb).2 (indicator_nonneg P x b) + · exact mul_nonneg hA (indicator_nonneg P x b) + have hh := mul_le_mul_of_nonneg_left hp (hν b hb) + simpa only [mul_assoc,mul_left_comm] using hh + rw [expectation_const_mul] at he + exact he.trans (mul_le_mul_of_nonneg_left + (divisibility_probability_le P hP S μ B ν α β H hα hβ hH hμ hmass hatom + hprime hνmass hνatom hsize) hA) + +end Ostmann.Arithmetic.PolynomialFlagReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialRootMass.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialRootMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..63d5005c4c30a90f2a58c27366caa7555aee62ba --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialRootMass.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PolynomialFlagReplacementExpectation + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PolynomialRootMass +open scoped BigOperators +open MvPolynomial ProductExpectation PolynomialFlagReplacement + +theorem expectation_const_mass {K : Type*} : ∀{n : ℕ} + (S : Fin n → Finset K) (μ : Fin n → K → ℝ) (a : ℝ), + expectation S μ (fun _ => a) = a*∏i,∑x∈S i,μ i x + | 0,S,μ,a => by simp [expectation] + | n+1,S,μ,a => by + simp only [expectation,←Finset.sum_mul] + rw [expectation_const_mass,Fin.prod_univ_succ] + simp only [Fin.tail_def] + ring + +theorem expectation_const_le {K : Type*} {n : ℕ} + (S : Fin n → Finset K) (μ : Fin n → K → ℝ) {C a : ℝ} + (hμ : ∀i x,x∈S i → 0 ≤ μ i x) (hmass : ∀i,∑x∈S i,μ i x ≤ C) + (ha : 0 ≤ a) : expectation S μ (fun _ => a) ≤ a*C^n := by + rw [expectation_const_mass] + apply mul_le_mul_of_nonneg_left _ ha + calc + _ ≤ ∏_i:Fin n,C := Finset.prod_le_prod₀ + (fun i _ => Finset.sum_nonneg (fun x hx => hμ i x hx)) (fun i _ => hmass i) + _ = _ := by simp + +theorem weighted_zero_bound {K : Type*} [CommRing K] [IsDomain K] [DecidableEq K] : + ∀{n : ℕ} (P : MvPolynomial (Fin n) K) (_hP : P ≠ 0) + (S : Fin n → Finset K) (μ : Fin n → K → ℝ) (α C : ℝ) + (_hα : 0 ≤ α) (_hC : 0 ≤ C) + (_hμ : ∀i a,a∈S i → 0 ≤ μ i a) + (_hmass : ∀i,∑a∈S i,μ i a ≤ C) + (_hatom : ∀i a,a∈S i → μ i a ≤ α), + expectation S μ (fun x => if eval x P=0 then 1 else 0) ≤ + (P.totalDegree:ℝ)*α*C^(n-1) + | 0,P,hP,S,μ,α,C,hα,hC,hμ,hmass,hatom => by + rw [P.eq_C_of_isEmpty] at hP ⊢ + simp only [expectation,eval_C,totalDegree_C,Nat.cast_zero,zero_mul] + simp [C_ne_zero.mp hP] + | n+1,P,hP,S,μ,α,C,hα,hC,hμ,hmass,hatom => by + let P' := finSuccEquiv K n P + let k := P'.natDegree + let Q := P'.leadingCoeff + have hP' : P' ≠ 0 := EmbeddingLike.map_ne_zero_iff.mpr hP + have hQ : Q ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr hP' + have hdegree : Q.totalDegree+k ≤ P.totalDegree := totalDegree_coeff_finSuccEquiv_add_le P k hQ + have hfiber (x : Fin n → K) : + (∑a∈S 0,μ 0 a*(if eval (Fin.cons a x) P=0 then 1 else 0)) ≤ + C*(if eval x Q=0 then 1 else 0)+(k:ℝ)*α := by + by_cases hx : eval x Q=0 + · simp only [hx,ite_true,mul_one] + calc + _ ≤ ∑a∈S 0,μ 0 a := Finset.sum_le_sum (fun a ha => by split_ifs <;> simp [hμ 0 a ha]) + _ ≤ C := hmass 0 + _ ≤ _ := le_add_of_nonneg_right (mul_nonneg (Nat.cast_nonneg _) hα) + · simp only [hx,ite_false,mul_zero,zero_add] + let Px := P'.map (eval x) + have hPx : Px ≠ 0 := by + intro h + apply hx + have hh := congrArg (fun f:Polynomial K => f.coeff k) h + simpa only [Px,Polynomial.coeff_map,Polynomial.coeff_zero,k,Q,Polynomial.leadingCoeff] using hh + have hPxdeg : Px.natDegree ≤ k := Polynomial.natDegree_map_le + calc + _ = ∑a∈S 0 with Px.eval a=0,μ 0 a := by + simp only [eval_eq_eval_mv_eval',Finset.sum_filter,Px,P'] + apply Finset.sum_congr rfl + intro a ha + split_ifs <;> simp + _ ≤ (Px.natDegree:ℝ)*α := + AccidentalDivisibility.weighted_polynomial_roots Px hPx (S 0) (μ 0) hα (hatom 0) + _ ≤ (k:ℝ)*α := mul_le_mul_of_nonneg_right (by exact_mod_cast hPxdeg) hα + have htail : C*((Q.totalDegree:ℝ)*α*C^(n-1))=(Q.totalDegree:ℝ)*α*C^n := by + cases n with + | zero => + have hq0 : Q.totalDegree=0 := by rw [Q.eq_C_of_isEmpty,totalDegree_C] + simp [hq0] + | succ n => simp only [Nat.add_sub_cancel,pow_succ]; ring + calc + _ ≤ expectation (Fin.tail S) (Fin.tail μ) + (fun x => C*(if eval x Q=0 then 1 else 0)+(k:ℝ)*α) := + ProductExpectation.mono (Fin.tail S) (Fin.tail μ) (fun i => hμ i.succ) hfiber + _ = C*expectation (Fin.tail S) (Fin.tail μ) (fun x => if eval x Q=0 then 1 else 0)+ + expectation (Fin.tail S) (Fin.tail μ) (fun _ => (k:ℝ)*α) := by + rw [ProductExpectation.add,expectation_const_mul] + _ ≤ C*((Q.totalDegree:ℝ)*α*C^(n-1))+((k:ℝ)*α)*C^n := add_le_add + (mul_le_mul_of_nonneg_left + (weighted_zero_bound Q hQ (Fin.tail S) (Fin.tail μ) α C hα hC + (fun i => hμ i.succ) (fun i => hmass i.succ) (fun i => hatom i.succ)) hC) + (expectation_const_le _ _ (fun i => hμ i.succ) (fun i => hmass i.succ) (by positivity)) + _ = ((Q.totalDegree:ℝ)+k)*α*C^n := by rw [htail]; ring + _ ≤ _ := by + simp only [Nat.add_sub_cancel] + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (by exact_mod_cast hdegree) hα) (pow_nonneg hC _) + +end Ostmann.Arithmetic.PolynomialRootMass + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialRootProbability.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialRootProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1fc4f674025ba224d1c22a871a9e23c53c9bdca --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PolynomialRootProbability.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.AccidentalDivisibility +import OAI.NumberTheory.Ostmann.Arithmetic.ProductExpectation + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PolynomialRootProbability +open scoped BigOperators +open MvPolynomial ProductExpectation + +theorem weighted_zero_bound {K : Type*} [CommRing K] [IsDomain K] [DecidableEq K] : + ∀ {n : ℕ} (P : MvPolynomial (Fin n) K) (_hP : P ≠ 0) + (S : Fin n → Finset K) (μ : Fin n → K → ℝ) (α : ℝ) (_hα : 0 ≤ α) + (_hμ : ∀ i a, a ∈ S i → 0 ≤ μ i a) + (_hmass : ∀ i, ∑ a ∈ S i, μ i a = 1) + (_hatom : ∀ i a, a ∈ S i → μ i a ≤ α), + expectation S μ (fun x => if eval x P = 0 then 1 else 0) ≤ + (P.totalDegree : ℝ) * α + | 0, P, hP, S, μ, α, hα, hμ, hmass, hatom => by + rw [P.eq_C_of_isEmpty] at hP ⊢ + simp only [expectation, eval_C, totalDegree_C, Nat.cast_zero, zero_mul] + simp [C_ne_zero.mp hP] + | n+1, P, hP, S, μ, α, hα, hμ, hmass, hatom => by + let P' := finSuccEquiv K n P + let k := P'.natDegree + let Q := P'.leadingCoeff + have hP' : P' ≠ 0 := EmbeddingLike.map_ne_zero_iff.mpr hP + have hQ : Q ≠ 0 := Polynomial.leadingCoeff_ne_zero.mpr hP' + have hdegree : Q.totalDegree+k ≤ P.totalDegree := + totalDegree_coeff_finSuccEquiv_add_le P k hQ + have hfiber : ∀ x : Fin n → K, + (∑ a ∈ S 0, μ 0 a * (if eval (Fin.cons a x) P=0 then 1 else 0)) ≤ + (if eval x Q=0 then 1 else 0) + (k:ℝ)*α := by + intro x + by_cases hx : eval x Q = 0 + · rw [ite_eq_left hx] + calc + _ ≤ ∑ a ∈ S 0, μ 0 a := Finset.sum_le_sum fun a ha => by + split_ifs <;> simp [hμ 0 a ha] + _ = 1 := hmass 0 + _ ≤ _ := le_add_of_nonneg_right (mul_nonneg (Nat.cast_nonneg _) hα) + · rw [ite_eq_right hx, zero_add] + let Px := P'.map (eval x) + have hPx : Px ≠ 0 := by + intro h + apply hx + have hh := congrArg (fun f : Polynomial K => f.coeff k) h + simpa only [Px, Polynomial.coeff_map, Polynomial.coeff_zero, + k, Q, Polynomial.leadingCoeff] using hh + have hPxdeg : Px.natDegree ≤ k := Polynomial.natDegree_map_le + calc + _ = ∑ a ∈ S 0 with Px.eval a=0, μ 0 a := by + simp only [eval_eq_eval_mv_eval', Finset.sum_filter, Px, P'] + apply Finset.sum_congr rfl + intro a ha + split_ifs <;> simp + _ ≤ (Px.natDegree:ℝ)*α := + AccidentalDivisibility.weighted_polynomial_roots Px hPx (S 0) (μ 0) hα (hatom 0) + _ ≤ (k:ℝ)*α := mul_le_mul_of_nonneg_right (by exact_mod_cast hPxdeg) hα + calc + _ ≤ expectation (Fin.tail S) (Fin.tail μ) + (fun x => (if eval x Q=0 then 1 else 0)+(k:ℝ)*α) := + ProductExpectation.mono (Fin.tail S) (Fin.tail μ) (fun i => hμ i.succ) hfiber + _ = expectation (Fin.tail S) (Fin.tail μ) + (fun x => if eval x Q=0 then 1 else 0)+(k:ℝ)*α := by + rw [ProductExpectation.add] + exact congrArg (fun t => expectation (Fin.tail S) (Fin.tail μ) + (fun x => if eval x Q=0 then 1 else 0) + t) + (ProductExpectation.const (Fin.tail S) (Fin.tail μ) + (fun i => hmass i.succ) ((k:ℝ)*α)) + _ ≤ (Q.totalDegree:ℝ)*α+(k:ℝ)*α := add_le_add + (weighted_zero_bound Q hQ (Fin.tail S) (Fin.tail μ) α hα + (fun i => hμ i.succ) (fun i => hmass i.succ) (fun i => hatom i.succ)) le_rfl + _ ≤ (P.totalDegree:ℝ)*α := by + rw [← add_mul, ← Nat.cast_add] + exact mul_le_mul_of_nonneg_right (by exact_mod_cast hdegree) hα + +end Ostmann.Arithmetic.PolynomialRootProbability + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeBandHarmonicTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeBandHarmonicTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..d84021d7823badd8a761bf71826409d669d716b1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeBandHarmonicTransfer.lean @@ -0,0 +1,53 @@ +import Mathlib.Order.Filter.AtTopBot.Basic +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeBandHarmonicTransferFinite + +namespace OAI + +noncomputable section +open Filter +open scoped BigOperators +namespace Ostmann.Arithmetic.PrimeBandHarmonicTransfer + +theorem eventually_harmonic_band_le (f : ℕ→ℝ) (hf : ∀p,0≤f p) + (hband : ∀δ:ℝ,0<δ → ∀ᶠ T:ℝ in atTop, + ∀P:Finset ℕ,(∀p∈P,p.Prime) → + (∀p∈P,T≤Real.log (p:ℝ) ∧ Real.log (p:ℝ)≤2*T) → + (∑p∈P,(Real.log (p:ℝ)/(p:ℝ))*f p)≤δ*T) + {α β : ℝ} (hα : 0<α) (hαβ : α<β) (ε : ℝ) (hε : 0<ε) : + ∀ᶠ L:ℝ in atTop,∀P:Finset ℕ,(∀p∈P,p.Prime) → + (∀p∈P,α*L≤Real.log (Real.log (p:ℝ)) ∧ Real.log (Real.log (p:ℝ))≤β*L) → + (∑p∈P,f p/(p:ℝ))≤ε*L := by + let C : ℝ := β/Real.log 2+1 + have hβ : 0<β := hα.trans hαβ + have hC : 0 P.filter (fun p : ℕ => logDyadicIndex (Real.log (p:ℝ))=j) + have hmap : ∀p∈P,logDyadicIndex (Real.log (p:ℝ))∈J := by + intro p hp + exact Finset.mem_range.mpr (Nat.lt_succ_of_le (logDyadicIndex_le (hP p hp).2)) + have he : (∑j∈J,∑p∈Q j,f p/(p:ℝ))=∑p∈P,f p/(p:ℝ) := + Finset.sum_fiberwise_of_maps_to hmap (fun p => f p/(p:ℝ)) + have hblock : ∀j∈J,(∑p∈Q j,f p/(p:ℝ))≤δ := by + intro j hj + by_cases hQ : (Q j).Nonempty + · obtain ⟨p,hp⟩ := hQ + have hpP := (Finset.mem_filter.mp hp).1 + have hjp := (Finset.mem_filter.mp hp).2 + have hT₀ : T₀≤logDyadicScale j := by + rw [←hjp] + exact hstart.trans (logDyadicScale_lower (hP p hpP).1) + have hbounds : ∀p∈Q j,logDyadicScale j≤Real.log (p:ℝ) ∧ + Real.log (p:ℝ)≤2*logDyadicScale j := by + intro p hp + obtain ⟨hpP,hpj⟩ := Finset.mem_filter.mp hp + have hpp := hprime p hpP + have hp1 : (1:ℝ)

hprime p (Finset.mem_filter.mp hp).1) hbounds + have hh : logDyadicScale j*(∑p∈Q j,f p/(p:ℝ))≤ + ∑p∈Q j,(Real.log (p:ℝ)/(p:ℝ))*f p := by + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro p hp + calc + _ ≤ Real.log (p:ℝ)*(f p/(p:ℝ)) := + mul_le_mul_of_nonneg_right (hbounds p hp).1 (div_nonneg (hf p) (Nat.cast_nonneg p)) + _ = _ := by ring + apply (mul_le_mul_iff_right₀ (Real.exp_pos ((j:ℝ)*Real.log 2))).mp + simpa only [logDyadicScale,mul_comm] using hh.trans hsum + · have hz : Q j=∅ := Finset.not_nonempty_iff_eq_empty.mp hQ + simpa only [hz,Finset.sum_empty] using hδ + calc + _ = ∑j∈J,∑p∈Q j,f p/(p:ℝ) := he.symm + _ ≤ ∑j∈J,δ := Finset.sum_le_sum hblock + _ = δ*((⌊b/Real.log 2⌋₊:ℝ)+1) := by + simp only [Finset.sum_const,nsmul_eq_mul,J,Finset.card_range,Nat.cast_add,Nat.cast_one] + ring + _ ≤ _ := mul_le_mul_of_nonneg_left + (by have hh := Nat.floor_le (div_nonneg hb log_two_pos.le); linarith) hδ + +end Ostmann.Arithmetic.PrimeBandHarmonicTransfer + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeBandHarmonicTransferGeometry.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeBandHarmonicTransferGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..6dbaa3972d9a637bad94f83d9bffffbb411e1a8e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeBandHarmonicTransferGeometry.lean @@ -0,0 +1,51 @@ +import Mathlib.Algebra.BigOperators.Group.Finset.Basic +import Mathlib.Algebra.Order.Floor.Ring +import Mathlib.Analysis.SpecialFunctions.Log.Basic +import Mathlib.Data.Nat.Prime.Basic +import Mathlib.Tactic.Linarith +import Mathlib.Tactic.NormNum +import Mathlib.Tactic.Positivity +import Mathlib.Tactic.Ring + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeBandHarmonicTransfer + +def logDyadicIndex (x : ℝ) : ℕ := ⌊Real.log x/Real.log 2⌋₊ + +def logDyadicScale (j : ℕ) : ℝ := Real.exp ((j:ℝ)*Real.log 2) + +lemma log_two_pos : (0:ℝ).mpr htone + have hwidth : 0 ≤ hi-lo := sub_nonneg.mpr horder + have hh := intervalIntegral.norm_integral_le_of_norm_le_const (f:=fun t : ℝ => t⁻¹) + (C:=1) (a:=lo) (b:=hi) (fun t ht => by + rw [Set.uIoc_of_le horder] at ht + have ht1 : 1 ≤ t := hlo.trans ht.1.le + have ht0 : 0 < t := by linarith + rw [Real.norm_eq_abs,abs_of_pos (inv_pos.mpr ht0)] + exact inv_le_one₀ ht0 |>.mpr ht1) + simp only [Real.norm_eq_abs,one_mul,abs_of_nonneg hwidth] at hh + rw [harmonicIntegral,abs_div,abs_mul,abs_of_nonneg (inv_nonneg.mpr htpos.le),abs_of_pos hZ, + div_eq_mul_inv] + calc + _ ≤ (1*(hi-lo))*Real.exp A := + mul_le_mul (mul_le_mul htinv hh (abs_nonneg _) (by norm_num)) hZi + (inv_nonneg.mpr hZ.le) (by positivity) + _ = _ := by ring + +theorem eventually_actual_primeCell_bounds (r : Row) (k : ℕ) + {C K d : ℝ} (hC : 0 ≤ C) (hK : 0 ≤ K) (hd : 0 < d) : + ∀ᶠ L : ℝ in atTop, ∀ (M : ℕ) (lo hi Z : ℝ), + 0 < M → Real.exp (r.a₀*L) ≤ lo → lo ≤ hi → hi-lo ≤ meshWidth r L → + 0 < Z → Z⁻¹ ≤ Real.exp (C*((Conclusion.bulkSize k L:ℝ)+1)) → + correctedPrimeError K d lo Z ≤ primeEnvelope r k C K d L ∧ + |harmonicIntegral M lo hi/Z|+primeEnvelope r k C K d L ≤ 2 := by + have hδ : 0 < r.δ := r.μ_pos.trans r.μ_lt_δ + filter_upwards [eventually_variation_error r k C (by norm_num : (0:ℝ)≤0) hδ, + eventually_primeEnvelope_budget r k (D:=0) hC (by norm_num : (0:ℝ)≤1) hK hd + (by norm_num : (0:ℝ)≤0) hδ.le, + eventually_ge_atTop (0:ℝ)] with L hv he hL + intro M lo hi Z hM hlo horder hwidth hZ hZi + have hlo1 : 1 ≤ lo := (Real.one_le_exp (mul_nonneg (row_a₀_pos r).le hL)).trans hlo + have hmass := harmonicIntegral_normalized_abs_le M hM hlo1 horder hZ hZi + have htarget : Real.exp (-Real.exp (r.target*L)) ≤ 1 := + Real.exp_le_one_iff.mpr (neg_nonpos.mpr (Real.exp_nonneg _)) + have henv : primeEnvelope r k C K d L ≤ 1 := by + have hh := he 0 1 (by omega) (by norm_num) (by simpa using (Real.exp_nonneg (r.μ*L))) + simpa only [jointMeshFactor,pow_zero,Nat.cast_one,mul_one,smoothGrowthFactor, + zero_mul,Real.exp_zero,one_mul] using hh.trans htarget + have hmass1 : |harmonicIntegral M lo hi/Z| ≤ 1 := by + apply (hmass.trans (mul_le_mul_of_nonneg_right hwidth (Real.exp_nonneg _))).trans + apply le_trans _ (hv.trans htarget) + simp only [meshWidth,← Real.exp_add,zero_mul,Real.exp_zero,mul_one] + apply Real.exp_le_exp.mpr + have hh : 0 ≤ C*((Conclusion.bulkSize k L:ℝ)+1) := by positivity + linarith + exact ⟨correctedPrimeError_le_envelope r k hK hd hL hlo hZ hZi,by linarith⟩ + +end Ostmann.Arithmetic.PrimeCellActualErrorBudget + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellActualErrorBudgetMixed.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellActualErrorBudgetMixed.lean new file mode 100644 index 0000000000000000000000000000000000000000..e786a942dc6ea38945201dc0234990e33ed2d957 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellActualErrorBudgetMixed.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellActualErrorBudgetMixedBasic + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellActualErrorBudget +open ScaleBudget PrimeCellMeshBudget LogCellPartition Filter + +theorem mixedGridError_le_two_parts {ι : Type*} [Fintype ι] + (M : ℕ) (hM : 0 < M) {lo hi η G B D a L ε : ℝ} (φ : ℝ → ℝ) + (j : Fin (gridCount lo hi η)) (horder : lo ≤ hi) (hη : 0 < η) (hη1 : η ≤ 1) + (hB : 0 ≤ B) (hD : 0 ≤ D) (hwindow : hi ≤ G+1) (hG : Real.exp (a*L) ≤ G) + (hφ : ∀ t ∈ Set.Icc lo hi, |φ (t-G)| ≤ B) (hε : 0 ≤ ε) : + mixedGridError (ι:=ι) M lo hi η G B D φ ε 2 j ≤ + (6*B+2*D)*Real.exp (-Real.exp (a*L))*2^Fintype.card ι+ + (Real.exp 1*B+(6*B+2*D))*((Fintype.card ι:ℝ)*2^Fintype.card ι)*ε := by + have hl := gridPoint_mem (η:=η) horder j.isLt.le + have hu := gridPoint_mem (η:=η) horder (show j.val+1≤gridCount lo hi η by omega) + have hwidth : gridPoint lo hi η (j.val+1)-gridPoint lo hi η j.val ≤ 1 := + (gridPoint_width lo hi η j.val).trans_le ((gridStep_le horder hη).trans hη1) + have hJ := integerDensityMass_abs_le M hM φ (gridPoint_mono horder (Nat.le_succ _)) hwidth + (hu.2.trans hwindow) hB (fun t ht => hφ t ⟨hl.1.trans ht.1,ht.2.trans hu.2⟩) + have hEI := mixedGridIntegerError_le j hB hD hwidth hG + have hq : Real.exp (-Real.exp (a*L)) ≤ 1 := Real.exp_le_one_iff.mpr (neg_nonpos.mpr (Real.exp_nonneg _)) + have hsmall : mixedGridIntegerError lo hi η G B D j ≤ 6*B+2*D := + hEI.trans (by simpa using mul_le_mul_of_nonneg_left hq (by positivity : 0 ≤ 6*B+2*D)) + unfold mixedGridError + calc + _ ≤ ((6*B+2*D)*Real.exp (-Real.exp (a*L))+ + (Real.exp 1*B+(6*B+2*D))*(Fintype.card ι:ℝ)*ε)*2^Fintype.card ι := by + apply mul_le_mul_of_nonneg_right _ (by positivity) + exact add_le_add hEI (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (add_le_add hJ hsmall) (Nat.cast_nonneg _)) hε) + _ = _ := by ring + +theorem eventually_mixedGridError_budget (r : Row) (k : ℕ) + {C K d B D σ : ℝ} (hC : 0 ≤ C) (hK : 0 ≤ K) (hd : 0 < d) + (hB : 0 ≤ B) (hD : 0 ≤ D) (hσ0 : 0 ≤ σ) (hσ : σ ≤ r.δ) : + ∀ᶠ L : ℝ in atTop, + ∀ (ι : Type*) [Fintype ι] (M : ℕ) (lo hi η G : ℝ) (φ : ℝ → ℝ) + (j : Fin (gridCount lo hi η)), + Fintype.card ι+1 ≤ 2^k*Conclusion.bulkSize k L+2 → 0 < M → + Real.log (M:ℝ) ≤ Real.exp (r.μ*L) → lo ≤ hi → 0 < η → η ≤ 1 → + hi ≤ G+1 → Real.exp (r.a₀*L) ≤ G → + (∀ t ∈ Set.Icc lo hi, |φ (t-G)| ≤ B) → + jointMeshFactor r L (Fintype.card ι+1) M*smoothGrowthFactor k C σ L* + mixedGridError (ι:=ι) M lo hi η G B D φ (primeEnvelope r k C K d L) 2 j ≤ + Real.exp (-Real.exp (r.target*L)) := by + let I : ℝ := 6*B+2*D + let J : ℝ := Real.exp 1*B+I + let C' : ℝ := C+dimensionCoefficient k + have hI : 0 ≤ I := by dsimp [I]; positivity + have hJ : 0 ≤ J := by dsimp [J]; positivity + filter_upwards [eventually_weighted_integer_decay r k C' (2*I) hσ0 hσ (by norm_num : (0:ℝ)<1), + eventually_primeEnvelope_budget r k (D:=C') hC (show 0 ≤ 2*J by positivity) hK hd hσ0 hσ] + with L hInteger hPrime + intro ι _ M lo hi η G φ j hn hM hmod horder hη hη1 hwindow hG hφ + let n : ℕ := Fintype.card ι + let Q : ℝ := jointMeshFactor r L (n+1) M + let q : ℝ := Real.exp (-Real.exp (r.a₀*L)) + let ε : ℝ := primeEnvelope r k C K d L + have hQ : 0 ≤ Q := by dsimp [Q,jointMeshFactor]; positivity + have hε : 0 ≤ ε := by dsimp [ε,primeEnvelope]; positivity + have hn0 : n ≤ 2^k*Conclusion.bulkSize k L+2 := (Nat.le_succ n).trans hn + have hfactors := tensor_two_factors_le k n L σ hn0 + have hg0 : 0 ≤ smoothGrowthFactor k C σ L := Real.exp_nonneg _ + have hpow : smoothGrowthFactor k C σ L*2^n ≤ smoothGrowthFactor k C' σ L := by + simpa only [smoothGrowthFactor_mul,C'] using mul_le_mul_of_nonneg_left hfactors.1 hg0 + have hnpow : smoothGrowthFactor k C σ L*((n:ℝ)*2^n) ≤ smoothGrowthFactor k C' σ L := by + simpa only [smoothGrowthFactor_mul,C'] using mul_le_mul_of_nonneg_left hfactors.2 hg0 + have hsplit := mixedGridError_le_two_parts (ι:=ι) M hM φ j horder hη hη1 hB hD hwindow hG hφ hε + have hsplit' : Q*smoothGrowthFactor k C σ L* + mixedGridError (ι:=ι) M lo hi η G B D φ ε 2 j ≤ + Q*smoothGrowthFactor k C' σ L*I*q+Q*smoothGrowthFactor k C' σ L*J*ε := by + calc + _ ≤ Q*smoothGrowthFactor k C σ L*(I*q*2^n+J*((n:ℝ)*2^n)*ε) := + mul_le_mul_of_nonneg_left hsplit (mul_nonneg hQ hg0) + _ = Q*(smoothGrowthFactor k C σ L*2^n)*I*q+ + Q*(smoothGrowthFactor k C σ L*((n:ℝ)*2^n))*J*ε := by ring + _ ≤ _ := add_le_add + (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hpow hQ) hI) (Real.exp_nonneg _)) + (mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hnpow hQ) hJ) hε) + have hi' := hInteger (n+1) M hn hM hmod + have hp' := hPrime (n+1) M hn hM hmod + simp only [neg_one_mul] at hi' + change Q*smoothGrowthFactor k C' σ L*(2*I)*q ≤ _ at hi' + change Q*smoothGrowthFactor k C' σ L*(2*J)*ε ≤ _ at hp' + change Q*smoothGrowthFactor k C σ L*mixedGridError (ι:=ι) M lo hi η G B D φ ε 2 j ≤ _ + nlinarith only [hsplit',hi',hp'] + +end Ostmann.Arithmetic.PrimeCellActualErrorBudget + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellActualErrorBudgetMixedBasic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellActualErrorBudgetMixedBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..fd769f7ff4f169a4c3bd9efddb1b67e25798e7a8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellActualErrorBudgetMixedBasic.lean @@ -0,0 +1,118 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellActualErrorBudgetPrime + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellActualErrorBudget +open ScaleBudget PrimeCellMeshBudget LogCellPartition Filter + +theorem integerDensityMass_abs_le (M : ℕ) (hM : 0 < M) + {lo hi G B : ℝ} (φ : ℝ → ℝ) (horder : lo ≤ hi) (hwidth : hi-lo ≤ 1) + (hwindow : hi ≤ G+1) (hB : 0 ≤ B) + (hφ : ∀ t ∈ Set.Icc lo hi, |φ (t-G)| ≤ B) : + |IntegerCell.integerDensityMass M lo hi G φ| ≤ Real.exp 1*B := by + have hbound (t : ℝ) (ht : t ∈ Set.uIoc lo hi) : + ‖Real.exp (t-G)*φ (t-G)‖ ≤ Real.exp 1*B := by + rw [Set.uIoc_of_le horder] at ht + rw [Real.norm_eq_abs,abs_mul,Real.abs_exp] + exact mul_le_mul (Real.exp_le_exp.mpr (by linarith [ht.2])) + (hφ t ⟨ht.1.le,ht.2⟩) (abs_nonneg _) (Real.exp_nonneg _) + have hh := intervalIntegral.norm_integral_le_of_norm_le_const hbound + rw [Real.norm_eq_abs,abs_of_nonneg (sub_nonneg.mpr horder)] at hh + have hh' : |∫ t in lo..hi, Real.exp (t-G)*φ (t-G)| ≤ Real.exp 1*B := + hh.trans (by simpa using mul_le_mul_of_nonneg_left hwidth (mul_nonneg (Real.exp_nonneg _) hB)) + have hMp : (0:ℝ) hg n M lower Z hn hM hmod hlo hZ hZi, + fun hmod hlo => hb n M lower Z hn hM hmod hlo hZ hZi⟩ + +end Ostmann.Arithmetic.PrimeCellActualErrorBudget + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellAssignedReplacement.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellAssignedReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..0bcfa8a4dd3a154f23ad9be0a68c21a5f591f203 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellAssignedReplacement.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.AssignedPrimeCellReplacement +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellGridIdentities + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open scoped BigOperators +open PrimeProgression PrimeCellReplacement PrimeCellFreezing Characters.RationalHistory +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + +theorem assignedJointTestSum_tupleWeight (N : ι → ℕ) (lo hi η Z : ι → ℝ) + (j : GridBoxIndex lo hi η) (F : (ι → (ZMod M)ˣ) → ℂ) : + assignedJointComplexTestSum N M lo hi η Z j F = + ∑ p : AssignedPrimeTuple N lo hi η j, + (assignedTupleWeight N lo hi η Z j p:ℂ)*jointUnitTest F (fun i => ((p i).val:ZMod M)) := by + simp only [assignedJointComplexTestSum,assignedTupleWeight,Complex.ofReal_prod] + +theorem assignedAbsMass_cast (N : ι → ℕ) (lo hi η Z : ι → ℝ) + (j : GridBoxIndex lo hi η) (F : (ι → (ZMod M)ˣ) → ℂ) : + (assignedAbsMass N M lo hi η Z j F:ℂ) = + assignedJointComplexTestSum N M lo hi η Z j (fun u => (‖F u‖:ℂ)) := by + simp only [assignedAbsMass,assignedJointComplexTestSum,Complex.ofReal_sum, + Complex.ofReal_mul,assignedTupleWeight,Complex.ofReal_prod,jointAbsTest_cast] + +theorem assignedAbsMass_le_of_error (N : ι → ℕ) (lo hi η Z : ι → ℝ) + (j : GridBoxIndex lo hi η) (F : (ι → (ZMod M)ˣ) → ℂ) (main error : ℝ) + (he : ‖assignedJointComplexTestSum N M lo hi η Z j (fun u => (‖F u‖:ℂ))- + (main:ℂ)*∑ u : ι → (ZMod M)ˣ,(‖F u‖:ℂ)‖ ≤ error*∑ u : ι → (ZMod M)ˣ,‖F u‖) : + assignedAbsMass N M lo hi η Z j F ≤ (main+error)*∑ u : ι → (ZMod M)ˣ,‖F u‖ := by + rw [← assignedAbsMass_cast,← Complex.ofReal_sum,← Complex.ofReal_mul,← Complex.ofReal_sub, + Complex.norm_real,Real.norm_eq_abs] at he + have hh := (le_abs_self _).trans he + linarith + +theorem assigned_smooth_replacement_of_errors (N : ι → ℕ) (lo hi η Z : ι → ℝ) + (hZ : ∀ i, 0 < Z i) (hlo : ∀ i, 0 < lo i) (horder : ∀ i, lo i ≤ hi i) + (j : GridBoxIndex lo hi η) (F : (ι → (ZMod M)ˣ) → ℂ) (f : (ι → ℝ) → ℂ) + {D mesh error : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hwidth : ∀ i, boxUpper lo hi η j i-boxLower lo hi η j i ≤ mesh) + (hf : ∀ z∈logRectangle (boxLower lo hi η j) (boxUpper lo hi η j), + DifferentiableAt ℝ (fun y => f (fun q => Real.exp (y q))) z) + (hd : ∀ z∈logRectangle (boxLower lo hi η j) (boxUpper lo hi η j),∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun q => Real.exp (z q)) i t)) 0‖ ≤ D) + {base : ι → ℝ} (hbase : base∈logRectangle (boxLower lo hi η j) (boxUpper lo hi η j)) + (he : ‖assignedJointComplexTestSum N M lo hi η Z j F- + (principalMass M (boxLower lo hi η j) (boxUpper lo hi η j) Z:ℂ)* + ∑ u : ι → (ZMod M)ˣ,F u‖ ≤ error*∑ u : ι → (ZMod M)ˣ,‖F u‖) + (heAbs : ‖assignedJointComplexTestSum N M lo hi η Z j (fun u => (‖F u‖:ℂ))- + (principalMass M (boxLower lo hi η j) (boxUpper lo hi η j) Z:ℂ)* + ∑ u : ι → (ZMod M)ˣ,(‖F u‖:ℂ)‖ ≤ error*∑ u : ι → (ZMod M)ˣ,‖F u‖) : + ‖smoothAssignedJointTestSum N M lo hi η Z j F f- + principalIntegral M (boxLower lo hi η j) (boxUpper lo hi η j) Z f* + ∑ u : ι → (ZMod M)ˣ,F u‖ ≤ + ((Fintype.card ι:ℝ)*D*mesh* + (2*principalMass M (boxLower lo hi η j) (boxUpper lo hi η j) Z+error)+ + ‖f (fun q => Real.exp (base q))‖*error)*∑ u : ι → (ZMod M)ˣ,‖F u‖ := by + classical + let v : ℝ := (Fintype.card ι:ℝ)*D*mesh + let f₀ := f (fun q => Real.exp (base q)) + let S := ∑ u : ι → (ZMod M)ˣ,F u + let T := ∑ u : ι → (ZMod M)ˣ,‖F u‖ + let mass := principalMass M (boxLower lo hi η j) (boxUpper lo hi η j) Z + let integral := principalIntegral M (boxLower lo hi η j) (boxUpper lo hi η j) Z f + let actual := assignedJointComplexTestSum N M lo hi η Z j F + have hv : 0 ≤ v := by dsimp [v]; positivity + have hmass := assignedAbsMass_le_of_error N lo hi η Z j F mass error heAbs + have hdisc := smooth_assigned_freezing_bound N lo hi η Z (fun i => (hZ i).le) j F f + hD hm hwidth hf hd hbase + rw [← assignedJointTestSum_tupleWeight] at hdisc + have hdisc' : ‖smoothAssignedJointTestSum N M lo hi η Z j F f-f₀*actual‖ ≤ + v*((mass+error)*T) := hdisc.trans (mul_le_mul_of_nonneg_left hmass hv) + have hap : ‖f₀*actual-f₀*((mass:ℂ)*S)‖ ≤ ‖f₀‖*(error*T) := by + rw [← mul_sub,norm_mul] + exact mul_le_mul_of_nonneg_left he (norm_nonneg _) + have hint := residue_integral_freezing_bound M Z (boxLower lo hi η j) (boxUpper lo hi η j) + hZ (fun i => (hlo i).trans_le (boxLower_ge lo hi η horder j i)) + (box_order lo hi η horder j) f hD hm hwidth hf hd hbase + have hint' : ‖(mass:ℂ)*f₀-integral‖ ≤ v*mass := by + rw [norm_sub_rev] + simpa only [integral,mass,principalIntegral,principalMass,Complex.real_smul] using hint + have hmain : ‖f₀*((mass:ℂ)*S)-integral*S‖ ≤ (v*mass)*T := by + have heq : f₀*((mass:ℂ)*S)-integral*S = ((mass:ℂ)*f₀-integral)*S := by ring + rw [heq,norm_mul] + exact mul_le_mul hint' (norm_sum_le _ _) (norm_nonneg _) ((norm_nonneg _).trans hint') + calc + _ ≤ ‖smoothAssignedJointTestSum N M lo hi η Z j F f-f₀*actual‖+ + ‖f₀*actual-f₀*((mass:ℂ)*S)‖+‖f₀*((mass:ℂ)*S)-integral*S‖ := by + have h₁ := norm_sub_le_norm_sub_add_norm_sub + (smoothAssignedJointTestSum N M lo hi η Z j F f) (f₀*actual) (integral*S) + have h₂ := norm_sub_le_norm_sub_add_norm_sub (f₀*actual) (f₀*((mass:ℂ)*S)) (integral*S) + simpa only [add_assoc] using h₁.trans (add_le_add le_rfl h₂) + _ ≤ v*((mass+error)*T)+‖f₀‖*(error*T)+(v*mass)*T := + add_le_add (add_le_add hdisc' hap) hmain + _ = _ := by dsimp only [v,f₀,T,mass]; ring + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellAssignedSmooth.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellAssignedSmooth.lean new file mode 100644 index 0000000000000000000000000000000000000000..af676f1378a4685ade1474eb76ad42dc18c8c66a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellAssignedSmooth.lean @@ -0,0 +1,103 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.LogCellPartitionTuples +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellSmoothReplacement + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open scoped BigOperators +open PrimeProgression PrimeCellReplacement PrimeCellFreezing Characters.RationalHistory +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + +def assignedTupleWeight (N : ι → ℕ) (lo hi η Z : ι → ℝ) + (j : GridBoxIndex lo hi η) (p : AssignedPrimeTuple N lo hi η j) : ℝ := + ∏ i, (Z i*((p i).val:ℝ))⁻¹ + +def assignedTupleLog (N : ι → ℕ) (lo hi η : ι → ℝ) + (j : GridBoxIndex lo hi η) (p : AssignedPrimeTuple N lo hi η j) : ι → ℝ := + fun i => Real.log ((p i).val:ℝ) + +omit [Fintype ι] [DecidableEq ι] in +theorem assignedTupleLog_mem [Fintype ι] [DecidableEq ι] (N : ι → ℕ) (lo hi η : ι → ℝ) + (j : GridBoxIndex lo hi η) (p : AssignedPrimeTuple N lo hi η j) : + assignedTupleLog N lo hi η j p ∈ logRectangle (boxLower lo hi η j) (boxUpper lo hi η j) := by + intro i _ + exact (mem_logPrimeSupport _ _ _ _).mp (Finset.mem_filter.mp (p i).property).1 |>.2.2 + +omit [Fintype ι] [DecidableEq ι] in +theorem exp_assignedTupleLog [Fintype ι] [DecidableEq ι] (N : ι → ℕ) (lo hi η : ι → ℝ) + (j : GridBoxIndex lo hi η) (p : AssignedPrimeTuple N lo hi η j) : + (fun i => Real.exp (assignedTupleLog N lo hi η j p i)) = fun i => ((p i).val:ℝ) := by + funext i + apply Real.exp_log + exact_mod_cast ((mem_logPrimeSupport _ _ _ _).mp (Finset.mem_filter.mp (p i).property).1).2.1.pos + +def assignedAbsMass (N : ι → ℕ) (M : ℕ) [NeZero M] (lo hi η Z : ι → ℝ) + (j : GridBoxIndex lo hi η) (F : (ι → (ZMod M)ˣ) → ℂ) : ℝ := + ∑ p : AssignedPrimeTuple N lo hi η j, assignedTupleWeight N lo hi η Z j p* + jointAbsTest F (fun i => ((p i).val:ZMod M)) + +def smoothAssignedJointTestSum (N : ι → ℕ) (M : ℕ) [NeZero M] (lo hi η Z : ι → ℝ) + (j : GridBoxIndex lo hi η) (F : (ι → (ZMod M)ˣ) → ℂ) (f : (ι → ℝ) → ℂ) : ℂ := + ∑ p : AssignedPrimeTuple N lo hi η j, (assignedTupleWeight N lo hi η Z j p:ℂ)* + jointUnitTest F (fun i => ((p i).val:ZMod M))*f (fun i => ((p i).val:ℝ)) + +omit [DecidableEq ι] in +theorem assignedTupleWeight_nonneg [DecidableEq ι] (N : ι → ℕ) (lo hi η Z : ι → ℝ) + (hZ : ∀ i, 0 ≤ Z i) (j : GridBoxIndex lo hi η) (p : AssignedPrimeTuple N lo hi η j) : + 0 ≤ assignedTupleWeight N lo hi η Z j p := + Finset.prod_nonneg fun i _ => inv_nonneg.mpr (mul_nonneg (hZ i) (Nat.cast_nonneg _)) + +theorem assigned_coefficient_norm_mass_le (N : ι → ℕ) (lo hi η Z : ι → ℝ) + (hZ : ∀ i, 0 ≤ Z i) (j : GridBoxIndex lo hi η) (F : (ι → (ZMod M)ˣ) → ℂ) : + (∑ p : AssignedPrimeTuple N lo hi η j, + ‖(assignedTupleWeight N lo hi η Z j p:ℂ)*jointUnitTest F (fun i => ((p i).val:ZMod M))‖) ≤ + assignedAbsMass N M lo hi η Z j F := by + apply Finset.sum_le_sum + intro p _ + rw [norm_mul,Complex.norm_real,Real.norm_eq_abs, + abs_of_nonneg (assignedTupleWeight_nonneg N lo hi η Z hZ j p)] + exact mul_le_mul_of_nonneg_left (jointUnitTest_norm_le F _) + (assignedTupleWeight_nonneg N lo hi η Z hZ j p) + +theorem smooth_assigned_freezing_bound (N : ι → ℕ) (lo hi η Z : ι → ℝ) + (hZ : ∀ i, 0 ≤ Z i) (j : GridBoxIndex lo hi η) + (F : (ι → (ZMod M)ˣ) → ℂ) (f : (ι → ℝ) → ℂ) + {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hwidth : ∀ i, boxUpper lo hi η j i-boxLower lo hi η j i ≤ mesh) + (hf : ∀ z∈logRectangle (boxLower lo hi η j) (boxUpper lo hi η j), + DifferentiableAt ℝ (fun y => f (fun q => Real.exp (y q))) z) + (hd : ∀ z∈logRectangle (boxLower lo hi η j) (boxUpper lo hi η j),∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun q => Real.exp (z q)) i t)) 0‖ ≤ D) + {base : ι → ℝ} (hbase : base∈logRectangle (boxLower lo hi η j) (boxUpper lo hi η j)) : + ‖smoothAssignedJointTestSum N M lo hi η Z j F f- + f (fun q => Real.exp (base q)) * + ∑ p : AssignedPrimeTuple N lo hi η j, + (assignedTupleWeight N lo hi η Z j p:ℂ)*jointUnitTest F (fun i => ((p i).val:ZMod M))‖ ≤ + (Fintype.card ι:ℝ)*D*mesh*assignedAbsMass N M lo hi η Z j F := by + classical + let c : AssignedPrimeTuple N lo hi η j → ℂ := fun p => + (assignedTupleWeight N lo hi η Z j p:ℂ)*jointUnitTest F (fun i => ((p i).val:ZMod M)) + have he := positive_weighted_freezing_bound Finset.univ c f + (boxLower lo hi η j) (boxUpper lo hi η j) (assignedTupleLog N lo hi η j) + (fun _ => base) hD hm hf hd (fun p _ => assignedTupleLog_mem N lo hi η j p) + (fun _ _ => hbase) + (fun p _ => logRectangle_coordinate_dist_le _ _ hwidth (assignedTupleLog_mem N lo hi η j p) hbase) + simp_rw [exp_assignedTupleLog] at he + have hconst : (∑ p : AssignedPrimeTuple N lo hi η j,c p*f (fun q => Real.exp (base q))) = + f (fun q => Real.exp (base q)) * ∑ p : AssignedPrimeTuple N lo hi η j,c p := by + rw [← Finset.sum_mul] + exact mul_comm _ _ + rw [hconst] at he + exact he.trans (mul_le_mul_of_nonneg_left (assigned_coefficient_norm_mass_le N lo hi η Z hZ j F) + (by positivity)) + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellFreezing.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellFreezing.lean new file mode 100644 index 0000000000000000000000000000000000000000..30ce429e441d60cc8ceac1b48151070627dc44d7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellFreezing.lean @@ -0,0 +1,73 @@ +import Mathlib + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellFreezing +open scoped BigOperators +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem opNorm_le_card_mul (L : (ι → ℝ) →L[ℝ] ℂ) {D : ℝ} (hD : 0 ≤ D) + (hL : ∀ i, ‖L (Pi.single i 1)‖ ≤ D) : ‖L‖ ≤ (Fintype.card ι:ℝ)*D := by + apply L.opNorm_le_bound (by positivity) + intro x + have hx : x=∑ i, (x i) • Pi.single i (1:ℝ) := by + funext j + simp [Finset.sum_apply,Pi.single_apply] + conv_lhs => arg 1; rw [hx] + rw [map_sum] + calc + _ ≤ ∑ i, ‖L ((x i) • Pi.single i (1:ℝ))‖ := norm_sum_le _ _ + _ ≤ ∑ _i : ι, ‖x‖*D := by + apply Finset.sum_le_sum + intro i _ + rw [map_smul,norm_smul] + exact mul_le_mul (norm_le_pi_norm x i) (hL i) (norm_nonneg _) (norm_nonneg _) + _ = _ := by simp; ring + +def logRectangle (lo hi : ι → ℝ) : Set (ι → ℝ) := + Set.pi Set.univ (fun i => Set.Icc (lo i) (hi i)) + +omit [Fintype ι] [DecidableEq ι] in +theorem logRectangle_convex (lo hi : ι → ℝ) : Convex ℝ (logRectangle lo hi) := + convex_pi (fun _ _ => convex_Icc _ _) + +theorem norm_sub_le_of_partials (f : (ι → ℝ) → ℂ) (lo hi : ι → ℝ) + {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hf : ∀ z ∈ logRectangle lo hi, DifferentiableAt ℝ f z) + (hderiv : ∀ z ∈ logRectangle lo hi, ∀ i, ‖fderiv ℝ f z (Pi.single i 1)‖ ≤ D) + {x y : ι → ℝ} (hx : x ∈ logRectangle lo hi) (hy : y ∈ logRectangle lo hi) + (hxy : ∀ i, |x i-y i| ≤ mesh) : + ‖f x-f y‖ ≤ (Fintype.card ι:ℝ)*D*mesh := by + have hh := (logRectangle_convex lo hi).norm_image_sub_le_of_norm_fderiv_le hf + (fun z hz => opNorm_le_card_mul _ hD (hderiv z hz)) hy hx + have hn : ‖x-y‖ ≤ mesh := (pi_norm_le_iff_of_nonneg hm).mpr (fun i => by + simpa only [Pi.sub_apply,Real.norm_eq_abs] using hxy i) + exact hh.trans (mul_le_mul_of_nonneg_left hn (by positivity)) + +theorem weighted_freezing_bound {A : Type*} (s : Finset A) (c : A → ℂ) + (f : (ι → ℝ) → ℂ) (lo hi : ι → ℝ) (x y : A → ι → ℝ) + {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hf : ∀ z ∈ logRectangle lo hi, DifferentiableAt ℝ f z) + (hderiv : ∀ z ∈ logRectangle lo hi, ∀ i, ‖fderiv ℝ f z (Pi.single i 1)‖ ≤ D) + (hx : ∀ a ∈ s, x a ∈ logRectangle lo hi) (hy : ∀ a ∈ s, y a ∈ logRectangle lo hi) + (hxy : ∀ a ∈ s, ∀ i, |x a i-y a i| ≤ mesh) : + ‖(∑ a ∈ s,c a*f (x a))-(∑ a ∈ s,c a*f (y a))‖ ≤ + (Fintype.card ι:ℝ)*D*mesh*∑ a ∈ s,‖c a‖ := by + rw [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ a ∈ s, ‖c a*f (x a)-c a*f (y a)‖ := norm_sum_le _ _ + _ ≤ ∑ a ∈ s, ‖c a‖*((Fintype.card ι:ℝ)*D*mesh) := by + apply Finset.sum_le_sum + intro a ha + rw [← mul_sub,norm_mul] + exact mul_le_mul_of_nonneg_left + (norm_sub_le_of_partials f lo hi hD hm hf hderiv (hx a ha) (hy a ha) (hxy a ha)) + (norm_nonneg _) + _ = _ := by rw [← Finset.sum_mul]; ring + +end Ostmann.Arithmetic.PrimeCellFreezing + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellFreezingLog.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellFreezingLog.lean new file mode 100644 index 0000000000000000000000000000000000000000..517c83c3de45c4f9f3832eb8b8ff281b663ff86d --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellFreezingLog.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.HistorySmoothWeightExprDeriv +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellFreezing + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellFreezing +open Characters.RationalHistory +open scoped BigOperators +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +theorem coordinate_deriv_eq (F : (ι → ℝ) → ℂ) (y : ι → ℝ) (i : ι) + (hF : DifferentiableAt ℝ F y) : + deriv (fun t : ℝ => F (y+t • (Pi.single i (1:ℝ) : ι → ℝ))) 0 = + fderiv ℝ F y ((Pi.single i (1:ℝ) : ι → ℝ)) := by + have hcurve := ((hasDerivAt_id (0:ℝ)).smul_const + (Pi.single i (1:ℝ) : ι → ℝ)).const_add y + simp only [one_smul] at hcurve + have hh : HasFDerivAt F (fderiv ℝ F y) (y+(0:ℝ) • (Pi.single i (1:ℝ) : ι → ℝ)) := by + simpa using hF.hasFDerivAt + simpa only [Function.comp_def, id_eq] using (hh.comp_hasDerivAt 0 hcurve).deriv + +omit [Fintype ι] in +theorem logCurve_eq_exp_coordinate (y : ι → ℝ) (i : ι) (t : ℝ) : + Expr.logCurve (fun j => Real.exp (y j)) i t = + (fun j => Real.exp ((y+t • (Pi.single i (1:ℝ) : ι → ℝ)) j)) := by + funext j + simp only [Expr.logCurve,Pi.add_apply,Pi.smul_apply,smul_eq_mul,Pi.single_apply] + by_cases hj : j=i + · subst j + simp [Real.exp_add] + · simp [hj] + +theorem logCurve_deriv_eq_fderiv (f : (ι → ℝ) → ℂ) (y : ι → ℝ) (i : ι) + (hf : DifferentiableAt ℝ (fun z => f (fun j => Real.exp (z j))) y) : + deriv (fun t : ℝ => f (Expr.logCurve (fun j => Real.exp (y j)) i t)) 0 = + fderiv ℝ (fun z => f (fun j => Real.exp (z j))) y ((Pi.single i (1:ℝ) : ι → ℝ)) := by + simp_rw [logCurve_eq_exp_coordinate] + exact coordinate_deriv_eq _ y i hf + +theorem positive_norm_sub_le (f : (ι → ℝ) → ℂ) (lo hi : ι → ℝ) + {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hf : ∀ z ∈ logRectangle lo hi, + DifferentiableAt ℝ (fun y => f (fun j => Real.exp (y j))) z) + (hd : ∀ z ∈ logRectangle lo hi, ∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun j => Real.exp (z j)) i t)) 0‖ ≤ D) + {x y : ι → ℝ} (hx : x ∈ logRectangle lo hi) (hy : y ∈ logRectangle lo hi) + (hxy : ∀ i,|x i-y i| ≤ mesh) : + ‖f (fun j => Real.exp (x j))-f (fun j => Real.exp (y j))‖ ≤ + (Fintype.card ι:ℝ)*D*mesh := by + apply norm_sub_le_of_partials _ lo hi hD hm hf _ hx hy hxy + intro z hz i + rw [← logCurve_deriv_eq_fderiv f z i (hf z hz)] + exact hd z hz i + +theorem positive_weighted_freezing_bound {A : Type*} (s : Finset A) (c : A → ℂ) + (f : (ι → ℝ) → ℂ) (lo hi : ι → ℝ) (x y : A → ι → ℝ) + {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hf : ∀ z ∈ logRectangle lo hi, + DifferentiableAt ℝ (fun y => f (fun j => Real.exp (y j))) z) + (hd : ∀ z ∈ logRectangle lo hi, ∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun j => Real.exp (z j)) i t)) 0‖ ≤ D) + (hx : ∀ a ∈ s,x a ∈ logRectangle lo hi) (hy : ∀ a ∈ s,y a ∈ logRectangle lo hi) + (hxy : ∀ a ∈ s,∀ i,|x a i-y a i| ≤ mesh) : + ‖(∑ a ∈ s,c a*f (fun j => Real.exp (x a j)))- + (∑ a ∈ s,c a*f (fun j => Real.exp (y a j)))‖ ≤ + (Fintype.card ι:ℝ)*D*mesh*∑ a ∈ s,‖c a‖ := by + apply weighted_freezing_bound s c _ lo hi x y hD hm hf _ hx hy hxy + intro z hz i + rw [← logCurve_deriv_eq_fderiv f z i (hf z hz)] + exact hd z hz i + +end Ostmann.Arithmetic.PrimeCellFreezing + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellGridIdentities.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellGridIdentities.lean new file mode 100644 index 0000000000000000000000000000000000000000..66e57e23ad1e0cf7ef15030064bab8a72d988d3e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellGridIdentities.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellAssignedSmooth + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open scoped BigOperators +open MeasureTheory PrimeProgression PrimeCellReplacement PrimeCellFreezing +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + +omit [Fintype ι] [DecidableEq ι] in +theorem box_order [Fintype ι] [DecidableEq ι] (lo hi η : ι → ℝ) (h : ∀ i, lo i ≤ hi i) + (j : GridBoxIndex lo hi η) : ∀ i, boxLower lo hi η j i ≤ boxUpper lo hi η j i := + fun i => gridPoint_mono (h i) (Nat.le_succ _) + +omit [Fintype ι] [DecidableEq ι] in +theorem boxLower_ge [Fintype ι] [DecidableEq ι] (lo hi η : ι → ℝ) (h : ∀ i, lo i ≤ hi i) + (j : GridBoxIndex lo hi η) : ∀ i, lo i ≤ boxLower lo hi η j i := + fun i => (gridPoint_mem (h i) (j i).isLt.le).1 + +omit [Fintype ι] [DecidableEq ι] in +theorem boxUpper_le [Fintype ι] [DecidableEq ι] (lo hi η : ι → ℝ) (h : ∀ i, lo i ≤ hi i) + (j : GridBoxIndex lo hi η) : ∀ i, boxUpper lo hi η j i ≤ hi i := + fun i => (gridPoint_mem (h i) (show (j i).val+1 ≤ gridCount (lo i) (hi i) (η i) by omega)).2 + +theorem closedBox_subset (lo hi η : ι → ℝ) (h : ∀ i, lo i ≤ hi i) + (j : GridBoxIndex lo hi η) : + logRectangle (boxLower lo hi η j) (boxUpper lo hi η j) ⊆ logRectangle lo hi := by + intro z hz i hi' + exact ⟨(boxLower_ge lo hi η h j i).trans (hz i hi').1, + (hz i hi').2.trans (boxUpper_le lo hi η h j i)⟩ + +omit [Fintype ι] [DecidableEq ι] in +theorem box_width_le [Fintype ι] [DecidableEq ι] (lo hi η : ι → ℝ) + (h : ∀ i, lo i ≤ hi i) (hη : ∀ i, 0 < η i) + (j : GridBoxIndex lo hi η) : + ∀ i, boxUpper lo hi η j i-boxLower lo hi η j i ≤ η i := by + intro i + exact (gridPoint_width _ _ _ _).trans_le (gridStep_le (h i) (hη i)) + +theorem smoothJointTestSum_eq_sum_assigned (N : ι → ℕ) (lo hi η Z : ι → ℝ) + (h : ∀ i, lo i ≤ hi i) (F : (ι → (ZMod M)ˣ) → ℂ) (f : (ι → ℝ) → ℂ) : + smoothJointTestSum N M lo hi Z F f = + ∑ j : GridBoxIndex lo hi η, smoothAssignedJointTestSum N M lo hi η Z j F f := by + simpa only [smoothJointTestSum,smoothAssignedJointTestSum,tupleWeight, + assignedTupleWeight,Complex.ofReal_prod,mul_assoc] using + sum_product_prime_prior_eq_sum_assigned N lo hi η Z h + (fun p => jointUnitTest F (fun i => (p i:ZMod M))*f (fun i => (p i:ℝ))) + +theorem principalMass_eq_sum_boxes (M : ℕ) (lo hi η Z : ι → ℝ) + (h : ∀ i, lo i ≤ hi i) (hlo : ∀ i, 0 < lo i) : + principalMass M lo hi Z = ∑ j : GridBoxIndex lo hi η, + principalMass M (boxLower lo hi η j) (boxUpper lo hi η j) Z := by + unfold principalMass + rw [← residue_logCellMass_eq_prod M Z lo hi h] + rw [logCellMass_eq_sum_boxes _ lo hi η h hlo] + apply Finset.sum_congr rfl + intro j _ + exact residue_logCellMass_eq_prod M Z _ _ (box_order lo hi η h j) + +theorem principalIntegral_eq_sum_boxes (M : ℕ) (lo hi η Z : ι → ℝ) + (h : ∀ i, lo i ≤ hi i) (hlo : ∀ i, 0 < lo i) (f : (ι → ℝ) → ℂ) + (hf : ContinuousOn (fun t => f (fun i => Real.exp (t i))) (logRectangle lo hi)) : + principalIntegral M lo hi Z f = ∑ j : GridBoxIndex lo hi η, + principalIntegral M (boxLower lo hi η j) (boxUpper lo hi η j) Z f := by + apply integral_rectangle_eq_sum_boxes lo hi η h + exact ((continuousOn_logCellDensity _ lo hi hlo).smul hf).integrableOn_compact + (isCompact_logRectangle lo hi) + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellGridReplacement.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellGridReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..57082c083364806c7c27dbd406950a45ad88a5af --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellGridReplacement.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellAssignedReplacement + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.LogCellPartition +open scoped BigOperators +open PrimeProgression PrimeCellReplacement PrimeCellFreezing Characters.RationalHistory + +theorem exists_grid_smooth_replacement_constants : + ∃ d K L₀ : ℝ, 0 < d ∧ 0 < K ∧ 1 ≤ L₀ ∧ + ∀ (ι : Type*) [Fintype ι] [DecidableEq ι] (N : ι → ℕ) (M : ℕ) [NeZero M] + (lo hi η Z : ι → ℝ), + (∀ i, L₀ ≤ lo i ∧ lo i ≤ hi i ∧ 0 < η i ∧ η i ≤ 1 ∧ + ⌊Real.exp (hi i)⌋₊ ≤ N i ∧ 0 < Z i ∧ + (M:ℝ) ≤ Real.exp (d*(lo i)^(1/3:ℝ))) → + ∀ ε B : ℝ, 0 ≤ ε → 1 ≤ B → + (∀ (j : GridBoxIndex lo hi η) i, + (K/Z i)*Real.exp (-d*(boxLower lo hi η j i)^(1/3:ℝ))+ + (Z i*Real.exp (boxLower lo hi η j i))⁻¹ ≤ ε) → + (∀ (j : GridBoxIndex lo hi η) i, + |harmonicIntegral M (boxLower lo hi η j i) (boxUpper lo hi η j i)/Z i|+ + ((K/Z i)*Real.exp (-d*(boxLower lo hi η j i)^(1/3:ℝ))+ + (Z i*Real.exp (boxLower lo hi η j i))⁻¹) ≤ B) → + ∀ (F : (ι → (ZMod M)ˣ) → ℂ) (f : (ι → ℝ) → ℂ) (D mesh A : ℝ), + 0 ≤ D → 0 ≤ mesh → (∀ i, η i ≤ mesh) → + (∀ z∈logRectangle lo hi,DifferentiableAt ℝ (fun y => f (fun i => Real.exp (y i))) z) → + (∀ z∈logRectangle lo hi,∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun q => Real.exp (z q)) i t)) 0‖ ≤ D) → + (∀ z∈logRectangle lo hi, ‖f (fun i => Real.exp (z i))‖ ≤ A) → + ‖smoothJointTestSum N M lo hi Z F f-principalIntegral M lo hi Z f* + ∑ u : ι → (ZMod M)ˣ,F u‖ ≤ + (2*((Fintype.card ι:ℝ)*D*mesh)*principalMass M lo hi Z+ + ((Fintype.card ι:ℝ)*D*mesh+A)* + (Fintype.card (GridBoxIndex lo hi η)*(Fintype.card ι*ε*B^Fintype.card ι)))* + ∑ u : ι → (ZMod M)ˣ,‖F u‖ := by + obtain ⟨d,K,L₀,hd,hK,hL₀,hAP⟩ := exists_assigned_joint_primeCell_replacement_constants + refine ⟨d,K,L₀,hd,hK,hL₀,?_⟩ + intro ι _ _ N M _ lo hi η Z hcell ε B hε hB hE hbound F f D mesh A hD hm hmesh hf hderiv hA + classical + have horder : ∀ i, lo i ≤ hi i := fun i => (hcell i).2.1 + have hlo : ∀ i, 0 < lo i := fun i => lt_of_lt_of_le (by linarith) (hcell i).1 + have hη : ∀ i, 0 < η i := fun i => (hcell i).2.2.1 + have hZ : ∀ i, 0 < Z i := fun i => (hcell i).2.2.2.2.2.1 + let v : ℝ := (Fintype.card ι:ℝ)*D*mesh + let E : ℝ := Fintype.card ι*ε*B^Fintype.card ι + let T : ℝ := ∑ u : ι → (ZMod M)ˣ,‖F u‖ + let mass : GridBoxIndex lo hi η → ℝ := + fun j => principalMass M (boxLower lo hi η j) (boxUpper lo hi η j) Z + have hE0 : 0 ≤ E := by dsimp [E]; positivity + have hT0 : 0 ≤ T := Finset.sum_nonneg fun _ _ => norm_nonneg _ + have hlocal (j : GridBoxIndex lo hi η) : + ‖smoothAssignedJointTestSum N M lo hi η Z j F f- + principalIntegral M (boxLower lo hi η j) (boxUpper lo hi η j) Z f* + ∑ u : ι → (ZMod M)ˣ,F u‖ ≤ (v*(2*mass j+E)+A*E)*T := by + have hbase : boxLower lo hi η j∈logRectangle (boxLower lo hi η j) (boxUpper lo hi η j) := + fun i _ => ⟨le_rfl,box_order lo hi η horder j i⟩ + have hb := assigned_smooth_replacement_of_errors (error := E) N lo hi η Z hZ hlo horder j F f hD hm + (fun i => (box_width_le lo hi η horder hη j i).trans (hmesh i)) + (fun z hz => hf z (closedBox_subset lo hi η horder j hz)) + (fun z hz => hderiv z (closedBox_subset lo hi η horder j hz)) hbase + have he := hAP ι N M lo hi η Z hcell j ε B hε hB (hE j) (hbound j) F + have heAbs := hAP ι N M lo hi η Z hcell j ε B hε hB (hE j) (hbound j) + (fun u => (‖F u‖:ℂ)) + have he' : ‖assignedJointComplexTestSum N M lo hi η Z j F- + (mass j:ℂ)*∑ u : ι → (ZMod M)ˣ,F u‖ ≤ E*T := by + simpa only [mass,principalMass,boxLower,boxUpper,Complex.ofReal_prod,E,T] using he + have heAbs' : ‖assignedJointComplexTestSum N M lo hi η Z j (fun u => (‖F u‖:ℂ))- + (mass j:ℂ)*∑ u : ι → (ZMod M)ˣ,(‖F u‖:ℂ)‖ ≤ E*T := by + simpa only [mass,principalMass,boxLower,boxUpper,Complex.ofReal_prod,E,T, + Complex.norm_real,Real.norm_eq_abs,abs_norm] using heAbs + exact (hb he' heAbs').trans (mul_le_mul_of_nonneg_right + (add_le_add le_rfl (mul_le_mul_of_nonneg_right + (hA _ (closedBox_subset lo hi η horder j hbase)) hE0)) hT0) + have hsum : (∑ j : GridBoxIndex lo hi η,(v*(2*mass j+E)+A*E)) = + 2*v*principalMass M lo hi Z+(v+A)*(Fintype.card (GridBoxIndex lo hi η)*E) := by + simp_rw [mul_add] + rw [Finset.sum_add_distrib,Finset.sum_add_distrib] + simp only [← mul_assoc,← Finset.mul_sum,Finset.sum_const,Finset.card_univ,nsmul_eq_mul] + rw [show (∑ j : GridBoxIndex lo hi η,mass j)=principalMass M lo hi Z from + (principalMass_eq_sum_boxes M lo hi η Z horder hlo).symm] + ring + rw [smoothJointTestSum_eq_sum_assigned N lo hi η Z horder F f, + principalIntegral_eq_sum_boxes M lo hi η Z horder hlo f + (fun z hz => (hf z hz).continuousAt.continuousWithinAt),Finset.sum_mul, + ← Finset.sum_sub_distrib] + calc + _ ≤ ∑ j : GridBoxIndex lo hi η, + ‖smoothAssignedJointTestSum N M lo hi η Z j F f- + principalIntegral M (boxLower lo hi η j) (boxUpper lo hi η j) Z f* + ∑ u : ι → (ZMod M)ˣ,F u‖ := norm_sum_le _ _ + _ ≤ ∑ j : GridBoxIndex lo hi η,(v*(2*mass j+E)+A*E)*T := + Finset.sum_le_sum fun j _ => hlocal j + _ = _ := by rw [← Finset.sum_mul,hsum] + +end Ostmann.Arithmetic.LogCellPartition + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellIntegralFreezing.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellIntegralFreezing.lean new file mode 100644 index 0000000000000000000000000000000000000000..39606613a5b940656f95db532782b93161cbc1d8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellIntegralFreezing.lean @@ -0,0 +1,101 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellIntegralFreezingMass + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellFreezing +open MeasureTheory Characters.RationalHistory +open scoped BigOperators +variable {ι : Type*} [Fintype ι] [DecidableEq ι] + +def logCellIntegral (w lo hi : ι → ℝ) (f : (ι → ℝ) → ℂ) : ℂ := + ∫ t in logRectangle lo hi, logCellDensity w t • f (fun j => Real.exp (t j)) + +omit [DecidableEq ι] in +theorem logCell_freezing_of_variation (w lo hi : ι → ℝ) + (hw : ∀ i, 0 ≤ w i) (hlo : ∀ i, 0 < lo i) + (F : (ι → ℝ) → ℂ) (hF : ContinuousOn F (logRectangle lo hi)) + (base : ι → ℝ) {C : ℝ} + (hvar : ∀ t ∈ logRectangle lo hi, ‖F t - F base‖ ≤ C) : + ‖(∫ t in logRectangle lo hi, logCellDensity w t • F t) - + logCellMass w lo hi • F base‖ ≤ C * logCellMass w lo hi := by + have hcompact := isCompact_logRectangle lo hi + have hwc := continuousOn_logCellDensity w lo hi hlo + have hwi := integrableOn_logCellDensity w lo hi hlo + have hFi : IntegrableOn (fun t => logCellDensity w t • F t) (logRectangle lo hi) := + (hwc.smul hF).integrableOn_compact hcompact + have hbi : IntegrableOn (fun t => logCellDensity w t • F base) (logRectangle lo hi) := + (hwc.smul continuousOn_const).integrableOn_compact hcompact + have heq : (∫ t in logRectangle lo hi, logCellDensity w t • F t) - + logCellMass w lo hi • F base = + ∫ t in logRectangle lo hi, logCellDensity w t • (F t - F base) := by + unfold logCellMass + rw [← integral_smul_const, ← integral_sub hFi hbi] + congr 1 + funext t + exact (smul_sub _ _ _).symm + rw [heq] + calc + _ ≤ ∫ t in logRectangle lo hi, logCellDensity w t * C := by + apply norm_integral_le_of_norm_le (hwi.mul_const C) + filter_upwards [ae_restrict_mem hcompact.measurableSet] with t ht + rw [norm_smul, Real.norm_eq_abs, + abs_of_nonneg (logCellDensity_nonneg w lo hi hw hlo ht)] + exact mul_le_mul_of_nonneg_left (hvar t ht) + (logCellDensity_nonneg w lo hi hw hlo ht) + _ = C * logCellMass w lo hi := by rw [integral_mul_const]; exact mul_comm _ _ + +omit [Fintype ι] [DecidableEq ι] in +theorem logRectangle_coordinate_dist_le (lo hi : ι → ℝ) {mesh : ℝ} + (hwidth : ∀ i, hi i - lo i ≤ mesh) + {x y : ι → ℝ} (hx : x ∈ logRectangle lo hi) (hy : y ∈ logRectangle lo hi) : + ∀ i, |x i - y i| ≤ mesh := by + intro i + have hxi := hx i (Set.mem_univ i) + have hyi := hy i (Set.mem_univ i) + exact abs_le.mpr ⟨by linarith [hwidth i, hxi.1, hyi.2], by linarith [hwidth i, hyi.1, hxi.2]⟩ + +theorem positive_integral_freezing_bound (w lo hi : ι → ℝ) + (hw : ∀ i, 0 ≤ w i) (hlo : ∀ i, 0 < lo i) + (f : (ι → ℝ) → ℂ) {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hwidth : ∀ i, hi i - lo i ≤ mesh) + (hf : ∀ z ∈ logRectangle lo hi, + DifferentiableAt ℝ (fun y => f (fun j => Real.exp (y j))) z) + (hd : ∀ z ∈ logRectangle lo hi, ∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun j => Real.exp (z j)) i t)) 0‖ ≤ D) + {base : ι → ℝ} (hbase : base ∈ logRectangle lo hi) : + ‖logCellIntegral w lo hi f - + logCellMass w lo hi • f (fun j => Real.exp (base j))‖ ≤ + (Fintype.card ι : ℝ) * D * mesh * logCellMass w lo hi := by + apply logCell_freezing_of_variation w lo hi hw hlo + (fun y => f (fun j => Real.exp (y j))) + (fun z hz => (hf z hz).continuousAt.continuousWithinAt) base + intro z hz + exact positive_norm_sub_le f lo hi hD hm hf hd hz hbase + (logRectangle_coordinate_dist_le lo hi hwidth hz hbase) + +theorem residue_integral_freezing_bound (M : ℕ) (Z lo hi : ι → ℝ) + (hZ : ∀ i, 0 < Z i) (hlo : ∀ i, 0 < lo i) + (horder : ∀ i, lo i ≤ hi i) + (f : (ι → ℝ) → ℂ) {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hwidth : ∀ i, hi i - lo i ≤ mesh) + (hf : ∀ z ∈ logRectangle lo hi, + DifferentiableAt ℝ (fun y => f (fun j => Real.exp (y j))) z) + (hd : ∀ z ∈ logRectangle lo hi, ∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun j => Real.exp (z j)) i t)) 0‖ ≤ D) + {base : ι → ℝ} (hbase : base ∈ logRectangle lo hi) : + ‖logCellIntegral (fun i => ((Nat.totient M : ℝ) * Z i)⁻¹) lo hi f - + (∏ i, PrimeProgression.harmonicIntegral M (lo i) (hi i) / Z i) • + f (fun j => Real.exp (base j))‖ ≤ + (Fintype.card ι : ℝ) * D * mesh * + ∏ i, PrimeProgression.harmonicIntegral M (lo i) (hi i) / Z i := by + rw [← residue_logCellMass_eq_prod M Z lo hi horder] + exact positive_integral_freezing_bound _ lo hi + (fun i => inv_nonneg.mpr (mul_nonneg (Nat.cast_nonneg _) (hZ i).le)) + hlo f hD hm hwidth hf hd hbase + +end Ostmann.Arithmetic.PrimeCellFreezing + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellIntegralFreezingMass.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellIntegralFreezingMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..d1d1fd38351d4f6c4c05860d2b7e753bfbd71089 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellIntegralFreezingMass.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellFreezingLog +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeProgression + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellFreezing +open MeasureTheory +open scoped BigOperators +variable {ι : Type*} [Fintype ι] + +def logCellDensity (w : ι → ℝ) (t : ι → ℝ) : ℝ := ∏ i, w i / t i + +def logCellMass (w lo hi : ι → ℝ) : ℝ := + ∫ t in logRectangle lo hi, logCellDensity w t + +theorem logCellMass_eq_prod (w lo hi : ι → ℝ) (horder : ∀ i, lo i ≤ hi i) : + logCellMass w lo hi = ∏ i, w i * ∫ t in lo i..hi i, (t : ℝ)⁻¹ := by + unfold logCellMass logCellDensity logRectangle + change (∫ t, ∏ i, w i / t i ∂(Measure.pi (fun _ : ι => (volume : Measure ℝ))).restrict + (Set.univ.pi (fun i => Set.Icc (lo i) (hi i)))) = _ + rw [Measure.restrict_pi_pi, integral_fintype_prod_eq_prod] + apply Finset.prod_congr rfl + intro i _ + simp_rw [div_eq_mul_inv] + rw [integral_const_mul, integral_Icc_eq_integral_Ioc, + ← intervalIntegral.integral_of_le (horder i)] + +theorem residue_logCellMass_eq_prod (M : ℕ) (Z lo hi : ι → ℝ) + (horder : ∀ i, lo i ≤ hi i) : + logCellMass (fun i => ((Nat.totient M : ℝ) * Z i)⁻¹) lo hi = + ∏ i, PrimeProgression.harmonicIntegral M (lo i) (hi i) / Z i := by + rw [logCellMass_eq_prod _ lo hi horder] + apply Finset.prod_congr rfl + intro i _ + simp only [PrimeProgression.harmonicIntegral, mul_inv_rev, div_eq_mul_inv] + ring + +omit [Fintype ι] in +theorem isCompact_logRectangle (lo hi : ι → ℝ) : IsCompact (logRectangle lo hi) := + isCompact_univ_pi fun _ => isCompact_Icc + +theorem continuousOn_logCellDensity (w lo hi : ι → ℝ) (hlo : ∀ i, 0 < lo i) : + ContinuousOn (logCellDensity w) (logRectangle lo hi) := by + apply continuousOn_finsetProd + intro i _ + exact continuousOn_const.div (continuous_apply i).continuousOn fun t ht => + ne_of_gt ((hlo i).trans_le (ht i (Set.mem_univ i)).1) + +theorem integrableOn_logCellDensity (w lo hi : ι → ℝ) (hlo : ∀ i, 0 < lo i) : + IntegrableOn (logCellDensity w) (logRectangle lo hi) := + (continuousOn_logCellDensity w lo hi hlo).integrableOn_compact + (isCompact_logRectangle lo hi) + +theorem logCellDensity_nonneg (w lo hi : ι → ℝ) (hw : ∀ i, 0 ≤ w i) + (hlo : ∀ i, 0 < lo i) {t : ι → ℝ} (ht : t ∈ logRectangle lo hi) : + 0 ≤ logCellDensity w t := + Finset.prod_nonneg fun i _ => div_nonneg (hw i) + (le_trans (hlo i).le (ht i (Set.mem_univ i)).1) + +theorem logCellMass_nonneg (w lo hi : ι → ℝ) (hw : ∀ i, 0 ≤ w i) + (hlo : ∀ i, 0 < lo i) : 0 ≤ logCellMass w lo hi := by + apply setIntegral_nonneg (isCompact_logRectangle lo hi).measurableSet + intro t ht + exact logCellDensity_nonneg w lo hi hw hlo ht + +end Ostmann.Arithmetic.PrimeCellFreezing + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointNormMass.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointNormMass.lean new file mode 100644 index 0000000000000000000000000000000000000000..c5b7c40d3bafdc28ed3e926566c2b10c3d25bad2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointNormMass.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellJointReplacement + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellReplacement +open scoped BigOperators +open PrimeProgression +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + +def jointAbsTest (F : (ι → (ZMod M)ˣ) → ℂ) (a : ι → ZMod M) : ℝ := by + classical + exact ∑ u : ι → (ZMod M)ˣ, if ∀ i, (u i : ZMod M)=a i then ‖F u‖ else 0 + +theorem jointAbsTest_nonneg (F : (ι → (ZMod M)ˣ) → ℂ) (a : ι → ZMod M) : + 0≤jointAbsTest F a := by + classical + exact Finset.sum_nonneg fun _ _ => by split_ifs <;> positivity + +theorem jointUnitTest_norm_le (F : (ι → (ZMod M)ˣ) → ℂ) (a : ι → ZMod M) : + ‖jointUnitTest F a‖≤jointAbsTest F a := by + classical + unfold jointUnitTest jointAbsTest + apply (norm_sum_le _ _).trans + apply Finset.sum_le_sum + intro u _ + split_ifs <;> simp + +theorem jointAbsTest_cast (F : (ι → (ZMod M)ˣ) → ℂ) (a : ι → ZMod M) : + (jointAbsTest F a:ℂ)=jointUnitTest (fun u => (‖F u‖:ℂ)) a := by + classical + simp only [jointAbsTest,jointUnitTest,Complex.ofReal_sum] + apply Finset.sum_congr rfl + intro u _ + split_ifs <;> simp + +def tupleWeight (N : ι → ℕ) (lo hi Z : ι → ℝ) (p : PrimeCellTuple N lo hi) : ℝ := + ∏ i, (Z i*((p i).val:ℝ))⁻¹ + +def jointAbsMass (N : ι → ℕ) (M : ℕ) [NeZero M] (lo hi Z : ι → ℝ) + (F : (ι → (ZMod M)ˣ) → ℂ) : ℝ := + ∑ p : PrimeCellTuple N lo hi, tupleWeight N lo hi Z p*jointAbsTest F (fun i => ((p i).val:ZMod M)) + +omit [DecidableEq ι] in +theorem tupleWeight_nonneg [_decidableEqIndex : DecidableEq ι] + (N : ι → ℕ) (lo hi Z : ι → ℝ) (hZ : ∀ i,0≤Z i) + (p : PrimeCellTuple N lo hi) : 0≤tupleWeight N lo hi Z p := + Finset.prod_nonneg fun i _ => inv_nonneg.mpr (mul_nonneg (hZ i) (Nat.cast_nonneg _)) + +theorem jointAbsMass_cast (N : ι → ℕ) (lo hi Z : ι → ℝ) + (F : (ι → (ZMod M)ˣ) → ℂ) : + (jointAbsMass N M lo hi Z F:ℂ)=jointComplexTestSum N M lo hi Z (fun u => (‖F u‖:ℂ)) := by + simp only [jointAbsMass,jointComplexTestSum,Complex.ofReal_sum,Complex.ofReal_mul, + tupleWeight,Complex.ofReal_prod,jointAbsTest_cast] + +theorem coefficient_norm_mass_le (N : ι → ℕ) (lo hi Z : ι → ℝ) (hZ : ∀ i,0≤Z i) + (F : (ι → (ZMod M)ˣ) → ℂ) : + (∑ p : PrimeCellTuple N lo hi, + ‖(tupleWeight N lo hi Z p:ℂ)*jointUnitTest F (fun i => ((p i).val:ZMod M))‖) ≤ + jointAbsMass N M lo hi Z F := by + apply Finset.sum_le_sum + intro p _ + rw [norm_mul,Complex.norm_real,Real.norm_eq_abs,abs_of_nonneg (tupleWeight_nonneg N lo hi Z hZ p)] + exact mul_le_mul_of_nonneg_left (jointUnitTest_norm_le F _) (tupleWeight_nonneg N lo hi Z hZ p) + +theorem jointAbsMass_le_of_error (N : ι → ℕ) (lo hi Z : ι → ℝ) + (F : (ι → (ZMod M)ˣ) → ℂ) (main error : ℝ) + (he : ‖jointComplexTestSum N M lo hi Z (fun u => (‖F u‖:ℂ))- + (main:ℂ)*∑ u : ι → (ZMod M)ˣ,(‖F u‖:ℂ)‖ ≤ error*∑ u : ι → (ZMod M)ˣ,‖F u‖) : + jointAbsMass N M lo hi Z F ≤ (main+error)*∑ u : ι → (ZMod M)ˣ,‖F u‖ := by + rw [← jointAbsMass_cast,← Complex.ofReal_sum,← Complex.ofReal_mul,← Complex.ofReal_sub, + Complex.norm_real,Real.norm_eq_abs] at he + have hh := (le_abs_self _).trans he + linarith + +end Ostmann.Arithmetic.PrimeCellReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointReplacement.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..ccc3f6c96726ca4b4818f6de11e2513f911ee450 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointReplacement.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellJointReplacementAlgebra +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellJointReplacementPrior + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellReplacement +open PrimeProgression +open scoped BigOperators + +theorem jointComplexTestSum_error {ι : Type*} [Fintype ι] [DecidableEq ι] + (N : ι → ℕ) (M : ℕ) [NeZero M] (lo hi Z main E : ι → ℝ) + (F : (ι → (ZMod M)ˣ) → ℂ) {ε B : ℝ} (hε : 0 ≤ ε) (hB : 1 ≤ B) + (hE : ∀ i, E i ≤ ε) (hbound : ∀ i, |main i| + E i ≤ B) + (hmass : ∀ i (u : (ZMod M)ˣ), + |residueMass (N i) M u (lo i) (hi i) (Z i) - main i| ≤ E i) : + ‖jointComplexTestSum N M lo hi Z F - + (∏ i, (main i : ℂ)) * ∑ u : ι → (ZMod M)ˣ, F u‖ ≤ + Fintype.card ι * ε * B ^ Fintype.card ι * ∑ u : ι → (ZMod M)ˣ, ‖F u‖ := by + classical + have hμ : ∀ i (u : (ZMod M)ˣ), + ‖(residueMass (N i) M u (lo i) (hi i) (Z i) : ℂ)‖ ≤ B := by + intro i u + have ht := abs_add_le (residueMass (N i) M u (lo i) (hi i) (Z i) - main i) (main i) + rw [sub_add_cancel] at ht + simp only [Complex.norm_real, Real.norm_eq_abs] + linarith [hmass i u, hbound i] + have hν : ∀ i (u : (ZMod M)ˣ), ‖(main i : ℂ)‖ ≤ B := by + intro i u + have he0 : 0 ≤ E i := (abs_nonneg _).trans (hmass i 1) + simp only [Complex.norm_real, Real.norm_eq_abs] + linarith [hbound i] + have he : ∀ i (u : (ZMod M)ˣ), + ‖(residueMass (N i) M u (lo i) (hi i) (Z i) : ℂ) - (main i : ℂ)‖ ≤ ε := by + intro i u + simpa only [← Complex.ofReal_sub, Complex.norm_real, Real.norm_eq_abs] using + (hmass i u).trans (hE i) + have h := joint_product_test_error + (fun i (u : (ZMod M)ˣ) => (residueMass (N i) M u (lo i) (hi i) (Z i) : ℂ)) + (fun i (_ : (ZMod M)ˣ) => (main i : ℂ)) F hε hB hμ hν he + rw [jointComplexTestSum_eq] + simpa only [Finset.mul_sum] using h + +theorem exists_joint_primeCell_replacement_constants : + ∃ d K L₀ : ℝ, 0 < d ∧ 0 < K ∧ 1 ≤ L₀ ∧ + ∀ (ι : Type*) [Fintype ι] [DecidableEq ι] (N : ι → ℕ) (M : ℕ) [NeZero M] + (lo hi Z : ι → ℝ), + (∀ i, L₀ ≤ lo i ∧ lo i ≤ hi i ∧ hi i - lo i ≤ 1 ∧ + ⌊Real.exp (hi i)⌋₊ ≤ N i ∧ 0 < Z i ∧ + (M : ℝ) ≤ Real.exp (d * (lo i) ^ (1 / 3 : ℝ))) → + ∀ ε B : ℝ, 0 ≤ ε → 1 ≤ B → + (∀ i, (K / Z i) * Real.exp (-d * (lo i) ^ (1 / 3 : ℝ)) ≤ ε) → + (∀ i, |harmonicIntegral M (lo i) (hi i) / Z i| + + (K / Z i) * Real.exp (-d * (lo i) ^ (1 / 3 : ℝ)) ≤ B) → + ∀ F : (ι → (ZMod M)ˣ) → ℂ, + ‖jointComplexTestSum N M lo hi Z F - + (∏ i, ((harmonicIntegral M (lo i) (hi i) / Z i : ℝ) : ℂ)) * + ∑ u : ι → (ZMod M)ˣ, F u‖ ≤ + Fintype.card ι * ε * B ^ Fintype.card ι * + ∑ u : ι → (ZMod M)ˣ, ‖F u‖ := by + obtain ⟨d, K, L₀, hd, hK, hL₀, h⟩ := exists_primeCell_replacement_constants + refine ⟨d, K, L₀, hd, hK, hL₀, ?_⟩ + intro ι _ _ N M _ lo hi Z hcell ε B hε hB hE hbound F + apply jointComplexTestSum_error N M lo hi Z + (fun i => harmonicIntegral M (lo i) (hi i) / Z i) + (fun i => (K / Z i) * Real.exp (-d * (lo i) ^ (1 / 3 : ℝ))) F hε hB hE hbound + intro i u + obtain ⟨hlo, hlohi, hlen, hN, hZ, hmod⟩ := hcell i + exact (h (lo i) (hi i) hlo hlohi hlen (N i) M (Z i) hN hZ hmod).1 u u.isUnit + +end Ostmann.Arithmetic.PrimeCellReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointReplacementAlgebra.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointReplacementAlgebra.lean new file mode 100644 index 0000000000000000000000000000000000000000..1d63fb460e732f451ae8989857919bd6deec6b02 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointReplacementAlgebra.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellReplacementUniform + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellReplacement +open scoped BigOperators + +theorem norm_prod_sub_prod_le {ι : Type*} (s : Finset ι) (f g : ι → ℂ) + {ε B : ℝ} (hε : 0 ≤ ε) (hB : 1 ≤ B) + (hf : ∀ i ∈ s, ‖f i‖ ≤ B) (hg : ∀ i ∈ s, ‖g i‖ ≤ B) + (he : ∀ i ∈ s, ‖f i - g i‖ ≤ ε) : + ‖(∏ i ∈ s, f i) - ∏ i ∈ s, g i‖ ≤ s.card * ε * B ^ s.card := by + classical + induction s using Finset.induction_on with + | empty => simp + | @insert a s ha ih => + have hB0 : 0 ≤ B := by linarith + have hfs : ∀ i ∈ s, ‖f i‖ ≤ B := fun i hi => hf i (Finset.mem_insert_of_mem hi) + have hgs : ∀ i ∈ s, ‖g i‖ ≤ B := fun i hi => hg i (Finset.mem_insert_of_mem hi) + have hes : ∀ i ∈ s, ‖f i - g i‖ ≤ ε := fun i hi => he i (Finset.mem_insert_of_mem hi) + have hi := ih hfs hgs hes + have hpf : ‖∏ i ∈ s, f i‖ ≤ B ^ s.card := by + rw [norm_prod] + calc + (∏ i ∈ s, ‖f i‖) ≤ ∏ _i ∈ s, B := + Finset.prod_le_prod₀ (fun i _ => norm_nonneg (f i)) hfs + _ = B ^ s.card := by simp + have hfa := he a (Finset.mem_insert_self _ _) + have hga := hg a (Finset.mem_insert_self _ _) + have hid : f a * (∏ i ∈ s, f i) - g a * (∏ i ∈ s, g i) = + (f a - g a) * (∏ i ∈ s, f i) + g a * ((∏ i ∈ s, f i) - ∏ i ∈ s, g i) := by ring + rw [Finset.prod_insert ha, Finset.prod_insert ha, hid, Finset.card_insert_of_notMem ha] + calc + _ ≤ ‖(f a - g a) * (∏ i ∈ s, f i)‖ + + ‖g a * ((∏ i ∈ s, f i) - ∏ i ∈ s, g i)‖ := norm_add_le _ _ + _ ≤ ε * B ^ s.card + B * (s.card * ε * B ^ s.card) := by + rw [norm_mul, norm_mul] + exact add_le_add + (mul_le_mul hfa hpf (norm_nonneg _) hε) + (mul_le_mul hga hi (norm_nonneg _) hB0) + _ ≤ ε * B ^ (s.card + 1) + B * (s.card * ε * B ^ s.card) := by + exact add_le_add (mul_le_mul_of_nonneg_left + (pow_le_pow_right₀ hB (Nat.le_succ _)) hε) le_rfl + _ = _ := by rw [pow_succ]; push_cast; ring + +theorem joint_product_test_error {ι : Type*} [Fintype ι] [DecidableEq ι] + {κ : ι → Type*} [∀ i, Fintype (κ i)] + (μ ν : ∀ i, κ i → ℂ) (F : (∀ i, κ i) → ℂ) {ε B : ℝ} + (hε : 0 ≤ ε) (hB : 1 ≤ B) + (hμ : ∀ i a, ‖μ i a‖ ≤ B) (hν : ∀ i a, ‖ν i a‖ ≤ B) + (he : ∀ i a, ‖μ i a - ν i a‖ ≤ ε) : + ‖(∑ a : ∀ i, κ i, (∏ i, μ i (a i)) * F a) - + ∑ a : ∀ i, κ i, (∏ i, ν i (a i)) * F a‖ ≤ + Fintype.card ι * ε * B ^ Fintype.card ι * ∑ a : ∀ i, κ i, ‖F a‖ := by + classical + rw [← Finset.sum_sub_distrib] + simp_rw [← sub_mul] + calc + _ ≤ ∑ a : ∀ i, κ i, ‖((∏ i, μ i (a i)) - ∏ i, ν i (a i)) * F a‖ := norm_sum_le _ _ + _ ≤ ∑ a : ∀ i, κ i, (Fintype.card ι * ε * B ^ Fintype.card ι) * ‖F a‖ := by + apply Finset.sum_le_sum + intro a ha + rw [norm_mul] + apply mul_le_mul_of_nonneg_right _ (norm_nonneg _) + simpa only [Finset.card_univ] using norm_prod_sub_prod_le Finset.univ + (fun i => μ i (a i)) (fun i => ν i (a i)) hε hB + (fun i _ => hμ i (a i)) (fun i _ => hν i (a i)) (fun i _ => he i (a i)) + _ = _ := by rw [Finset.mul_sum] + +end Ostmann.Arithmetic.PrimeCellReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointReplacementPrior.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointReplacementPrior.lean new file mode 100644 index 0000000000000000000000000000000000000000..3b16fc733d5040603f8a26de26cb48c137f8da58 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellJointReplacementPrior.lean @@ -0,0 +1,104 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellReplacementTests + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellReplacement +open PrimeProgression +open scoped BigOperators + +def jointUnitTest {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + (F : (ι → (ZMod M)ˣ) → ℂ) (a : ι → ZMod M) : ℂ := by + classical + exact ∑ u : ι → (ZMod M)ˣ, if ∀ i, (u i : ZMod M) = a i then F u else 0 + +lemma jointUnitTest_units {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + (F : (ι → (ZMod M)ˣ) → ℂ) (u : ι → (ZMod M)ˣ) : + jointUnitTest F (fun i => (u i : ZMod M)) = F u := by + classical + have he (v : ι → (ZMod M)ˣ) : (∀ i, (v i : ZMod M) = u i) ↔ v = u := by + constructor + · intro h + funext i + exact Units.ext (h i) + · rintro rfl + exact fun _ => rfl + simp only [jointUnitTest, he] + simp + +lemma jointUnitTest_nonunit {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + (F : (ι → (ZMod M)ˣ) → ℂ) (a : ι → ZMod M) (i : ι) (hi : ¬ IsUnit (a i)) : + jointUnitTest F a = 0 := by + classical + apply Finset.sum_eq_zero + intro u hu + apply ite_eq_right + intro h + exact hi (h i ▸ (u i).isUnit) + +theorem finite_product_prior_partition {ι : Type*} [Fintype ι] [DecidableEq ι] + {α : ι → Type*} [∀ i, Fintype (α i)] {M : ℕ} [NeZero M] + (ρ : ∀ i, α i → ZMod M) (w : ∀ i, α i → ℂ) + (F : (ι → (ZMod M)ˣ) → ℂ) : + (∑ p : ∀ i, α i, (∏ i, w i (p i)) * jointUnitTest F (fun i => ρ i (p i))) = + ∑ u : ι → (ZMod M)ˣ, + (∏ i, ∑ p : α i, if (u i : ZMod M) = ρ i p then w i p else 0) * F u := by + classical + simp_rw [jointUnitTest, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro u hu + rw [Fintype.prod_sum, Finset.sum_mul] + apply Finset.sum_congr rfl + intro p hp + rw [Fintype.prod_ite_zero] + by_cases h : ∀ i, (u i : ZMod M) = ρ i (p i) + · simp [h] + · simp [h] + +abbrev PrimeCellTuple {ι : Type*} (N : ι → ℕ) (lo hi : ι → ℝ) := + ∀ i, {p : ℕ // p ∈ logPrimeSupport (N i) (lo i) (hi i)} + +def jointComplexTestSum {ι : Type*} [Fintype ι] [DecidableEq ι] (N : ι → ℕ) (M : ℕ) [NeZero M] + (lo hi Z : ι → ℝ) (F : (ι → (ZMod M)ˣ) → ℂ) : ℂ := + ∑ p : PrimeCellTuple N lo hi, + (∏ i, (((Z i * ((p i).val : ℝ))⁻¹ : ℝ) : ℂ)) * + jointUnitTest F (fun i => ((p i).val : ZMod M)) + +theorem jointComplexTestSum_eq {ι : Type*} [Fintype ι] [DecidableEq ι] + (N : ι → ℕ) (M : ℕ) [NeZero M] (lo hi Z : ι → ℝ) + (F : (ι → (ZMod M)ˣ) → ℂ) : + jointComplexTestSum N M lo hi Z F = + ∑ u : ι → (ZMod M)ˣ, + (∏ i, (residueMass (N i) M (u i) (lo i) (hi i) (Z i) : ℂ)) * F u := by + classical + have hpart := finite_product_prior_partition + (fun i (p : {p : ℕ // p ∈ logPrimeSupport (N i) (lo i) (hi i)}) => (p.val : ZMod M)) + (fun i (p : {p : ℕ // p ∈ logPrimeSupport (N i) (lo i) (hi i)}) => + (((Z i * (p.val : ℝ))⁻¹ : ℝ) : ℂ)) F + change jointComplexTestSum N M lo hi Z F = _ at hpart + rw [hpart] + apply Finset.sum_congr rfl + intro u hu + congr 1 + apply Finset.prod_congr rfl + intro i hi' + rw [Finset.sum_coe_sort (logPrimeSupport (N i) (lo i) (hi i)) + (fun p : ℕ => if (u i : ZMod M) = (p : ZMod M) then + (((Z i * (p : ℝ))⁻¹ : ℝ) : ℂ) else 0)] + simp only [residueMass, Complex.ofReal_sum, Finset.sum_filter] + apply Finset.sum_congr rfl + intro p hp + by_cases he : (p : ZMod M) = (u i : ZMod M) + · simp [he] + · simp [he, Ne.symm he] + +end Ostmann.Arithmetic.PrimeCellReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellMeshBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellMeshBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..b2935cdb203e5b0a67b0776f5f8e2cd3a34cabb9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellMeshBudget.lean @@ -0,0 +1,105 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellMeshGrowth + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellMeshBudget +open ScaleBudget Filter + +theorem actual_coordinate_count_le (k n : ℕ) {L : ℝ} (hL : 1 ≤ L) + (hn : n ≤ 2^k*Conclusion.bulkSize k L+2) : + (n:ℝ) ≤ ((2:ℝ)^k*Conclusion.bulkScale k+2)*L := by + have hm := (Conclusion.bulkSize_bounds k (by linarith : 0 ≤ L)).2 + have hh : (n:ℝ) ≤ (2:ℝ)^k*(Conclusion.bulkSize k L:ℝ)+2 := by exact_mod_cast hn + have hmul := mul_le_mul_of_nonneg_left hm (pow_nonneg (by norm_num : (0:ℝ)≤2) k) + nlinarith + +theorem actual_log_joint_mesh_card_le (r : Row) (k n M : ℕ) {L : ℝ} + (hL : 1 ≤ L) (hn : n ≤ 2^k*Conclusion.bulkSize k L+2) + (hM : 0 < M) (hmod : Real.log (M:ℝ) ≤ Real.exp (r.μ*L)) : + Real.log (((meshIntervals r L)^n*M^n : ℕ):ℝ) ≤ + (((2:ℝ)^k*Conclusion.bulkScale k+2)*L)* + (Real.exp (r.δ*L)+r.a₁*L+Real.log 4+Real.exp (r.μ*L)) := by + apply (log_joint_mesh_card_le r (by linarith) n M hM hmod).trans + apply mul_le_mul_of_nonneg_right (actual_coordinate_count_le k n hL hn) + have ha := row_a₁_pos r + have hlog : 0 ≤ Real.log (4:ℝ) := Real.log_nonneg (by norm_num) + positivity + +theorem eventually_variation_error (r : Row) (k : ℕ) (C : ℝ) + {σ : ℝ} (hσ : 0 ≤ σ) (hgap : σ < r.δ) : + ∀ᶠ L : ℝ in atTop, + Real.exp (-Real.exp (r.δ*L)+ + C*((Conclusion.bulkSize k L:ℝ)+1)*Real.exp (σ*L)+ + C*((Conclusion.bulkSize k L:ℝ)+1)) ≤ + Real.exp (-Real.exp (r.target*L)) := by + filter_upwards [eventually_double_exp_error (2*bulkCostConstant k C) 1 + hgap r.target_lt_δ (by norm_num : (0:ℝ)<1), + eventually_ge_atTop (1:ℝ)] with L he hL + apply le_trans _ he + apply Real.exp_le_exp.mpr + have hh := variation_cost_le k C hL hσ + simp only [pow_one] + linarith only [hh] + +theorem eventually_joint_progression_error (r : Row) (k : ℕ) (C : ℝ) + {σ c : ℝ} (hσ : σ ≤ r.δ) (hc : 0 < c) : + ∀ᶠ L : ℝ in atTop, + Real.exp (-c*Real.exp ((r.a₀/3)*L)+ + C*((Conclusion.bulkSize k L:ℝ)+1)* + (Real.exp (r.δ*L)+L+Real.exp (r.μ*L)+Real.exp (σ*L))) ≤ + Real.exp (-Real.exp (r.target*L)) := by + have hgap : r.δ < r.a₀/3 := by + linarith [r.δ_lt_δ',r.δ'_lt_θ,r.zero_gap] + filter_upwards [eventually_double_exp_error (4*bulkCostConstant k C) 2 + hgap (r.target_lt_δ.trans hgap) hc, + eventually_ge_atTop (1:ℝ)] with L he hL + apply le_trans _ he + apply Real.exp_le_exp.mpr + linarith only [joint_error_cost_le r k C hL hσ] + +theorem eventually_joint_integer_error (r : Row) (k : ℕ) (C : ℝ) + {σ c : ℝ} (hσ : σ ≤ r.δ) (hc : 0 < c) : + ∀ᶠ L : ℝ in atTop, + Real.exp (-c*Real.exp (r.a₀*L)+ + C*((Conclusion.bulkSize k L:ℝ)+1)* + (Real.exp (r.δ*L)+L+Real.exp (r.μ*L)+Real.exp (σ*L))) ≤ + Real.exp (-Real.exp (r.target*L)) := by + have hgap : r.δ < r.a₀ := by + linarith [r.μ_pos,r.μ_lt_δ,r.δ_lt_δ',r.δ'_lt_θ,r.zero_gap] + filter_upwards [eventually_double_exp_error (4*bulkCostConstant k C) 2 + hgap (r.target_lt_δ.trans hgap) hc, + eventually_ge_atTop (1:ℝ)] with L he hL + apply le_trans _ he + apply Real.exp_le_exp.mpr + linarith only [joint_error_cost_le r k C hL hσ] + +theorem eventually_giant_and_bulk_errors (k : ℕ) (C : ℝ) {c : ℝ} (hc : 0 < c) : + ∀ᶠ L : ℝ in atTop, + (Real.exp (-Real.exp (giant.δ*L)+ + C*((Conclusion.bulkSize k L:ℝ)+1)*Real.exp ((12/1000:ℝ)*L)+ + C*((Conclusion.bulkSize k L:ℝ)+1)) ≤ Real.exp (-Real.exp (giant.target*L))) ∧ + (Real.exp (-Real.exp (bulk.δ*L)+ + C*((Conclusion.bulkSize k L:ℝ)+1)*Real.exp ((1/1000:ℝ)*L)+ + C*((Conclusion.bulkSize k L:ℝ)+1)) ≤ Real.exp (-Real.exp (bulk.target*L))) ∧ + (Real.exp (-c*Real.exp ((giant.a₀/3)*L)+ + C*((Conclusion.bulkSize k L:ℝ)+1)* + (Real.exp (giant.δ*L)+L+Real.exp (giant.μ*L)+Real.exp ((12/1000:ℝ)*L))) ≤ + Real.exp (-Real.exp (giant.target*L))) ∧ + (Real.exp (-c*Real.exp ((bulk.a₀/3)*L)+ + C*((Conclusion.bulkSize k L:ℝ)+1)* + (Real.exp (bulk.δ*L)+L+Real.exp (bulk.μ*L)+Real.exp ((1/1000:ℝ)*L))) ≤ + Real.exp (-Real.exp (bulk.target*L))) := by + filter_upwards [eventually_variation_error giant k C (by norm_num : (0:ℝ)≤12/1000) + (by norm_num [giant]), + eventually_variation_error bulk k C (by norm_num : (0:ℝ)≤1/1000) (by norm_num [bulk]), + eventually_joint_progression_error giant k C (by norm_num [giant] : (12/1000:ℝ)≤giant.δ) hc, + eventually_joint_progression_error bulk k C (by norm_num [bulk] : (1/1000:ℝ)≤bulk.δ) hc] + with L h1 h2 h3 h4 + exact ⟨h1,h2,h3,h4⟩ + +end Ostmann.Arithmetic.PrimeCellMeshBudget + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellMeshCounts.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellMeshCounts.lean new file mode 100644 index 0000000000000000000000000000000000000000..6b5b099ae56a2434d93d25aa600bf4b62e2de9cb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellMeshCounts.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ScaleBudget +import OAI.NumberTheory.Ostmann.Conclusion.Scales + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellMeshBudget +open ScaleBudget Filter + +def meshWidth (r : Row) (L : ℝ) : ℝ := Real.exp (-Real.exp (r.δ*L)) + +def meshIntervals (r : Row) (L : ℝ) : ℕ := + ⌈Real.exp (r.a₁*L)/meshWidth r L⌉₊+1 + +lemma row_a₁_pos (r : Row) : 0 < r.a₁ := by + linarith [r.μ_pos,r.μ_lt_δ,r.δ_lt_δ',r.δ'_lt_θ,r.zero_gap,r.range] + +lemma mesh_ratio (r : Row) (L : ℝ) : + Real.exp (r.a₁*L)/meshWidth r L = Real.exp (r.a₁*L+Real.exp (r.δ*L)) := by + rw [meshWidth,← Real.exp_sub] + congr 1 + ring + +lemma meshIntervals_pos (r : Row) (L : ℝ) : 0 < meshIntervals r L := by + unfold meshIntervals + omega + +theorem log_meshIntervals_le (r : Row) {L : ℝ} (hL : 0 ≤ L) : + Real.log (meshIntervals r L : ℝ) ≤ Real.exp (r.δ*L)+r.a₁*L+Real.log 4 := by + have ha := row_a₁_pos r + have hbase : 1 ≤ Real.exp (r.a₁*L+Real.exp (r.δ*L)) := + Real.one_le_exp (by positivity) + have hceil := Nat.ceil_lt_add_one (Real.exp_nonneg (r.a₁*L+Real.exp (r.δ*L))) + have hN : (meshIntervals r L : ℝ) ≤ 4*Real.exp (r.a₁*L+Real.exp (r.δ*L)) := by + rw [meshIntervals,mesh_ratio,Nat.cast_add,Nat.cast_one] + linarith + have hNp : (0:ℝ) < meshIntervals r L := by exact_mod_cast meshIntervals_pos r L + have hh := Real.log_le_log hNp hN + rw [Real.log_mul (by norm_num : (4:ℝ)≠0) (Real.exp_ne_zero _),Real.log_exp] at hh + linarith + +theorem log_joint_mesh_card_le (r : Row) {L : ℝ} (hL : 0 ≤ L) + (n M : ℕ) (hM : 0 < M) (hmod : Real.log (M:ℝ) ≤ Real.exp (r.μ*L)) : + Real.log (((meshIntervals r L)^n*M^n : ℕ):ℝ) ≤ + (n:ℝ)*(Real.exp (r.δ*L)+r.a₁*L+Real.log 4+Real.exp (r.μ*L)) := by + have hNp : (0:ℝ) < meshIntervals r L := by exact_mod_cast meshIntervals_pos r L + have hMp : (0:ℝ) (p : ZMod M) = a), + (Z * (p : ℝ))⁻¹ + +theorem residueMass_eq (N M : ℕ) (a : ZMod M) (lo hi Z : ℝ) : + residueMass N M a lo hi Z = harmonicProgression N M a lo hi / Z := by + simp only [residueMass, harmonicProgression, mul_inv_rev, div_eq_mul_inv, Finset.sum_mul] + +theorem residueMass_nonneg (N M : ℕ) (a : ZMod M) (lo hi : ℝ) {Z : ℝ} + (hZ : 0 ≤ Z) : 0 ≤ residueMass N M a lo hi Z := by + unfold residueMass + exact Finset.sum_nonneg fun p _ => inv_nonneg.mpr (mul_nonneg hZ (Nat.cast_nonneg p)) + +theorem residueMass_error_of_harmonic_error (N M : ℕ) (a : ZMod M) + (lo hi : ℝ) {Z E : ℝ} (hZ : 0 < Z) + (h : |harmonicProgression N M a lo hi - harmonicIntegral M lo hi| ≤ E) : + |residueMass N M a lo hi Z - harmonicIntegral M lo hi / Z| ≤ E / Z := by + rw [residueMass_eq, ← sub_div, abs_div, abs_of_pos hZ] + exact div_le_div_of_nonneg_right h hZ.le + +theorem exists_residueMass_error_constants : + ∃ d K L₀ : ℝ, 0 < d ∧ 0 < K ∧ 1 ≤ L₀ ∧ ∀ lo hi : ℝ, + L₀ ≤ lo → lo ≤ hi → hi-lo ≤ 1 → ∀ (N M : ℕ) (a : ZMod M) (Z : ℝ), + ⌊Real.exp hi⌋₊ ≤ N → 0 < M → IsUnit a → 0 < Z → + (M : ℝ) ≤ Real.exp (d * lo ^ (1/3 : ℝ)) → + |residueMass N M a lo hi Z - harmonicIntegral M lo hi / Z| ≤ + (K/Z) * Real.exp (-d * lo ^ (1/3 : ℝ)) := by + obtain ⟨d,K,L₀,hd,hK,hL₀,h⟩ := exists_harmonicProgression_error_constants + refine ⟨d,K,L₀,hd,hK,hL₀,?_⟩ + intro lo hi hlo hlohi hlen N M a Z hN hM ha hZ hmod + have he := residueMass_error_of_harmonic_error N M a lo hi hZ + (h lo hi hlo hlohi hlen N M a hN hM ha hmod) + convert he using 1; ring + +end Ostmann.Arithmetic.PrimeCellReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellReplacementBounds.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellReplacementBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..248f0b78d4ed9c0b97694ada0a60b5d48c4fed15 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellReplacementBounds.lean @@ -0,0 +1,62 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellReplacementTests + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellReplacement +open scoped BigOperators +open PrimeProgression + +theorem realTestSum_error (N M : ℕ) [NeZero M] (lo hi Z main E : ℝ) + (F : (ZMod M)ˣ → ℝ) (hF : ∀ u, 0 ≤ F u) + (hmass : ∀ u : (ZMod M)ˣ, |residueMass N M u lo hi Z - main| ≤ E) : + |realTestSum N M lo hi Z F - main * ∑ u : (ZMod M)ˣ, F u| ≤ + E * ∑ u : (ZMod M)ˣ, F u := by + have he : realTestSum N M lo hi Z F - main * ∑ u : (ZMod M)ˣ, F u = + ∑ u : (ZMod M)ˣ, (residueMass N M u lo hi Z - main) * F u := by + rw [realTestSum_eq, Finset.mul_sum, ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro u _ + ring + rw [he] + calc + _ ≤ ∑ u : (ZMod M)ˣ, |(residueMass N M u lo hi Z - main) * F u| := + Finset.abs_sum_le_sum_abs _ _ + _ ≤ ∑ u : (ZMod M)ˣ, E * F u := by + apply Finset.sum_le_sum + intro u _ + rw [abs_mul, abs_of_nonneg (hF u)] + exact mul_le_mul_of_nonneg_right (hmass u) (hF u) + _ = _ := (Finset.mul_sum _ _ _).symm + +theorem complexTestSum_error (N M : ℕ) [NeZero M] (lo hi Z main E : ℝ) + (F : (ZMod M)ˣ → ℂ) + (hmass : ∀ u : (ZMod M)ˣ, |residueMass N M u lo hi Z - main| ≤ E) : + ‖complexTestSum N M lo hi Z F - (main : ℂ) * ∑ u : (ZMod M)ˣ, F u‖ ≤ + E * ∑ u : (ZMod M)ˣ, ‖F u‖ := by + have he : complexTestSum N M lo hi Z F - (main : ℂ) * ∑ u : (ZMod M)ˣ, F u = + ∑ u : (ZMod M)ˣ, ((residueMass N M u lo hi Z - main : ℝ) : ℂ) * F u := by + rw [complexTestSum_eq, Finset.mul_sum, ← Finset.sum_sub_distrib] + apply Finset.sum_congr rfl + intro u _ + rw [Complex.ofReal_sub, sub_mul] + rw [he] + calc + _ ≤ ∑ u : (ZMod M)ˣ, ‖((residueMass N M u lo hi Z - main : ℝ) : ℂ) * F u‖ := + norm_sum_le _ _ + _ ≤ ∑ u : (ZMod M)ˣ, E * ‖F u‖ := by + apply Finset.sum_le_sum + intro u _ + rw [norm_mul, Complex.norm_real, Real.norm_eq_abs] + exact mul_le_mul_of_nonneg_right (hmass u) (norm_nonneg _) + _ = _ := (Finset.mul_sum _ _ _).symm + +end Ostmann.Arithmetic.PrimeCellReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellReplacementTests.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellReplacementTests.lean new file mode 100644 index 0000000000000000000000000000000000000000..ee3fb683338b81cfa53ad5aaeb5bb0044c59d53f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellReplacementTests.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellReplacement + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellReplacement +open scoped BigOperators +open PrimeProgression + +def unitTest {M : ℕ} [NeZero M] {A : Type*} [AddCommMonoid A] + (F : (ZMod M)ˣ → A) (a : ZMod M) : A := by + classical + exact ∑ u : (ZMod M)ˣ, if (u : ZMod M) = a then F u else 0 + +theorem unitTest_unit {M : ℕ} [NeZero M] {A : Type*} [AddCommMonoid A] + (F : (ZMod M)ˣ → A) (u : (ZMod M)ˣ) : unitTest F (u : ZMod M) = F u := by + classical + simp [unitTest, Units.val_inj] + +theorem unitTest_nonunit {M : ℕ} [NeZero M] {A : Type*} [AddCommMonoid A] + (F : (ZMod M)ˣ → A) {a : ZMod M} (ha : ¬ IsUnit a) : unitTest F a = 0 := by + classical + apply Finset.sum_eq_zero + intro u _ + apply ite_eq_right + intro he + exact ha (he ▸ u.isUnit) + +theorem sum_weighted_unitTest {M : ℕ} [NeZero M] {A : Type*} [Semiring A] + (S : Finset ℕ) (w : ℕ → A) (F : (ZMod M)ˣ → A) : + (∑ p ∈ S, w p * unitTest F (p : ZMod M)) = + ∑ u : (ZMod M)ˣ, (∑ p ∈ S.filter (fun p : ℕ => (p : ZMod M) = u), w p) * F u := by + classical + simp_rw [unitTest, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro u _ + rw [Finset.sum_mul, Finset.sum_filter] + apply Finset.sum_congr rfl + intro p _ + by_cases hp : (u : ZMod M) = (p : ZMod M) <;> simp [hp, eq_comm] + +theorem sum_weighted_unitTest_filter_coprime {M : ℕ} [NeZero M] + {A : Type*} [Semiring A] (S : Finset ℕ) (w : ℕ → A) (F : (ZMod M)ˣ → A) : + (∑ p ∈ S, w p * unitTest F (p : ZMod M)) = + ∑ p ∈ S.filter (fun p => p.Coprime M), w p * unitTest F (p : ZMod M) := by + classical + symm + apply Finset.sum_subset (Finset.filter_subset _ _) + intro p hp hn + have hcp : ¬ p.Coprime M := by simpa only [Finset.mem_filter, hp, true_and] using hn + have hu : ¬ IsUnit (p : ZMod M) := fun h => hcp ((ZMod.isUnit_iff_coprime p M).mp h) + rw [unitTest_nonunit F hu, mul_zero] + +def complexTestSum (N M : ℕ) [NeZero M] (lo hi Z : ℝ) (F : (ZMod M)ˣ → ℂ) : ℂ := + ∑ p ∈ logPrimeSupport N lo hi, ((Z*(p:ℝ))⁻¹ : ℝ) * unitTest F (p : ZMod M) + +def realTestSum (N M : ℕ) [NeZero M] (lo hi Z : ℝ) (F : (ZMod M)ˣ → ℝ) : ℝ := + ∑ p ∈ logPrimeSupport N lo hi, (Z*(p:ℝ))⁻¹ * unitTest F (p : ZMod M) + +theorem complexTestSum_eq (N M : ℕ) [NeZero M] (lo hi Z : ℝ) + (F : (ZMod M)ˣ → ℂ) : + complexTestSum N M lo hi Z F = ∑ u : (ZMod M)ˣ, (residueMass N M u lo hi Z : ℂ) * F u := by + simpa only [complexTestSum, residueMass, Complex.ofReal_sum] using + sum_weighted_unitTest (logPrimeSupport N lo hi) (fun p => (((Z*(p:ℝ))⁻¹ : ℝ) : ℂ)) F + +theorem realTestSum_eq (N M : ℕ) [NeZero M] (lo hi Z : ℝ) + (F : (ZMod M)ˣ → ℝ) : + realTestSum N M lo hi Z F = ∑ u : (ZMod M)ˣ, residueMass N M u lo hi Z * F u := + sum_weighted_unitTest (logPrimeSupport N lo hi) (fun p => (Z*(p:ℝ))⁻¹) F + +end Ostmann.Arithmetic.PrimeCellReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellReplacementUniform.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellReplacementUniform.lean new file mode 100644 index 0000000000000000000000000000000000000000..d0ca7dd5e12caa826d3088c8a0f83e644ad5d7f3 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellReplacementUniform.lean @@ -0,0 +1,49 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellReplacementBounds + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellReplacement +open scoped BigOperators +open PrimeProgression + +theorem exists_primeCell_replacement_constants : + ∃ d K L₀ : ℝ, 0 < d ∧ 0 < K ∧ 1 ≤ L₀ ∧ ∀ lo hi : ℝ, + L₀ ≤ lo → lo ≤ hi → hi-lo ≤ 1 → ∀ (N M : ℕ) [NeZero M] (Z : ℝ), + ⌊Real.exp hi⌋₊ ≤ N → 0 < Z → + (M : ℝ) ≤ Real.exp (d * lo ^ (1/3 : ℝ)) → + (∀ a : ZMod M, IsUnit a → + |residueMass N M a lo hi Z - harmonicIntegral M lo hi / Z| ≤ + (K/Z) * Real.exp (-d * lo ^ (1/3 : ℝ))) ∧ + (∀ F : (ZMod M)ˣ → ℝ, (∀ u, 0 ≤ F u) → + |realTestSum N M lo hi Z F - + (harmonicIntegral M lo hi / Z) * ∑ u : (ZMod M)ˣ, F u| ≤ + ((K/Z) * Real.exp (-d * lo ^ (1/3 : ℝ))) * ∑ u : (ZMod M)ˣ, F u) ∧ + (∀ F : (ZMod M)ˣ → ℂ, + ‖complexTestSum N M lo hi Z F - + ((harmonicIntegral M lo hi / Z : ℝ) : ℂ) * ∑ u : (ZMod M)ˣ, F u‖ ≤ + ((K/Z) * Real.exp (-d * lo ^ (1/3 : ℝ))) * ∑ u : (ZMod M)ˣ, ‖F u‖) := by + obtain ⟨d,K,L₀,hd,hK,hL₀,h⟩ := exists_residueMass_error_constants + refine ⟨d,K,L₀,hd,hK,hL₀,?_⟩ + intro lo hi hlo hlohi hlen N M _ Z hN hZ hmod + have hmass (u : (ZMod M)ˣ) : + |residueMass N M u lo hi Z - harmonicIntegral M lo hi / Z| ≤ + (K/Z) * Real.exp (-d * lo ^ (1/3 : ℝ)) := + h lo hi hlo hlohi hlen N M u Z hN (NeZero.pos M) u.isUnit hZ hmod + refine ⟨?_, ?_, ?_⟩ + · intro a ha + exact h lo hi hlo hlohi hlen N M a Z hN (NeZero.pos M) ha hZ hmod + · intro F hF + exact realTestSum_error N M lo hi Z _ _ F hF hmass + · intro F + exact complexTestSum_error N M lo hi Z _ _ F hmass + +end Ostmann.Arithmetic.PrimeCellReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellSmoothFreezing.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellSmoothFreezing.lean new file mode 100644 index 0000000000000000000000000000000000000000..df11dcc76f51b0184fe809a0fdbbd9e8485cc648 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellSmoothFreezing.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellIntegralFreezing +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellJointNormMass + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellReplacement +open scoped BigOperators +open PrimeProgression PrimeCellFreezing Characters.RationalHistory +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + +def tupleLog (N : ι → ℕ) (lo hi : ι → ℝ) (p : PrimeCellTuple N lo hi) : ι → ℝ := + fun i => Real.log ((p i).val:ℝ) + +omit [Fintype ι] [DecidableEq ι] in +theorem tupleLog_mem [_fintypeIndex : Fintype ι] [_decidableEqIndex : DecidableEq ι] + (N : ι → ℕ) (lo hi : ι → ℝ) (p : PrimeCellTuple N lo hi) : + tupleLog N lo hi p ∈ logRectangle lo hi := by + intro i _ + exact (mem_logPrimeSupport _ _ _ _).mp (p i).property |>.2.2 + +omit [Fintype ι] [DecidableEq ι] in +theorem exp_tupleLog [_fintypeIndex : Fintype ι] [_decidableEqIndex : DecidableEq ι] + (N : ι → ℕ) (lo hi : ι → ℝ) (p : PrimeCellTuple N lo hi) : + (fun i => Real.exp (tupleLog N lo hi p i)) = fun i => ((p i).val:ℝ) := by + funext i + apply Real.exp_log + exact_mod_cast ((mem_logPrimeSupport _ _ _ _).mp (p i).property).2.1.pos + +def smoothJointTestSum (N : ι → ℕ) (M : ℕ) [NeZero M] (lo hi Z : ι → ℝ) + (F : (ι → (ZMod M)ˣ) → ℂ) (f : (ι → ℝ) → ℂ) : ℂ := + ∑ p : PrimeCellTuple N lo hi, (tupleWeight N lo hi Z p:ℂ)* + jointUnitTest F (fun i => ((p i).val:ZMod M))*f (fun i => ((p i).val:ℝ)) + +theorem jointTestSum_tupleWeight (N : ι → ℕ) (lo hi Z : ι → ℝ) + (F : (ι → (ZMod M)ˣ) → ℂ) : + jointComplexTestSum N M lo hi Z F = + ∑ p : PrimeCellTuple N lo hi,(tupleWeight N lo hi Z p:ℂ)*jointUnitTest F (fun i => ((p i).val:ZMod M)) := by + simp only [jointComplexTestSum,tupleWeight,Complex.ofReal_prod] + +theorem smooth_freezing_bound (N : ι → ℕ) (lo hi Z : ι → ℝ) (hZ : ∀ i,0 ≤ Z i) + (F : (ι → (ZMod M)ˣ) → ℂ) (f : (ι → ℝ) → ℂ) + {D mesh : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) (hwidth : ∀ i,hi i-lo i ≤ mesh) + (hf : ∀ z∈logRectangle lo hi,DifferentiableAt ℝ (fun y => f (fun j => Real.exp (y j))) z) + (hd : ∀ z∈logRectangle lo hi,∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun j => Real.exp (z j)) i t)) 0‖ ≤ D) + {base : ι → ℝ} (hbase : base∈logRectangle lo hi) : + ‖smoothJointTestSum N M lo hi Z F f- + f (fun j => Real.exp (base j))*jointComplexTestSum N M lo hi Z F‖ ≤ + (Fintype.card ι:ℝ)*D*mesh*jointAbsMass N M lo hi Z F := by + classical + let c : PrimeCellTuple N lo hi → ℂ := fun p => + (tupleWeight N lo hi Z p:ℂ)*jointUnitTest F (fun i => ((p i).val:ZMod M)) + have he := positive_weighted_freezing_bound Finset.univ c f lo hi (tupleLog N lo hi) + (fun _ => base) hD hm hf hd (fun p _ => tupleLog_mem N lo hi p) (fun _ _ => hbase) + (fun p _ => logRectangle_coordinate_dist_le lo hi hwidth (tupleLog_mem N lo hi p) hbase) + simp_rw [exp_tupleLog] at he + have hconst : (∑ p : PrimeCellTuple N lo hi,c p*f (fun j => Real.exp (base j))) = + f (fun j => Real.exp (base j))*jointComplexTestSum N M lo hi Z F := by + rw [← Finset.sum_mul,jointTestSum_tupleWeight] + exact mul_comm _ _ + rw [hconst] at he + exact he.trans (mul_le_mul_of_nonneg_left (coefficient_norm_mass_le N lo hi Z hZ F) + (by positivity)) + +end Ostmann.Arithmetic.PrimeCellReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellSmoothReplacement.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellSmoothReplacement.lean new file mode 100644 index 0000000000000000000000000000000000000000..66a77edc3b575db8ae79d597e417172a3512977e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeCellSmoothReplacement.lean @@ -0,0 +1,83 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeCellSmoothFreezing + +namespace OAI + +open _root_.Erdos970 _root_.OAI.Erdos970 + +open Erdos970.Erdos970Dependency.SiegelWalfisz + +noncomputable section +namespace Ostmann.Arithmetic.PrimeCellReplacement +open scoped BigOperators +open PrimeProgression PrimeCellFreezing Characters.RationalHistory +variable {ι : Type*} [Fintype ι] [DecidableEq ι] {M : ℕ} [NeZero M] + +def principalMass (M : ℕ) (lo hi Z : ι → ℝ) : ℝ := + ∏ i, harmonicIntegral M (lo i) (hi i)/Z i + +def principalIntegral (M : ℕ) (lo hi Z : ι → ℝ) (f : (ι → ℝ) → ℂ) : ℂ := + logCellIntegral (fun i => ((Nat.totient M:ℝ)*Z i)⁻¹) lo hi f + +theorem smooth_replacement_of_errors (N : ι → ℕ) (lo hi Z : ι → ℝ) + (hZ : ∀ i, 0 < Z i) (hlo : ∀ i, 0 < lo i) (horder : ∀ i, lo i ≤ hi i) + (F : (ι → (ZMod M)ˣ) → ℂ) (f : (ι → ℝ) → ℂ) + {D mesh error : ℝ} (hD : 0 ≤ D) (hm : 0 ≤ mesh) + (hwidth : ∀ i, hi i-lo i ≤ mesh) + (hf : ∀ z∈logRectangle lo hi,DifferentiableAt ℝ (fun y => f (fun j => Real.exp (y j))) z) + (hd : ∀ z∈logRectangle lo hi,∀ i, + ‖deriv (fun t => f (Expr.logCurve (fun j => Real.exp (z j)) i t)) 0‖ ≤ D) + {base : ι → ℝ} (hbase : base∈logRectangle lo hi) + (he : ‖jointComplexTestSum N M lo hi Z F- + (principalMass M lo hi Z:ℂ)*∑ u : ι → (ZMod M)ˣ,F u‖ ≤ error*∑ u : ι → (ZMod M)ˣ,‖F u‖) + (heAbs : ‖jointComplexTestSum N M lo hi Z (fun u => (‖F u‖:ℂ))- + (principalMass M lo hi Z:ℂ)*∑ u : ι → (ZMod M)ˣ,(‖F u‖:ℂ)‖ ≤ + error*∑ u : ι → (ZMod M)ˣ,‖F u‖) : + ‖smoothJointTestSum N M lo hi Z F f-principalIntegral M lo hi Z f*∑ u : ι → (ZMod M)ˣ,F u‖ ≤ + ((Fintype.card ι:ℝ)*D*mesh*(2*principalMass M lo hi Z+error)+ + ‖f (fun j => Real.exp (base j))‖*error)*∑ u : ι → (ZMod M)ˣ,‖F u‖ := by + classical + let v : ℝ := (Fintype.card ι:ℝ)*D*mesh + let f₀ := f (fun j => Real.exp (base j)) + let S := ∑ u : ι → (ZMod M)ˣ,F u + let T := ∑ u : ι → (ZMod M)ˣ,‖F u‖ + have hv : 0 ≤ v := by dsimp [v]; positivity + have hmass := jointAbsMass_le_of_error N lo hi Z F (principalMass M lo hi Z) error heAbs + have hdisc := smooth_freezing_bound N lo hi Z (fun i => (hZ i).le) F f hD hm hwidth hf hd hbase + have hdisc' : ‖smoothJointTestSum N M lo hi Z F f-f₀*jointComplexTestSum N M lo hi Z F‖ ≤ + v*((principalMass M lo hi Z+error)*T) := + hdisc.trans (mul_le_mul_of_nonneg_left hmass hv) + have hap : ‖f₀*jointComplexTestSum N M lo hi Z F-f₀*((principalMass M lo hi Z:ℂ)*S)‖ ≤ + ‖f₀‖*(error*T) := by + rw [← mul_sub,norm_mul] + exact mul_le_mul_of_nonneg_left he (norm_nonneg _) + have hint := residue_integral_freezing_bound M Z lo hi hZ hlo horder f hD hm hwidth hf hd hbase + have hint' : ‖(principalMass M lo hi Z:ℂ)*f₀-principalIntegral M lo hi Z f‖ ≤ + v*principalMass M lo hi Z := by + rw [norm_sub_rev] + simpa only [principalIntegral,principalMass,Complex.real_smul] using hint + have hmain : ‖f₀*((principalMass M lo hi Z:ℂ)*S)-principalIntegral M lo hi Z f*S‖ ≤ + (v*principalMass M lo hi Z)*T := by + have heq : f₀*((principalMass M lo hi Z:ℂ)*S)-principalIntegral M lo hi Z f*S = + ((principalMass M lo hi Z:ℂ)*f₀-principalIntegral M lo hi Z f)*S := by ring + rw [heq,norm_mul] + have hnonneg : 0 ≤ v*principalMass M lo hi Z := (norm_nonneg _).trans hint' + exact mul_le_mul hint' (norm_sum_le _ _) (norm_nonneg _) hnonneg + calc + _ ≤ ‖smoothJointTestSum N M lo hi Z F f-f₀*jointComplexTestSum N M lo hi Z F‖+ + ‖f₀*jointComplexTestSum N M lo hi Z F-f₀*((principalMass M lo hi Z:ℂ)*S)‖+ + ‖f₀*((principalMass M lo hi Z:ℂ)*S)-principalIntegral M lo hi Z f*S‖ := by + have h₁ := norm_sub_le_norm_sub_add_norm_sub + (smoothJointTestSum N M lo hi Z F f) (f₀*jointComplexTestSum N M lo hi Z F) + (principalIntegral M lo hi Z f*S) + have h₂ := norm_sub_le_norm_sub_add_norm_sub (f₀*jointComplexTestSum N M lo hi Z F) + (f₀*((principalMass M lo hi Z:ℂ)*S)) (principalIntegral M lo hi Z f*S) + simpa only [add_assoc] using h₁.trans (add_le_add le_rfl h₂) + _ ≤ v*((principalMass M lo hi Z+error)*T)+‖f₀‖*(error*T)+(v*principalMass M lo hi Z)*T := + add_le_add (add_le_add hdisc' hap) hmain + _ = _ := by dsimp only [v,f₀,T]; ring + +end Ostmann.Arithmetic.PrimeCellReplacement + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeHarmonicError.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeHarmonicError.lean new file mode 100644 index 0000000000000000000000000000000000000000..f0a7822f73f9c7a098ed046522ddf4a8a4de406b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeHarmonicError.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.ZeroDensity.ThetaMainTerm + +namespace OAI + +/-! # Quantitative transfer from theta errors to harmonic interval errors -/ + +namespace Ostmann + +open MeasureTheory + +/-- Partial summation loses only endpoint weights and the variation of the +harmonic weight. The theta estimate is used on exactly this interval. -/ +theorem primeHarmonic_error_le (q a : ℕ) (φ χ β : ℝ) (hβ : β ≠ 0) + {u v : ℝ} (hu : 1 < u) (huv : u ≤ v) + (E B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hθ : ∀ t ∈ Set.Icc u v, |primeProgressionTheta q a t - thetaMainTerm φ χ β t| ≤ E) + (hf : ∀ t ∈ Set.Icc u v, |primeHarmonicWeight t| ≤ B) + (hdf : ∀ t ∈ Set.Icc u v, |primeHarmonicDerivative t| ≤ D) : + |reciprocalPrimeInterval q a u v - + ∫ t in Set.Ioc u v, primeHarmonicWeight t * thetaMainDensity φ χ β t| ≤ + E * (2 * B + (v - u) * D) := by + let A := primeProgressionTheta q a + let M := thetaMainTerm φ χ β + let f := primeHarmonicWeight + let f' := primeHarmonicDerivative + have hdint : IntegrableOn f' (Set.Icc u v) := + (continuousOn_primeHarmonicDerivative hu).integrableOn_Icc + have hAint : IntegrableOn (fun t => f' t * A t) (Set.Icc u v) := + integrableOn_mul_sum_Icc (primeProgressionLog q a) + (le_of_lt (lt_trans zero_lt_one hu)) hdint + have hMcont : ContinuousOn M (Set.Icc u v) := by + intro x hx + exact (hasDerivAt_thetaMainTerm φ χ β hβ + (lt_trans zero_lt_one (lt_of_lt_of_le hu hx.1))).continuousAt.continuousWithinAt + have hMint : IntegrableOn (fun t => f' t * M t) (Set.Icc u v) := + ((continuousOn_primeHarmonicDerivative hu).mul hMcont).integrableOn_Icc + have hsub : (∫ t in Set.Ioc u v, f' t * A t) - + (∫ t in Set.Ioc u v, f' t * M t) = ∫ t in Set.Ioc u v, f' t * (A t - M t) := by + rw [← integral_sub (hAint.mono_set Set.Ioc_subset_Icc_self) + (hMint.mono_set Set.Ioc_subset_Icc_self)] + apply setIntegral_congr_fun measurableSet_Ioc + intro t _ + dsimp + ring + have heq : reciprocalPrimeInterval q a u v - + (∫ t in Set.Ioc u v, f t * thetaMainDensity φ χ β t) = + f v * (A v - M v) - f u * (A u - M u) - + ∫ t in Set.Ioc u v, f' t * (A t - M t) := by + rw [reciprocalPrimeInterval_eq_partialSummation q a hu huv, + thetaMain_harmonic_integral φ χ β hβ hu huv, ← hsub] + dsimp [f, f', A, M] + ring + have hbound (t : ℝ) (ht : t ∈ Set.Icc u v) : |f t * (A t - M t)| ≤ B * E := by + rw [abs_mul] + exact mul_le_mul (hf t ht) (hθ t ht) (abs_nonneg _) hB + have hi := intervalIntegral.norm_integral_le_of_norm_le_const + (a := u) (b := v) (C := D * E) (f := fun t => f' t * (A t - M t)) (fun t ht => by + have ht' : t ∈ Set.Icc u v := Set.Ioc_subset_Icc_self ((Set.uIoc_of_le huv) ▸ ht) + rw [norm_mul, Real.norm_eq_abs, Real.norm_eq_abs] + exact mul_le_mul (hdf t ht') (hθ t ht') (abs_nonneg _) hD) + rw [intervalIntegral.integral_of_le huv, Real.norm_eq_abs, + abs_of_nonneg (sub_nonneg.mpr huv)] at hi + rw [heq] + have h1 := norm_sub_le (f v * (A v - M v)) (f u * (A u - M u)) + have h2 := norm_sub_le (f v * (A v - M v) - f u * (A u - M u)) + (∫ t in Set.Ioc u v, f' t * (A t - M t)) + simp only [Real.norm_eq_abs] at h1 h2 + have hv := hbound v ⟨huv, le_rfl⟩ + have hu' := hbound u ⟨le_rfl, huv⟩ + nlinarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeIntegerTransfer.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeIntegerTransfer.lean new file mode 100644 index 0000000000000000000000000000000000000000..4c8d5cf43546c61cf3a8cf06b2c6722c2c619c2e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeIntegerTransfer.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.Ostmann.Preliminaries.TransferCauchy +import OAI.NumberTheory.Ostmann.Construction.PrimePriorAtoms + +namespace OAI + +/-! # Extending the nonnegative transfer square from primes to integers -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem prime_prior_integer_extension (S T : Finset ℕ) (hST : S ⊆ T) + (w : ℝ → ℝ) (Z u : ℝ) (hZ : 0 ≤ Z) (hu : 0 ≤ u) + (hpos : ∀ p ∈ S, p ≠ 0) (hw : ∀ n ∈ T, 0 ≤ w (Real.log n)) + (F : ℕ → ℝ) (hF : ∀ n ∈ T, 0 ≤ F n) : + (∑ p : S, primeSamplePrior S w Z p * (((p : ℕ) : ℝ) * u * F p)) ≤ + Z * ∑ n ∈ T, w (Real.log n) * u * F n := by + calc + _ = ∑ p : S, Z * (w (Real.log (p : ℕ)) * u * F p) := by + apply Finset.sum_congr rfl + intro p _ + calc + _ = (((p : ℕ) : ℝ) * primeSamplePrior S w Z p) * (u * F p) := by ring + _ = _ := by rw [primeSamplePrior_value_mul S w Z p (hpos p p.property)]; ring + _ = Z * ∑ n ∈ S, w (Real.log n) * u * F n := by + rw [← Finset.mul_sum] + congr 1 + exact Finset.sum_coe_sort S (fun n : ℕ => w (Real.log n) * u * F n) + _ ≤ _ := mul_le_mul_of_nonneg_left + (Finset.sum_le_sum_of_subset_of_nonneg hST + (fun n hn _ => mul_nonneg (mul_nonneg (hw n hn) hu) (hF n hn))) hZ + +/-- This is the finite version of the prime-to-integer extension in +equation (53), using the original reciprocal-prime prior exactly. -/ +theorem prime_integer_transfer_bound (S T : Finset ℕ) (hST : S ⊆ T) + (w : ℝ → ℝ) (Z u : ℝ) (hZ : 0 ≤ Z) (hu : 0 ≤ u) + (hpos : ∀ p ∈ S, p ≠ 0) (hw : ∀ n ∈ T, 0 ≤ w (Real.log n)) + (hmass : (∑ p : S, primeSamplePrior S w Z p) = 1) + {A : S → Type*} [∀ p, Fintype (A p)] + (row coefficient : ∀ p, A p → ℂ) + (hrow : ∀ p : S, (∑ a, ‖row p a‖ ^ 2) ≤ ((p : ℕ) : ℝ) * u) + (F : ℕ → ℝ) (hF : ∀ n ∈ T, 0 ≤ F n) + (hcoeff : ∀ p : S, (∑ a, ‖coefficient p a‖ ^ 2) ≤ F p) : + ‖∑ p : S, (primeSamplePrior S w Z p : ℂ) * ∑ a, row p a * coefficient p a‖ ^ 2 ≤ + Z * ∑ n ∈ T, w (Real.log n) * u * F n := by + have hμ (p : S) : 0 ≤ primeSamplePrior S w Z p := + primeSamplePrior_nonneg S w Z hZ (fun p hp => hw p (hST hp)) p + apply (finite_transfer_row_bound _ hμ hmass row coefficient _ hrow).trans + apply le_trans _ (prime_prior_integer_extension S T hST w Z u hZ hu hpos hw F hF) + apply Finset.sum_le_sum + intro p _ + apply mul_le_mul_of_nonneg_left _ (hμ p) + exact mul_le_mul_of_nonneg_left (hcoeff p) (mul_nonneg (Nat.cast_nonneg _) hu) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeIntervalVariation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeIntervalVariation.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff7bc9d3ee4eea89145fcc87386e624d1effc1c7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeIntervalVariation.lean @@ -0,0 +1,81 @@ +import Mathlib.Algebra.BigOperators.Intervals +import OAI.NumberTheory.Ostmann.ZeroDensity.UniformPrimeProgressions +import OAI.NumberTheory.Ostmann.Characters.WeightedPhaseExtraction + +namespace OAI + +/-! # Weighted short prime intervals from the published progression input -/ + +namespace Ostmann +open MeasureTheory +open scoped BigOperators + +theorem reciprocalPrimeInterval_add (q a : ℕ) (u v w : ℝ) (huv : u ≤ v) (hvw : v ≤ w) : + reciprocalPrimeInterval q a u v + reciprocalPrimeInterval q a v w = + reciprocalPrimeInterval q a u w := by + exact Finset.sum_Ioc_consecutive _ (Nat.floor_le_floor huv) (Nat.floor_le_floor hvw) + +theorem primeLogDensity_integral_add (φ χ β u v w : ℝ) (hu : 0 < u) (huv : u ≤ v) (hvw : v ≤ w) : + (∫ y in Set.Ioc u v, primeLogDensity φ χ β y) + + (∫ y in Set.Ioc v w, primeLogDensity φ χ β y) = + ∫ y in Set.Ioc u w, primeLogDensity φ χ β y := by + rw [← intervalIntegral.integral_of_le huv, ← intervalIntegral.integral_of_le hvw, + ← intervalIntegral.integral_of_le (huv.trans hvw)] + exact intervalIntegral.integral_add_adjacent_intervals + ((continuousOn_primeLogDensity φ χ β hu).intervalIntegrable_of_Icc huv) + ((continuousOn_primeLogDensity φ χ β (hu.trans_le huv)).intervalIntegrable_of_Icc hvw) + +/-- The reference density is the actual selected Page-corrected density. +It stays inside the integral throughout weighted summation. -/ +noncomputable def selectedPrimeLogDensity (P : PublishedProgressionInput) (Q q a : ℕ) : ℝ → ℝ := + primeLogDensity (Nat.totient q) + (pageCoefficient (pageAtModulus q (selectedPageZero P Q)) a) + (pageBeta (pageAtModulus q (selectedPageZero P Q))) + +/-- Finite Abel summation turns the uniform interval error into a variation +error for the actual complex weights. There is no factor for the number of +partition intervals. -/ +theorem PublishedProgressionInput.weighted_prime_interval_variation + (P : PublishedProgressionInput) {Q q a : ℕ} + (hQ : 2 ≤ Q) (hq : 1 ≤ q) (hqQ : q ≤ Q) (ha : a.Coprime q) + (s : ℕ → ℝ) (hs : Monotone s) (hs0 : 1 ≤ s 0) (N : ℕ) (hshort : s N ≤ s 0 + 1) + (w : ℕ → ℂ) : + ‖∑ j ∈ Finset.range N, w j * + ((reciprocalPrimeInterval q a (Real.exp (s j)) (Real.exp (s (j + 1))) - + ∫ y in Set.Ioc (s j) (s (j + 1)), selectedPrimeLogDensity P Q q a y : ℝ) : ℂ)‖ ≤ + discreteVariation w N * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s 0)) + + Real.exp (-P.kappa * s 0 / Real.log (4 * (Q : ℝ)))) := by + let E : ℝ → ℝ := fun t => reciprocalPrimeInterval q a (Real.exp (s 0)) (Real.exp t) - + ∫ y in Set.Ioc (s 0) t, selectedPrimeLogDensity P Q q a y + have hzero : E (s 0) = 0 := by simp [E, reciprocalPrimeInterval] + have hstep (j : ℕ) : + reciprocalPrimeInterval q a (Real.exp (s j)) (Real.exp (s (j + 1))) - + (∫ y in Set.Ioc (s j) (s (j + 1)), selectedPrimeLogDensity P Q q a y) = + E (s (j + 1)) - E (s j) := by + have hp := reciprocalPrimeInterval_add q a (Real.exp (s 0)) (Real.exp (s j)) + (Real.exp (s (j + 1))) (Real.exp_le_exp.mpr (hs (Nat.zero_le _))) + (Real.exp_le_exp.mpr (hs (Nat.le_succ _))) + have hi := primeLogDensity_integral_add (Nat.totient q) + (pageCoefficient (pageAtModulus q (selectedPageZero P Q)) a) + (pageBeta (pageAtModulus q (selectedPageZero P Q))) (s 0) (s j) (s (j + 1)) + (by linarith) (hs (Nat.zero_le _)) (hs (Nat.le_succ _)) + change (∫ y in Set.Ioc (s 0) (s j), selectedPrimeLogDensity P Q q a y) + + (∫ y in Set.Ioc (s j) (s (j + 1)), selectedPrimeLogDensity P Q q a y) = + (∫ y in Set.Ioc (s 0) (s (j + 1)), selectedPrimeLogDensity P Q q a y) at hi + dsimp only [E] + linarith + have hprefix (k : ℕ) (hk : k ≤ N) : + ‖∑ j ∈ Finset.range k, ((E (s (j + 1)) - E (s j) : ℝ) : ℂ)‖ ≤ + 18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s 0)) + + Real.exp (-P.kappa * s 0 / Real.log (4 * (Q : ℝ))) := by + rw [← Complex.ofReal_sum, Finset.sum_range_sub (fun j => E (s j)), hzero, sub_zero, + Complex.norm_real, Real.norm_eq_abs] + exact P.uniform_log_interval hQ hq hqQ ha hs0 (hs (Nat.zero_le k)) + ((hs hk).trans hshort) + simp_rw [hstep] + exact weighted_sum_le_variation w _ N _ hprefix + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamilies.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..f4c73e29fff939f9348fff0d82c388a33446d339 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamilies.lean @@ -0,0 +1,3 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeLineFamiliesRepeated + + diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesBasic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..a2633057f3dc758e60348c93d0c6b4a0c6b83230 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesBasic.lean @@ -0,0 +1,116 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeLines + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeLineFamilies +variable {ι K : Type*} [Field K] + +def CommonZero (a b : ι → K) (z : Kˣ × Kˣ) : Prop := + ∀ i, a i * (z.1 : K) + b i * (z.2 : K) = 0 + +def Solutions (a b : ι → K) := {z : Kˣ × Kˣ // CommonZero a b z} + +def minor (a b : ι → K) (i j : ι) : K := a i * b j - b i * a j + +def AllZero (a b : ι → K) : Prop := ∀ i, a i = 0 ∧ b i = 0 + +def AllMinorsZero (a b : ι → K) : Prop := ∀ i j, minor a b i j = 0 + +theorem rank_two_empty (a b : ι → K) (i j : ι) (hij : minor a b i j ≠ 0) + (z : Kˣ × Kˣ) : ¬ CommonZero a b z := by + intro hz + exact PrimeLines.rank_two_impossible (a i) (b i) (a j) (b j) + (z.1 : K) (z.2 : K) hij (Units.ne_zero z.2) (hz i) (hz j) + +theorem single_coefficient_empty (a b : ι → K) (i : ι) + (hi : (a i = 0 ∧ b i ≠ 0) ∨ (a i ≠ 0 ∧ b i = 0)) + (z : Kˣ × Kˣ) : ¬ CommonZero a b z := by + intro hz + rcases hi with hi | hi + · exact PrimeLines.no_unit_solution_of_zero_coefficient hi.1 hi.2 z.1 z.2 (hz i) + · have h := hz i + rw [hi.2, zero_mul, add_zero] at h + exact mul_ne_zero hi.1 (Units.ne_zero z.1) h + +theorem all_zero_common (a b : ι → K) (hz : AllZero a b) (z : Kˣ × Kˣ) : + CommonZero a b z := by + intro i + simp only [(hz i).1, (hz i).2, zero_mul, zero_add] + +theorem commonZero_iff_row (a b : ι → K) (i : ι) (hai : a i ≠ 0) + (hm : ∀ j, minor a b i j = 0) (z : Kˣ × Kˣ) : + CommonZero a b z ↔ a i * (z.1 : K) + b i * (z.2 : K) = 0 := by + refine ⟨fun hz => hz i, ?_⟩ + intro hi j + have hd := hm j + change a i * b j - b i * a j = 0 at hd + have he : a i * (a j * (z.1 : K) + b j * (z.2 : K)) = 0 := by + linear_combination a j * hi + (z.2 : K) * hd + exact (mul_eq_zero.mp he).resolve_left hai + +def unitLineEquiv (a b : ι → K) (i : ι) (hai : a i ≠ 0) (hbi : b i ≠ 0) + (hm : ∀ j, minor a b i j = 0) : Solutions a b ≃ Kˣ := + (Equiv.subtypeEquivRight (fun z => commonZero_iff_row a b i hai hm z)).trans + (PrimeLines.unitLineEquiv (a i) (b i) hai hbi) + +def allZeroEquiv (a b : ι → K) (hz : AllZero a b) : + Solutions a b ≃ Kˣ × Kˣ where + toFun z := z.val + invFun z := ⟨z, all_zero_common a b hz z⟩ + left_inv _ := rfl + right_inv _ := rfl + +theorem solutions_nonempty_iff (a b : ι → K) : + Nonempty (Solutions a b) ↔ AllZero a b ∨ + (AllMinorsZero a b ∧ ∃ i, a i ≠ 0 ∧ b i ≠ 0) := by + classical + constructor + · rintro ⟨z⟩ + by_cases hz : AllZero a b + · exact Or.inl hz + · right + have hm : AllMinorsZero a b := by + intro i j + by_contra hij + exact rank_two_empty a b i j hij z.val z.property + refine ⟨hm, ?_⟩ + obtain ⟨i, hi⟩ : ∃ i, ¬ (a i = 0 ∧ b i = 0) := by + simpa only [AllZero, not_forall] using hz + have ha : a i ≠ 0 := by + intro ha + have hb : b i ≠ 0 := fun hb => hi ⟨ha, hb⟩ + exact single_coefficient_empty a b i (Or.inl ⟨ha, hb⟩) z.val z.property + have hb : b i ≠ 0 := by + intro hb + exact single_coefficient_empty a b i (Or.inr ⟨ha, hb⟩) z.val z.property + exact ⟨i, ha, hb⟩ + · rintro (hz | ⟨hm, i, hai, hbi⟩) + · exact ⟨(allZeroEquiv a b hz).symm (1, 1)⟩ + · exact ⟨(unitLineEquiv a b i hai hbi (hm i)).symm 1⟩ + +theorem card_rank_one [Fintype K] [DecidableEq K] (a b : ι → K) (i : ι) + (hai : a i ≠ 0) (hbi : b i ≠ 0) (hm : ∀ j, minor a b i j = 0) : + Nat.card (Solutions a b) = Fintype.card Kˣ := by + rw [Nat.card_congr (unitLineEquiv a b i hai hbi hm), Nat.card_eq_fintype_card] + +theorem card_all_zero [Fintype K] [DecidableEq K] (a b : ι → K) (hz : AllZero a b) : + Nat.card (Solutions a b) = Fintype.card (Kˣ × Kˣ) := by + rw [Nat.card_congr (allZeroEquiv a b hz), Nat.card_eq_fintype_card] + +theorem card_rank_two (a b : ι → K) (i j : ι) (hij : minor a b i j ≠ 0) : + Nat.card (Solutions a b) = 0 := by + have : IsEmpty (Solutions a b) := ⟨fun z => rank_two_empty a b i j hij z.val z.property⟩ + simp + +theorem card_single_coefficient (a b : ι → K) (i : ι) + (hi : (a i = 0 ∧ b i ≠ 0) ∨ (a i ≠ 0 ∧ b i = 0)) : + Nat.card (Solutions a b) = 0 := by + have : IsEmpty (Solutions a b) := + ⟨fun z => single_coefficient_empty a b i hi z.val z.property⟩ + simp + +end Ostmann.Arithmetic.PrimeLineFamilies +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesProbability.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..fe3229766759477aee841c0cceeb2dd2688e5bae --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesProbability.lean @@ -0,0 +1,67 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeLineFamiliesBasic + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeLineFamilies +variable {ι : Type*} (p : ℕ) [Fact p.Prime] + +def probability (a b : ι → ZMod p) : ℝ := + (Nat.card (Solutions a b) : ℝ) / Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) + +theorem probability_rank_one (a b : ι → ZMod p) (i : ι) + (hai : a i ≠ 0) (hbi : b i ≠ 0) (hm : ∀ j, minor a b i j = 0) : + probability p a b = ((p-1 : ℕ) : ℝ)⁻¹ := by + rw [probability, card_rank_one a b i hai hbi hm, Fintype.card_prod, ZMod.card_units] + have hp1 : 0 < p-1 := Nat.sub_pos_of_lt (Fact.out : p.Prime).one_lt + push_cast + field_simp + +theorem probability_all_zero (a b : ι → ZMod p) (hz : AllZero a b) : + probability p a b = 1 := by + rw [probability, card_all_zero a b hz] + exact div_self (Nat.cast_ne_zero.mpr Fintype.card_ne_zero) + +theorem probability_rank_two (a b : ι → ZMod p) (i j : ι) + (hij : minor a b i j ≠ 0) : probability p a b = 0 := by + simp only [probability, card_rank_two a b i j hij, Nat.cast_zero, zero_div] + +theorem probability_single_coefficient (a b : ι → ZMod p) (i : ι) + (hi : (a i = 0 ∧ b i ≠ 0) ∨ (a i ≠ 0 ∧ b i = 0)) : + probability p a b = 0 := by + simp only [probability, card_single_coefficient a b i hi, Nat.cast_zero, zero_div] + +theorem probability_eq_flags (a b : ι → ZMod p) : + probability p a b = (by + classical + exact if AllZero a b then 1 + else if AllMinorsZero a b ∧ ∃ i, a i ≠ 0 ∧ b i ≠ 0 + then ((p-1 : ℕ) : ℝ)⁻¹ else 0) := by + classical + by_cases hz : AllZero a b + · simp only [hz, ite_true] + exact probability_all_zero p a b hz + · simp only [hz, ite_false] + by_cases hr : AllMinorsZero a b ∧ ∃ i, a i ≠ 0 ∧ b i ≠ 0 + · simp only [hr] + obtain ⟨hm, i, hai, hbi⟩ := hr + exact probability_rank_one p a b i hai hbi (hm i) + · simp only [hr, ite_false] + have : IsEmpty (Solutions a b) := ⟨fun z => by + have h := (solutions_nonempty_iff a b).mp ⟨z⟩ + exact h.elim hz hr⟩ + simp only [probability, Nat.card_of_isEmpty, Nat.cast_zero, zero_div] + +theorem probability_le_unit_line (a b : ι → ZMod p) (hz : ¬ AllZero a b) : + probability p a b ≤ ((p-1 : ℕ) : ℝ)⁻¹ := by + classical + rw [probability_eq_flags] + simp only [hz, ite_false] + split_ifs + · exact le_rfl + · positivity + +end Ostmann.Arithmetic.PrimeLineFamilies +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..7e1fe730e64c3e4f06d5b207553c972fe2125edb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesProduct.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeLineFamiliesProbability +import OAI.NumberTheory.Ostmann.Arithmetic.RepeatedLabels + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeLineFamilies +open scoped BigOperators + +def independentEquiv {κ : Type*} (I : κ → Type*) (K : κ → Type*) + [∀ k, Field (K k)] (a b : ∀ k, I k → K k) : + {z : ∀ k, (K k)ˣ × (K k)ˣ // ∀ k, CommonZero (a k) (b k) (z k)} ≃ + ∀ k, Solutions (a k) (b k) where + toFun z k := ⟨z.val k, z.property k⟩ + invFun z := ⟨fun k => (z k).val, fun k => (z k).property⟩ + left_inv _ := rfl + right_inv _ := rfl + +theorem independent_card {κ : Type*} [Fintype κ] (I : κ → Type*) (K : κ → Type*) + [∀ k, Field (K k)] (a b : ∀ k, I k → K k) : + Nat.card {z : ∀ k, (K k)ˣ × (K k)ˣ // ∀ k, CommonZero (a k) (b k) (z k)} = + ∏ k, Nat.card (Solutions (a k) (b k)) := by + rw [Nat.card_congr (independentEquiv I K a b), Nat.card_pi] + +variable {κ : Type*} [Fintype κ] [DecidableEq κ] (I : κ → Type*) (p : κ → ℕ) + [∀ k, Fact (p k).Prime] + +def independentProbability (a b : ∀ k, I k → ZMod (p k)) : ℝ := + (Nat.card {z : ∀ k, (ZMod (p k))ˣ × (ZMod (p k))ˣ // + ∀ k, CommonZero (a k) (b k) (z k)} : ℝ) / + Fintype.card (∀ k, (ZMod (p k))ˣ × (ZMod (p k))ˣ) + +theorem independentProbability_eq (a b : ∀ k, I k → ZMod (p k)) : + independentProbability I p a b = ∏ k, probability (p k) (a k) (b k) := by + classical + simp only [independentProbability, independent_card, Fintype.card_pi, + Nat.cast_prod, probability, Finset.prod_div_distrib] + +theorem weighted_independentProbability {ι : Type*} + (s : Finset ι) (label : ι → κ) (a b : ∀ k, I k → ZMod (p k)) : + (∏ i ∈ s, (p (label i) : ℝ)) * independentProbability I p a b = + ∏ k, (p k : ℝ) ^ RepeatedLabels.multiplicity s label k * + probability (p k) (a k) (b k) := by + rw [RepeatedLabels.product_by_multiplicity s label (fun k => (p k : ℝ)), + independentProbability_eq, + Finset.prod_mul_distrib] + +end Ostmann.Arithmetic.PrimeLineFamilies +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesRepeated.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesRepeated.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9254f5fc9d139dc5435811a88dfebef27f2636a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineFamiliesRepeated.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeLineFamiliesProduct + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeLineFamilies +open scoped BigOperators +variable {ι κ : Type*} (label : ι → κ) (p : κ → ℕ) [∀ k, Fact (p k).Prime] + +def LabeledCommonZero + (a b : ∀ k, {i // label i = k} → ZMod (p k)) + (z : ∀ k, (ZMod (p k))ˣ × (ZMod (p k))ˣ) : Prop := + ∀ i, a (label i) ⟨i, rfl⟩ * ((z (label i)).1 : ZMod (p (label i))) + + b (label i) ⟨i, rfl⟩ * ((z (label i)).2 : ZMod (p (label i))) = 0 + +theorem labeledCommonZero_iff + (a b : ∀ k, {i // label i = k} → ZMod (p k)) + (z : ∀ k, (ZMod (p k))ˣ × (ZMod (p k))ˣ) : + LabeledCommonZero label p a b z ↔ ∀ k, CommonZero (a k) (b k) (z k) := by + constructor + · intro h k ⟨i, hi⟩ + subst k + exact h i + · intro h i + exact h (label i) ⟨i, rfl⟩ + +def labeledEquiv (a b : ∀ k, {i // label i = k} → ZMod (p k)) : + {z : ∀ k, (ZMod (p k))ˣ × (ZMod (p k))ˣ // LabeledCommonZero label p a b z} ≃ + ∀ k, Solutions (a k) (b k) := + (Equiv.subtypeEquivRight (labeledCommonZero_iff label p a b)).trans + (independentEquiv (fun k => {i // label i = k}) (fun k => ZMod (p k)) a b) + +theorem labeled_probability [Fintype κ] [DecidableEq κ] + (a b : ∀ k, {i // label i = k} → ZMod (p k)) : + (Nat.card {z : ∀ k, (ZMod (p k))ˣ × (ZMod (p k))ˣ // + LabeledCommonZero label p a b z} : ℝ) / + Fintype.card (∀ k, (ZMod (p k))ˣ × (ZMod (p k))ˣ) = + ∏ k, probability (p k) (a k) (b k) := by + classical + rw [Nat.card_congr (labeledEquiv label p a b), Nat.card_pi] + simp only [Fintype.card_pi, Nat.cast_prod, probability, Finset.prod_div_distrib] + +theorem representative_domination {η : Type*} [DecidableEq η] {J : Type*} + (q : ℕ) [Fact q.Prime] (a b : J → ZMod q) (hz : ¬ AllZero a b) + (s : Finset η) {i₀ : η} (hi₀ : i₀ ∈ s) {B : ℝ} (hB : 0 ≤ B) + (μ : η → ℝ) (hμ : ∀ i ∈ s, 0 ≤ μ i) + (hbound : ∀ i ∈ s, (q : ℝ) * μ i ≤ B) : + ((∏ i ∈ s, μ i) * (q : ℝ) ^ s.card) * probability q a b ≤ + 2 * μ i₀ * B ^ (s.card-1) := by + have hq : 2 ≤ (q : ℝ) := by exact_mod_cast (Fact.out : q.Prime).two_le + have hw : 0 ≤ (∏ i ∈ s, μ i) * (q : ℝ) ^ s.card := + mul_nonneg (Finset.prod_nonneg hμ) (pow_nonneg (Nat.cast_nonneg q) _) + calc + _ ≤ ((∏ i ∈ s, μ i) * (q : ℝ) ^ s.card) * ((q-1 : ℕ) : ℝ)⁻¹ := + mul_le_mul_of_nonneg_left (probability_le_unit_line q a b hz) hw + _ = ((∏ i ∈ s, μ i) * (q : ℝ) ^ s.card) / ((q : ℝ)-1) := by + rw [Nat.cast_sub (Fact.out : q.Prime).one_lt.le] + simp only [Nat.cast_one, div_eq_mul_inv] + _ ≤ _ := RepeatedLabels.representative_domination s hi₀ hq hB μ hμ hbound + +end Ostmann.Arithmetic.PrimeLineFamilies +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineScalar.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineScalar.lean new file mode 100644 index 0000000000000000000000000000000000000000..188fa72bae4fff3f7c846fca85c7edbacdc48d0c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLineScalar.lean @@ -0,0 +1,73 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternExternalPrior + +namespace OAI + +/-! # The bounded cost of restricting both giants to prime residues -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem internalLineScalar_prime_le_twice (p : ℕ) (hp : p.Prime) : + internalLineScalar false p ≤ 2 * internalLineScalar true p := by + have hsub : 0 < p - 1 := Nat.sub_pos_of_lt hp.one_lt + have hpos : (0 : ℝ) < p := Nat.cast_pos.mpr hp.pos + have hsubpos : (0 : ℝ) < (p - 1 : ℕ) := Nat.cast_pos.mpr hsub + have hsize : (p : ℝ) ≤ 2 * (p - 1 : ℕ) := by + have h := Nat.sub_add_cancel hp.one_le + have := hp.two_le + exact_mod_cast (show p ≤ 2 * (p - 1) by omega) + simp only [internalLineScalar, Bool.false_eq_true, ite_false, ite_true] + have h : (1 : ℝ) / (p - 1 : ℕ) ≤ 2 / p := by + apply (div_le_div_iff₀ hsubpos hpos).mpr + simpa only [one_mul] using hsize + simpa only [div_eq_mul_inv, one_mul] using h + +theorem prime_line_scalar_product_le {C : Type*} [Fintype C] + (p : C → ℕ) (hp : ∀ c, (p c).Prime) : + (∏ c, internalLineScalar false (p c)) ≤ + (2 : ℝ) ^ Fintype.card C * ∏ c, internalLineScalar true (p c) := by + calc + _ ≤ ∏ c, (2 * internalLineScalar true (p c)) := + Finset.prod_le_prod₀ (fun c _ => internalLineScalar_nonneg false (p c)) + (fun c _ => internalLineScalar_prime_le_twice (p c) (hp c)) + _ = _ := by simp only [Finset.prod_mul_distrib, Finset.prod_const, Finset.card_univ] + +/-- The change of giant law costs two per internal equality class, never per +external or bulk coordinate. -/ +theorem movingPattern_fin_prime_prior_bound {A B C : Type*} + [Fintype B] [Fintype C] {N : ℕ} + (e : Fin (N + 1) ≃ B ⊕ C) (μ : ℕ → A → ℝ) (ν : B → A → ℝ) (prime : A → ℕ) + (n : ℕ) (pattern : Bool × MovingSampleIndex n → C) + (rep : ∀ c, {i : Bool × MovingSampleIndex n // pattern i = c}) (E : ℝ) + (hprime : ∀ a, (prime a).Prime) (hμ : ∀ j a, 0 ≤ μ j a) (hν : ∀ j a, 0 ≤ ν j a) + (hbound : ∀ j a, (prime a : ℝ) * μ j a ≤ E) + (G : (Fin (N + 1) → A) → ℂ) (D : ℝ) (hD : 0 ≤ D) (hG : ∀ x, ‖G x‖ ≤ D) + (x : Fin (N + 1) → A) : + let W := ((∏ b, ν b (x (e.symm (.inl b))) : ℝ) : ℂ) * + (movingPairCompensatedMass μ prime ((movingSamplePairCoordinates A n).symm + (fun i => x (e.symm (.inr (pattern i))))) : ℂ) * G x + ‖W‖ * (∏ c, internalLineScalar false (prime (x (e.symm (.inr c))))) ≤ + (D * ((4 : ℝ) ^ Fintype.card C * E ^ (4 * n * 2 ^ n - Fintype.card C))) * + productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x := by + intro W + have h := movingPattern_fin_prior_bound e μ ν prime n pattern rep E hprime hμ hν hbound + G D hD hG x + have hc := prime_line_scalar_product_le (fun c => prime (x (e.symm (.inr c)))) + (fun _ => hprime _) + calc + _ ≤ ‖W‖ * ((2 : ℝ) ^ Fintype.card C * + ∏ c, internalLineScalar true (prime (x (e.symm (.inr c))))) := + mul_le_mul_of_nonneg_left hc (norm_nonneg _) + _ = (2 : ℝ) ^ Fintype.card C * (‖W‖ * + ∏ c, internalLineScalar true (prime (x (e.symm (.inr c))))) := by ring + _ ≤ (2 : ℝ) ^ Fintype.card C * ((D * ((2 : ℝ) ^ Fintype.card C * + E ^ (4 * n * 2 ^ n - Fintype.card C))) * + productPrior (fun i => Sum.elim ν + (fun c => μ (movingSampleTier (rep c).val.2)) (e i)) x) := + mul_le_mul_of_nonneg_left h (by positivity) + _ = _ := by rw [show (4 : ℝ) = 2 * 2 by norm_num, mul_pow]; ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLines.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLines.lean new file mode 100644 index 0000000000000000000000000000000000000000..31be0f22e4e6011e7d5db97f3d09d9f43df2560b --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeLines.lean @@ -0,0 +1,82 @@ +import Mathlib + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeLines +open scoped BigOperators + +variable {K : Type*} [Field K] + +def mixedLineEquiv (a b : K) (ha : a ≠ 0) : + {z : K × Kˣ // a*z.1 + b*(z.2 : K) = 0} ≃ Kˣ where + toFun z := z.val.2 + invFun y := ⟨((-b*(y:K))/a,y), by dsimp; field_simp; ring⟩ + left_inv z := by + apply Subtype.ext + apply Prod.ext + · dsimp + apply (div_eq_iff ha).2 + linear_combination -z.property + · rfl + right_inv _ := rfl + +def unitLineEquiv (a b : K) (ha : a ≠ 0) (hb : b ≠ 0) : + {z : Kˣ × Kˣ // a*(z.1 : K) + b*(z.2 : K) = 0} ≃ Kˣ where + toFun z := z.val.2 + invFun y := ⟨(Units.mk0 ((-b*(y:K))/a) + (div_ne_zero (mul_ne_zero (neg_ne_zero.mpr hb) (Units.ne_zero y)) ha), y), by + dsimp; field_simp; ring⟩ + left_inv z := by + apply Subtype.ext + apply Prod.ext + · apply Units.ext + dsimp + apply (div_eq_iff ha).2 + linear_combination -z.property + · rfl + right_inv _ := rfl + +theorem rank_two_impossible (a b c d x y : K) + (hdet : a*d-b*c ≠ 0) (hy : y ≠ 0) + (h₁ : a*x+b*y=0) (h₂ : c*x+d*y=0) : False := by + have h : (a*d-b*c)*y=0 := by linear_combination a*h₂-c*h₁ + exact (mul_ne_zero hdet hy) h + +theorem no_unit_solution_of_zero_coefficient {a b : K} (ha : a = 0) (hb : b ≠ 0) + (x y : Kˣ) : a*(x:K)+b*(y:K) ≠ 0 := by + simp only [ha, zero_mul, zero_add] + exact mul_ne_zero hb (Units.ne_zero y) + +theorem card_mixed_line [Fintype K] [DecidableEq K] (a b : K) (ha : a ≠ 0) : + Nat.card {z : K × Kˣ // a*z.1+b*(z.2:K)=0} = Fintype.card Kˣ := by + rw [Nat.card_congr (mixedLineEquiv a b ha), Nat.card_eq_fintype_card] + +theorem card_unit_line [Fintype K] [DecidableEq K] (a b : K) (ha : a ≠ 0) (hb : b ≠ 0) : + Nat.card {z : Kˣ × Kˣ // a*(z.1:K)+b*(z.2:K)=0} = Fintype.card Kˣ := by + rw [Nat.card_congr (unitLineEquiv a b ha hb), Nat.card_eq_fintype_card] + +theorem prime_mixed_probability (p : ℕ) [Fact p.Prime] + (a b : ZMod p) (ha : a ≠ 0) : + (Nat.card {z : ZMod p × (ZMod p)ˣ // a*z.1+b*(z.2:ZMod p)=0} : ℝ) / + Fintype.card (ZMod p × (ZMod p)ˣ) = (p:ℝ)⁻¹ := by + rw [card_mixed_line a b ha, Fintype.card_prod, ZMod.card, ZMod.card_units] + have hp : 0 < p := (Fact.out : p.Prime).pos + have hp1 : 0 < p-1 := Nat.sub_pos_of_lt (Fact.out : p.Prime).one_lt + push_cast + field_simp + +theorem prime_unit_probability (p : ℕ) [Fact p.Prime] + (a b : ZMod p) (ha : a ≠ 0) (hb : b ≠ 0) : + (Nat.card {z : (ZMod p)ˣ × (ZMod p)ˣ // a*(z.1:ZMod p)+b*(z.2:ZMod p)=0} : ℝ) / + Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) = ((p-1:ℕ):ℝ)⁻¹ := by + rw [card_unit_line a b ha hb, Fintype.card_prod, ZMod.card_units] + have hp1 : 0 < p-1 := Nat.sub_pos_of_lt (Fact.out : p.Prime).one_lt + push_cast + field_simp + +end Ostmann.Arithmetic.PrimeLines + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamilies.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..5a57dd274399b22bb23cc8d7626aa9238c94556a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamilies.lean @@ -0,0 +1,3 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeMixedLineFamiliesRepeated + + diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesBasic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..361aa44842500b64159619e425d97e0f33cd3098 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesBasic.lean @@ -0,0 +1,108 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeLines + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeMixedLineFamilies +variable {ι K : Type*} [Field K] + +def CommonZero (a b : ι → K) (z : K × Kˣ) : Prop := + ∀ i, a i * z.1 + b i * (z.2 : K) = 0 + +def Solutions (a b : ι → K) := {z : K × Kˣ // CommonZero a b z} + +def minor (a b : ι → K) (i j : ι) : K := a i*b j-b i*a j + +def AllZero (a b : ι → K) : Prop := ∀ i, a i=0 ∧ b i=0 + +def AllMinorsZero (a b : ι → K) : Prop := ∀ i j, minor a b i j=0 + +theorem rank_two_empty (a b : ι → K) (i j : ι) (hij : minor a b i j ≠ 0) + (z : K × Kˣ) : ¬ CommonZero a b z := by + intro hz + exact PrimeLines.rank_two_impossible (a i) (b i) (a j) (b j) + z.1 (z.2 : K) hij (Units.ne_zero z.2) (hz i) (hz j) + +theorem zero_external_coefficient_empty (a b : ι → K) (i : ι) + (hai : a i=0) (hbi : b i≠0) (z : K × Kˣ) : ¬ CommonZero a b z := by + intro hz + have h := hz i + rw [hai,zero_mul,zero_add] at h + exact mul_ne_zero hbi (Units.ne_zero z.2) h + +theorem all_zero_common (a b : ι → K) (hz : AllZero a b) (z : K × Kˣ) : + CommonZero a b z := by + intro i + simp only [(hz i).1,(hz i).2,zero_mul,zero_add] + +theorem commonZero_iff_row (a b : ι → K) (i : ι) (hai : a i≠0) + (hm : ∀ j, minor a b i j=0) (z : K × Kˣ) : + CommonZero a b z ↔ a i*z.1+b i*(z.2:K)=0 := by + refine ⟨fun hz => hz i,?_⟩ + intro hi j + have hd := hm j + change a i*b j-b i*a j=0 at hd + have he : a i*(a j*z.1+b j*(z.2:K))=0 := by + linear_combination a j*hi+(z.2:K)*hd + exact (mul_eq_zero.mp he).resolve_left hai + +def mixedLineEquiv (a b : ι → K) (i : ι) (hai : a i≠0) + (hm : ∀ j, minor a b i j=0) : Solutions a b ≃ Kˣ := + (Equiv.subtypeEquivRight (fun z => commonZero_iff_row a b i hai hm z)).trans + (PrimeLines.mixedLineEquiv (a i) (b i) hai) + +def allZeroEquiv (a b : ι → K) (hz : AllZero a b) : Solutions a b ≃ K × Kˣ where + toFun z := z.val + invFun z := ⟨z,all_zero_common a b hz z⟩ + left_inv _ := rfl + right_inv _ := rfl + +theorem solutions_nonempty_iff (a b : ι → K) : + Nonempty (Solutions a b) ↔ AllZero a b ∨ + (AllMinorsZero a b ∧ ∃ i, a i≠0) := by + classical + constructor + · rintro ⟨z⟩ + by_cases hz : AllZero a b + · exact Or.inl hz + · right + have hm : AllMinorsZero a b := by + intro i j + by_contra hij + exact rank_two_empty a b i j hij z.val z.property + refine ⟨hm,?_⟩ + obtain ⟨i,hi⟩ : ∃ i, ¬ (a i=0 ∧ b i=0) := by + simpa only [AllZero,not_forall] using hz + refine ⟨i,?_⟩ + intro ha + have hb : b i≠0 := fun hb => hi ⟨ha,hb⟩ + exact zero_external_coefficient_empty a b i ha hb z.val z.property + · rintro (hz | ⟨hm,i,hai⟩) + · exact ⟨(allZeroEquiv a b hz).symm (0,1)⟩ + · exact ⟨(mixedLineEquiv a b i hai (hm i)).symm 1⟩ + +theorem card_rank_one [Fintype K] [DecidableEq K] (a b : ι → K) (i : ι) + (hai : a i≠0) (hm : ∀ j, minor a b i j=0) : + Nat.card (Solutions a b) = Fintype.card Kˣ := by + rw [Nat.card_congr (mixedLineEquiv a b i hai hm),Nat.card_eq_fintype_card] + +theorem card_all_zero [Fintype K] [DecidableEq K] (a b : ι → K) (hz : AllZero a b) : + Nat.card (Solutions a b) = Fintype.card (K × Kˣ) := by + rw [Nat.card_congr (allZeroEquiv a b hz),Nat.card_eq_fintype_card] + +theorem card_rank_two (a b : ι → K) (i j : ι) (hij : minor a b i j≠0) : + Nat.card (Solutions a b)=0 := by + have : IsEmpty (Solutions a b) := ⟨fun z => rank_two_empty a b i j hij z.val z.property⟩ + simp + +theorem card_zero_external_coefficient (a b : ι → K) (i : ι) (hai : a i=0) (hbi : b i≠0) : + Nat.card (Solutions a b)=0 := by + have : IsEmpty (Solutions a b) := + ⟨fun z => zero_external_coefficient_empty a b i hai hbi z.val z.property⟩ + simp + +end Ostmann.Arithmetic.PrimeMixedLineFamilies + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesProbability.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..1e6af2a8871e549f8291b0221452e678a902a34c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesProbability.lean @@ -0,0 +1,72 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeMixedLineFamiliesBasic + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeMixedLineFamilies +variable {ι : Type*} (p : ℕ) [Fact p.Prime] + +def probability (a b : ι → ZMod p) : ℝ := + (Nat.card (Solutions a b):ℝ) / Fintype.card (ZMod p × (ZMod p)ˣ) + +theorem probability_rank_one (a b : ι → ZMod p) (i : ι) + (hai : a i≠0) (hm : ∀ j, minor a b i j=0) : probability p a b=(p:ℝ)⁻¹ := by + rw [probability,card_rank_one a b i hai hm,Fintype.card_prod,ZMod.card,ZMod.card_units] + have hp : 0

by + have hh := (solutions_nonempty_iff a b).mp ⟨z⟩ + exact hh.elim hz hr⟩ + simp only [probability,Nat.card_of_isEmpty,Nat.cast_zero,zero_div] + +theorem probability_le_mixed_line (a b : ι → ZMod p) (hz : ¬ AllZero a b) : + probability p a b ≤ (p:ℝ)⁻¹ := by + classical + rw [probability_eq_flags] + simp only [hz,ite_false] + split_ifs + · exact le_rfl + · positivity + +theorem probability_le_unit_line (a b : ι → ZMod p) (hz : ¬ AllZero a b) : + probability p a b ≤ ((p-1:ℕ):ℝ)⁻¹ := by + apply (probability_le_mixed_line p a b hz).trans + apply inv_anti₀ + · exact_mod_cast Nat.sub_pos_of_lt (Fact.out : p.Prime).one_lt + · exact_mod_cast Nat.sub_le p 1 + +end Ostmann.Arithmetic.PrimeMixedLineFamilies + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesProduct.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesProduct.lean new file mode 100644 index 0000000000000000000000000000000000000000..938097226b0b0403e9188b3cbdd295aba966ba17 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesProduct.lean @@ -0,0 +1,52 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeMixedLineFamiliesProbability +import OAI.NumberTheory.Ostmann.Arithmetic.RepeatedLabels + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeMixedLineFamilies +open scoped BigOperators + +def independentEquiv {κ : Type*} (I : κ → Type*) (K : κ → Type*) + [∀ k, Field (K k)] (a b : ∀ k, I k → K k) : + {z : ∀ k, K k × (K k)ˣ // ∀ k, CommonZero (a k) (b k) (z k)} ≃ + ∀ k, Solutions (a k) (b k) where + toFun z k := ⟨z.val k, z.property k⟩ + invFun z := ⟨fun k => (z k).val, fun k => (z k).property⟩ + left_inv _ := rfl + right_inv _ := rfl + +theorem independent_card {κ : Type*} [Fintype κ] (I : κ → Type*) (K : κ → Type*) + [∀ k, Field (K k)] (a b : ∀ k, I k → K k) : + Nat.card {z : ∀ k, K k × (K k)ˣ // ∀ k, CommonZero (a k) (b k) (z k)} = + ∏ k, Nat.card (Solutions (a k) (b k)) := by + rw [Nat.card_congr (independentEquiv I K a b), Nat.card_pi] + +variable {κ : Type*} [Fintype κ] [DecidableEq κ] (I : κ → Type*) (p : κ → ℕ) + [∀ k, Fact (p k).Prime] + +def independentProbability (a b : ∀ k, I k → ZMod (p k)) : ℝ := + (Nat.card {z : ∀ k, ZMod (p k) × (ZMod (p k))ˣ // + ∀ k, CommonZero (a k) (b k) (z k)} : ℝ) / + Fintype.card (∀ k, ZMod (p k) × (ZMod (p k))ˣ) + +theorem independentProbability_eq (a b : ∀ k, I k → ZMod (p k)) : + independentProbability I p a b = ∏ k, probability (p k) (a k) (b k) := by + classical + simp only [independentProbability, independent_card, Fintype.card_pi, + Nat.cast_prod, probability, Finset.prod_div_distrib] + +theorem weighted_independentProbability {ι : Type*} + (s : Finset ι) (label : ι → κ) (a b : ∀ k, I k → ZMod (p k)) : + (∏ i ∈ s, (p (label i) : ℝ)) * independentProbability I p a b = + ∏ k, (p k : ℝ) ^ RepeatedLabels.multiplicity s label k * + probability (p k) (a k) (b k) := by + rw [RepeatedLabels.product_by_multiplicity s label (fun k => (p k : ℝ)), + independentProbability_eq, + Finset.prod_mul_distrib] + +end Ostmann.Arithmetic.PrimeMixedLineFamilies + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesRepeated.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesRepeated.lean new file mode 100644 index 0000000000000000000000000000000000000000..c2f50fbcb9246a693c36edfc57f6f6ae5b5fe7bd --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeMixedLineFamiliesRepeated.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeMixedLineFamiliesProduct + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeMixedLineFamilies +open scoped BigOperators +variable {ι κ : Type*} (label : ι → κ) (p : κ → ℕ) [∀ k, Fact (p k).Prime] + +def LabeledCommonZero + (a b : ∀ k, {i // label i = k} → ZMod (p k)) + (z : ∀ k, ZMod (p k) × (ZMod (p k))ˣ) : Prop := + ∀ i, a (label i) ⟨i, rfl⟩ * ((z (label i)).1 : ZMod (p (label i))) + + b (label i) ⟨i, rfl⟩ * ((z (label i)).2 : ZMod (p (label i))) = 0 + +theorem labeledCommonZero_iff + (a b : ∀ k, {i // label i = k} → ZMod (p k)) + (z : ∀ k, ZMod (p k) × (ZMod (p k))ˣ) : + LabeledCommonZero label p a b z ↔ ∀ k, CommonZero (a k) (b k) (z k) := by + constructor + · intro h k ⟨i, hi⟩ + subst k + exact h i + · intro h i + exact h (label i) ⟨i, rfl⟩ + +def labeledEquiv (a b : ∀ k, {i // label i = k} → ZMod (p k)) : + {z : ∀ k, ZMod (p k) × (ZMod (p k))ˣ // LabeledCommonZero label p a b z} ≃ + ∀ k, Solutions (a k) (b k) := + (Equiv.subtypeEquivRight (labeledCommonZero_iff label p a b)).trans + (independentEquiv (fun k => {i // label i = k}) (fun k => ZMod (p k)) a b) + +theorem labeled_probability [Fintype κ] [DecidableEq κ] + (a b : ∀ k, {i // label i = k} → ZMod (p k)) : + (Nat.card {z : ∀ k, ZMod (p k) × (ZMod (p k))ˣ // + LabeledCommonZero label p a b z} : ℝ) / + Fintype.card (∀ k, ZMod (p k) × (ZMod (p k))ˣ) = + ∏ k, probability (p k) (a k) (b k) := by + classical + rw [Nat.card_congr (labeledEquiv label p a b), Nat.card_pi] + simp only [Fintype.card_pi, Nat.cast_prod, probability, Finset.prod_div_distrib] + +theorem representative_domination {η : Type*} [DecidableEq η] {J : Type*} + (q : ℕ) [Fact q.Prime] (a b : J → ZMod q) (hz : ¬ AllZero a b) + (s : Finset η) {i₀ : η} (hi₀ : i₀ ∈ s) {B : ℝ} (hB : 0 ≤ B) + (μ : η → ℝ) (hμ : ∀ i ∈ s, 0 ≤ μ i) + (hbound : ∀ i ∈ s, (q : ℝ) * μ i ≤ B) : + ((∏ i ∈ s, μ i) * (q : ℝ) ^ s.card) * probability q a b ≤ + 2 * μ i₀ * B ^ (s.card-1) := by + have hq : 2 ≤ (q : ℝ) := by exact_mod_cast (Fact.out : q.Prime).two_le + have hw : 0 ≤ (∏ i ∈ s, μ i) * (q : ℝ) ^ s.card := + mul_nonneg (Finset.prod_nonneg hμ) (pow_nonneg (Nat.cast_nonneg q) _) + calc + _ ≤ ((∏ i ∈ s, μ i) * (q : ℝ) ^ s.card) * ((q-1 : ℕ) : ℝ)⁻¹ := + mul_le_mul_of_nonneg_left (probability_le_unit_line q a b hz) hw + _ = ((∏ i ∈ s, μ i) * (q : ℝ) ^ s.card) / ((q : ℝ)-1) := by + rw [Nat.cast_sub (Fact.out : q.Prime).one_lt.le] + simp only [Nat.cast_one, div_eq_mul_inv] + _ ≤ _ := RepeatedLabels.representative_domination s hi₀ hq hB μ hμ hbound + +end Ostmann.Arithmetic.PrimeMixedLineFamilies + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePairDecay.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePairDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..083fcc5f4f63b40095e53bb7e42455d31d67e6f7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePairDecay.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.Ostmann.Construction.PrimeOriginalPair +import OAI.NumberTheory.Ostmann.Characters.DyadicCharacterBudget + +namespace OAI + +/-! # Numerical decay with all range, unit and large-prime support costs -/ + +namespace Ostmann + +open scoped BigOperators +open Filter + +theorem eventual_ranged_word_pair_decay {σ : Type*} {n : ℕ} + (K z α β γ c : ℝ) (d : ℕ) + (hK : 0 ≤ K) (hz : 0 ≤ z) (hα : 0 < α) (hαβ : α < β) + (hγβ : γ < β) (hc : 0 < c) : + ∀ᶠ L : ℝ in atTop, + ∀ (template template' : WordTransferTemplate σ n) + (D D' : WordRangeDecoration σ n) (t t' : FrequencyTree ℤ n) + (ht : NonzeroInternalFrequencies n t) (ht' : NonzeroInternalFrequencies n t') + (B A E : ℕ) (f f' : WordFourierParameters n) (P Q : Finset ℕ) + (lower : ℝ) (Bq : ℕ) (m : ℝ), + 0 ≤ m → m ≤ z * L → + Real.exp (c * Real.exp (α * L)) ≤ lower → + Real.exp (Real.exp (β * L)) ≤ (A : ℝ) → + (Bq : ℝ) ≤ Real.exp (Real.exp (γ * L)) → + 2 * ((Nat.log 2 E + 1 : ℕ) : ℝ) * (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ * + (f.budget template t ht * f'.budget template' t' ht') ^ 2 ≤ + Real.exp (K * (1 + m) ^ d) → + 2 * ((Nat.log 2 E + 1 : ℕ) : ℝ) * (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B : ℕ) * + (3 ^ (2 * (((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)) + + ((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)))) : ℕ) * + (f.budget template t ht * f'.budget template' t' ht') ^ 2 ≤ + Real.exp (K * (1 + m) ^ d) → + rangedWordTransferPairBound template template' D D' t t' ht ht' B f f' + A E P Q lower Bq ≤ (Real.exp (-(c / 4) * Real.exp (α * L))) ^ 2 := by + filter_upwards [eventual_one_sided_squared_budget K z α β γ c d hK hz hα hαβ hγβ hc] + with L hL template template' D D' t t' ht ht' B A E f f' P Q lower Bq m + hm hmL hlower hA hBq hcost₁ hcost₂ + have hh := dyadic_character_numeric_bound + ((Nat.log 2 E + 1 : ℕ) : ℝ) (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ (∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ + (wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B : ℕ) + (3 ^ (2 * (((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)) + + ((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)))) : ℕ) + (f.budget template t ht * f'.budget template' t' ht') A lower Bq + (Real.exp (K * (1 + m) ^ d)) α β γ c L + (by positivity) (by positivity) (by positivity) (by positivity) (by positivity) + hlower hA (Nat.cast_nonneg _) hBq hcost₁ hcost₂ + apply hh.trans + apply (hL m hm hmL).trans_eq + rw [← Real.exp_nat_mul] + congr 1 + ring + +/-- Point-mass and polynomial history losses remain negligible alongside the +already proved one-sided character error. -/ +theorem eventual_prime_support_decay (K z α c : ℝ) (d : ℕ) + (hK : 0 ≤ K) (hz : 0 ≤ z) (hα : 0 < α) (hc : 0 < c) : + ∀ᶠ L : ℝ in atTop, ∀ (m δ loss atom value : ℝ), + 0 ≤ m → m ≤ z * L → 0 ≤ loss → + loss ≤ Real.exp (K * (1 + m) ^ d) → + atom ≤ Real.exp (-c * Real.exp (α * L)) → + δ ≤ Real.exp (-(c / 4) * Real.exp (α * L)) → + value ≤ δ + loss * atom → value ≤ Real.exp (-(c / 8) * Real.exp (α * L)) := by + have hpoly := eventual_polynomial_log_budget K z α (c / 2) d hK hz hα (by positivity) + have htwo := eventual_diagonal_atom_error 0 z α (c / 4) d (by norm_num) hz hα (by positivity) + filter_upwards [hpoly, htwo] with L hpoly htwo m δ loss atom value hm hmL hloss hcost hatom hδ hv + have he : loss * atom ≤ Real.exp (-(c / 2) * Real.exp (α * L)) := by + calc + _ ≤ loss * Real.exp (-c * Real.exp (α * L)) := mul_le_mul_of_nonneg_left hatom hloss + _ ≤ Real.exp (K * (1 + m) ^ d) * Real.exp (-c * Real.exp (α * L)) := + mul_le_mul_of_nonneg_right hcost (Real.exp_nonneg _) + _ = Real.exp (K * (1 + m) ^ d - c * Real.exp (α * L)) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (by linarith [hpoly m hm hmL]) + have he' : Real.exp (-(c / 2) * Real.exp (α * L)) ≤ + Real.exp (-(c / 4) * Real.exp (α * L)) := by + apply Real.exp_le_exp.mpr + nlinarith [Real.exp_pos (α * L)] + have hh := htwo m hm hmL + simp only [zero_mul, zero_sub] at hh + calc + value ≤ δ + loss * atom := hv + _ ≤ Real.exp (-(c / 4) * Real.exp (α * L)) + Real.exp (-(c / 4) * Real.exp (α * L)) := + add_le_add hδ (he.trans he') + _ = 2 * Real.exp (-(c / 4) * Real.exp (α * L)) := by ring + _ ≤ _ := by convert hh using 1 <;> congr 2 <;> ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePairHaarRegularity.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePairHaarRegularity.lean new file mode 100644 index 0000000000000000000000000000000000000000..9cfea3629bfc7c33130a662d7b8fbf8975d59017 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePairHaarRegularity.lean @@ -0,0 +1,84 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingSeparatedAverageNorm +import OAI.NumberTheory.Ostmann.Arithmetic.HarmonicPairIntegral + +namespace OAI + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators + +theorem continuous_pageGiantWeight (P : PublishedProgressionInput) (Q q a : ℕ) : + Continuous (pageGiantWeight P Q q a) := by + unfold pageGiantWeight pageMultiplier + fun_prop + +theorem continuous_correctedPrimePairAverage (P : PublishedProgressionInput) (Q q : ℕ) + [NeZero q] (c : ℕ → ℕ → ℂ) : + Continuous (Function.uncurry (correctedPrimePairAverage P Q q c)) := by + unfold correctedPrimePairAverage Function.uncurry + apply continuous_const.mul + apply continuous_finsetSum + intro z _ + exact ((continuous_const.mul ((continuous_pageGiantWeight P Q q _).comp continuous_fst)).mul + ((continuous_pageGiantWeight P Q q _).comp continuous_snd)) + +theorem correctedPrimePairAverage_norm_le (P : PublishedProgressionInput) (Q q : ℕ) + [NeZero q] (c : ℕ → ℕ → ℂ) (A : ℝ) (hA : 0 ≤ A) + (hc : ∀ a : (ZMod q)ˣ, ∀ b : (ZMod q)ˣ, + ‖c (a : ZMod q).val (b : ZMod q).val‖ ≤ A) + (x y : ℝ) (hx : 0 ≤ x) (hy : 0 ≤ y) : + ‖correctedPrimePairAverage P Q q c x y‖ ≤ 4 * A := by + have hcard : (Fintype.card ((ZMod q)ˣ × (ZMod q)ˣ) : ℝ) ≠ 0 := by + exact_mod_cast Fintype.card_ne_zero + have hpoint (z : (ZMod q)ˣ × (ZMod q)ˣ) : + ‖c (z.1 : ZMod q).val (z.2 : ZMod q).val * + pageGiantWeight P Q q (z.1 : ZMod q).val x * + pageGiantWeight P Q q (z.2 : ZMod q).val y‖ ≤ 4 * A := by + simp only [norm_mul] + calc + _ ≤ A * 2 * 2 := + mul_le_mul (mul_le_mul (hc z.1 z.2) (pageGiantWeight_norm_le_two P Q q _ x hx) + (norm_nonneg _) hA) (pageGiantWeight_norm_le_two P Q q _ y hy) + (norm_nonneg _) (by positivity) + _ = _ := by ring + unfold correctedPrimePairAverage + rw [norm_mul, norm_inv, Complex.norm_natCast] + calc + _ ≤ (Fintype.card ((ZMod q)ˣ × (ZMod q)ˣ) : ℝ)⁻¹ * ∑ _z : (ZMod q)ˣ × (ZMod q)ˣ, 4 * A := + mul_le_mul_of_nonneg_left + ((norm_sum_le _ _).trans (Finset.sum_le_sum (fun z _ => hpoint z))) (by positivity) + _ = 4 * A := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + rw [← mul_assoc, inv_mul_cancel₀ hcard, one_mul] + +/-- The finite external average may have a different CRT modulus for every +assignment. Its pointwise arithmetic bound passes through both giant cells. -/ +theorem prime_pair_haar_sum_norm {A : Type*} [Fintype A] + (P : PublishedProgressionInput) (Q : ℕ) (q : A → ℕ) [∀ a, NeZero (q a)] + (c : A → ℕ → ℕ → ℂ) (H : A → ℝ → ℝ → ℂ) + (hH : ∀ a, Measurable (Function.uncurry (H a))) + (K B : A → ℝ) (hK : ∀ a, 0 ≤ K a) (hB : ∀ a, 0 ≤ B a) + (hbound : ∀ a x y, ‖H a x y‖ ≤ K a) + (hc : ∀ a, ∀ z : (ZMod (q a))ˣ, ∀ w : (ZMod (q a))ˣ, + ‖c a (z : ZMod (q a)).val (w : ZMod (q a)).val‖ ≤ B a) + (u v r s C : ℝ) (hu : 1 ≤ u) (hr : 1 ≤ r) + (huv : u ≤ v) (hrs : r ≤ s) (hv : v ≤ u + 1) (hs : s ≤ r + 1) + (hC : 0 ≤ C) (w : A → ℂ) + (hmean : ∀ x ∈ Set.Ioc u v, ∀ y ∈ Set.Ioc r s, + ‖∑ a, w a * (H a x y * correctedPrimePairAverage P Q (q a) (c a) x y)‖ ≤ C) : + ‖∑ a, w a * ∫ x in Set.Ioc u v, ∫ y in Set.Ioc r s, + H a x y * correctedPrimePairAverage P Q (q a) (c a) x y / ((x : ℂ) * (y : ℂ))‖ ≤ + C / (u * r) := by + apply finite_harmonic_pair_sum_norm u v r s C hu hr huv hrs hv hs hC w + (fun a x y => H a x y * correctedPrimePairAverage P Q (q a) (c a) x y) + (fun a => (hH a).mul (continuous_correctedPrimePairAverage P Q (q a) (c a)).measurable) + (fun a => K a * (4 * B a)) (fun a => mul_nonneg (hK a) (mul_nonneg (by norm_num) (hB a))) _ hmean + intro a x hx y hy + rw [norm_mul] + exact mul_le_mul (hbound a x y) + (correctedPrimePairAverage_norm_le P Q (q a) (c a) (B a) (hB a) (hc a) x y + (by linarith [hx.1]) (by linarith [hy.1])) (norm_nonneg _) (hK a) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePairResidues.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePairResidues.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6608200a2920987978535711f66efc439f83132 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePairResidues.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ResidueIntervals + +namespace OAI + +/-! # The original two giant sums as a finite residue-pair sum -/ + +namespace Ostmann +open scoped BigOperators Classical + +theorem finite_pair_comparison {A B : Type*} (S : Finset A) (T : Finset B) + (F G : A → B → ℂ) (δ : ℝ) (h : ∀ a ∈ S, ∀ b ∈ T, ‖F a b - G a b‖ ≤ δ) : + ‖(∑ a ∈ S, ∑ b ∈ T, F a b) - (∑ a ∈ S, ∑ b ∈ T, G a b)‖ ≤ + (S.card : ℝ) * T.card * δ := by + simp only [← Finset.sum_sub_distrib] + calc + _ ≤ ∑ a ∈ S, ‖∑ b ∈ T, (F a b - G a b)‖ := norm_sum_le _ _ + _ ≤ ∑ a ∈ S, ∑ b ∈ T, δ := by + apply Finset.sum_le_sum + intro a ha + exact (norm_sum_le _ _).trans (Finset.sum_le_sum fun b hb => h a ha b hb) + _ = _ := by simp; ring + +theorem prime_pair_residue_factorization (q : ℕ) (hq : 0 < q) (u v r s : ℝ) + (hu : ∀ p ∈ Finset.Ioc ⌊Real.exp u⌋₊ ⌊Real.exp v⌋₊, p.Prime → q < p) + (hr : ∀ p ∈ Finset.Ioc ⌊Real.exp r⌋₊ ⌊Real.exp s⌋₊, p.Prime → q < p) + (F : ℕ → ℕ → ℂ) (c : ℕ → ℕ → ℂ) (H : ℝ → ℝ → ℂ) + (hfactor : ∀ p ∈ Finset.Ioc ⌊Real.exp u⌋₊ ⌊Real.exp v⌋₊, p.Prime → + ∀ t ∈ Finset.Ioc ⌊Real.exp r⌋₊ ⌊Real.exp s⌋₊, t.Prime → + ∀ a ∈ reducedResidues q, ∀ b ∈ reducedResidues q, + Nat.ModEq q p a → Nat.ModEq q t b → + F p t = c a b * H (Real.log p) (Real.log t)) : + complexPrimeInterval 1 0 r s (fun y => complexPrimeInterval 1 0 u v + (fun x => F ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊)) = + ∑ b ∈ reducedResidues q, ∑ a ∈ reducedResidues q, + complexPrimeInterval q b r s (fun y => complexPrimeInterval q a u v + (fun x => c a b * H x y)) := by + rw [complexPrimeInterval_residues q hq r s hr] + apply Finset.sum_congr rfl + intro b hb + rw [← complexPrimeInterval_finset_sum] + apply complexPrimeInterval_congr + intro t ht hprime htb + have ht0 : (0 : ℝ) < t := by exact_mod_cast hprime.pos + rw [Real.exp_log ht0, Nat.floor_natCast, complexPrimeInterval_residues q hq u v hu] + apply Finset.sum_congr rfl + intro a ha + apply complexPrimeInterval_congr + intro p hp hpp hpa + have hp0 : (0 : ℝ) < p := by exact_mod_cast hpp.pos + rw [Real.exp_log hp0, Nat.floor_natCast] + exact hfactor p hp hpp t ht hprime a ha b hb hpa htb + +theorem mixed_pair_residue_factorization (q : ℕ) (hq : 0 < q) (u v r s J : ℝ) + (hr : ∀ p ∈ Finset.Ioc ⌊Real.exp r⌋₊ ⌊Real.exp s⌋₊, p.Prime → q < p) + (F : ℕ → ℕ → ℂ) (c : ℕ → ℕ → ℂ) (H : ℝ → ℝ → ℂ) + (hfactor : ∀ p ∈ Finset.Ioc ⌊Real.exp u⌋₊ ⌊Real.exp v⌋₊, + ∀ t ∈ Finset.Ioc ⌊Real.exp r⌋₊ ⌊Real.exp s⌋₊, t.Prime → + ∀ a ∈ Finset.range q, ∀ b ∈ reducedResidues q, + Nat.ModEq q p a → Nat.ModEq q t b → + F p t = c a b * H (Real.log p) (Real.log t)) : + complexPrimeInterval 1 0 r s (fun y => complexIntegerInterval 1 0 u v J + (fun x => F ⌊Real.exp x⌋₊ ⌊Real.exp y⌋₊)) = + ∑ b ∈ reducedResidues q, ∑ a ∈ Finset.range q, + complexPrimeInterval q b r s (fun y => complexIntegerInterval q a u v J + (fun x => c a b * H x y)) := by + rw [complexPrimeInterval_residues q hq r s hr] + apply Finset.sum_congr rfl + intro b hb + rw [← complexPrimeInterval_finset_sum] + apply complexPrimeInterval_congr + intro t ht hprime htb + have ht0 : (0 : ℝ) < t := by exact_mod_cast hprime.pos + rw [Real.exp_log ht0, Nat.floor_natCast, complexIntegerInterval_residues q hq u v J] + apply Finset.sum_congr rfl + intro a ha + apply complexIntegerInterval_congr + intro p hp hpa + have hp0 : (0 : ℝ) < p := + (Real.exp_pos u).trans (Nat.lt_of_floor_lt (Finset.mem_Ioc.mp hp).1) + rw [Real.exp_log hp0, Nat.floor_natCast] + exact hfactor p hp t ht hprime a ha b hb hpa htb + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePartitionVariation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePartitionVariation.lean new file mode 100644 index 0000000000000000000000000000000000000000..e29dd92fa10762dcb0496e4a324a1c5fdfc69e5c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePartitionVariation.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.Ostmann.ZeroDensity.ComplexPrimeWeights + +namespace OAI + +/-! # Partition approximation without a partition-count loss -/ + +namespace Ostmann +open MeasureTheory +open scoped BigOperators + +theorem complexPrimeInterval_partition (q a : ℕ) (s : ℕ → ℝ) (hs : Monotone s) + (w : ℝ → ℂ) (N : ℕ) : + (∑ j ∈ Finset.range N, complexPrimeInterval q a (s j) (s (j + 1)) w) = + complexPrimeInterval q a (s 0) (s N) w := by + induction N with + | zero => simp [complexPrimeInterval] + | succ N ih => + rw [Finset.sum_range_succ, ih] + exact complexPrimeInterval_add q a _ _ _ w (hs (Nat.zero_le _)) (hs (Nat.le_succ _)) + +theorem reciprocalPrimeInterval_partition (q a : ℕ) (s : ℕ → ℝ) (hs : Monotone s) (N : ℕ) : + (∑ j ∈ Finset.range N, reciprocalPrimeInterval q a (Real.exp (s j)) (Real.exp (s (j + 1)))) = + reciprocalPrimeInterval q a (Real.exp (s 0)) (Real.exp (s N)) := by + induction N with + | zero => simp [reciprocalPrimeInterval] + | succ N ih => + rw [Finset.sum_range_succ, ih] + exact reciprocalPrimeInterval_add q a _ _ _ + (Real.exp_le_exp.mpr (hs (Nat.zero_le _))) (Real.exp_le_exp.mpr (hs (Nat.le_succ _))) + +theorem integral_Ioc_partition {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E] + (s : ℕ → ℝ) (hs : Monotone s) (N : ℕ) (f : ℝ → E) + (hf : ContinuousOn f (Set.Icc (s 0) (s N))) : + (∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), f y) = + ∫ y in Set.Ioc (s 0) (s N), f y := by + have heq (j : ℕ) : (∫ y in Set.Ioc (s j) (s (j + 1)), f y) = + ∫ y in (s j)..(s (j + 1)), f y := + (intervalIntegral.integral_of_le (hs (Nat.le_succ _))).symm + simp_rw [heq] + rw [← intervalIntegral.integral_of_le (hs (Nat.zero_le _))] + apply intervalIntegral.sum_integral_adjacent_intervals + intro j hj + apply (hf.mono ?_).intervalIntegrable_of_Icc (hs (Nat.le_succ _)) + intro y hy + exact ⟨(hs (Nat.zero_le _)).trans hy.1, hy.2.trans (hs (by omega))⟩ + +/-- The oscillation error is proportional to total mass and total interval +length. The progression error is proportional to variation, with neither +error multiplied by the number of intervals. -/ +theorem PublishedProgressionInput.prime_partition_variation (P : PublishedProgressionInput) + {Q q a : ℕ} (hQ : 2 ≤ Q) (hq : 1 ≤ q) (hqQ : q ≤ Q) (ha : a.Coprime q) + (s : ℕ → ℝ) (hs : Monotone s) (hs0 : 1 ≤ s 0) (N : ℕ) (hshort : s N ≤ s 0 + 1) + (w : ℝ → ℂ) (hwc : ContinuousOn w (Set.Icc (s 0) (s N))) (η : ℝ) (hη : 0 ≤ η) + (hw : ∀ j < N, ∀ y ∈ Set.Ioc (s j) (s (j + 1)), ‖w y - w (s j)‖ ≤ η) : + ‖complexPrimeInterval q a (s 0) (s N) w - + ∫ y in Set.Ioc (s 0) (s N), w y * (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + discreteVariation (fun j => w (s j)) N * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s 0)) + + Real.exp (-P.kappa * s 0 / Real.log (4 * (Q : ℝ)))) + + η * (reciprocalPrimeInterval q a (Real.exp (s 0)) (Real.exp (s N)) + + 2 * (s N - s 0)) := by + let A (j : ℕ) := complexPrimeInterval q a (s j) (s (j + 1)) w + let B (j : ℕ) := w (s j) * (reciprocalPrimeInterval q a (Real.exp (s j)) (Real.exp (s (j + 1))) : ℂ) + let C (j : ℕ) := w (s j) * (∫ y in Set.Ioc (s j) (s (j + 1)), selectedPrimeLogDensity P Q q a y : ℝ) + let D (j : ℕ) := ∫ y in Set.Ioc (s j) (s (j + 1)), w y * (selectedPrimeLogDensity P Q q a y : ℂ) + have hρ : ContinuousOn (selectedPrimeLogDensity P Q q a) (Set.Icc (s 0) (s N)) := + continuousOn_primeLogDensity _ _ _ (by linarith) + have hA : ‖∑ j ∈ Finset.range N, (A j - B j)‖ ≤ + η * reciprocalPrimeInterval q a (Real.exp (s 0)) (Real.exp (s N)) := by + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ j ∈ Finset.range N, η * reciprocalPrimeInterval q a (Real.exp (s j)) (Real.exp (s (j + 1))) := by + apply Finset.sum_le_sum + intro j hj + exact complexPrimeInterval_freeze q a _ _ w _ η (hw j (Finset.mem_range.mp hj)) + _ = _ := by rw [← Finset.mul_sum, reciprocalPrimeInterval_partition q a s hs N] + have hD : ‖∑ j ∈ Finset.range N, (C j - D j)‖ ≤ 2 * η * (s N - s 0) := by + apply (norm_sum_le _ _).trans + calc + _ ≤ ∑ j ∈ Finset.range N, 2 * η * (s (j + 1) - s j) := by + apply Finset.sum_le_sum + intro j hj + rw [norm_sub_rev] + apply complex_density_integral_freeze _ _ _ _ _ + (by exact_mod_cast Nat.totient_pos.mpr (by omega : 0 < q)) + (pageCoefficient_abs_le_one _ _) (pageBeta_le_one _) + (hs0.trans (hs (Nat.zero_le _))) (hs (Nat.le_succ _)) w + · apply hwc.mono + intro y hy + exact ⟨(hs (Nat.zero_le _)).trans hy.1, + hy.2.trans (hs (by have := Finset.mem_range.mp hj; omega))⟩ + · exact hη + · exact hw j (Finset.mem_range.mp hj) + _ = _ := by rw [← Finset.mul_sum, Finset.sum_range_sub s] + have hBC : ‖∑ j ∈ Finset.range N, (B j - C j)‖ ≤ + discreteVariation (fun j => w (s j)) N * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s 0)) + + Real.exp (-P.kappa * s 0 / Real.log (4 * (Q : ℝ)))) := by + simpa only [B, C, ← mul_sub, ← Complex.ofReal_sub] using + P.weighted_prime_interval_variation hQ hq hqQ ha s hs hs0 N hshort (fun j => w (s j)) + have hid : complexPrimeInterval q a (s 0) (s N) w - + (∫ y in Set.Ioc (s 0) (s N), w y * (selectedPrimeLogDensity P Q q a y : ℂ)) = + (∑ j ∈ Finset.range N, (A j - B j)) + + (∑ j ∈ Finset.range N, (B j - C j)) + (∑ j ∈ Finset.range N, (C j - D j)) := by + have hcont : ContinuousOn (fun y => w y * (selectedPrimeLogDensity P Q q a y : ℂ)) + (Set.Icc (s 0) (s N)) := hwc.mul (Complex.continuous_ofReal.comp_continuousOn hρ) + rw [← complexPrimeInterval_partition q a s hs w N, + ← integral_Ioc_partition s hs N (fun y => w y * (selectedPrimeLogDensity P Q q a y : ℂ)) hcont] + simp only [Finset.sum_sub_distrib, A, D] + ring + rw [hid] + exact ((norm_add_le _ _).trans (add_le_add (norm_add_le _ _) le_rfl)).trans + (by linarith [add_le_add (add_le_add hA hBC) hD]) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePatternFrequencyNormSum.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePatternFrequencyNormSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..46f5cb89031992856c6e321f3c2b57825a6f9c22 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePatternFrequencyNormSum.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PatternFrequencyNormSum +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePatternUniformBudget + +namespace OAI + +/-! # Summing two-prime arithmetic coefficients with their actual pattern cost -/ + +namespace Ostmann +open scoped Classical BigOperators + +/-- The same retained frequency sum survives summing every equality pattern +of the original internal prime samples. -/ +theorem prime_pattern_frequency_norm_sum_le (S : Finset ℤ) (n N V : ℕ) + (D E K err : ℝ) (hD : 0 ≤ D) (hE : 0 ≤ E) (hK : 0 ≤ K) (herr : 0 ≤ err) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) : + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + ∀ R : Setoid (Bool × MovingSampleIndex n) → FrequencyTree (S × S) n → ℂ, + (∀ s t, ‖R s t‖ ≤ + ((4 : ℝ) ^ Fintype.card (Quotient s) * E ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) * + (err + K * (frequencyLeafWeight (pairedFrequencyLeaf S V) n t * + ((frequencySplitList S n t).map (pairFrequencySupportBound D)).prod))) → + ‖∑ s, ∑ t, R s t‖ ≤ + ((2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) * (max 4 E) ^ (4 * n * 2 ^ n)) * + ((Fintype.card (FrequencyTree (S × S) n) : ℝ) * err + + K * ((8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) * + (2 * (V : ℝ)) ^ (2 * 2 ^ n))) := by + dsimp only + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + intro R hR + let T : ℝ := (Fintype.card (FrequencyTree (S × S) n) : ℝ) * err + + K * ((8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) * + (2 * (V : ℝ)) ^ (2 * 2 ^ n)) + have hlog := Real.log_natCast_nonneg N + have hT : 0 ≤ T := by dsimp only [T]; positivity + have hs (s : Setoid (Bool × MovingSampleIndex n)) : + ‖∑ t, R s t‖ ≤ T * ((4 : ℝ) ^ Fintype.card (Quotient s) * + E ^ (4 * n * 2 ^ n - Fintype.card (Quotient s))) := by + let κ : ℝ := (4 : ℝ) ^ Fintype.card (Quotient s) * + E ^ (4 * n * 2 ^ n - Fintype.card (Quotient s)) + have hκ : 0 ≤ κ := mul_nonneg (by positivity) (pow_nonneg hE _) + have h := paired_frequency_norm_sum_le S n N V D (κ * K) (κ * err) hD + (mul_nonneg hκ hK) hS hdiv (R s) (fun t => by + simpa only [κ, mul_add, mul_assoc] using hR s t) + exact h.trans_eq (by dsimp only [T]; ring) + have h := movingPattern_prime_error_sum_le n E T hE hT (fun s => ∑ t, R s t) hs + exact h.trans_eq (by ring) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePatternUniformBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePatternUniformBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..74d9b599df52f93a5ce1c221259faa046654f48a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePatternUniformBudget.lean @@ -0,0 +1,50 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingPatternUniformBudget + +namespace OAI + +/-! # Equality-pattern costs for two prime giants -/ + +namespace Ostmann +open scoped Classical BigOperators + +theorem movingPattern_prime_loss_le (n r : ℕ) (hr : r ≤ 4 * n * 2 ^ n) + (E : ℝ) (hE : 0 ≤ E) : + (4 : ℝ) ^ r * E ^ (4 * n * 2 ^ n - r) ≤ + (max 4 E) ^ (4 * n * 2 ^ n) := by + have hK : 0 ≤ max (4 : ℝ) E := (by norm_num : (0 : ℝ) ≤ 4).trans (le_max_left _ _) + calc + _ ≤ (max 4 E) ^ r * (max 4 E) ^ (4 * n * 2 ^ n - r) := + mul_le_mul (pow_le_pow_left₀ (by norm_num) (le_max_left _ _) r) + (pow_le_pow_left₀ hE (le_max_right _ _) _) (by positivity) (pow_nonneg hK _) + _ = _ := by rw [← pow_add, Nat.add_sub_of_le hr] + +/-- Summing every original equality pattern introduces only a depth-dependent +factor. The number of protected bulk slots never appears in this cost. -/ +theorem movingPattern_prime_error_sum_le (n : ℕ) (E D : ℝ) (hE : 0 ≤ E) (hD : 0 ≤ D) : + letI := sampleSetoidFintype (Bool × MovingSampleIndex n) + ∀ R : Setoid (Bool × MovingSampleIndex n) → ℂ, + (∀ s, ‖R s‖ ≤ D * ((4 : ℝ) ^ Fintype.card (Quotient s) * + E ^ (4 * n * 2 ^ n - Fintype.card (Quotient s)))) → + ‖∑ s, R s‖ ≤ (2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) * + (D * (max 4 E) ^ (4 * n * 2 ^ n)) := by + let _ := sampleSetoidFintype (Bool × MovingSampleIndex n) + intro R hR + have hp := movingSamplePair_pattern_count n + dsimp only at hp + have hcard : (Fintype.card (Setoid (Bool × MovingSampleIndex n)) : ℝ) ≤ + (2 : ℝ) ^ ((4 * n * 2 ^ n) ^ 2) := by exact_mod_cast hp + calc + ‖∑ s, R s‖ ≤ ∑ s, ‖R s‖ := norm_sum_le _ _ + _ ≤ ∑ _s : Setoid (Bool × MovingSampleIndex n), D * (max 4 E) ^ (4 * n * 2 ^ n) := by + apply Finset.sum_le_sum + intro s _ + exact (hR s).trans (mul_le_mul_of_nonneg_left + (movingPattern_prime_loss_le n _ (movingPattern_quotient_card_le n s) E hE) hD) + _ = (Fintype.card (Setoid (Bool × MovingSampleIndex n)) : ℝ) * + (D * (max 4 E) ^ (4 * n * 2 ^ n)) := by + rw [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + _ ≤ _ := mul_le_mul_of_nonneg_right hcard (by positivity) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePowerSquares.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePowerSquares.lean new file mode 100644 index 0000000000000000000000000000000000000000..b24fcc493d3f69cb53b13ef410b55cfe234fadba --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimePowerSquares.lean @@ -0,0 +1,63 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.TwoPowerSquares + +namespace OAI + +/-! # The simultaneous square-root budget over all prime-power factors -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem prime_power_square_fiber_card_le (p n : ℕ) [Fact p.Prime] + (a : (ZMod (p ^ n))ˣ) : + Nat.card {x : (ZMod (p ^ n))ˣ // x ^ 2 = a} ≤ if p = 2 then 4 else 2 := by + split_ifs with hp + · subst p + exact two_power_square_fiber_card_le n a + · exact odd_prime_power_square_fiber_card_le p n hp a + +theorem distinct_primes_square_budget {I : Type*} [Fintype I] + (p : I → ℕ) (hp : Function.Injective p) : + (∏ i, if p i = 2 then 4 else 2) ≤ 2 ^ (Fintype.card I + 1) := by + by_cases htwo : ∃ i, p i = 2 + · obtain ⟨i, hi⟩ := htwo + have hcard : 1 ≤ Fintype.card I := Fintype.card_pos_iff.mpr ⟨i⟩ + have hrest : (∏ j ∈ (Finset.univ : Finset I).erase i, if p j = 2 then 4 else 2) = + 2 ^ (Fintype.card I - 1) := by + calc + _ = ∏ _j ∈ (Finset.univ : Finset I).erase i, 2 := by + apply Finset.prod_congr rfl + intro j hj + have hji := (Finset.mem_erase.mp hj).1 + have hj2 : p j ≠ 2 := fun hj2 => hji (hp (hj2.trans hi.symm)) + simp only [hj2, ↓reduceIte] + _ = _ := by simp + rw [← Finset.prod_erase_mul (Finset.univ : Finset I) + (fun j => if p j = 2 then 4 else 2) (Finset.mem_univ i), hi, ite_eq_left rfl, hrest] + have hexp : Fintype.card I - 1 + 2 = Fintype.card I + 1 := by omega + calc + _ = 2 ^ (Fintype.card I - 1 + 2) := by rw [pow_add]; norm_num + _ ≤ _ := le_of_eq (by rw [hexp]) + · have hnone : ∀ i, p i ≠ 2 := by simpa using htwo + simp only [hnone, ↓reduceIte, Finset.prod_const, Finset.card_univ] + rw [pow_succ] + omega + +/-- For a modulus presented as a product of distinct prime powers, every +unit square has at most `2^(number of primes + 1)` roots. -/ +theorem prime_powers_square_fiber_card_le {I : Type*} [Fintype I] + (p n : I → ℕ) [∀ i, Fact (p i).Prime] [∀ i, NeZero (p i ^ n i)] + [NeZero (∏ i, p i ^ n i)] (hp : Function.Injective p) + (hc : Pairwise (fun i j => (p i ^ n i).Coprime (p j ^ n j))) + (a : (ZMod (∏ i, p i ^ n i))ˣ) : + Nat.card {x : (ZMod (∏ i, p i ^ n i))ˣ // x ^ 2 = a} ≤ + 2 ^ (Fintype.card I + 1) := by + rw [crt_square_fiber_card (fun i => p i ^ n i) hc a] + calc + _ ≤ ∏ i, if p i = 2 then 4 else 2 := Finset.prod_le_prod fun i _ => + prime_power_square_fiber_card_le (p i) (n i) _ + _ ≤ _ := distinct_primes_square_budget p hp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeProgression.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeProgression.lean new file mode 100644 index 0000000000000000000000000000000000000000..c29d77e381b66db3036a1757bf79a0a72a9cb8cf --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeProgression.lean @@ -0,0 +1,61 @@ +import Mathlib + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeProgression +open scoped BigOperators + +def logPrimeSupport (N : ℕ) (lo hi : ℝ) : Finset ℕ := by + classical + exact (Finset.range (N+1)).filter fun p => + p.Prime ∧ lo ≤ Real.log (p:ℝ) ∧ Real.log (p:ℝ) ≤ hi + +@[simp] theorem mem_logPrimeSupport (N p : ℕ) (lo hi : ℝ) : + p ∈ logPrimeSupport N lo hi ↔ + p ≤ N ∧ p.Prime ∧ lo ≤ Real.log (p:ℝ) ∧ Real.log (p:ℝ) ≤ hi := by + classical + simp [logPrimeSupport] + +def harmonicProgression (N M : ℕ) (a : ZMod M) (lo hi : ℝ) : ℝ := + ∑ p ∈ (logPrimeSupport N lo hi).filter (fun p : ℕ => (p:ZMod M)=a), (p:ℝ)⁻¹ + +def harmonicIntegral (M : ℕ) (lo hi : ℝ) : ℝ := + (Nat.totient M:ℝ)⁻¹ * ∫ t in lo..hi, (t:ℝ)⁻¹ + +def correctedIntegral (M : ℕ) (χa β lo hi : ℝ) : ℝ := + (Nat.totient M:ℝ)⁻¹ * ∫ t in lo..hi, + (1-χa*Real.exp ((β-1)*t))/t + +theorem sum_harmonicProgression (N M : ℕ) [NeZero M] (lo hi : ℝ) : + (∑ a : ZMod M, harmonicProgression N M a lo hi) = + ∑ p ∈ logPrimeSupport N lo hi, (p:ℝ)⁻¹ := by + classical + exact Finset.sum_fiberwise (logPrimeSupport N lo hi) (fun p => (p:ZMod M)) (fun p => (p:ℝ)⁻¹) + +theorem harmonicProgression_nonneg (N M : ℕ) (a : ZMod M) (lo hi : ℝ) : + 0 ≤ harmonicProgression N M a lo hi := + Finset.sum_nonneg fun _ _ => inv_nonneg.mpr (Nat.cast_nonneg _) + +theorem deletion_error (S E : Finset ℕ) (w : ℕ → ℝ) {α : ℝ} + (hα : 0 ≤ α) (hw : ∀ p ∈ S, 0 ≤ w p ∧ w p ≤ α) : + 0 ≤ (∑ p ∈ S, w p) - (∑ p ∈ S \ E, w p) ∧ + (∑ p ∈ S, w p) - (∑ p ∈ S \ E, w p) ≤ E.card*α := by + classical + have hsplit : (∑ p ∈ S, w p) = (∑ p ∈ S \ E, w p)+(∑ p ∈ S ∩ E, w p) := by + rw [← Finset.sum_union (Finset.disjoint_sdiff_inter S E), Finset.sdiff_union_inter] + rw [hsplit,add_sub_cancel_left] + constructor + · exact Finset.sum_nonneg fun p hp => (hw p (Finset.mem_inter.mp hp).1).1 + · calc + _ ≤ ∑ _p ∈ S ∩ E, α := Finset.sum_le_sum fun p hp => + (hw p (Finset.mem_inter.mp hp).1).2 + _ = (S ∩ E).card*α := by simp + _ ≤ E.card*α := mul_le_mul_of_nonneg_right + (by exact_mod_cast Finset.card_le_card (Finset.inter_subset_right (s₁:=S) (s₂:=E))) hα + +end Ostmann.Arithmetic.PrimeProgression + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareFibers.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareFibers.lean new file mode 100644 index 0000000000000000000000000000000000000000..4ab472a99eed134bdd0ca2e4cc6308506bc5cf65 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareFibers.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.Ostmann.Construction.ExternalSquareFibers + +namespace OAI + +/-! # Disintegration of the actual two-prime law at a prime square -/ + +namespace Ostmann +open scoped Classical BigOperators + +noncomputable def primeSquareFiberEquiv (p : ℕ) [Fact p.Prime] + (z : (ZMod p)ˣ × (ZMod p)ˣ) : + {w : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ // + primePairResidueReduction (dvd_pow_self p (by decide : 2 ≠ 0)) w = z} ≃ + SquareLiftPairs p (z.1 : ZMod p) (z.2 : ZMod p) where + toFun w := + (⟨w.1.1, congrArg (fun t : (ZMod p)ˣ × (ZMod p)ˣ => (t.1 : ZMod p)) w.2⟩, + ⟨w.1.2, congrArg (fun t : (ZMod p)ˣ × (ZMod p)ˣ => (t.2 : ZMod p)) w.2⟩) + invFun v := by + have hx : squareReduction p (v.1 : ZMod (p ^ 2)) ≠ 0 := by + rw [v.1.property] + exact Units.ne_zero z.1 + have hy : squareReduction p (v.2 : ZMod (p ^ 2)) ≠ 0 := by + rw [v.2.property] + exact Units.ne_zero z.2 + let ux := ((isUnit_square_iff (v.1 : ZMod (p ^ 2))).mpr hx).unit + let uy := ((isUnit_square_iff (v.2 : ZMod (p ^ 2))).mpr hy).unit + refine ⟨(ux, uy), ?_⟩ + apply Prod.ext <;> apply Units.ext + · change squareReduction p (ux : ZMod (p ^ 2)) = (z.1 : ZMod p) + rw [IsUnit.unit_spec] + exact v.1.property + · change squareReduction p (uy : ZMod (p ^ 2)) = (z.2 : ZMod p) + rw [IsUnit.unit_spec] + exact v.2.property + left_inv w := by + apply Subtype.ext + apply Prod.ext <;> apply Units.ext <;> exact IsUnit.unit_spec _ + right_inv v := by + apply Prod.ext <;> apply Subtype.ext <;> dsimp only <;> exact IsUnit.unit_spec _ + +noncomputable def primeSquareDecompose (p : ℕ) [Fact p.Prime] : + ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) ≃ + Σ z : (ZMod p)ˣ × (ZMod p)ˣ, SquareLiftPairs p (z.1 : ZMod p) (z.2 : ZMod p) := + (Equiv.sigmaFiberEquiv + (primePairResidueReduction (dvd_pow_self p (by decide : 2 ≠ 0)))).symm.trans + (Equiv.sigmaCongrRight (primeSquareFiberEquiv p)) + +theorem primeSquare_average (p : ℕ) [Fact p.Prime] + (F : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ → ℂ) : + (Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * (∑ z, F z) = + (Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) : ℂ)⁻¹ * + ∑ z : (ZMod p)ˣ × (ZMod p)ˣ, ((p : ℂ) ^ 2)⁻¹ * + ∑ v : SquareLiftPairs p (z.1 : ZMod p) (z.2 : ZMod p), + F ((primeSquareDecompose p).symm ⟨z, v⟩) := by + let e := primeSquareDecompose p + have hc : Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) = + Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) * p ^ 2 := by + rw [Fintype.card_congr e, Fintype.card_sigma] + simp only [squareLiftPairs_card, Finset.sum_const, Finset.card_univ, smul_eq_mul] + have hs := e.symm.sum_comp F + rw [Fintype.sum_sigma] at hs + rw [← hs, hc, Nat.cast_mul, Nat.cast_pow, mul_inv_rev, ← Finset.mul_sum] + ring + +theorem primeSquareDecompose_symm_values (p : ℕ) [Fact p.Prime] + (z : (ZMod p)ˣ × (ZMod p)ˣ) (v : SquareLiftPairs p (z.1 : ZMod p) (z.2 : ZMod p)) : + ((((primeSquareDecompose p).symm ⟨z, v⟩).1 : ZMod (p ^ 2)), + (((primeSquareDecompose p).symm ⟨z, v⟩).2 : ZMod (p ^ 2))) = + (v.1.val, v.2.val) := by + exact congrArg (fun w : SquareLiftPairs p (z.1 : ZMod p) (z.2 : ZMod p) => + (w.1.val, w.2.val)) ((primeSquareFiberEquiv p z).apply_symm_apply v) + +theorem primeSquare_raw_average (p : ℕ) [Fact p.Prime] + (F : ZMod (p ^ 2) → ZMod (p ^ 2) → ℂ) : + (Fintype.card ((ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ) : ℂ)⁻¹ * + (∑ z : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ, F z.1 z.2) = + (Fintype.card ((ZMod p)ˣ × (ZMod p)ˣ) : ℂ)⁻¹ * + ∑ z : (ZMod p)ˣ × (ZMod p)ˣ, ((p : ℂ) ^ 2)⁻¹ * + ∑ v : SquareLiftPairs p (z.1 : ZMod p) (z.2 : ZMod p), F v.1.val v.2.val := by + have h := primeSquare_average p + (fun z : (ZMod (p ^ 2))ˣ × (ZMod (p ^ 2))ˣ => F z.1 z.2) + have he (z : (ZMod p)ˣ × (ZMod p)ˣ) + (v : SquareLiftPairs p (z.1 : ZMod p) (z.2 : ZMod p)) : + F ((primeSquareDecompose p).symm ⟨z, v⟩).1 + ((primeSquareDecompose p).symm ⟨z, v⟩).2 = F v.1.val v.2.val := + congrArg (fun a : ZMod (p ^ 2) × ZMod (p ^ 2) => F a.1 a.2) + (primeSquareDecompose_symm_values p z v) + simpa only [he] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareLiftFamilies.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareLiftFamilies.lean new file mode 100644 index 0000000000000000000000000000000000000000..f15ac659fd8dbd5e796e891be89cdac0a031f43f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareLiftFamilies.lean @@ -0,0 +1,163 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeSquareLifts + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeSquareLiftFamilies +open scoped BigOperators + +def affineSwapEquiv {K : Type*} [Field K] (a b c : K) : + {z : K × K // a*z.1+b*z.2=c} ≃ + {z : K × K // b*z.1+a*z.2=c} where + toFun z := ⟨(z.val.2,z.val.1), by simpa [add_comm] using z.property⟩ + invFun z := ⟨(z.val.2,z.val.1), by simpa [add_comm] using z.property⟩ + left_inv _ := rfl + right_inv _ := rfl + +def affineRowEquiv {K : Type*} [Field K] (a b c : K) (h : a ≠ 0 ∨ b ≠ 0) : + {z : K × K // a*z.1+b*z.2=c} ≃ K := by + classical + by_cases ha : a = 0 + · exact (affineSwapEquiv a b c).trans + (PrimeSquareLifts.affineLineEquiv b a c (h.resolve_left (not_not.mpr ha))) + · exact PrimeSquareLifts.affineLineEquiv a b c ha + +variable (p : ℕ) [Fact p.Prime] + +def row (a b c : ZMod p) : Finset (ZMod p × ZMod p) := + Finset.univ.filter fun z => a*z.1+b*z.2=c + +theorem row_card (a b c : ZMod p) (h : a ≠ 0 ∨ b ≠ 0) : + (row p a b c).card = p := by + classical + rw [row, ← Fintype.card_subtype] + rw [← Nat.card_eq_fintype_card, Nat.card_congr (affineRowEquiv a b c h), + Nat.card_eq_fintype_card, ZMod.card] + +theorem row_probability (a b c : ZMod p) (h : a ≠ 0 ∨ b ≠ 0) : + ((row p a b c).card : ℝ) / Fintype.card (ZMod p × ZMod p) = (p:ℝ)⁻¹ := by + rw [row_card p a b c h, Fintype.card_prod, ZMod.card] + have hp : (p:ℝ) ≠ 0 := by exact_mod_cast (Fact.out : p.Prime).ne_zero + push_cast + field_simp + +variable {ι : Type*} (s : Finset ι) (a b c : ι → ZMod p) + +def badLifts : Finset (ZMod p × ZMod p) := by + classical + exact s.biUnion fun i => row p (a i) (b i) (c i) + +def survivingLifts : Finset (ZMod p × ZMod p) := (badLifts p s a b c)ᶜ + +@[simp] theorem mem_badLifts (z : ZMod p × ZMod p) : + z ∈ badLifts p s a b c ↔ ∃ i ∈ s, a i*z.1+b i*z.2=c i := by + classical + simp [badLifts, row] + +@[simp] theorem mem_survivingLifts (z : ZMod p × ZMod p) : + z ∈ survivingLifts p s a b c ↔ ∀ i ∈ s, a i*z.1+b i*z.2 ≠ c i := by + classical + simp [survivingLifts] + +theorem badLifts_card_le (h : ∀ i ∈ s, a i ≠ 0 ∨ b i ≠ 0) : + (badLifts p s a b c).card ≤ s.card * p := by + classical + calc + _ ≤ ∑ i ∈ s, (row p (a i) (b i) (c i)).card := Finset.card_biUnion_le + _ = ∑ _i ∈ s, p := Finset.sum_congr rfl fun i hi => row_card p _ _ _ (h i hi) + _ = s.card * p := by simp + +theorem badLifts_probability_le (h : ∀ i ∈ s, a i ≠ 0 ∨ b i ≠ 0) : + ((badLifts p s a b c).card : ℝ) / Fintype.card (ZMod p × ZMod p) ≤ + (s.card:ℝ) / p := by + have hp : (0:ℝ) < p := by exact_mod_cast (Fact.out : p.Prime).pos + calc + _ ≤ ((s.card*p:ℕ):ℝ) / Fintype.card (ZMod p × ZMod p) := by + gcongr + exact badLifts_card_le p s a b c h + _ = (s.card:ℝ) / p := by + rw [Fintype.card_prod, ZMod.card] + push_cast + field_simp + +theorem survivingLifts_probability_ge (h : ∀ i ∈ s, a i ≠ 0 ∨ b i ≠ 0) : + 1 - (s.card:ℝ) / p ≤ + ((survivingLifts p s a b c).card : ℝ) / Fintype.card (ZMod p × ZMod p) := by + classical + have hn : (0:ℝ) < Fintype.card (ZMod p × ZMod p) := by positivity + have hcard : (survivingLifts p s a b c).card + (badLifts p s a b c).card = + Fintype.card (ZMod p × ZMod p) := Finset.card_compl_add_card _ + have hsum : ((survivingLifts p s a b c).card:ℝ) / + Fintype.card (ZMod p × ZMod p) + ((badLifts p s a b c).card:ℝ) / + Fintype.card (ZMod p × ZMod p) = 1 := by + rw [← add_div, ← Nat.cast_add, hcard, div_self (ne_of_gt hn)] + linarith [badLifts_probability_le p s a b c h] + +theorem bounded_test_loss (h : ∀ i ∈ s, a i ≠ 0 ∨ b i ≠ 0) + (f : ZMod p × ZMod p → ℝ) (B : ℝ) (hB : 0 ≤ B) + (hf : ∀ z, 0 ≤ f z ∧ f z ≤ B) : + 0 ≤ ((∑ z, f z) - ∑ z ∈ survivingLifts p s a b c, f z) / + Fintype.card (ZMod p × ZMod p) ∧ + ((∑ z, f z) - ∑ z ∈ survivingLifts p s a b c, f z) / + Fintype.card (ZMod p × ZMod p) ≤ B * ((s.card:ℝ) / p) := by + classical + have heq : (∑ z, f z) - ∑ z ∈ survivingLifts p s a b c, f z = + ∑ z ∈ badLifts p s a b c, f z := by + have he := Finset.sum_add_sum_compl (badLifts p s a b c) f + dsimp [survivingLifts] + linarith + rw [heq] + constructor + · exact div_nonneg (Finset.sum_nonneg fun z _ => (hf z).1) (Nat.cast_nonneg _) + · calc + _ ≤ ((badLifts p s a b c).card:ℝ) * B / + Fintype.card (ZMod p × ZMod p) := by + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + calc + _ ≤ ∑ _z ∈ badLifts p s a b c, B := Finset.sum_le_sum fun z _ => (hf z).2 + _ = _ := by simp + _ = B * (((badLifts p s a b c).card:ℝ) / + Fintype.card (ZMod p × ZMod p)) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left (badLifts_probability_le p s a b c h) hB + +theorem square_divides_some_lift_iff + (A B k : ι → ℤ) (x y u v : ℤ) + (hbase : ∀ i ∈ s, A i*x+B i*y=(p:ℤ)*k i) : + (∃ i ∈ s, (p:ℤ)*(p:ℤ) ∣ + A i*(x+(p:ℤ)*u)+B i*(y+(p:ℤ)*v)) ↔ + ((u:ZMod p),(v:ZMod p)) ∈ + badLifts p s (fun i => (A i:ZMod p)) (fun i => (B i:ZMod p)) + (fun i => -(k i:ZMod p)) := by + rw [mem_badLifts] + exact exists_congr fun i => and_congr_right fun hi => + PrimeSquareLifts.square_divides_lift_iff_residue p _ _ _ _ _ _ _ (hbase i hi) + +def integerBadLifts (A B : ι → ℤ) (x y : ℤ) : Finset (ZMod p × ZMod p) := by + classical + exact Finset.univ.filter fun z => ∃ i ∈ s, (p:ℤ)*(p:ℤ) ∣ + A i*(x+(p:ℤ)*(z.1.val:ℤ))+B i*(y+(p:ℤ)*(z.2.val:ℤ)) + +theorem integerBadLifts_eq (A B k : ι → ℤ) (x y : ℤ) + (hbase : ∀ i ∈ s, A i*x+B i*y=(p:ℤ)*k i) : + integerBadLifts p s A B x y = + badLifts p s (fun i => (A i:ZMod p)) (fun i => (B i:ZMod p)) + (fun i => -(k i:ZMod p)) := by + classical + ext z + simp only [integerBadLifts, Finset.mem_filter, Finset.mem_univ, true_and] + rw [square_divides_some_lift_iff p s A B k x y _ _ hbase] + simp + +theorem integer_bad_lift_probability_le (A B k : ι → ℤ) (x y : ℤ) + (hbase : ∀ i ∈ s, A i*x+B i*y=(p:ℤ)*k i) + (hrow : ∀ i ∈ s, (A i:ZMod p) ≠ 0 ∨ (B i:ZMod p) ≠ 0) : + ((integerBadLifts p s A B x y).card:ℝ) / + Fintype.card (ZMod p × ZMod p) ≤ (s.card:ℝ) / p := by + rw [integerBadLifts_eq p s A B k x y hbase] + exact badLifts_probability_le p s _ _ _ hrow + +end Ostmann.Arithmetic.PrimeSquareLiftFamilies + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareLifts.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareLifts.lean new file mode 100644 index 0000000000000000000000000000000000000000..85e68453629876acada374a174e9b48959dd5c85 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareLifts.lean @@ -0,0 +1,51 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeLines + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeSquareLifts + +theorem square_divides_lift_iff {p a b x y k u v : ℤ} (hp : p ≠ 0) + (hbase : a*x+b*y=p*k) : + p*p ∣ a*(x+p*u)+b*(y+p*v) ↔ p ∣ k+a*u+b*v := by + have heq : a*(x+p*u)+b*(y+p*v)=p*(k+a*u+b*v) := by + linear_combination hbase + rw [heq, mul_dvd_mul_iff_left hp] + +def affineLineEquiv {K : Type*} [Field K] (a b c : K) (ha : a ≠ 0) : + {z : K × K // a*z.1+b*z.2=c} ≃ K where + toFun z := z.val.2 + invFun y := ⟨((c-b*y)/a,y), by dsimp; field_simp; ring⟩ + left_inv z := by + apply Subtype.ext + apply Prod.ext + · dsimp + apply (div_eq_iff ha).2 + linear_combination -z.property + · rfl + right_inv _ := rfl + +theorem prime_lift_probability (p : ℕ) [Fact p.Prime] + (a b c : ZMod p) (ha : a ≠ 0) : + (Nat.card {z : ZMod p × ZMod p // a*z.1+b*z.2=c} : ℝ) / + Fintype.card (ZMod p × ZMod p) = (p:ℝ)⁻¹ := by + rw [Nat.card_congr (affineLineEquiv a b c ha), Nat.card_eq_fintype_card, + Fintype.card_prod, ZMod.card] + have hp : p ≠ 0 := (Fact.out : p.Prime).ne_zero + push_cast + field_simp + +theorem square_divides_lift_iff_residue (p : ℕ) [Fact p.Prime] + (a b x y k u v : ℤ) (hbase : a*x+b*y=(p:ℤ)*k) : + (p:ℤ)*(p:ℤ) ∣ a*(x+(p:ℤ)*u)+b*(y+(p:ℤ)*v) ↔ + (a:ZMod p)*(u:ZMod p)+(b:ZMod p)*(v:ZMod p)=-(k:ZMod p) := by + rw [square_divides_lift_iff (by exact_mod_cast (Fact.out : p.Prime).ne_zero) hbase] + rw [← ZMod.intCast_zmod_eq_zero_iff_dvd] + push_cast + constructor <;> intro h <;> linear_combination h + +end Ostmann.Arithmetic.PrimeSquareLifts + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareResidueLaw.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareResidueLaw.lean new file mode 100644 index 0000000000000000000000000000000000000000..1bc4ca200a32510995ce245a608ec2c64f30fb5e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareResidueLaw.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.HistoryCRTIntegrationBasic +import OAI.NumberTheory.Ostmann.Arithmetic.PrimeSquareResidueLawBasic + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeSquareResidueLaw +open scoped BigOperators +open ResidueHaar HistoryCRTIntegration +attribute [local instance] Classical.propDecidable + +def pairDigitsEquiv (A B C D : Type*) : (A × B) × (C × D) ≃ (A × C) × (B × D) where + toFun z := ((z.1.1,z.2.1),(z.1.2,z.2.2)) + invFun z := ((z.1.1,z.2.1),(z.1.2,z.2.2)) + left_inv _ := rfl + right_inv _ := rfl + +theorem average_pair {A B : Type*} [Fintype A] [Fintype B] (F : A × B → ℂ) : + average F = average (fun a => average (fun b => F (a,b))) := by + simp only [average,Fintype.card_prod,Nat.cast_mul,mul_inv_rev, + Fintype.sum_prod_type,← Finset.mul_sum] + ring + +variable (p : ℕ) [Fact p.Prime] + +def unitPairLiftEquiv : UnitPair p × (ZMod p × ZMod p) ≃ UnitPair (p^2) := + (pairDigitsEquiv _ _ _ _).trans ((unitLiftEquiv p).prodCongr (unitLiftEquiv p)) + +def mixedPairLiftEquiv : MixedPair p × (ZMod p × ZMod p) ≃ MixedPair (p^2) := + (pairDigitsEquiv _ _ _ _).trans ((ringLiftEquiv p).prodCongr (unitLiftEquiv p)) + +@[simp] theorem unitPairLiftEquiv_fst (z : UnitPair p × (ZMod p × ZMod p)) : + ((unitPairLiftEquiv p z).1:ZMod (p^2)) = lift p (z.1.1:ZMod p) z.2.1 := + unitLiftEquiv_coe p _ + +@[simp] theorem unitPairLiftEquiv_snd (z : UnitPair p × (ZMod p × ZMod p)) : + ((unitPairLiftEquiv p z).2:ZMod (p^2)) = lift p (z.1.2:ZMod p) z.2.2 := + unitLiftEquiv_coe p _ + +@[simp] theorem mixedPairLiftEquiv_fst (z : MixedPair p × (ZMod p × ZMod p)) : + (mixedPairLiftEquiv p z).1 = lift p z.1.1 z.2.1 := rfl + +@[simp] theorem mixedPairLiftEquiv_snd (z : MixedPair p × (ZMod p × ZMod p)) : + ((mixedPairLiftEquiv p z).2:ZMod (p^2)) = lift p (z.1.2:ZMod p) z.2.2 := + unitLiftEquiv_coe p _ + +omit [Fact p.Prime] in +theorem lift_eq_intCast [Fact p.Prime] (x u : ZMod p) : + lift p x u = (((x.val:ℤ)+(p:ℤ)*(u.val:ℤ):ℤ):ZMod (p^2)) := by + simp only [lift,Nat.cast_add,Nat.cast_mul,Int.cast_add,Int.cast_mul,Int.cast_natCast] + +def reduction : ZMod (p^2) →+* ZMod p := + ZMod.castHom (by simpa only [pow_two] using dvd_mul_right p p) (ZMod p) + +@[simp] theorem lift_reduction (x u : ZMod p) : reduction p (lift p x u) = x := by + simp only [lift,map_natCast,Nat.cast_add,Nat.cast_mul,map_add,map_mul, + ZMod.natCast_self,zero_mul,add_zero,ZMod.natCast_zmod_val] + +theorem ringLiftEquiv_base_reduction (z : ZMod (p^2)) : + ((ringLiftEquiv p).symm z).1 = reduction p z := by + have h := lift_reduction p ((ringLiftEquiv p).symm z).1 + ((ringLiftEquiv p).symm z).2 + rw [show lift p ((ringLiftEquiv p).symm z).1 ((ringLiftEquiv p).symm z).2 = z from + (ringLiftEquiv p).apply_symm_apply z] at h + exact h.symm + +@[simp] theorem unitLiftEquiv_reduction (z : (ZMod p)ˣ × ZMod p) : + reduction p (unitLiftEquiv p z : ZMod (p^2)) = (z.1:ZMod p) := by + rw [unitLiftEquiv_coe,lift_reduction] + +theorem unit_pair_average (F : UnitPair (p^2) → ℂ) : + average F = average (fun b : UnitPair p => + average (fun u : ZMod p × ZMod p => F (unitPairLiftEquiv p (b,u)))) := + (average_equiv (unitPairLiftEquiv p) F).symm.trans (average_pair _) + +theorem mixed_pair_average (F : MixedPair (p^2) → ℂ) : + average F = average (fun b : MixedPair p => + average (fun u : ZMod p × ZMod p => F (mixedPairLiftEquiv p (b,u)))) := + (average_equiv (mixedPairLiftEquiv p) F).symm.trans (average_pair _) + +theorem unit_joint_average (F : UnitPair p × (ZMod p × ZMod p) → ℂ) : + average (fun z : UnitPair (p^2) => F ((unitPairLiftEquiv p).symm z)) = + average (fun b : UnitPair p => average (fun u : ZMod p × ZMod p => F (b,u))) := + (average_equiv (unitPairLiftEquiv p).symm F).trans (average_pair F) + +theorem mixed_joint_average (F : MixedPair p × (ZMod p × ZMod p) → ℂ) : + average (fun z : MixedPair (p^2) => F ((mixedPairLiftEquiv p).symm z)) = + average (fun b : MixedPair p => average (fun u : ZMod p × ZMod p => F (b,u))) := + (average_equiv (mixedPairLiftEquiv p).symm F).trans (average_pair F) + +end Ostmann.Arithmetic.PrimeSquareResidueLaw + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareResidueLawBasic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareResidueLawBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..a5200f5414e0e992e3b805b3777549d32c489aba --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeSquareResidueLawBasic.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ResidueHaar + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.PrimeSquareResidueLaw +attribute [local instance] Classical.propDecidable + +variable (p : ℕ) [Fact p.Prime] + +def lift (x u : ZMod p) : ZMod (p^2) := ((x.val + p*u.val : ℕ) : ZMod (p^2)) + +theorem lift_lt (x u : ZMod p) : x.val + p*u.val < p^2 := by + have hx := x.val_lt + have hu := Nat.mul_le_mul_left p (Nat.succ_le_of_lt u.val_lt) + nlinarith + +@[simp] theorem lift_val (x u : ZMod p) : (lift p x u).val = x.val+p*u.val := + ZMod.val_natCast_of_lt (lift_lt p x u) + +theorem quotient_lt (z : ZMod (p^2)) : z.val / p < p := by + apply (Nat.div_lt_iff_lt_mul (Fact.out : p.Prime).pos).mpr + simpa only [pow_two] using z.val_lt + +def ringLiftEquiv : ZMod p × ZMod p ≃ ZMod (p^2) where + toFun z := lift p z.1 z.2 + invFun z := ((z.val : ZMod p),((z.val / p : ℕ):ZMod p)) + left_inv z := by + apply Prod.ext + · simp [lift_val,Nat.cast_add,Nat.cast_mul] + · change (((lift p z.1 z.2).val / p : ℕ) : ZMod p) = z.2 + rw [lift_val,Nat.add_mul_div_left _ _ (Fact.out : p.Prime).pos, + Nat.div_eq_of_lt z.1.val_lt,Nat.zero_add,ZMod.natCast_zmod_val] + right_inv z := by + change lift p (z.val:ZMod p) ((z.val/p:ℕ):ZMod p) = z + unfold lift + rw [ZMod.val_natCast,ZMod.val_natCast,Nat.mod_eq_of_lt (quotient_lt p z), + Nat.mod_add_div,ZMod.natCast_zmod_val] + +@[simp] theorem ringLiftEquiv_apply (z : ZMod p × ZMod p) : + ringLiftEquiv p z = lift p z.1 z.2 := rfl + +@[simp] theorem ringLiftEquiv_symm_fst (z : ZMod (p^2)) : + ((ringLiftEquiv p).symm z).1 = (z.val:ZMod p) := rfl + +@[simp] theorem ringLiftEquiv_symm_snd (z : ZMod (p^2)) : + ((ringLiftEquiv p).symm z).2 = ((z.val/p:ℕ):ZMod p) := rfl + +theorem lift_isUnit_iff (x u : ZMod p) : IsUnit (lift p x u) ↔ IsUnit x := by + rw [lift,ZMod.isUnit_natCast_iff_not_dvd_pow (Fact.out : p.Prime) (by decide)] + have hbase : IsUnit x ↔ ¬ p ∣ x.val := by + conv_lhs => rw [← ZMod.natCast_zmod_val x] + rw [ZMod.isUnit_iff_coprime,Nat.coprime_comm, + (Fact.out : p.Prime).coprime_iff_not_dvd] + rw [hbase] + exact not_congr (Nat.dvd_add_iff_left (dvd_mul_right p u.val)).symm + +def unitsSubtypeEquiv (M : Type*) [Monoid M] : Mˣ ≃ {x : M // IsUnit x} where + toFun u := ⟨u,u.isUnit⟩ + invFun x := x.property.unit + left_inv u := by apply Units.ext; exact IsUnit.unit_spec _ + right_inv x := by apply Subtype.ext; exact x.property.unit_spec + +def unitLiftEquiv : (ZMod p)ˣ × ZMod p ≃ (ZMod (p^2))ˣ := + (((unitsSubtypeEquiv (ZMod p)).prodCongr (Equiv.refl (ZMod p))).trans + ((Equiv.prodSubtypeFstEquivSubtypeProd).symm.trans + ((ringLiftEquiv p).subtypeEquiv (fun z => (lift_isUnit_iff p z.1 z.2).symm)))).trans + (unitsSubtypeEquiv (ZMod (p^2))).symm + +@[simp] theorem unitLiftEquiv_coe (z : (ZMod p)ˣ × ZMod p) : + (unitLiftEquiv p z : ZMod (p^2)) = lift p (z.1:ZMod p) z.2 := by + exact IsUnit.unit_spec _ + +end Ostmann.Arithmetic.PrimeSquareResidueLaw + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeTupleResidueRow.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeTupleResidueRow.lean new file mode 100644 index 0000000000000000000000000000000000000000..26e62df535340e398ad384b76f707ad3ec1b08ef --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeTupleResidueRow.lean @@ -0,0 +1,30 @@ +import OAI.NumberTheory.Ostmann.Construction.GroupedPhaseFactorization + +namespace OAI + +/-! # The actual harmonic-prior pivot row -/ + +namespace Ostmann + +open scoped BigOperators Classical + +noncomputable def primeTupleResidueRow (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + {n : ℕ} (χ : Fin n → ∀ p : ℕ, DirichletCharacter ℂ p) + (κ : Fin n → P → ℂ) (t : ∀ p : ℕ, ZMod p) (Y : ℕ) (ε : Fin n → ℤ) + (x : Fin n → P) (u : Fin (∏ i, (x i : ℕ))) : ℂ := by + letI : ∀ i, Fact (x i : ℕ).Prime := fun i => ⟨hP (x i) (x i).property⟩ + exact groupedResidueRow (fun i => (x i : ℕ)) (fun i => χ i (x i)) + (fun i => κ i (x i)) (fun i => t (x i)) Y ε u + +theorem primeTupleResidueRow_norm_le_one (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + {n : ℕ} (χ : Fin n → ∀ p : ℕ, DirichletCharacter ℂ p) + (κ : Fin n → P → ℂ) (hκ : ∀ i p, ‖κ i p‖ ≤ 1) (t : ∀ p : ℕ, ZMod p) + (Y : ℕ) (ε : Fin n → ℤ) (x : Fin n → P) (u : Fin (∏ i, (x i : ℕ))) : + ‖primeTupleResidueRow P hP χ κ t Y ε x u‖ ≤ 1 := by + let : ∀ i, Fact (x i : ℕ).Prime := fun i => ⟨hP (x i) (x i).property⟩ + exact groupedResidueRow_norm_le_one (fun i => (x i : ℕ)) (fun i => χ i (x i)) + (fun i => κ i (x i)) (fun i => hκ i (x i)) (fun i => t (x i)) Y ε u + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeWordCellGeometry.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeWordCellGeometry.lean new file mode 100644 index 0000000000000000000000000000000000000000..95ad419d30304bb1dc3b1d921fc2d9292e985262 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/PrimeWordCellGeometry.lean @@ -0,0 +1,53 @@ +import OAI.NumberTheory.Ostmann.Construction.PrimeShellIndex +import OAI.NumberTheory.Ostmann.Construction.HarmonicWordPriors + +namespace OAI + +/-! # Exact real cells for the selected harmonic word laws -/ + +namespace Ostmann +open scoped Classical + +theorem primeLogIndex_eq_iff (p h : ℕ) (hp : p.Prime) : + primeLogIndex p = h ↔ (h : ℝ) < Real.log (p : ℝ) ∧ + Real.log (p : ℝ) ≤ (h : ℝ) + 1 := by + constructor + · intro heq + simpa only [heq] using primeLogIndex_bounds p hp + · intro hh + have hi := primeLogIndex_bounds p hp + by_contra heq + rcases lt_or_gt_of_ne heq with hlt | hgt + · have hb : (primeLogIndex p : ℝ) + 1 ≤ h := by + exact_mod_cast Nat.succ_le_of_lt hlt + linarith + · have hb : (h : ℝ) + 1 ≤ primeLogIndex p := by + exact_mod_cast Nat.succ_le_of_lt hgt + linarith + +/-- Intersecting a whole shell with an integer cell clips its endpoints; +no boundary prime is removed or added. Prescribed exclusions remain intact. -/ +theorem primeLogIndex_filter_shell (a b : ℝ) (D : Finset ℕ) (h : ℕ) : + ((primeLogCellSet 1 0 a b \ D).filter (fun p => primeLogIndex p = h)) = + primeLogCellSet 1 0 (max a (h : ℝ)) (min b ((h : ℝ) + 1)) \ D := by + ext p + simp only [Finset.mem_filter, Finset.mem_sdiff, mem_primeLogCellSet_iff, + Nat.modEq_one, true_and, Set.mem_Ioc, max_lt_iff, le_min_iff] + constructor + · rintro ⟨⟨⟨hp, hlo, hhi⟩, hD⟩, hi⟩ + have hh := (primeLogIndex_eq_iff p h hp).mp hi + exact ⟨⟨hp, ⟨hlo, hh.1⟩, hhi, hh.2⟩, hD⟩ + · rintro ⟨⟨hp, ⟨hlo, hhl⟩, hhi, hhh⟩, hD⟩ + exact ⟨⟨⟨hp, hlo, hhi⟩, hD⟩, (primeLogIndex_eq_iff p h hp).mpr ⟨hhl, hhh⟩⟩ + +/-- Passing a selected cell to the common prime sample space preserves its +original harmonic normalizer exactly. -/ +theorem primeCellWordPrior_lift (P Q : Finset ℕ) (hQP : Q ⊆ P) (h : ℕ) (p : Q) : + primeSubsetPrior P (Q.filter (fun q => primeLogIndex q = h)) ⟨p, hQP p.property⟩ = + primeCellWordPrior Q h p := by + simp only [primeSubsetPrior, Finset.mem_filter, p.property, true_and, + primeCellWordPrior, finiteCellMass] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ProductExpectation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ProductExpectation.lean new file mode 100644 index 0000000000000000000000000000000000000000..b3415bf902e0836022fde887888f5f6ccc1a6133 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ProductExpectation.lean @@ -0,0 +1,45 @@ +import Mathlib + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.ProductExpectation +open scoped BigOperators + +def expectation {K : Type*} : {n : ℕ} → (Fin n → Finset K) → + (Fin n → K → ℝ) → ((Fin n → K) → ℝ) → ℝ + | 0, _, _, f => f Fin.elim0 + | _n+1, S, μ, f => expectation (Fin.tail S) (Fin.tail μ) + (fun x => ∑ a ∈ S 0, μ 0 a * f (Fin.cons a x)) + +theorem mono {K : Type*} : ∀ {n : ℕ} (S : Fin n → Finset K) (μ : Fin n → K → ℝ) + (_hμ : ∀ i a, a ∈ S i → 0 ≤ μ i a) {f g : (Fin n → K) → ℝ} + (_hfg : ∀ x, f x ≤ g x), expectation S μ f ≤ expectation S μ g + | 0, _, _, _, _, _, hfg => hfg _ + | n+1, S, μ, hμ, f, g, hfg => by + apply mono (Fin.tail S) (Fin.tail μ) (fun i => hμ i.succ) + intro x + exact Finset.sum_le_sum fun a ha => + mul_le_mul_of_nonneg_left (hfg (Fin.cons a x)) (hμ 0 a ha) + +theorem const {K : Type*} : ∀ {n : ℕ} (S : Fin n → Finset K) (μ : Fin n → K → ℝ) + (_hμ : ∀ i, ∑ a ∈ S i, μ i a = 1) (c : ℝ), + expectation S μ (fun _ => c) = c + | 0, _, _, _, _ => rfl + | n+1, S, μ, hμ, c => by + simp only [expectation, ← Finset.sum_mul, hμ, one_mul] + exact const (Fin.tail S) (Fin.tail μ) (fun i => hμ i.succ) c + +theorem add {K : Type*} : ∀ {n : ℕ} (S : Fin n → Finset K) (μ : Fin n → K → ℝ) + (f g : (Fin n → K) → ℝ), + expectation S μ (fun x => f x + g x) = expectation S μ f + expectation S μ g + | 0, _, _, _, _ => rfl + | n+1, S, μ, f, g => by + simp only [expectation, mul_add, Finset.sum_add_distrib] + exact add (Fin.tail S) (Fin.tail μ) _ _ + +end Ostmann.Arithmetic.ProductExpectation + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ProductExpectationFinite.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ProductExpectationFinite.lean new file mode 100644 index 0000000000000000000000000000000000000000..9bafa0022826889bf5e88fb27bfe166bd164d68c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ProductExpectationFinite.lean @@ -0,0 +1,38 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ProductExpectation + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.ProductExpectation +open scoped BigOperators + +theorem eq_product_sum {K : Type*} : ∀ {n : ℕ} (S : Fin n → Finset K) + (μ : Fin n → K → ℝ) (f : (Fin n → K) → ℝ), + expectation S μ f = ∑ x ∈ Fintype.piFinset S, (∏ i, μ i (x i))*f x + | 0, S, μ, f => by + classical + simp only [expectation, Fintype.piFinset_of_isEmpty, + Fintype.prod_empty, one_mul, Finset.univ_unique, Finset.sum_singleton] + exact congrArg f (Subsingleton.elim _ _) + | n+1, S, μ, f => by + classical + have hS := Finset.filter_piFinset_eq_map_consEquiv S (fun _ => True) + simp only [Finset.filter_true] at hS + rw [expectation, eq_product_sum, hS, Finset.sum_map, Finset.sum_product] + simp only [Equiv.toEmbedding_apply, Fin.consEquiv_apply, Fin.prod_univ_succ, + Fin.cons_zero, Fin.cons_succ] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x hx + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro a ha + change (∏ i : Fin n, μ i.succ (x i)) * (μ 0 a * f (Fin.cons a x)) = + (μ 0 a * ∏ i : Fin n, μ i.succ (x i))*f (Fin.cons a x) + ring + +end Ostmann.Arithmetic.ProductExpectation + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedComplexityBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedComplexityBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ec46c08d7c4dd970c62273fdd793057283b2dc8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedComplexityBudget.lean @@ -0,0 +1,58 @@ +import OAI.NumberTheory.Ostmann.Construction.WordPeriodBudget +import OAI.NumberTheory.Ostmann.Arithmetic.RangedExpandedWordPairBound + +namespace OAI + +/-! # The actual range partition cost is polynomial at fixed depth -/ + +namespace Ostmann + +/-- Include the extra root product interval in `D`; the same bound then +covers the normalized reciprocal-product comparison. -/ +theorem ranged_word_complexity_le {V : Type*} {n : ℕ} + (D D' : WordRangeDecoration V n) (B : ℕ) (b d m : ℝ) + (hd : 0 ≤ d) (hm : 0 ≤ m) + (hB : (B : ℝ) ≤ b * (1 + m)) + (hD : (D.count : ℝ) ≤ d * (1 + m)) + (hD' : (D'.count : ℝ) ≤ d * (1 + m)) : + (((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1) : ℕ) : ℝ) ≤ + (((3 * 2 ^ n + 3 * (2 ^ n - 1) : ℕ) : ℝ) + 4 * d) * + b ^ (n + 1) * (1 + m) ^ (n + 2) := by + let c : ℝ := 3 * 2 ^ n + 3 * ((2 ^ n - 1 : ℕ) : ℝ) + have hc : 0 ≤ c := by dsimp only [c]; positivity + have h1 : 1 ≤ 1 + m := by linarith + have hpoly : (B : ℝ) ^ (n + 1) ≤ b ^ (n + 1) * (1 + m) ^ (n + 1) := by + simpa only [mul_pow] using pow_le_pow_left₀ (Nat.cast_nonneg B) hB (n + 1) + have hcount : c + 2 * ((D.count : ℝ) + D'.count) ≤ (c + 4 * d) * (1 + m) := by + nlinarith + push_cast + change (c + 2 * ((D.count : ℝ) + D'.count)) * (B : ℝ) ^ (n + 1) ≤ _ + calc + _ ≤ ((c + 4 * d) * (1 + m)) * (b ^ (n + 1) * (1 + m) ^ (n + 1)) := + mul_le_mul hcount hpoly (by positivity) (by positivity) + _ = _ := by rw [show n + 2 = n + 1 + 1 from rfl, pow_succ]; ring + +theorem ranged_boolean_partition_le {V : Type*} {n : ℕ} + (D D' : WordRangeDecoration V n) (B : ℕ) (K m : ℝ) + (hcost : (((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1) : ℕ) : ℝ) ≤ + K * (1 + m) ^ (n + 2)) : + ((3 ^ (2 * ((((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1))) + + ((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)))) : ℕ) : ℝ) ≤ + Real.exp ((4 * Real.log 3 * K) * (1 + m) ^ (n + 2)) := by + let r := (3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1) + calc + _ = Real.exp ((2 * (r + r) : ℕ) * Real.log 3) := by + rw [Real.exp_nat_mul, Real.exp_log (by norm_num : (0 : ℝ) < 3)] + norm_cast + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have hh := mul_le_mul_of_nonneg_left hcost (show 0 ≤ 4 * Real.log 3 by positivity) + change (2 * (r + r) : ℕ) * Real.log 3 ≤ _ + change (r : ℝ) ≤ _ at hcost + change 4 * Real.log 3 * (r : ℝ) ≤ _ at hh + push_cast + nlinarith only [hh] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedExpandedWordPairBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedExpandedWordPairBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..9e6977b4e56c293f4f5b712205d06401d63ee1be --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedExpandedWordPairBound.lean @@ -0,0 +1,110 @@ +import OAI.NumberTheory.Ostmann.Construction.ExpandedWordPairBound +import OAI.NumberTheory.Ostmann.Arithmetic.RangedWordPairBound + +namespace OAI + +/-! # Original-prior correlation with every intermediate range test -/ + +namespace Ostmann + +open scoped BigOperators ComplexConjugate Classical + +noncomputable def rangedWordTransferPairBound {σ : Type*} {n : ℕ} + (template template' : WordTransferTemplate σ n) + (D D' : WordRangeDecoration σ n) (t t' : FrequencyTree ℤ n) + (hn : NonzeroInternalFrequencies n t) (hn' : NonzeroInternalFrequencies n t') + (B : ℕ) (f f' : WordFourierParameters n) (A E : ℕ) + (P Q : Finset ℕ) (b : ℝ) (Bq : ℕ) : ℝ := + let M := wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B + let R := (3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1) + let C := f.budget template t hn * f'.budget template' t' hn' + ((Nat.log 2 E + 1 : ℕ) : ℝ) * (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (((∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ * b⁻¹) * (2 * C ^ 2) + + (M : ℝ) * ((3 ^ (2 * (R + R)) : ℕ) * (2 * (A : ℝ)⁻¹ * C ^ 2)) * (Bq : ℝ) ^ 2) + +theorem selected_ranged_expanded_word_pair_bound {V : Type*} [Fintype V] + (a b : V) (hab : a ≠ b) {n : ℕ} + (template template' : WordTransferTemplate (ExpandedScheduledVariable V n) n) + (D D' : WordRangeDecoration (ExpandedScheduledVariable V n) n) (t t' : FrequencyTree ℤ n) + (hn : NonzeroInternalFrequencies n t) (hn' : NonzeroInternalFrequencies n t') + (B : ℕ) (hB : 1 ≤ B) (hwords : template.WordsBounded B) (hwords' : template'.WordsBounded B) + (hD : D.WordsBounded B) (hD' : D'.WordsBounded B) + (hz : ∀ s ∈ allFrequencyList n t, s ≠ 0) (hz' : ∀ s ∈ allFrequencyList n t', s ≠ 0) + (f f' : WordFourierParameters n) + (χ : V → ∀ p : ℕ, DirichletCharacter ℂ p) (graph : V → V → ℤ) + (unary : V → ℕ → ℂ) (hunary : ∀ i x, ‖unary i x‖ ≤ 1) + (hself : graph a a = 0 ∧ graph b b = 0) (hreverse : graph b a = 0) + (P Q : Finset ℕ) (hprime : ∀ q ∈ Q, q.Prime) + (hnonprincipal : ∀ q ∈ Q, χ a q ^ graph a b ≠ 1) + (A E : ℕ) (hA : 0 < A) + (hMA : wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B ≤ A) + (hsmall : ∀ q ∈ Q, ∀ s ∈ allFrequencyList n t, s.natAbs < q) + (hsmall' : ∀ q ∈ Q, ∀ s ∈ allFrequencyList n t', s.natAbs < q) + (hlow : ∀ p ∈ P, 2 * A ≤ p) (hhigh : ∀ p ∈ P, p ≤ E) + (lower : ℝ) (hlower : 0 < lower) (hlowerQ : ∀ q ∈ Q, lower ≤ (q : ℝ)) + (hPmass : 0 < ∑ p ∈ P, (p : ℝ)⁻¹) (hQmass : 0 < ∑ q ∈ Q, (q : ℝ)⁻¹) + (Bq : ℕ) (hBq : ∀ q : Q, (q : ℕ) ≤ Bq) (outside : OtherVertices a b → ℕ) : + ‖∑ p : P, (primeSubsetPrior P P p : ℂ) * + ∑ q : Q, (primeSubsetPrior Q Q q : ℂ) * + (let x := twoCoordinateAssignment a b hab outside (q : ℕ) (p : ℕ) + finiteEdgeWeight (dirichletGraphEdge χ graph) unary x * + (f.rangedCoefficient D template t hn (expandedPrimeValues n (fun i => (x i : ℤ))) * + conj (f'.rangedCoefficient D' template' t' hn' (expandedPrimeValues n (fun i => (x i : ℤ))))))‖ ^ 2 ≤ + rangedWordTransferPairBound template template' D D' t t' hn hn' B f f' A E P Q lower Bq := by + let e := twoVertexEquiv a b hab + let fixed (q : Q) := expandedPrimeValues n + (twoCoordinateAssignment a b hab (fun i => (outside i : ℤ)) (q : ℕ) 0) + have hh := rangedWordTransfer_pair_dyadic_bound template template' D D' t t' hn hn' B hB hwords hwords' + hD hD' hz hz' f f' (fun i => χ (e i)) (fun i j => graph (e i) (e j)) + (fun i => unary (e i)) outside (fun i x => hunary (e i) x) hself hreverse + P Q hprime hnonprincipal A E hA hMA hsmall hsmall' hlow hhigh lower hlower hlowerQ + hPmass hQmass fixed (.inl b) Bq hBq + simp_rw [finiteEdgeWeight_twoCoordinate_reindex a b hab, + expandedPrimeValues_twoCoordinate a b hab n] + exact hh + +/-- Every remaining coordinate keeps its own original harmonic prior. +Only the displayed numerical estimate remains to be specialized. -/ +theorem ranged_expanded_word_pair_original_bound {V : Type*} [Fintype V] + (a b : V) (hab : a ≠ b) {n : ℕ} + (template template' : WordTransferTemplate (ExpandedScheduledVariable V n) n) + (D D' : WordRangeDecoration (ExpandedScheduledVariable V n) n) (t t' : FrequencyTree ℤ n) + (hn : NonzeroInternalFrequencies n t) (hn' : NonzeroInternalFrequencies n t') + (B : ℕ) (hB : 1 ≤ B) (hwords : template.WordsBounded B) (hwords' : template'.WordsBounded B) + (hD : D.WordsBounded B) (hD' : D'.WordsBounded B) + (hz : ∀ s ∈ allFrequencyList n t, s ≠ 0) (hz' : ∀ s ∈ allFrequencyList n t', s ≠ 0) + (f f' : WordFourierParameters n) + (χ : V → ∀ p : ℕ, DirichletCharacter ℂ p) (graph : V → V → ℤ) + (unary : V → ℕ → ℂ) (hunary : ∀ i x, ‖unary i x‖ ≤ 1) + (hself : graph a a = 0 ∧ graph b b = 0) (hreverse : graph b a = 0) + (P : Finset ℕ) (Q : V → Finset ℕ) (hQP : ∀ i, Q i ⊆ P) + (hQmass : ∀ i, 0 < ∑ q ∈ Q i, (q : ℝ)⁻¹) + (hprime : ∀ q ∈ Q a, q.Prime) + (hnonprincipal : ∀ q ∈ Q a, χ a q ^ graph a b ≠ 1) + (A E : ℕ) (hA : 0 < A) + (hMA : wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B ≤ A) + (hsmall : ∀ q ∈ Q a, ∀ s ∈ allFrequencyList n t, s.natAbs < q) + (hsmall' : ∀ q ∈ Q a, ∀ s ∈ allFrequencyList n t', s.natAbs < q) + (hlow : ∀ p ∈ Q b, 2 * A ≤ p) (hhigh : ∀ p ∈ Q b, p ≤ E) + (lower : ℝ) (hlower : 0 < lower) (hlowerQ : ∀ q ∈ Q a, lower ≤ (q : ℝ)) + (Bq : ℕ) (hBq : ∀ q : Q a, (q : ℕ) ≤ Bq) + (δ : ℝ) (hδ : 0 ≤ δ) + (hnum : rangedWordTransferPairBound template template' D D' t t' hn hn' B f f' A E (Q b) (Q a) lower Bq ≤ δ ^ 2) : + ‖∑ x : V → P, ((∏ i, primeSubsetPrior P (Q i) (x i) : ℝ) : ℂ) * + (finiteEdgeWeight (dirichletGraphEdge χ graph) unary (fun i => (x i : ℕ)) * + (f.rangedCoefficient D template t hn (expandedPrimeValues n (fun i => (x i : ℤ))) * + conj (f'.rangedCoefficient D' template' t' hn' (expandedPrimeValues n (fun i => (x i : ℤ))))))‖ ≤ δ := by + apply original_harmonic_pair_bound a b hab P Q hQP (fun i => (hQmass i).ne') + (fun x => finiteEdgeWeight (dirichletGraphEdge χ graph) unary x * + (f.rangedCoefficient D template t hn (expandedPrimeValues n (fun i => (x i : ℤ))) * + conj (f'.rangedCoefficient D' template' t' hn' (expandedPrimeValues n (fun i => (x i : ℤ)))))) δ hδ + intro outside + have hs := selected_ranged_expanded_word_pair_bound a b hab template template' D D' t t' hn hn' B hB + hwords hwords' hD hD' hz hz' f f' χ graph unary hunary hself hreverse (Q b) (Q a) hprime + hnonprincipal A E hA hMA hsmall hsmall' hlow hhigh lower hlower hlowerQ + (hQmass b) (hQmass a) Bq hBq (fun i => (outside i : ℕ)) + exact (sq_le_sq₀ (norm_nonneg _) hδ).mp (hs.trans hnum) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairAdmissibility.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairAdmissibility.lean new file mode 100644 index 0000000000000000000000000000000000000000..c9d14d3c54a0172ebef6bf3aa23b980d2d835efe --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairAdmissibility.lean @@ -0,0 +1,65 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.RangedPairNumericBudget + +namespace OAI + +/-! # The actual periods and frequencies fit below the separated prime scales -/ + +namespace Ostmann +open Filter + +/-- A fixed-depth polynomial period is below the long-prime cutoff. Every +actual frequency is also below the smallest retained prime. -/ +theorem eventual_word_pair_admissible (n : ℕ) (b C z α β c : ℝ) + (hb : 0 ≤ b) (hC : 0 ≤ C) (hz : 0 ≤ z) (hα : 0 < α) + (hαβ : α < β) (hc : 0 < c) : + ∀ᶠ L : ℝ in atTop, ∀ (t t' : FrequencyTree ℤ n) + (B V A : ℕ) (lower m : ℝ), + 0 ≤ m → m ≤ z * L → (B : ℝ) ≤ b * (1 + m) → + (V : ℝ) ≤ Real.exp (C * (1 + m)) → + (∀ s ∈ allFrequencyList n t, s.natAbs ≤ V) → + (∀ s ∈ allFrequencyList n t', s.natAbs ≤ V) → + Real.exp (c * Real.exp (α * L)) ≤ lower → + Real.exp (Real.exp (β * L)) ≤ (A : ℝ) → + wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B ≤ A ∧ + (∀ p : ℕ, lower ≤ (p : ℝ) → ∀ s ∈ allFrequencyList n t, s.natAbs < p) ∧ + (∀ p : ℕ, lower ≤ (p : ℝ) → ∀ s ∈ allFrequencyList n t', s.natAbs < p) := by + let K := 2 * C * wordPeriodExponent n b + have hK : 0 ≤ K := by dsimp [K, wordPeriodExponent]; positivity + have hβ : 0 < β := hα.trans hαβ + filter_upwards [eventual_polynomial_log_budget K z β 1 (n + 2) hK hz hβ (by norm_num), + eventual_polynomial_log_budget C z α (c / 2) 1 hC hz hα (by positivity)] + with L hperiod hfreq + intro t t' B V A lower m hm hmL hB hV hf hf' hlower hA + have hp := wordTransferFullPeriod_le_exp n t B V b C m hC hm hB hV hf + have hp' := wordTransferFullPeriod_le_exp n t' B V b C m hC hm hB hV hf' + have hMA : wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B ≤ A := by + have hexp := hperiod m hm hmL + simp only [one_mul] at hexp + have hmulp : ((wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B : ℕ) : ℝ) ≤ + Real.exp (K * (1 + m) ^ (n + 2)) := by + push_cast + apply (mul_le_mul hp hp' (by positivity) (Real.exp_nonneg _)).trans_eq + rw [← Real.exp_add] + congr 1 + dsimp [K] + ring + exact_mod_cast hmulp.trans ((Real.exp_le_exp.mpr hexp).trans hA) + have hVlow : (V : ℝ) < lower := by + have hfl := hfreq m hm hmL + simp only [pow_one] at hfl + have hstrict : C * (1 + m) < c * Real.exp (α * L) := by + nlinarith only [hfl, mul_pos hc (Real.exp_pos (α * L))] + exact hV.trans_lt ((Real.exp_lt_exp.mpr hstrict).trans_le hlower) + refine ⟨hMA, ?_, ?_⟩ + · intro p hp s hs + have hsp : (s.natAbs : ℝ) < (p : ℝ) := + (Nat.cast_le.mpr (hf s hs)).trans_lt (hVlow.trans_le hp) + exact_mod_cast hsp + · intro p hp s hs + have hsp : (s.natAbs : ℝ) < (p : ℝ) := + (Nat.cast_le.mpr (hf' s hs)).trans_lt (hVlow.trans_le hp) + exact_mod_cast hsp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairNumericBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairNumericBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..55f572320fcd9a2f1fd5713a4ba0b1b464c55bf7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairNumericBudget.lean @@ -0,0 +1,155 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.RangedComplexityBudget +import OAI.NumberTheory.Ostmann.Construction.WordFourierBudgetBounds +import OAI.NumberTheory.Ostmann.Arithmetic.PrimePairDecay +import OAI.NumberTheory.Ostmann.Construction.DyadicShellBudget + +namespace OAI + +/-! # Explicit numerical costs of the two actual ranged word histories -/ + +namespace Ostmann +open scoped BigOperators +open Filter + +noncomputable def rangedPairExponent (n : ℕ) (b d C S H : ℝ) : ℝ := + H + 2 * C * wordPeriodExponent n b + + 4 * Real.log 3 * (((3 * 2 ^ n + 3 * (2 ^ n - 1) : ℕ) : ℝ) + 4 * d) * + b ^ (n + 1) + 2 * ((4 * S + 2 * C) * (2 ^ n : ℕ)) + +theorem rangedPairExponent_nonneg (n : ℕ) (b d C S H : ℝ) + (hb : 0 ≤ b) (hd : 0 ≤ d) (hC : 0 ≤ C) (hS : 0 ≤ S) (hH : 0 ≤ H) : + 0 ≤ rangedPairExponent n b d C S H := by + unfold rangedPairExponent wordPeriodExponent + positivity + +/-- The period, Boolean partition, Fourier variation and harmonic normalizers +all have a common explicit polynomial exponent. -/ +theorem ranged_pair_numeric_costs {σ : Type*} {n : ℕ} + (T T' : WordTransferTemplate σ n) (D D' : WordRangeDecoration σ n) + (t t' : FrequencyTree ℤ n) (ht : NonzeroInternalFrequencies n t) + (ht' : NonzeroInternalFrequencies n t') + (B V E : ℕ) (f f' : WordFourierParameters n) (P Q : Finset ℕ) + (b d C S H m : ℝ) (hb : 0 ≤ b) (hd : 0 ≤ d) (hC : 0 ≤ C) + (hS : 1 ≤ S) (hH : 0 ≤ H) (hm : 0 ≤ m) + (hB : (B : ℝ) ≤ b * (1 + m)) + (hD : (D.count : ℝ) ≤ d * (1 + m)) (hD' : (D'.count : ℝ) ≤ d * (1 + m)) + (hV : (V : ℝ) ≤ Real.exp (C * (1 + m))) + (hf : ∀ s ∈ allFrequencyList n t, s.natAbs ≤ V) + (hf' : ∀ s ∈ allFrequencyList n t', s.natAbs ≤ V) + (hs₀ : SchwartzMap.seminorm ℝ 0 0 f.profile ≤ S) + (hs₁ : SchwartzMap.seminorm ℝ 0 1 f.profile ≤ S) + (hs₀' : SchwartzMap.seminorm ℝ 0 0 f'.profile ≤ S) + (hs₁' : SchwartzMap.seminorm ℝ 0 1 f'.profile ≤ S) + (hr : ∀ i, f.upper i - f.lower i ≤ Real.exp (C * (1 + m))) + (hr' : ∀ i, f'.upper i - f'.lower i ≤ Real.exp (C * (1 + m))) + (hE : ((Nat.log 2 E + 1 : ℕ) : ℝ) ≤ Real.exp (H * (1 + m))) + (hP : (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ ≤ Real.exp (H * (1 + m))) + (hQ : (∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ ≤ Real.exp (H * (1 + m))) : + let K := Real.log 2 + 6 * rangedPairExponent n b d C S H + 2 * ((Nat.log 2 E + 1 : ℕ) : ℝ) * (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ * (f.budget T t ht * f'.budget T' t' ht') ^ 2 ≤ + Real.exp (K * (1 + m) ^ (n + 2)) ∧ + 2 * ((Nat.log 2 E + 1 : ℕ) : ℝ) * (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B : ℕ) * + (3 ^ (2 * (((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)) + + ((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)))) : ℕ) * + (f.budget T t ht * f'.budget T' t' ht') ^ 2 ≤ + Real.exp (K * (1 + m) ^ (n + 2)) := by + let W := wordPeriodExponent n b + let R := (((3 * 2 ^ n + 3 * (2 ^ n - 1) : ℕ) : ℝ) + 4 * d) * b ^ (n + 1) + let F := (4 * S + 2 * C) * (2 ^ n : ℕ) + let K₀ := rangedPairExponent n b d C S H + have hW : 0 ≤ W := by dsimp [W, wordPeriodExponent]; positivity + have hR : 0 ≤ R := by dsimp [R]; positivity + have hF : 0 ≤ F := by dsimp [F]; positivity + have hK₀ : 0 ≤ K₀ := rangedPairExponent_nonneg n b d C S H hb hd hC (by linarith) hH + have hpow : 1 + m ≤ (1 + m) ^ (n + 2) := by + simpa only [pow_one] using pow_le_pow_right₀ (by linarith : 1 ≤ 1 + m) + (show 1 ≤ n + 2 by omega) + have hunit : 1 ≤ (1 + m) ^ (n + 2) := one_le_pow₀ (by linarith) + have hKeq : K₀ = H + 2 * C * W + 4 * Real.log 3 * R + 2 * F := by + dsimp [K₀, rangedPairExponent, W, R, F] + ring + have hlog3 : 0 ≤ Real.log 3 := Real.log_nonneg (by norm_num) + have hCW : 0 ≤ 2 * C * W := by positivity + have hRR : 0 ≤ 4 * Real.log 3 * R := by positivity + have hHK : H ≤ K₀ := by rw [hKeq]; linarith + have hWK : 2 * C * W ≤ K₀ := by rw [hKeq]; linarith + have hRK : 4 * Real.log 3 * R ≤ K₀ := by rw [hKeq]; linarith + have hFK : 2 * F ≤ K₀ := by rw [hKeq]; linarith + have hlift (a : ℝ) (ha : 0 ≤ a) (haK : a ≤ K₀) : + a * (1 + m) ≤ K₀ * (1 + m) ^ (n + 2) := + (mul_le_mul_of_nonneg_left hpow ha).trans + (mul_le_mul_of_nonneg_right haK (by positivity)) + have hfreq (s : ℤ) (hs : s.natAbs ≤ V) : |(s : ℝ)| ≤ Real.exp (C * (1 + m)) := by + have hh : |(s : ℝ)| ≤ (V : ℝ) := by + simpa only [Nat.cast_natAbs, Int.cast_abs] using (show (s.natAbs : ℝ) ≤ (V : ℝ) from by exact_mod_cast hs) + exact hh.trans hV + have hbudget := f.budget_le_exp T t ht S C m hS hC hm hs₀ hs₁ + (fun s hs => hfreq s (hf s hs)) hr + have hbudget' := f'.budget_le_exp T' t' ht' S C m hS hC hm hs₀' hs₁' + (fun s hs => hfreq s (hf' s hs)) hr' + have hBpair : f.budget T t ht * f'.budget T' t' ht' ≤ + Real.exp (K₀ * (1 + m) ^ (n + 2)) := by + calc + _ ≤ Real.exp (F * (1 + m)) * Real.exp (F * (1 + m)) := + mul_le_mul hbudget hbudget' (f'.budget_nonneg _ _ _) (Real.exp_nonneg _) + _ = Real.exp ((2 * F) * (1 + m)) := by rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (hlift (2 * F) (by positivity) hFK) + have hperiod : (wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B : ℝ) ≤ + Real.exp (K₀ * (1 + m) ^ (n + 2)) := by + calc + _ ≤ Real.exp (C * W * (1 + m) ^ (n + 2)) * + Real.exp (C * W * (1 + m) ^ (n + 2)) := + mul_le_mul (wordTransferFullPeriod_le_exp n t B V b C m hC hm hB hV hf) + (wordTransferFullPeriod_le_exp n t' B V b C m hC hm hB hV hf') + (by positivity) (Real.exp_nonneg _) + _ = Real.exp ((2 * C * W) * (1 + m) ^ (n + 2)) := by + rw [← Real.exp_add]; congr 1; ring + _ ≤ _ := Real.exp_le_exp.mpr (mul_le_mul_of_nonneg_right hWK (by positivity)) + have hpartition := ranged_boolean_partition_le D D' B R m + (ranged_word_complexity_le D D' B b d m hd hm hB hD hD') + have hpartition' := hpartition.trans (Real.exp_le_exp.mpr + (mul_le_mul_of_nonneg_right hRK (by positivity : 0 ≤ (1 + m) ^ (n + 2)))) + have hcost := dyadic_character_cost ((Nat.log 2 E + 1 : ℕ) : ℝ) + (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ (∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ + (wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B : ℕ) + (3 ^ (2 * (((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)) + + ((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)))) : ℕ) + (f.budget T t ht * f'.budget T' t' ht') (K₀ * (1 + m) ^ (n + 2)) + (by positivity) (by positivity) (by positivity) (by positivity) (by positivity) + (mul_nonneg (f.budget_nonneg _ _ _) (f'.budget_nonneg _ _ _)) (by positivity) + (hE.trans (Real.exp_le_exp.mpr (hlift H hH hHK))) + (hP.trans (Real.exp_le_exp.mpr (hlift H hH hHK))) + (hQ.trans (Real.exp_le_exp.mpr (hlift H hH hHK))) + (by exact_mod_cast hperiod) hpartition' hBpair + have hexp : Real.log 2 + 6 * (K₀ * (1 + m) ^ (n + 2)) ≤ + (Real.log 2 + 6 * K₀) * (1 + m) ^ (n + 2) := by + have hlog : 0 ≤ Real.log 2 := Real.log_nonneg (by norm_num) + nlinarith + exact ⟨hcost.1.trans (Real.exp_le_exp.mpr hexp), hcost.2.trans (Real.exp_le_exp.mpr hexp)⟩ + +/-- The dyadic shell count uses only a double-exponential endpoint bound; +its own cost is singly exponential in the word length. -/ +theorem dyadic_shell_linear_exponential (E : ℕ) (C m : ℝ) + (hC : 0 ≤ C) (hm : 0 ≤ m) + (hE : (E : ℝ) ≤ Real.exp (Real.exp (C * (1 + m)))) : + ((Nat.log 2 E + 1 : ℕ) : ℝ) ≤ + Real.exp ((2 + 1 / Real.log 2 + C) * (1 + m)) := by + let a : ℝ := 2 + 1 / Real.log 2 + have ha : 0 ≤ a := by dsimp [a]; positivity + have hT : 1 ≤ Real.exp (C * (1 + m)) := Real.one_le_exp (by positivity) + have hc := dyadic_shell_count_bound 1 (Real.exp (C * (1 + m))) + (by norm_num) hT E (by simpa only [one_mul] using hE) + have hea : a ≤ Real.exp a := by linarith [Real.add_one_le_exp a] + push_cast + calc + _ ≤ a * Real.exp (C * (1 + m)) := hc + _ ≤ Real.exp a * Real.exp (C * (1 + m)) := + mul_le_mul_of_nonneg_right hea (Real.exp_nonneg _) + _ = Real.exp (a + C * (1 + m)) := (Real.exp_add _ _).symm + _ ≤ _ := Real.exp_le_exp.mpr (by dsimp [a] at *; nlinarith) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairParameterDecay.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairParameterDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..de1df8e2755d91e53700a93236235875baa636f5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairParameterDecay.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.RangedPairNumericBudget + +namespace OAI + +namespace Ostmann +open scoped BigOperators +open Filter + +/-- Explicit size bounds control all arithmetic costs, +so separated prime scales give the required error without a numerical +cancellation assumption. -/ +theorem eventual_ranged_pair_decay_from_data {σ : Type*} (n : ℕ) + (b d C S H z α β γ c : ℝ) + (hb : 0 ≤ b) (hd : 0 ≤ d) (hC : 0 ≤ C) (hS : 1 ≤ S) (hH : 0 ≤ H) + (hz : 0 ≤ z) (hα : 0 < α) (hαβ : α < β) (hγβ : γ < β) (hc : 0 < c) : + ∀ᶠ L : ℝ in atTop, ∀ + (T T' : WordTransferTemplate σ n) (D D' : WordRangeDecoration σ n) + (t t' : FrequencyTree ℤ n) (ht : NonzeroInternalFrequencies n t) + (ht' : NonzeroInternalFrequencies n t') + (B V A E : ℕ) (f f' : WordFourierParameters n) (P Q : Finset ℕ) + (lower : ℝ) (Bq : ℕ) (m : ℝ), + 0 ≤ m → m ≤ z * L → + (B : ℝ) ≤ b * (1 + m) → + (D.count : ℝ) ≤ d * (1 + m) → (D'.count : ℝ) ≤ d * (1 + m) → + (V : ℝ) ≤ Real.exp (C * (1 + m)) → + (∀ s ∈ allFrequencyList n t, s.natAbs ≤ V) → + (∀ s ∈ allFrequencyList n t', s.natAbs ≤ V) → + SchwartzMap.seminorm ℝ 0 0 f.profile ≤ S → + SchwartzMap.seminorm ℝ 0 1 f.profile ≤ S → + SchwartzMap.seminorm ℝ 0 0 f'.profile ≤ S → + SchwartzMap.seminorm ℝ 0 1 f'.profile ≤ S → + (∀ i, f.upper i - f.lower i ≤ Real.exp (C * (1 + m))) → + (∀ i, f'.upper i - f'.lower i ≤ Real.exp (C * (1 + m))) → + ((Nat.log 2 E + 1 : ℕ) : ℝ) ≤ Real.exp (H * (1 + m)) → + (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ ≤ Real.exp (H * (1 + m)) → + (∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ ≤ Real.exp (H * (1 + m)) → + Real.exp (c * Real.exp (α * L)) ≤ lower → + Real.exp (Real.exp (β * L)) ≤ (A : ℝ) → + (Bq : ℝ) ≤ Real.exp (Real.exp (γ * L)) → + rangedWordTransferPairBound T T' D D' t t' ht ht' B f f' + A E P Q lower Bq ≤ (Real.exp (-(c / 4) * Real.exp (α * L))) ^ 2 := by + let K := Real.log 2 + 6 * rangedPairExponent n b d C S H + have hK : 0 ≤ K := by + have hh := rangedPairExponent_nonneg n b d C S H hb hd hC (by linarith) hH + dsimp [K] + positivity + filter_upwards [eventual_ranged_word_pair_decay K z α β γ c (n + 2) + hK hz hα hαβ hγβ hc] with L hL + intro T T' D D' t t' ht ht' B V A E f f' P Q lower Bq m + hm hmL hB hD hD' hV hf hf' hs₀ hs₁ hs₀' hs₁' hr hr' hE hP hQ hlower hA hBq + have hcost := ranged_pair_numeric_costs T T' D D' t t' ht ht' B V E f f' P Q + b d C S H m hb hd hC hS hH hm hB hD hD' hV hf hf' hs₀ hs₁ hs₀' hs₁' hr hr' + hE hP hQ + exact hL T T' D D' t t' ht ht' B A E f f' P Q lower Bq m hm hmL hlower hA hBq + hcost.1 hcost.2 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairUniformDecay.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairUniformDecay.lean new file mode 100644 index 0000000000000000000000000000000000000000..04501e2b51d0116247f835aa21dfd1442ebc7794 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedPairUniformDecay.lean @@ -0,0 +1,102 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.RangedPairParameterDecay + +namespace OAI + +/-! # One-sided numerical decay uniform over the growing prime-coordinate space -/ +namespace Ostmann +universe u +open Filter +open scoped BigOperators + +theorem eventual_ranged_word_pair_decay_uniform {n : ℕ} + (K z α β γ c : ℝ) (d : ℕ) + (hK : 0 ≤ K) (hz : 0 ≤ z) (hα : 0 < α) (hαβ : α < β) + (hγβ : γ < β) (hc : 0 < c) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u), + ∀ (template template' : WordTransferTemplate σ n) + (D D' : WordRangeDecoration σ n) (t t' : FrequencyTree ℤ n) + (ht : NonzeroInternalFrequencies n t) (ht' : NonzeroInternalFrequencies n t') + (B A E : ℕ) (f f' : WordFourierParameters n) (P Q : Finset ℕ) + (lower : ℝ) (Bq : ℕ) (m : ℝ), + 0 ≤ m → m ≤ z * L → + Real.exp (c * Real.exp (α * L)) ≤ lower → + Real.exp (Real.exp (β * L)) ≤ (A : ℝ) → + (Bq : ℝ) ≤ Real.exp (Real.exp (γ * L)) → + 2 * ((Nat.log 2 E + 1 : ℕ) : ℝ) * (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ * + (f.budget template t ht * f'.budget template' t' ht') ^ 2 ≤ + Real.exp (K * (1 + m) ^ d) → + 2 * ((Nat.log 2 E + 1 : ℕ) : ℝ) * (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B : ℕ) * + (3 ^ (2 * (((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)) + + ((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)))) : ℕ) * + (f.budget template t ht * f'.budget template' t' ht') ^ 2 ≤ + Real.exp (K * (1 + m) ^ d) → + rangedWordTransferPairBound template template' D D' t t' ht ht' B f f' + A E P Q lower Bq ≤ (Real.exp (-(c / 4) * Real.exp (α * L))) ^ 2 := by + filter_upwards [eventual_one_sided_squared_budget K z α β γ c d hK hz hα hαβ hγβ hc] + with L hL σ template template' D D' t t' ht ht' B A E f f' P Q lower Bq m + hm hmL hlower hA hBq hcost₁ hcost₂ + have hh := dyadic_character_numeric_bound + ((Nat.log 2 E + 1 : ℕ) : ℝ) (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ (∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ + (wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B : ℕ) + (3 ^ (2 * (((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)) + + ((3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1)))) : ℕ) + (f.budget template t ht * f'.budget template' t' ht') A lower Bq + (Real.exp (K * (1 + m) ^ d)) α β γ c L + (by positivity) (by positivity) (by positivity) (by positivity) (by positivity) + hlower hA (Nat.cast_nonneg _) hBq hcost₁ hcost₂ + apply hh.trans + apply (hL m hm hmL).trans_eq + rw [← Real.exp_nat_mul] + congr 1 + ring + +theorem eventual_ranged_pair_decay_from_data_uniform (n : ℕ) + (b d C S H z α β γ c : ℝ) + (hb : 0 ≤ b) (hd : 0 ≤ d) (hC : 0 ≤ C) (hS : 1 ≤ S) (hH : 0 ≤ H) + (hz : 0 ≤ z) (hα : 0 < α) (hαβ : α < β) (hγβ : γ < β) (hc : 0 < c) : + ∀ᶠ L : ℝ in atTop, ∀ (σ : Type u), ∀ + (T T' : WordTransferTemplate σ n) (D D' : WordRangeDecoration σ n) + (t t' : FrequencyTree ℤ n) (ht : NonzeroInternalFrequencies n t) + (ht' : NonzeroInternalFrequencies n t') + (B V A E : ℕ) (f f' : WordFourierParameters n) (P Q : Finset ℕ) + (lower : ℝ) (Bq : ℕ) (m : ℝ), + 0 ≤ m → m ≤ z * L → + (B : ℝ) ≤ b * (1 + m) → + (D.count : ℝ) ≤ d * (1 + m) → (D'.count : ℝ) ≤ d * (1 + m) → + (V : ℝ) ≤ Real.exp (C * (1 + m)) → + (∀ s ∈ allFrequencyList n t, s.natAbs ≤ V) → + (∀ s ∈ allFrequencyList n t', s.natAbs ≤ V) → + SchwartzMap.seminorm ℝ 0 0 f.profile ≤ S → + SchwartzMap.seminorm ℝ 0 1 f.profile ≤ S → + SchwartzMap.seminorm ℝ 0 0 f'.profile ≤ S → + SchwartzMap.seminorm ℝ 0 1 f'.profile ≤ S → + (∀ i, f.upper i - f.lower i ≤ Real.exp (C * (1 + m))) → + (∀ i, f'.upper i - f'.lower i ≤ Real.exp (C * (1 + m))) → + ((Nat.log 2 E + 1 : ℕ) : ℝ) ≤ Real.exp (H * (1 + m)) → + (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ ≤ Real.exp (H * (1 + m)) → + (∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ ≤ Real.exp (H * (1 + m)) → + Real.exp (c * Real.exp (α * L)) ≤ lower → + Real.exp (Real.exp (β * L)) ≤ (A : ℝ) → + (Bq : ℝ) ≤ Real.exp (Real.exp (γ * L)) → + rangedWordTransferPairBound T T' D D' t t' ht ht' B f f' + A E P Q lower Bq ≤ (Real.exp (-(c / 4) * Real.exp (α * L))) ^ 2 := by + let K := Real.log 2 + 6 * rangedPairExponent n b d C S H + have hK : 0 ≤ K := by + have hh := rangedPairExponent_nonneg n b d C S H hb hd hC (by linarith) hH + dsimp [K] + positivity + filter_upwards [eventual_ranged_word_pair_decay_uniform (n := n) K z α β γ c (n + 2) + hK hz hα hαβ hγβ hc] with L hL + intro σ T T' D D' t t' ht ht' B V A E f f' P Q lower Bq m + hm hmL hB hD hD' hV hf hf' hs₀ hs₁ hs₀' hs₁' hr hr' hE hP hQ hlower hA hBq + have hcost := ranged_pair_numeric_costs T T' D D' t t' ht ht' B V E f f' P Q + b d C S H m hb hd hC hS hH hm hB hD hD' hV hf hf' hs₀ hs₁ hs₀' hs₁' hr hr' + hE hP hQ + exact hL σ T T' D D' t t' ht ht' B A E f f' P Q lower Bq m hm hmL hlower hA hBq + hcost.1 hcost.2 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedWordPairBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedWordPairBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..ea64c4123506fa0b00de9a866485148356d4d7fa --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RangedWordPairBound.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.Ostmann.Construction.WordRangePolynomial +import OAI.NumberTheory.Ostmann.Arithmetic.GuardedHistoryPair +import OAI.NumberTheory.Ostmann.Construction.DyadicGuardedGraph + +namespace OAI + +/-! # One-sided cancellation with every original word and product range -/ + +namespace Ostmann + +open scoped BigOperators ComplexConjugate Classical + +theorem rangedWordTransfer_pair_dyadic_bound {J σ : Type*} [Fintype J] {n : ℕ} + (template template' : WordTransferTemplate σ n) + (D D' : WordRangeDecoration σ n) (t t' : FrequencyTree ℤ n) + (hn : NonzeroInternalFrequencies n t) (hn' : NonzeroInternalFrequencies n t') + (B : ℕ) (hB : 1 ≤ B) (hwords : template.WordsBounded B) (hwords' : template'.WordsBounded B) + (hD : D.WordsBounded B) (hD' : D'.WordsBounded B) + (hz : ∀ s ∈ allFrequencyList n t, s ≠ 0) (hz' : ∀ s ∈ allFrequencyList n t', s ≠ 0) + (f f' : WordFourierParameters n) + (χ : (Bool ⊕ J) → ∀ p : ℕ, DirichletCharacter ℂ p) + (graph : (Bool ⊕ J) → (Bool ⊕ J) → ℤ) + (unary : (Bool ⊕ J) → ℕ → ℂ) (outside : J → ℕ) + (hunary : ∀ i x, ‖unary i x‖ ≤ 1) + (hself : graph (.inl true) (.inl true) = 0 ∧ graph (.inl false) (.inl false) = 0) + (hreverse : graph (.inl false) (.inl true) = 0) + (P Q : Finset ℕ) (hprime : ∀ q ∈ Q, q.Prime) + (hnonprincipal : ∀ q ∈ Q, χ (.inl true) q ^ graph (.inl true) (.inl false) ≠ 1) + (A E : ℕ) (hA : 0 < A) + (hMA : wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B ≤ A) + (hsmall : ∀ q ∈ Q, ∀ s ∈ allFrequencyList n t, s.natAbs < q) + (hsmall' : ∀ q ∈ Q, ∀ s ∈ allFrequencyList n t', s.natAbs < q) + (hlow : ∀ p ∈ P, 2 * A ≤ p) (hhigh : ∀ p ∈ P, p ≤ E) + (b : ℝ) (hb : 0 < b) (hbQ : ∀ q ∈ Q, b ≤ (q : ℝ)) + (hPmass : 0 < ∑ p ∈ P, (p : ℝ)⁻¹) (hQmass : 0 < ∑ q ∈ Q, (q : ℝ)⁻¹) + (fixed : Q → σ → ℤ) (coord : σ) (Bq : ℕ) (hBq : ∀ q : Q, (q : ℕ) ≤ Bq) : + let M := wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B + let R := (3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1) + let C := f.budget template t hn * f'.budget template' t' hn' + ‖∑ p : P, (primeSubsetPrior P P p : ℂ) * + ∑ q : Q, (primeSubsetPrior Q Q q : ℂ) * + (finiteEdgeWeight (dirichletGraphEdge χ graph) unary + (twoVertexLabels outside (q : ℕ) (p : ℕ)) * + (f.rangedCoefficient D template t hn (Function.update (fixed q) coord (p : ℕ)) * + conj (f'.rangedCoefficient D' template' t' hn' (Function.update (fixed q) coord (p : ℕ)))))‖ ^ 2 ≤ + ((Nat.log 2 E + 1 : ℕ) : ℝ) * (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (((∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ * b⁻¹) * (2 * C ^ 2) + + (M : ℝ) * ((3 ^ (2 * (R + R)) : ℕ) * (2 * (A : ℝ)⁻¹ * C ^ 2)) * (Bq : ℝ) ^ 2) := by + let M := wordTransferFullPeriod n t B * wordTransferFullPeriod n t' B + let R := (3 * 2 ^ n + 3 * (2 ^ n - 1) + 2 * (D.count + D'.count)) * B ^ (n + 1) + let G := template.guardAt t hn + let G' := template'.guardAt t' hn' + have hMpos : 0 < M := Nat.mul_pos (wordTransferFullPeriod_pos n t B hz) + (wordTransferFullPeriod_pos n t' B hz') + let : NeZero M := ⟨Nat.ne_of_gt hMpos⟩ + have hM (q : Q) : M.Coprime (q : ℕ) := by + exact ((prime_coprime_wordTransferFullPeriod n t B q (hprime q q.property) + (fun s hs => ⟨Int.natAbs_pos.mpr (hz s hs), hsmall q q.property s hs⟩)).mul_right + (prime_coprime_wordTransferFullPeriod n t' B q (hprime q q.property) + (fun s hs => ⟨Int.natAbs_pos.mpr (hz' s hs), hsmall' q q.property s hs⟩))).symm + have hden (i : Fin ((2 ^ n - 1 + (2 ^ n - 1)) + (2 ^ n - 1 + (2 ^ n - 1)))) : + Fin.append (wordGuardDenominators G) (wordGuardDenominators G') i ≠ 0 := by + exact Fin.addCases (fun j => by simpa only [Fin.append_left] using template.guardAt_denominators_ne_zero t hn j) + (fun j => by simpa only [Fin.append_right] using template'.guardAt_denominators_ne_zero t' hn' j) i + have hdiv (i : Fin ((2 ^ n - 1 + (2 ^ n - 1)) + (2 ^ n - 1 + (2 ^ n - 1)))) : + Fin.append (wordGuardDenominators G) (wordGuardDenominators G') i * + ((Fin.append (wordGuardModuli G) (wordGuardModuli G') i : ℕ) : ℤ) ∣ (M : ℤ) := by + refine Fin.addCases (fun j => ?_) (fun j => ?_) i + · simpa only [Fin.append_left, M, Nat.cast_mul] using + (template.guardAt_full_period t hn B hB hwords j).trans (dvd_mul_right _ _) + · simpa only [Fin.append_right, M, Nat.cast_mul] using + (template'.guardAt_full_period t' hn' B hB hwords' j).trans (dvd_mul_left _ _) + simp_rw [f.rangedCoefficient_local D template t hn, f'.rangedCoefficient_local D' template' t' hn'] + simp_rw [← guardedHistoryAmplitude_pair] + apply dyadic_guarded_graph_bound χ graph unary outside hunary hself hreverse P Q hprime + hnonprincipal A E M hA hMA hM hlow hhigh b hb hbQ hPmass hQmass + · exact fun _ => hden + · exact fun _ => hdiv + · exact mul_nonneg (f.budget_nonneg template t hn) (f'.budget_nonneg template' t' hn') + · intro q + rw [pairedPolynomialFactors_budget, f.factors_budget, f'.factors_budget] + · intro q + rw [polynomialWeightComplexity_pair] + have hleft := f.ranged_complexity_bound D template t hn (fixed q) coord B hB hwords hD + have hright := f'.ranged_complexity_bound D' template' t' hn' (fixed q) coord B hB hwords' hD' + apply Nat.add_le_add + · apply hleft.trans + apply Nat.mul_le_mul_right + omega + · apply hright.trans + apply Nat.mul_le_mul_right + omega + + · exact hBq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealBulkKernel.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealBulkKernel.lean new file mode 100644 index 0000000000000000000000000000000000000000..f228901b23b3158c2664e01a204dc0fc5baa3839 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealBulkKernel.lean @@ -0,0 +1,157 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.BulkLogContinuity +import OAI.NumberTheory.Ostmann.Arithmetic.BulkIntegrands +import OAI.NumberTheory.Ostmann.Arithmetic.RealNodeSupport +import OAI.NumberTheory.Ostmann.Arithmetic.MovingKernelPair + +namespace OAI + +/-! # The full original kernel on real bulk coordinates -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap ComplexConjugate + +noncomputable def realValueFullSupport {σ : Type*} (value : σ → ℝ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (X lo hi L R : ℝ) : Prop := + realValueNodeSupport value childBound pivotBound T L R ∧ + ∀ j, T.realValueLeafModuli value L R j / X ∈ Set.Icc lo hi + +noncomputable def realValueSupportFlag {σ : Type*} (value : σ → ℝ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (X lo hi L R : ℝ) : ℂ := + if realValueFullSupport value childBound pivotBound T X lo hi L R then 1 else 0 + +noncomputable def realValueKernel {σ : Type*} (value : σ → ℝ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (L R : ℝ) : ℂ := + realValueSupportFlag value childBound pivotBound T X lo hi L R * + realValueSmoothWeight value T ψ X lo hi hlo hhi φ G L R + +theorem realValueSupportFlag_norm {σ : Type*} (value : σ → ℝ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (X lo hi L R : ℝ) : ‖realValueSupportFlag value childBound pivotBound T X lo hi L R‖ ≤ 1 := by + unfold realValueSupportFlag + split_ifs <;> norm_num + +/-- The real extension has precisely the old arithmetic gates and windows. -/ +theorem realValueSupportFlag_nat {σ : Type*} (value : σ → ℕ) (hv : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (X lo hi L R : ℝ) : + realValueSupportFlag (fun i => (value i : ℝ)) childBound pivotBound T X lo hi L R = + movingRealGateWeight value T + (T.formulaNodes value hv childBound pivotBound hf (.prime false) (.prime true)) + X lo hi (topGiantReal L R) := by + have hn := realValueNodeSupport_nat value hv childBound pivotBound T hf + (.prime false) (.prime true) (topGiantReal L R) + simp only [HistoryFormula.realEval_prime, topGiantReal, Bool.false_eq_true, ite_false, ite_true] at hn + simp only [realValueSupportFlag, realValueFullSupport, movingRealGateWeight, + movingArchimedeanFlag, movingRealWindowFlag, MovingSlotData.realValueLeafModuli_nat, + topGiantReal, Bool.false_eq_true, ite_false, ite_true] + rw [hn] + split_ifs <;> simp_all + +theorem realValueKernel_nat {σ : Type*} (value : σ → ℕ) (hv : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hf : T.Frequencies (· ≠ 0)) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) (L R : ℝ) : + realValueKernel (fun i => (value i : ℝ)) childBound pivotBound T ψ X lo hi hlo hhi φ G L R = + movingRealKernel value T + (T.formulaNodes value hv childBound pivotBound hf (.prime false) (.prime true)) + ψ X lo hi hlo hhi φ G L R := by + rw [realValueKernel, realValueSupportFlag_nat value hv childBound pivotBound T hf, + realValueSmoothWeight_nat] + rfl + +theorem MovingSlotReversal.continuous_bulkLogComposite {σ : Type*} + (base : σ → ℝ) (S : Finset σ) (s : MovingSlotReversal σ) + (L R : (σ → ℝ) → ℝ) (hL : Continuous L) (hR : Continuous R) : + Continuous (fun x => s.realCompositePivot (bulkLogValues base S x) (L x) (R x)) := by + unfold realCompositePivot + exact (((continuous_const.mul + (continuous_realSlotProduct _ (continuous_bulkLogValues base S) s.rightSlots)).mul hR).sub + ((continuous_const.mul + (continuous_realSlotProduct _ (continuous_bulkLogValues base S) s.leftSlots)).mul hL)).div_const _ + +theorem isClosed_bulkLogNodeSupport {σ : Type*} (base : σ → ℝ) (S : Finset σ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hT : ∀ i ∈ S, T.CompensationAbsent i) (L R : (σ → ℝ) → ℝ) + (hL : Continuous L) (hR : Continuous R) : + IsClosed {x | realValueNodeSupport (bulkLogValues base S x) childBound pivotBound T (L x) (R x)} := by + induction T generalizing L R with + | leaf => simpa only [realValueNodeSupport, Set.ofPred_true] using isClosed_univ + | @node n s CL CR u left right ihL ihR => + let step := MovingSlotData.step s CL CR u left right false + have hQ := step.continuous_bulkLogComposite base S L R hL hR + have hp := step.continuous_bulkLogPivot base S (fun i hi => (hT i hi).1) L R hL hR + have hgap := hR.mul (continuous_realSlotProduct _ (continuous_bulkLogValues base S) CR) + exact (isClosed_le continuous_const hQ).inter + ((isClosed_le hQ continuous_const).inter ((isClosed_le continuous_const hgap).inter + ((ihL (fun i hi => (hT i hi).2.1) _ L hp hL).inter + (ihR (fun i hi => (hT i hi).2.2) _ R hp hR)))) + +theorem isClosed_bulkLogFullSupport {σ : Type*} (base : σ → ℝ) (S : Finset σ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hT : ∀ i ∈ S, T.CompensationAbsent i) (X lo hi : ℝ) (L R : (σ → ℝ) → ℝ) + (hL : Continuous L) (hR : Continuous R) : + IsClosed {x | realValueFullSupport (bulkLogValues base S x) childBound pivotBound T X lo hi (L x) (R x)} := by + have hw : IsClosed {x | ∀ j, T.realValueLeafModuli (bulkLogValues base S x) (L x) (R x) j / X ∈ Set.Icc lo hi} := by + simp only [Set.ofPred_forall] + apply isClosed_iInter + intro j + exact isClosed_Icc.preimage ((T.continuous_bulkLogLeafModuli base S hT L R hL hR j).div_const X) + exact (isClosed_bulkLogNodeSupport base S childBound pivotBound T hT L R hL hR).inter hw + +theorem measurable_bulkLogKernel {σ : Type*} [Fintype σ] (base : σ → ℝ) (S : Finset σ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) + (hT : ∀ i ∈ S, T.CompensationAbsent i) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) (hφ : ∀ x, |φ x| ≤ B) + (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (L R : ℝ) : Measurable (fun x => realValueKernel (bulkLogValues base S x) + childBound pivotBound T ψ X lo hi hlo hhi φ G L R) := by + have hg : Measurable (fun x => realValueSupportFlag (bulkLogValues base S x) + childBound pivotBound T X lo hi L R) := by + unfold realValueSupportFlag + exact Measurable.ite + (isClosed_bulkLogFullSupport base S childBound pivotBound T hT X lo hi + (fun _ => L) (fun _ => R) continuous_const continuous_const).measurableSet + measurable_const measurable_const + exact hg.mul (continuous_bulkLogSmoothWeight base S T hT ψ X lo hi hlo hhi φ G B D hB hD + hφ hlip hout (fun _ => L) (fun _ => R) continuous_const continuous_const).measurable + +theorem realValueKernel_norm {σ : Type*} (value : σ → ℝ) (i : σ) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : MovingSlotData σ n) (hT : T.CompensationAbsent i) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : T.Frequencies (fun s => |(s : ℝ)| ≤ V)) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L R : ℝ) : + ‖realValueKernel value childBound pivotBound T ψ X lo hi hlo hhi φ G L R‖ ≤ + movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1) := by + rw [realValueKernel, norm_mul] + have hb := realValueSmoothWeight_norm value i T hT ψ X lo hi V hlo hhi hV + φ G B D hB hD hφ hlip hout L R + exact (mul_le_mul_of_nonneg_right (realValueSupportFlag_norm _ _ _ _ _ _ _ _ _) (norm_nonneg _)).trans + (by simpa only [one_mul] using hb) + +noncomputable def bulkLogKernelIntegrand {σ : Type*} [Fintype σ] + (base : σ → ℝ) (S : Finset σ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (hT : ∀ i ∈ S, T.CompensationAbsent i) + (i : σ) (hiS : i ∈ S) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hV : T.Frequencies (fun s => |(s : ℝ)| ≤ V)) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L R : ℝ) : BulkIntegrand σ where + toFun x := realValueKernel (bulkLogValues base S x) childBound pivotBound T ψ X lo hi hlo hhi φ G L R + measurable := measurable_bulkLogKernel base S childBound pivotBound T hT ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout L R + bounded := by + let C := movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1) + have hb (x : σ → ℝ) := realValueKernel_norm (bulkLogValues base S x) i childBound pivotBound + T (hT i hiS) ψ X lo hi V hlo hhi hV φ G B D hB hD hφ hlip hout L R + exact ⟨C, (norm_nonneg _).trans (hb base), hb⟩ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealBulkKernelPair.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealBulkKernelPair.lean new file mode 100644 index 0000000000000000000000000000000000000000..6cac2662f6665101ea555b919becf0965e8675cc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealBulkKernelPair.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.BulkKernelPairComparison +import OAI.NumberTheory.Ostmann.Arithmetic.BulkPrimeIntegrands + +namespace OAI + +/-! # The original paired kernel as a bounded measurable bulk integrand -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators SchwartzMap ComplexConjugate + +theorem realValueKernelPair_nat {σ : Type*} (value : σ → ℕ) (hv : ∀ i, value i ≠ 0) + (childBound pivotBound : ℕ → ℕ) {n : ℕ} (T : Bool → MovingSlotData σ n) + (hf : ∀ b, (T b).Frequencies (· ≠ 0)) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) (L R : ℝ) : + realValueKernelPair (fun i => (value i : ℝ)) childBound pivotBound T ψ X lo hi hlo hhi φ G L R = + movingRealKernelPair value T + (fun b => (T b).formulaNodes value hv childBound pivotBound (hf b) (.prime false) (.prime true)) + ψ X lo hi hlo hhi φ G L R := by + rw [realValueKernelPair, realValueKernel_nat value hv childBound pivotBound (T false) (hf false), + realValueKernel_nat value hv childBound pivotBound (T true) (hf true)] + rfl + +noncomputable def bulkLogKernelPairIntegrand {σ : Type*} [Fintype σ] + (base : σ → ℝ) (S : Finset σ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (hT : ∀ b i, i ∈ S → (T b).CompensationAbsent i) + (i : σ) (hiS : i ∈ S) (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (hV : ∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (L R : ℝ) : BulkIntegrand σ where + toFun x := realValueKernelPair (bulkLogValues base S x) childBound pivotBound T ψ X lo hi hlo hhi φ G L R + measurable := (measurable_bulkLogKernel base S childBound pivotBound (T false) (hT false) + ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout L R).mul + (Complex.continuous_conj.measurable.comp (measurable_bulkLogKernel base S childBound pivotBound + (T true) (hT true) ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout L R)) + bounded := by + let W := movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1) + have hb (b : Bool) (x : σ → ℝ) := realValueKernel_norm (bulkLogValues base S x) i childBound pivotBound + (T b) (hT b i hiS) ψ X lo hi V hlo hhi (hV b) φ G B D hB hD hφ hlip hout L R + have hW : 0 ≤ W := (norm_nonneg _).trans (hb false base) + refine ⟨W ^ 2, sq_nonneg _, fun x => ?_⟩ + rw [realValueKernelPair, norm_mul, Complex.norm_conj, pow_two] + exact mul_le_mul (hb false x) (hb true x) (norm_nonneg _) hW + +/-- The full sharp paired kernel has the same derived one-coordinate Page +comparison, uniformly in every other real bulk coordinate. -/ +theorem PublishedProgressionInput.bulk_kernel_log_slice_comparison + (P : PublishedProgressionInput) {σ : Type*} [Fintype σ] + (base : σ → ℝ) (S : Finset σ) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : Bool → MovingSlotData σ n) (i : σ) (hiS : i ∈ S) + (hT : ∀ b, (T b).CompensationAbsent i) + (ψ : 𝓢(ℝ, ℂ)) (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : ∀ b, (T b).Frequencies (fun s => |(s : ℝ)| ≤ V)) + (φ : ℝ → ℝ) (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (d r : ℕ) (hsize : ∀ b, (T b).SizeLE d) (hregular : ∀ b, (T b).RegularLengthLE r) + (L R : ℝ) (f : BulkIntegrand σ) + (hf : ∀ x, f x = realValueKernelPair (bulkLogValues base S x) childBound pivotBound T ψ X lo hi hlo hhi φ G L R) + {Q q a : ℕ} (hQ : 2 ≤ Q) (hq : 1 ≤ q) (hqQ : q ≤ Q) (ha : a.Coprime q) + (u v : ℝ) (hu : 1 ≤ u) (huv : u ≤ v) (hshort : v ≤ u + 1) (x : σ → ℝ) : + letI := finite_primeGiantMeasure P Q q a u v (lt_of_lt_of_le zero_lt_one hu) + ‖f.average (primeLogCellMeasure q a u v) i x - f.average (primeGiantMeasure P Q q a u v) i x‖ ≤ + bulkKernelPairComparisonBudget ψ V lo hi n d r 0 B D * bulkPrimeErrorFactor P Q u := by + let _ := finite_primeGiantMeasure P Q q a u v (lt_of_lt_of_le zero_lt_one hu) + let value := bulkLogValues base S x + let H := fun y => realValueKernelPair (Function.update value i (Real.exp y)) childBound pivotBound T + ψ X lo hi hlo hhi φ G L R + have hH (y : ℝ) : f (Function.update x i y) = H y := by + rw [hf, bulkLogValues_update base S x i hiS] + rw [f.average_prime_eq_interval q a u v i x H hH, + f.average_page P Q q a u v (lt_of_lt_of_le zero_lt_one hu) i x] + simp_rw [hH] + have h := P.bulk_kernel_pair_prime_comparison value i childBound pivotBound T hT (Polynomial.C L) (Polynomial.C R) + ψ X lo hi V hlo hhi hV φ G B D hB hD hφ hlip hout d r 0 hsize hregular + (by simp) (by simp) hQ hq hqQ ha u v hu huv hshort + simpa only [Polynomial.eval_C] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealBulkPrimeComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealBulkPrimeComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..7df645201e18c90f29388a1ad80f169ed87a76d7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealBulkPrimeComparison.lean @@ -0,0 +1,79 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.BulkPrimeComparison + +namespace OAI + +/-! # Bulk-prime comparison with real values in the other coordinates -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap +open MeasureTheory + +noncomputable def realBulkPrimeSmoothSum {σ : Type*} (value : σ → ℝ) (i : σ) + {n : ℕ} (T : MovingSlotData σ n) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) + (G : ℕ → ℝ) (q a : ℕ) (u v : ℝ) : ℂ := + ∑ p ∈ primeLogCellSet q a u v, + realValueSmoothWeight (Function.update value i p) T ψ X lo hi hlo hhi φ G + (L.eval (p : ℝ)) (R.eval (p : ℝ)) * ((p : ℝ)⁻¹ : ℂ) + +theorem realBulkPrimeSmoothSum_polynomial {σ : Type*} (value : σ → ℝ) (i : σ) + {n : ℕ} (T : MovingSlotData σ n) (hT : T.CompensationAbsent i) + (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) + (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) (q a : ℕ) (u v : ℝ) : + realBulkPrimeSmoothSum value i T L R ψ X lo hi hlo hhi φ G q a u v = + complexPrimeInterval q a u v (fun y => smoothPolynomialWeight + (bulkSmoothFactors value i T L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip) (Real.exp y)) := by + unfold realBulkPrimeSmoothSum primeLogCellSet complexPrimeInterval + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro p _ + by_cases hp : p.Prime ∧ Nat.ModEq q p a + · rw [ite_eq_left hp, ite_eq_left hp] + dsimp only + rw [Real.exp_log (show (0 : ℝ) < p by exact_mod_cast hp.1.pos)] + rw [bulkSmoothFactors_value value i T hT L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout p] + · rw [ite_eq_right hp, ite_eq_right hp] + +/-- The same comparison allows arbitrary real values in every other bulk slot. The real +integral is the polynomial extension proved equal to the original sampling +expression at every prime, with all endpoint primes retained. -/ +theorem PublishedProgressionInput.real_bulk_prime_comparison (P : PublishedProgressionInput) + {σ : Type*} (value : σ → ℝ) (i : σ) {n : ℕ} (T : MovingSlotData σ n) + (hT : T.CompensationAbsent i) (L R : Polynomial ℝ) (ψ : 𝓢(ℝ, ℂ)) + (X lo hi V : ℝ) (hlo : 1 ≤ lo) (hhi : lo ≤ hi) + (hV : T.Frequencies (fun s => |(s : ℝ)| ≤ V)) (φ : ℝ → ℝ) + (G : ℕ → ℝ) (B D : ℝ) (hB : 0 ≤ B) (hD : 0 ≤ D) + (hφ : ∀ x, |φ x| ≤ B) (hlip : ∀ x y, |φ x - φ y| ≤ D * |x - y|) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (d r e : ℕ) (hsize : T.SizeLE d) (hregular : T.RegularLengthLE r) + (hL : L.natDegree ≤ e) (hR : R.natDegree ≤ e) + {Q q a : ℕ} (hQ : 2 ≤ Q) (hq : 1 ≤ q) (hqQ : q ≤ Q) (ha : a.Coprime q) + (u v : ℝ) (hu : 1 ≤ u) (huv : u ≤ v) (hshort : v ≤ u + 1) : + let F := bulkSmoothFactors value i T L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip + let K := (2 ^ n + (T.bulkNodePolynomials value i L R).length) * (2 * (n * d + e) + r) + ‖realBulkPrimeSmoothSum value i T L R ψ X lo hi hlo hhi φ G q a u v - + ∫ y in Set.Ioc u v, smoothPolynomialWeight F (Real.exp y) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + (K + 1 : ℕ) * + (movingFourierVariationBudget ψ V lo hi n * (2 * B + D * (Real.exp 2 - 1)) ^ (2 ^ n - 1)) * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt u) + + Real.exp (-P.kappa * u / Real.log (4 * (Q : ℝ))) + 2 * Real.exp (-u)) := by + dsimp only + obtain ⟨S, hcard, hroots⟩ := bulkSmoothFactors_root_cuts value i T L R ψ X lo hi hlo hhi + φ G B D hB hD hφ hlip d r e hsize hregular hL hR + rw [realBulkPrimeSmoothSum_polynomial value i T hT L R ψ X lo hi hlo hhi φ G B D hB hD hφ hlip hout] + apply (P.smooth_prime_all_roots hQ hq hqQ ha u v hu huv hshort _ S hroots).trans + have hC := P.errorConstant_nonneg + apply mul_le_mul_of_nonneg_right _ (by positivity) + apply mul_le_mul + · exact_mod_cast Nat.add_le_add_right hcard 1 + · exact bulkSmoothFactors_budget value i T L R ψ X lo hi V hlo hhi hV φ G B D hB hD hφ hlip + · exact smoothPolynomialBudget_nonneg _ + · positivity + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealNodeSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealNodeSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..fd681f0066bebeadbaefb3d90a7a937e06859225 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealNodeSupport.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Construction.HistoryRealEvaluation +import OAI.NumberTheory.Ostmann.Arithmetic.RealSlotEvaluation + +namespace OAI + +/-! # The original real node inequalities with variable bulk values -/ + +namespace Ostmann +open scoped Classical + +noncomputable def MovingSlotReversal.realCompositePivot {σ : Type*} + (s : MovingSlotReversal σ) (value : σ → ℝ) (L R : ℝ) : ℝ := + ((s.leftFrequency : ℝ) * realSlotProduct value s.rightSlots * R - + (s.rightFrequency : ℝ) * realSlotProduct value s.leftSlots * L) / s.rootFrequency + +noncomputable def realValueNodeSupport {σ : Type*} (value : σ → ℝ) + (childBound pivotBound : ℕ → ℕ) : {n : ℕ} → MovingSlotData σ n → ℝ → ℝ → Prop + | _, .leaf _ _, _, _ => True + | n + 1, .node s CL CR u left right, L, R => + let step := MovingSlotData.step s CL CR u left right false + let Q := step.realCompositePivot value L R + let p := step.realValuePivot value L R + 1 ≤ Q ∧ Q ≤ pivotBound (n + 1) ∧ + ((2 * pivotBound (n + 1) * childBound (n + 1) + 1 : ℕ) : ℝ) ≤ + R * realSlotProduct value CR ∧ + realValueNodeSupport value childBound pivotBound left p L ∧ + realValueNodeSupport value childBound pivotBound right p R + +theorem MovingSlotReversal.giantFormula_realEval {σ : Type*} + (s : MovingSlotReversal σ) (value : σ → ℕ) (hs : s.rootFrequency ≠ 0) + (hu : MovingSlotReversal.naturalProduct value s.compensationSlots ≠ 0) + (L R : HistoryFormula Bool) (x : Bool → ℝ) : + (s.giantFormula value hs hu L R).realEval x = + s.realValuePivot (fun i => (value i : ℝ)) (L.realEval x) (R.realEval x) := by + simp only [giantFormula, HistoryFormula.realEval_solve, HistoryFormula.realEval_product, + HistoryFormula.realEval_external, Int.cast_mul, Int.cast_natCast, realValuePivot, + realSlotProduct_nat] + ring + +theorem movingNodeGuard_realEval (CL CR : ℕ) (s v w : ℤ) (hs : s ≠ 0) + (childBound pivotBound : ℕ) (L R : HistoryFormula Bool) (x : Bool → ℝ) : + (movingNodeGuard CL CR s v w hs childBound pivotBound L R).archimedeanAt x ↔ + 1 ≤ ((v : ℝ) * (CR : ℝ) * R.realEval x - (w : ℝ) * (CL : ℝ) * L.realEval x) / s ∧ + ((v : ℝ) * (CR : ℝ) * R.realEval x - (w : ℝ) * (CL : ℝ) * L.realEval x) / s ≤ pivotBound ∧ + ((2 * pivotBound * childBound + 1 : ℕ) : ℝ) ≤ R.realEval x * CR := by + simp only [movingNodeGuard, wordTransferGuard, WordTransferGuard.archimedeanAt, + HistoryFormula.realEval_bind, HistoryPivotStep.formula, wordTransferStep, movingNodeWord, + HistoryFormula.realEval_solve, HistoryFormula.realEval_listProduct, List.map_cons, List.map_nil, + List.prod_cons, List.prod_nil, HistoryFormula.realEval_prime, Bool.false_eq_true, ite_false, + ite_true, HistoryFormula.realEval_product, HistoryFormula.realEval_external, Int.cast_natCast, mul_one] + ring_nf + +/-- Exact agreement with all original archimedean formula-node tests. -/ +theorem realValueNodeSupport_nat {σ : Type*} (value : σ → ℕ) + (hvalue : ∀ i, value i ≠ 0) (childBound pivotBound : ℕ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (hf : T.Frequencies (· ≠ 0)) + (L R : HistoryFormula Bool) (x : Bool → ℝ) : + movingArchimedeanGate (T.formulaNodes value hvalue childBound pivotBound hf L R) x ↔ + realValueNodeSupport (fun i => (value i : ℝ)) childBound pivotBound T (L.realEval x) (R.realEval x) := by + induction T generalizing L R with + | leaf => simp [MovingSlotData.formulaNodes, movingArchimedeanGate, realValueNodeSupport] + | node s CL CR u left right ihL ihR => + simp only [MovingSlotData.formulaNodes, movingArchimedeanGate, List.forall_mem_cons, + List.forall_mem_append, realValueNodeSupport] + rw [show (∀ f ∈ left.formulaNodes value hvalue childBound pivotBound hf.2.1 + ((MovingSlotData.step s CL CR u left right false).giantFormula value hf.1 + (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) L R) L, f.guard.archimedeanAt x) ↔ _ from + ihL hf.2.1 _ L, + show (∀ f ∈ right.formulaNodes value hvalue childBound pivotBound hf.2.2 + ((MovingSlotData.step s CL CR u left right false).giantFormula value hf.1 + (MovingSlotReversal.naturalProduct_ne_zero value hvalue u) L R) R, f.guard.archimedeanAt x) ↔ _ from + ihR hf.2.2 _ R] + rw [movingNodeGuard_realEval] + simp only [MovingSlotReversal.giantFormula_realEval, MovingSlotReversal.realCompositePivot, + MovingSlotData.step, realSlotProduct_nat] + tauto + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealSlotEvaluation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealSlotEvaluation.lean new file mode 100644 index 0000000000000000000000000000000000000000..cd53a76e920e878dd7c33b1890089977314f06c0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RealSlotEvaluation.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingRealSmooth + +namespace OAI + +/-! # Real bulk coordinates in the original smooth moving tree -/ + +namespace Ostmann +open scoped Classical BigOperators SchwartzMap ComplexConjugate + +noncomputable def realSlotProduct {σ : Type*} (value : σ → ℝ) (slots : List σ) : ℝ := + (slots.map value).prod + +noncomputable def MovingSlotReversal.realValuePivot {σ : Type*} + (s : MovingSlotReversal σ) (value : σ → ℝ) (L R : ℝ) : ℝ := + ((s.leftFrequency : ℝ) * realSlotProduct value s.rightSlots * R - + (s.rightFrequency : ℝ) * realSlotProduct value s.leftSlots * L) / + ((s.rootFrequency : ℝ) * realSlotProduct value s.compensationSlots) + +noncomputable def MovingSlotData.realValueLeafModuli {σ : Type*} (value : σ → ℝ) : + {n : ℕ} → MovingSlotData σ n → ℝ → ℝ → TreeLeafIndex n → ℝ + | _, .leaf _ regular, L, R, _ => L * R * realSlotProduct value regular + | _, .node s CL CR u left right, L, R, j => + let p := (MovingSlotData.step s CL CR u left right false).realValuePivot value L R + match j with + | .inl j => left.realValueLeafModuli value p L j + | .inr j => right.realValueLeafModuli value p R j + +noncomputable def realValueNodeCutoff {σ : Type*} (value : σ → ℝ) + (φ : ℝ → ℝ) (G : ℕ → ℝ) : {n : ℕ} → MovingSlotData σ n → ℝ → ℝ → ℂ + | _, .leaf _ _, _, _ => 1 + | n + 1, .node s CL CR u left right, L, R => + let p := (MovingSlotData.step s CL CR u left right false).realValuePivot value L R + (positiveLogCutoff φ (G (n + 1)) p : ℂ) * + realValueNodeCutoff value φ G left p L * realValueNodeCutoff value φ G right p R + +noncomputable def realValueFourierWeight {σ : Type*} (value : σ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (L R : ℝ) : ℂ := + ∏ j : TreeLeafIndex n, + let v := (fourierPolynomialFactor Polynomial.X ψ (T.leafFrequencies j) lo hi hlo hhi).value + (T.realValueLeafModuli value L R j / X) + if treeLeafTupleEquiv Bool n (transferConjugations n false) j then conj v else v + +noncomputable def realValueSmoothWeight {σ : Type*} (value : σ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) (L R : ℝ) : ℂ := + realValueFourierWeight value T ψ X lo hi hlo hhi L R * realValueNodeCutoff value φ G T L R + +theorem realSlotProduct_nat {σ : Type*} (value : σ → ℕ) (slots : List σ) : + realSlotProduct (fun j => (value j : ℝ)) slots = + (MovingSlotReversal.naturalProduct value slots : ℝ) := by + induction slots with + | nil => simp [realSlotProduct, MovingSlotReversal.naturalProduct] + | cons j slots ih => simpa only [realSlotProduct, MovingSlotReversal.naturalProduct, + List.map_cons, List.prod_cons, Nat.cast_mul] using congrArg ((value j : ℝ) * ·) ih + +theorem MovingSlotReversal.realValuePivot_nat {σ : Type*} + (s : MovingSlotReversal σ) (value : σ → ℕ) (L R : ℝ) : + s.realValuePivot (fun j => (value j : ℝ)) L R = s.realPivot value L R := by + simp only [realValuePivot, realPivot, realSlotProduct_nat] + +theorem MovingSlotData.realValueLeafModuli_nat {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (L R : ℝ) (j : TreeLeafIndex n) : + T.realValueLeafModuli (fun i => (value i : ℝ)) L R j = T.realLeafModuli value L R j := by + induction T generalizing L R with + | leaf => simp only [realValueLeafModuli, realLeafModuli, realSlotProduct_nat] + | node s CL CR u left right ihL ihR => + cases j with + | inl j => simp only [realValueLeafModuli, realLeafModuli, MovingSlotReversal.realValuePivot_nat, ihL] + | inr j => simp only [realValueLeafModuli, realLeafModuli, MovingSlotReversal.realValuePivot_nat, ihR] + +theorem realValueNodeCutoff_nat {σ : Type*} (value : σ → ℕ) (φ : ℝ → ℝ) (G : ℕ → ℝ) + {n : ℕ} (T : MovingSlotData σ n) (L R : ℝ) : + realValueNodeCutoff (fun i => (value i : ℝ)) φ G T L R = movingRealNodeCutoff value φ G T L R := by + induction T generalizing L R with + | leaf => rfl + | node s CL CR u left right ihL ihR => + simp only [realValueNodeCutoff, movingRealNodeCutoff, MovingSlotReversal.realValuePivot_nat, ihL, ihR] + +/-- The extension agrees exactly with the original function at every natural +prime tuple, including points where a cutoff vanishes. -/ +theorem realValueSmoothWeight_nat {σ : Type*} (value : σ → ℕ) + {n : ℕ} (T : MovingSlotData σ n) (ψ : 𝓢(ℝ, ℂ)) (X lo hi : ℝ) + (hlo : 1 ≤ lo) (hhi : lo ≤ hi) (φ : ℝ → ℝ) (G : ℕ → ℝ) (L R : ℝ) : + realValueSmoothWeight (fun i => (value i : ℝ)) T ψ X lo hi hlo hhi φ G L R = + movingRealSmoothWeight value T ψ X lo hi hlo hhi φ G L R := by + simp only [realValueSmoothWeight, movingRealSmoothWeight, realValueFourierWeight, + movingRealFourierWeight, realValueNodeCutoff_nat, MovingSlotData.realValueLeafModuli_nat] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedCoprimalityBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedCoprimalityBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..0d7546b460127de6d18ff0607060156411eb1c2f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedCoprimalityBound.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.Ostmann.Construction.ExpandedHistoryFormula + +namespace OAI + +/-! # Large-prime support after reconstruction + +An identically divisible reconstructed numerator has empty valid support. +Otherwise the original independent prime priors give the polynomial error. +No conditioning of those priors is used in either case. -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem reconstructed_coprimality_bound + {A I : Type*} [Fintype A] [Nonempty A] [Fintype I] {n : ℕ} + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (F : I → HistoryFormula (Fin (n + 1))) (coord : I → Fin (n + 1)) + (y : I → (Fin (n + 1) → A) → ℤ) + (μ : Fin (n + 1) → A → ℝ) (hμ : ∀ i a, 0 ≤ μ i a) (hmass : ∀ i, ∑ a, μ i a = 1) + (α V R : ℝ) (β : I → ℝ) (hα : 0 ≤ α) (hβ : ∀ j, 0 ≤ β j) + (hV : 0 < V) (hR : 3 ≤ R) + (hmax : ∀ i a, μ i a ≤ α) (hpmax : ∀ j a, μ (coord j) a ≤ β j) + (hlower : ∀ a, V ≤ Real.log (prime a : ℝ)) (hupper : ∀ a, (prime a : ℝ) ≤ R) + (hinputs : ∀ j, (F j).InputsBounded R) + (W : (Fin (n + 1) → A) → ℂ) (B δ : ℝ) + (hB : 0 ≤ B) (hδ : 0 ≤ δ) (hW : ∀ x, ‖W x‖ ≤ B) + (hvalid : ∀ x, W x ≠ 0 → ∀ j, + (F j).value (fun i => (prime (x i) : ℚ)) = y j x ∧ + ¬prime (x (coord j)) ∣ (F j).cleared.denominator.natAbs) + (hcancel : ‖∑ x, (productPrior μ x : ℂ) * W x‖ ≤ δ) : + ‖∑ x, (productPrior μ x : ℂ) * + (if ∀ j, (prime (x (coord j))).Coprime (y j x).natAbs then W x else 0)‖ ≤ + δ + B * ∑ j, ((F j).cost : ℝ) * (α + Real.log R / V * β j) := by + by_cases hz : ∀ j, zeroHistoryVariable (coord j) (F j).cleared.numerator ≠ 0 + · have hgate (x : Fin (n + 1) → A) : + (if ∀ j, (prime (x (coord j))).Coprime (y j x).natAbs then W x else 0) = + (if ∀ j, ¬prime (x (coord j)) ∣ + (integerTestValue (fun a => (prime a : ℤ)) (F j).cleared.numerator x).natAbs + then W x else 0) := by + by_cases hw : W x = 0 + · simp only [hw, ite_self] + · have hi (j : I) := (F j).cleared.prime_coprime_integer_value + (fun i => (prime (x i) : ℤ)) (prime (x (coord j))) (hprime _) + (hvalid x hw j).2 (y j x) (by + simpa only [HistoryFormula.value, Int.cast_natCast] using (hvalid x hw j).1) + have hg : (∀ j, (prime (x (coord j))).Coprime (y j x).natAbs) ↔ + (∀ j, ¬prime (x (coord j)) ∣ + (integerTestValue (fun a => (prime a : ℤ)) (F j).cleared.numerator x).natAbs) := + forall_congr' hi + simp only [hg] + simp_rw [hgate] + let S := ∑ x, (productPrior μ x : ℂ) * W x + have he := formula_coprimality_removal prime hpInj hprime F coord hz μ hμ hmass + α V R β hα hβ hV hR hmax hpmax hlower hupper hinputs W B hB hW + calc + _ = ‖((∑ x, (productPrior μ x : ℂ) * + (if ∀ j, ¬prime (x (coord j)) ∣ + (integerTestValue (fun a => (prime a : ℤ)) (F j).cleared.numerator x).natAbs + then W x else 0)) - S) + S‖ := by rw [sub_add_cancel] + _ ≤ ‖(∑ x, (productPrior μ x : ℂ) * + (if ∀ j, ¬prime (x (coord j)) ∣ + (integerTestValue (fun a => (prime a : ℤ)) (F j).cleared.numerator x).natAbs + then W x else 0)) - S‖ + ‖S‖ := norm_add_le _ _ + _ ≤ B * ∑ j, ((F j).cost : ℝ) * (α + Real.log R / V * β j) + δ := + add_le_add he hcancel + _ = _ := add_comm _ _ + · obtain ⟨j, hj⟩ := not_forall.mp hz + have hj0 : zeroHistoryVariable (coord j) (F j).cleared.numerator = 0 := + Classical.not_not.mp hj + have hzero (x : Fin (n + 1) → A) : + (if ∀ k, (prime (x (coord k))).Coprime (y k x).natAbs then W x else 0) = 0 := by + split_ifs with hg + · by_contra hw + have hn := zero_cleared_history_support (F j).cleared.numerator (coord j) hj0 + (fun i => (prime (x i) : ℤ)) (prime (x (coord j))) (hprime _) rfl + (F j).cleared.denominator (y j x) + ((F j).cleared.integer_value_cleared _ _ (by + simpa only [HistoryFormula.value, Int.cast_natCast] using (hvalid x hw j).1)) + (hvalid x hw j).2 + exact hn (hg j) + · rfl + simp_rw [hzero, mul_zero] + rw [Finset.sum_const_zero, norm_zero] + have hlog : 0 ≤ Real.log R := Real.log_nonneg (by linarith) + exact add_nonneg hδ (mul_nonneg hB (Finset.sum_nonneg fun j _ => + mul_nonneg (Nat.cast_nonneg _) (add_nonneg hα + (mul_nonneg (div_nonneg hlog hV.le) (hβ j))))) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedDyadicGraph.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedDyadicGraph.lean new file mode 100644 index 0000000000000000000000000000000000000000..a33cdf56fcdfa577f45c70b07b6053776b1827c1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedDyadicGraph.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Construction.ConstructedHistoryGuards +import OAI.NumberTheory.Ostmann.Construction.DyadicGuardedGraph + +namespace OAI + +/-! # One-sided graph cancellation for the original reconstructed history support -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem reconstructed_dyadic_graph_bound {J σ : Type*} [Fintype J] {n t : ℕ} + (steps : List (HistoryPivotStep σ)) (frequencies : List ℤ) (C : ℕ) (hC : 1 ≤ C) + (hfreq : ∀ s ∈ frequencies, s ≠ 0) + (hsteps : ∀ step ∈ steps, step.s ∈ frequencies) + (hsize : ∀ step ∈ steps, step.left.length + step.right.length + 4 ≤ C) + (units : Fin steps.length → ℕ) + (hunits : ∀ i, (units i : ℤ) ∣ (historyFrequencyBase frequencies : ℤ)) + (χ : (Bool ⊕ J) → ∀ p : ℕ, DirichletCharacter ℂ p) + (graph : (Bool ⊕ J) → (Bool ⊕ J) → ℤ) + (unary : (Bool ⊕ J) → ℕ → ℂ) (outside : J → ℕ) + (hunary : ∀ i x, ‖unary i x‖ ≤ 1) + (hself : graph (.inl true) (.inl true) = 0 ∧ graph (.inl false) (.inl false) = 0) + (hreverse : graph (.inl false) (.inl true) = 0) + (P Q : Finset ℕ) (hprime : ∀ q ∈ Q, q.Prime) + (hnonprincipal : ∀ q ∈ Q, χ (.inl true) q ^ graph (.inl true) (.inl false) ≠ 1) + (A E : ℕ) (hA : 0 < A) + (hMA : historyFrequencyPeriod frequencies (C ^ steps.length + 1) ≤ A) + (hsmall : ∀ q ∈ Q, ∀ s ∈ frequencies, s.natAbs < q) + (hlow : ∀ p ∈ P, 2 * A ≤ p) (hhigh : ∀ p ∈ P, p ≤ E) + (b : ℝ) (hb : 0 < b) (hbQ : ∀ q ∈ Q, b ≤ (q : ℝ)) + (hPmass : 0 < ∑ p ∈ P, (p : ℝ)⁻¹) (hQmass : 0 < ∑ q ∈ Q, (q : ℝ)⁻¹) + (fixed : Q → σ → ℤ) (coord : σ) + (F : Q → Fin n → ClippedPolynomialFactor) (H : Q → Fin t → Polynomial ℝ) + (keep : Q → (Fin t → Bool) → Bool) (B : ℝ) (R Bq : ℕ) + (hB : 0 ≤ B) (hbudget : ∀ q, smoothPolynomialBudget (F q) ≤ B) + (hcomplexity : ∀ q, polynomialWeightComplexity (F q) (H q) ≤ R) + (hBq : ∀ q : Q, (q : ℕ) ≤ Bq) : + ‖∑ p : P, (primeSubsetPrior P P p : ℂ) * + ∑ q : Q, (primeSubsetPrior Q Q q : ℂ) * + (finiteEdgeWeight (dirichletGraphEdge χ graph) unary + (twoVertexLabels outside (q : ℕ) (p : ℕ)) * + reconstructedHistoryAmplitude steps units (fixed q) coord (F q) (H q) (keep q) (p : ℕ))‖ ^ 2 ≤ + ((Nat.log 2 E + 1 : ℕ) : ℝ) * (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (((∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ * b⁻¹) * (2 * B ^ 2) + + (historyFrequencyPeriod frequencies (C ^ steps.length + 1) : ℝ) * + ((3 ^ (2 * R) : ℕ) * (2 * (A : ℝ)⁻¹ * B ^ 2)) * (Bq : ℝ) ^ 2) := by + let M := historyFrequencyPeriod frequencies (C ^ steps.length + 1) + have hMpos : 0 < M := historyFrequencyPeriod_pos _ _ hfreq + let : NeZero M := ⟨Nat.ne_of_gt hMpos⟩ + have hM (q : Q) : M.Coprime (q : ℕ) := by + apply Nat.Coprime.symm + apply prime_coprime_historyFrequencyPeriod frequencies _ _ (hprime q q.property) + intro s hs + exact ⟨Int.natAbs_pos.mpr (hfreq s hs), hsmall q q.property s hs⟩ + have hdiv (i : Fin steps.length) : + (reconstructionFormulaAt steps .prime i).cleared.denominator * (units i : ℤ) ∣ (M : ℤ) := + constructed_history_test_period_of_dvd steps frequencies C hC hsteps hsize + _ (hunits i) _ (reconstructionFormulaAt_mem steps .prime i) + simp_rw [reconstructedHistoryAmplitude_exact] + exact dyadic_guarded_graph_bound χ graph unary outside hunary hself hreverse + P Q hprime hnonprincipal A E M hA hMA hM hlow hhigh b hb hbQ hPmass hQmass + (fun _ i => (reconstructionFormulaAt steps .prime i).cleared.numerator) + (fun _ i => (reconstructionFormulaAt steps .prime i).cleared.denominator) + (fun _ => units) fixed coord + (fun _ i => (reconstructionFormulaAt steps .prime i).cleared.denominator_ne_zero) + (fun _ => hdiv) F H keep B R Bq hB hbudget hcomplexity hBq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedHistoryTests.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedHistoryTests.lean new file mode 100644 index 0000000000000000000000000000000000000000..9ff0091955d61c59ec6a42659e0b6107c667f012 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedHistoryTests.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.IntegerHistoryReconstruction +import OAI.NumberTheory.Ostmann.Arithmetic.ClearedPolynomialRanges + +namespace OAI + +/-! # Original reconstructed-integer tests are literal cleared polynomial tests -/ + +namespace Ostmann + +open scoped Classical + +/-- Cast the exact integral numerator equation, avoiding any approximation +of a reconstructed rational value. -/ +theorem ClearedHistoryValue.real_value_of_integer {σ : Type*} (F : ClearedHistoryValue σ) + (x : σ → ℤ) (y : ℤ) (hy : F.eval (fun i => (x i : ℚ)) = y) : + MvPolynomial.eval₂ (Int.castRingHom ℝ) (fun i => (x i : ℝ)) F.numerator / + (F.denominator : ℝ) = y := by + have he : (MvPolynomial.eval₂Hom (RingHom.id ℤ) x F.numerator : ℝ) = + MvPolynomial.eval₂ (Int.castRingHom ℝ) (fun i => (x i : ℝ)) F.numerator := by + simpa [Int.castRingHom] using + (MvPolynomial.map_eval₂Hom (RingHom.id ℤ) x (Int.castRingHom ℝ) F.numerator) + have hint := F.integer_value_cleared x y hy + have hr := congrArg (fun z : ℤ => (z : ℝ)) hint + rw [he, Int.cast_mul] at hr + rw [hr] + have hd : (F.denominator : ℝ) ≠ 0 := Int.cast_ne_zero.mpr F.denominator_ne_zero + exact mul_div_cancel_left₀ (y : ℝ) hd + +theorem reconstructed_integer_coprimality {σ : Type*} (steps : List (HistoryPivotStep σ)) + (x : σ → ℤ) (hx : ValidIntegerReconstruction steps x) (i : σ) + (p : ℕ) (hp : p.Prime) + (hden : ¬p ∣ (integerReconstructionFormulas steps i).cleared.denominator.natAbs) : + p.Coprime (reconstructIntegers steps x i).natAbs ↔ + ¬p ∣ (MvPolynomial.eval₂Hom (RingHom.id ℤ) x + (integerReconstructionFormulas steps i).cleared.numerator).natAbs := by + exact (integerReconstructionFormulas steps i).cleared.prime_coprime_integer_value x p hp hden + (reconstructIntegers steps x i) (integerReconstructionFormulas_value steps x hx i) + +theorem reconstructed_integer_real {σ : Type*} (steps : List (HistoryPivotStep σ)) + (x : σ → ℤ) (hx : ValidIntegerReconstruction steps x) (i : σ) : + MvPolynomial.eval₂ (Int.castRingHom ℝ) (fun j => (x j : ℝ)) + (integerReconstructionFormulas steps i).cleared.numerator / + ((integerReconstructionFormulas steps i).cleared.denominator : ℝ) = + (reconstructIntegers steps x i : ℝ) := + (integerReconstructionFormulas steps i).cleared.real_value_of_integer x + (reconstructIntegers steps x i) (integerReconstructionFormulas_value steps x hx i) + +/-- Every retained pivot or product range is exactly a pair of polynomial +inequalities after fixing all but one of the original independent primes. -/ +theorem reconstructed_integer_range {σ : Type*} (steps : List (HistoryPivotStep σ)) + (x : σ → ℤ) (i coord : σ) (lo hi : ℝ) (z : ℤ) + (hx : ValidIntegerReconstruction steps (Function.update x coord z)) : + clearedIntervalKeep (polynomialSupportCode + (clearedIntervalPolynomials + (specializeHistoryVariable (fun j => (x j : ℝ)) coord + (integerReconstructionFormulas steps i).cleared.numerator) + ((integerReconstructionFormulas steps i).cleared.denominator : ℝ) lo hi) z) = true ↔ + (reconstructIntegers steps (Function.update x coord z) i : ℝ) ∈ Set.Icc lo hi := by + rw [specialized_cleared_interval_test _ _ coord _ lo hi z + (Int.cast_ne_zero.mpr (integerReconstructionFormulas steps i).cleared.denominator_ne_zero)] + have hupdate : Function.update (fun j => (x j : ℝ)) coord (z : ℝ) = + (fun j => (Function.update x coord z j : ℝ)) := by + funext j + by_cases hj : j = coord + · subst j; simp only [Function.update_self] + · simp only [Function.update_of_ne hj] + rw [hupdate, reconstructed_integer_real steps _ hx i] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedPairGraphBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedPairGraphBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..100977a1151c5717b547a62243e1635c73aa27cb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedPairGraphBound.lean @@ -0,0 +1,100 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.GuardedHistoryPair +import OAI.NumberTheory.Ostmann.Construction.DyadicGuardedGraph + +namespace OAI + +/-! # Cancellation for two complete histories with their original common variables -/ + +namespace Ostmann + +open scoped BigOperators ComplexConjugate Classical + +theorem reconstructed_pair_dyadic_graph_bound {J σ : Type*} [Fintype J] {n m t u : ℕ} + (steps steps' : List (HistoryPivotStep σ)) (frequencies : List ℤ) (C : ℕ) (hC : 1 ≤ C) + (hfreq : ∀ s ∈ frequencies, s ≠ 0) + (hsteps : ∀ step ∈ steps, step.s ∈ frequencies) + (hsteps' : ∀ step ∈ steps', step.s ∈ frequencies) + (hsize : ∀ step ∈ steps, step.left.length + step.right.length + 4 ≤ C) + (hsize' : ∀ step ∈ steps', step.left.length + step.right.length + 4 ≤ C) + (units : Fin steps.length → ℕ) (units' : Fin steps'.length → ℕ) + (hunits : ∀ i, (units i : ℤ) ∣ (historyFrequencyBase frequencies : ℤ)) + (hunits' : ∀ i, (units' i : ℤ) ∣ (historyFrequencyBase frequencies : ℤ)) + (χ : (Bool ⊕ J) → ∀ p : ℕ, DirichletCharacter ℂ p) + (graph : (Bool ⊕ J) → (Bool ⊕ J) → ℤ) + (unary : (Bool ⊕ J) → ℕ → ℂ) (outside : J → ℕ) + (hunary : ∀ i x, ‖unary i x‖ ≤ 1) + (hself : graph (.inl true) (.inl true) = 0 ∧ graph (.inl false) (.inl false) = 0) + (hreverse : graph (.inl false) (.inl true) = 0) + (P Q : Finset ℕ) (hprime : ∀ q ∈ Q, q.Prime) + (hnonprincipal : ∀ q ∈ Q, χ (.inl true) q ^ graph (.inl true) (.inl false) ≠ 1) + (A E : ℕ) (hA : 0 < A) + (hMA : historyFrequencyPeriod frequencies (C ^ (steps.length + steps'.length) + 1) ≤ A) + (hsmall : ∀ q ∈ Q, ∀ s ∈ frequencies, s.natAbs < q) + (hlow : ∀ p ∈ P, 2 * A ≤ p) (hhigh : ∀ p ∈ P, p ≤ E) + (b : ℝ) (hb : 0 < b) (hbQ : ∀ q ∈ Q, b ≤ (q : ℝ)) + (hPmass : 0 < ∑ p ∈ P, (p : ℝ)⁻¹) (hQmass : 0 < ∑ q ∈ Q, (q : ℝ)⁻¹) + (fixed : Q → σ → ℤ) (coord : σ) + (F : Q → Fin n → ClippedPolynomialFactor) (G : Q → Fin m → ClippedPolynomialFactor) + (H : Q → Fin t → Polynomial ℝ) (I : Q → Fin u → Polynomial ℝ) + (keep : Q → (Fin t → Bool) → Bool) (keep' : Q → (Fin u → Bool) → Bool) + (B B' : ℝ) (R R' Bq : ℕ) (hB : 0 ≤ B) (hB' : 0 ≤ B') + (hbudget : ∀ q, smoothPolynomialBudget (F q) ≤ B) + (hbudget' : ∀ q, smoothPolynomialBudget (G q) ≤ B') + (hcomplexity : ∀ q, polynomialWeightComplexity (F q) (H q) ≤ R) + (hcomplexity' : ∀ q, polynomialWeightComplexity (G q) (I q) ≤ R') + (hBq : ∀ q : Q, (q : ℕ) ≤ Bq) : + ‖∑ p : P, (primeSubsetPrior P P p : ℂ) * + ∑ q : Q, (primeSubsetPrior Q Q q : ℂ) * + (finiteEdgeWeight (dirichletGraphEdge χ graph) unary + (twoVertexLabels outside (q : ℕ) (p : ℕ)) * + (reconstructedHistoryAmplitude steps units (fixed q) coord (F q) (H q) (keep q) (p : ℕ) * + conj (reconstructedHistoryAmplitude steps' units' (fixed q) coord + (G q) (I q) (keep' q) (p : ℕ))))‖ ^ 2 ≤ + ((Nat.log 2 E + 1 : ℕ) : ℝ) * (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (((∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ * b⁻¹) * (2 * (B * B') ^ 2) + + (historyFrequencyPeriod frequencies (C ^ (steps.length + steps'.length) + 1) : ℝ) * + ((3 ^ (2 * (R + R')) : ℕ) * (2 * (A : ℝ)⁻¹ * (B * B') ^ 2)) * (Bq : ℝ) ^ 2) := by + let M := historyFrequencyPeriod frequencies (C ^ (steps.length + steps'.length) + 1) + have hMpos : 0 < M := historyFrequencyPeriod_pos _ _ hfreq + let : NeZero M := ⟨Nat.ne_of_gt hMpos⟩ + have hM (q : Q) : M.Coprime (q : ℕ) := by + apply Nat.Coprime.symm + apply prime_coprime_historyFrequencyPeriod frequencies _ _ (hprime q q.property) + intro s hs + exact ⟨Int.natAbs_pos.mpr (hfreq s hs), hsmall q q.property s hs⟩ + have hdiv (i : Fin (steps.length + steps'.length)) : + Fin.append (fun i => (reconstructionFormulaAt steps .prime i).cleared.denominator) + (fun i => (reconstructionFormulaAt steps' .prime i).cleared.denominator) i * + ((Fin.append units units' i : ℕ) : ℤ) ∣ (M : ℤ) := by + refine Fin.addCases (fun j => ?_) (fun j => ?_) i + · simpa only [Fin.append_left] using + constructed_history_test_period_of_length steps frequencies C _ hC (by omega) + hsteps hsize _ (hunits j) _ (reconstructionFormulaAt_mem steps .prime j) + · simpa only [Fin.append_right] using + constructed_history_test_period_of_length steps' frequencies C _ hC (by omega) + hsteps' hsize' _ (hunits' j) _ (reconstructionFormulaAt_mem steps' .prime j) + have hden (i : Fin (steps.length + steps'.length)) : + Fin.append (fun i => (reconstructionFormulaAt steps .prime i).cleared.denominator) + (fun i => (reconstructionFormulaAt steps' .prime i).cleared.denominator) i ≠ 0 := by + refine Fin.addCases (fun j => ?_) (fun j => ?_) i + · simpa only [Fin.append_left] using + (reconstructionFormulaAt steps .prime j).cleared.denominator_ne_zero + · simpa only [Fin.append_right] using + (reconstructionFormulaAt steps' .prime j).cleared.denominator_ne_zero + simp_rw [reconstructedHistoryAmplitude_pair] + apply dyadic_guarded_graph_bound χ graph unary outside hunary hself hreverse P Q hprime + hnonprincipal A E M hA hMA hM hlow hhigh b hb hbQ hPmass hQmass + · exact fun _ => hden + · exact fun _ => hdiv + · exact mul_nonneg hB hB' + · intro q + rw [pairedPolynomialFactors_budget] + exact mul_le_mul (hbudget q) (hbudget' q) (smoothPolynomialBudget_nonneg _) hB + · intro q + rw [polynomialWeightComplexity_pair] + exact Nat.add_le_add (hcomplexity q) (hcomplexity' q) + · exact hBq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedPhaseWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedPhaseWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..942ed0084117afeff4ea46ded277ba60a62ddcda --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedPhaseWeight.lean @@ -0,0 +1,109 @@ +import OAI.NumberTheory.Ostmann.Construction.CopiedDirectedPhase +import OAI.NumberTheory.Ostmann.Construction.OriginalAveragedTransfer + +namespace OAI + +/-! # The forced-pivot off-diagonal is the actual next directed amplitude -/ + +namespace Ostmann + +open scoped BigOperators ComplexConjugate Classical + +private theorem branchPairwise_parts {H Y : Type*} [Fintype H] [Fintype Y] + (L : H → ℕ) (U : Y → ℕ) + (hc : Pairwise (fun i j => (Sum.elim L U i).Coprime (Sum.elim L U j))) : + Pairwise (fun h k => (L h).Coprime (L k)) ∧ + Pairwise (fun y z => (U y).Coprime (U z)) ∧ (∏ h, L h).Coprime (∏ y, U y) := by + refine ⟨fun h k hne => hc (fun he => hne (Sum.inl.inj he)), + fun y z hne => hc (fun he => hne (Sum.inr.inj he)), ?_⟩ + exact Nat.coprime_fintype_prod_left_iff.mpr fun h => + Nat.coprime_fintype_prod_right_iff.mpr fun y => hc (i := .inl h) (j := .inr y) (by intro he; cases he) + +noncomputable def retainedWeightedCoefficient {A H Y : Type*} [Fintype H] [Fintype Y] + (L : A → H → ℕ) (U : Y → ℕ) + [∀ a h, Fact (L a h).Prime] [∀ y, Fact (U y).Prime] + (t : ∀ p : ℕ, ZMod p) + (χH : H → ∀ p : ℕ, DirichletCharacter ℂ p) + (χY : Y → ∀ p : ℕ, DirichletCharacter ℂ p) + (b : Option (H ⊕ Y) → Option (H ⊕ Y) → ℤ) + (ν : A → H → ℂ) (νY : A → Y → ℂ) (v : A → ℤ) + (W : ℕ → A → ℂ) (M : ℕ) (a : A) : ℂ := + W M a * retainedPrimePhase (L a) U t χH χY b (ν a) (νY a) M (v a) + +noncomputable def copiedWeightedAmplitude {A H Y : Type*} [Fintype A] [Fintype H] [Fintype Y] + (L : A → H → ℕ) (U : Y → ℕ) + [∀ a h, Fact (L a h).Prime] [∀ y, Fact (U y).Prime] + (t : ∀ p : ℕ, ZMod p) + (χH : H → ∀ p : ℕ, DirichletCharacter ℂ p) + (χY : Y → ∀ p : ℕ, DirichletCharacter ℂ p) + (b : Option (H ⊕ Y) → Option (H ⊕ Y) → ℤ) + (ν : A → H → ℂ) (νY : A → Y → ℂ) (v : A → ℤ) + (W : ℕ → A → ℂ) (T : Finset ℕ) (V : ℕ) : ℂ := + ∑ s ∈ transferFrequencyRange V, ∑ a, ∑ a', + let N := v a * (∏ h, L a' h) - v a' * (∏ h, L a h) + let M := reconstructedPivot N s + if validTransferredPivot T N s then + W M a * conj (W M a') * + copiedDirectedPhase (L a) (L a') U t χH χY b (ν a) (ν a') (νY a) (νY a') (v a) (v a') s + else 0 + +/-- Only the original branch supports are hypotheses. Cross-copy distinctness +and the units at the new root are consequences of the equation and ranges. -/ +theorem reconstructedOffDiagonal_eq_copiedWeightedAmplitude + {A H Y : Type*} [Fintype A] [Fintype H] [Fintype Y] + (L : A → H → ℕ) (U : Y → ℕ) + [∀ a h, Fact (L a h).Prime] [∀ y, Fact (U y).Prime] + (t : ∀ p : ℕ, ZMod p) + (χH : H → ∀ p : ℕ, DirichletCharacter ℂ p) + (χY : Y → ∀ p : ℕ, DirichletCharacter ℂ p) + (b : Option (H ⊕ Y) → Option (H ⊕ Y) → ℤ) + (ν : A → H → ℂ) (νY : A → Y → ℂ) (v : A → ℤ) + (W : ℕ → A → ℂ) (T : Finset ℕ) (B K V : ℕ) + (hT : ∀ M ∈ T, 0 < M) + (hsupport : ∀ M ∈ T, ∀ a, W M a ≠ 0 → + Pairwise (fun i j => (Sum.elim (L a) U i).Coprime (Sum.elim (L a) U j)) ∧ + M.Coprime ((∏ h, L a h) * ∏ y, U y) ∧ (v a).natAbs ≤ B ∧ (∏ h, L a h) ≤ K) + (hscale : ∀ M ∈ T, 2 * B * K ≤ V * M) + (hlargeL : ∀ a h, V < L a h) (hlargeU : ∀ y, V < U y) + (hb : ∀ y, b (some (.inr y)) (some (.inr y)) = 0) : + reconstructedOffDiagonal T V (fun a => ∏ h, L a h) v + (retainedWeightedCoefficient L U t χH χY b ν νY v W) = + copiedWeightedAmplitude L U t χH χY b ν νY v W T V := by + unfold reconstructedOffDiagonal copiedWeightedAmplitude + apply Finset.sum_congr rfl + intro s _ + apply Finset.sum_congr rfl + intro a _ + apply Finset.sum_congr rfl + intro a' _ + dsimp only + split_ifs with hvalid + · let M := reconstructedPivot (v a * (∏ h, L a' h) - v a' * (∏ h, L a h)) s + by_cases hWa : W M a = 0 + · dsimp only [M] at hWa + simp only [retainedWeightedCoefficient, hWa, zero_mul] + by_cases hWa' : W M a' = 0 + · dsimp only [M] at hWa' + simp only [retainedWeightedCoefficient, hWa', zero_mul, map_zero, mul_zero] + have hMT : M ∈ T := hvalid.2.2.2 + obtain ⟨hpA, hmA, hvA, hLA⟩ := hsupport M hMT a hWa + obtain ⟨hpB, hmB, hvB, hLB⟩ := hsupport M hMT a' hWa' + obtain ⟨hpL, hpU, hLU⟩ := branchPairwise_parts (L a) U hpA + obtain ⟨hpR, _, hRU⟩ := branchPairwise_parts (L a') U hpB + have he := transfer_copiedDirectedPhase_of_ranges (L a) (L a') U t χH χY b + (ν a) (ν a') (νY a) (νY a') M (v a) (v a') s + (validTransferredPivot_equation T _ s hvalid) B K V (hT M hMT) hvalid.1 hvA hvB hLA hLB + (hscale M hMT) hpL hpR hpU hLU hRU + (Nat.coprime_mul_iff_right.mp hmA).1 (Nat.coprime_mul_iff_right.mp hmB).1 + (Nat.coprime_mul_iff_right.mp hmA).2 (hlargeL a) (hlargeL a') hlargeU hb + simp only [retainedWeightedCoefficient, map_mul (starRingEnd ℂ)] + calc + _ = (W M a * conj (W M a')) * + (retainedPrimePhase (L a) U t χH χY b (ν a) (νY a) M (v a) * + conj (retainedPrimePhase (L a') U t χH χY b (ν a') (νY a') M (v a'))) := by ring + _ = _ := by rw [he] + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedWordCoprimality.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedWordCoprimality.lean new file mode 100644 index 0000000000000000000000000000000000000000..021f2fb904530af43eb0e77511bdf5a89c745a0f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedWordCoprimality.lean @@ -0,0 +1,95 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ReconstructedWordQueries +import OAI.NumberTheory.Ostmann.Construction.FormulaCoprimality + +namespace OAI + +/-! # The original word coprimalities, with constructed degree and denominator bounds -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem HistoryFormula.prime_denominator_unit {σ : Type*} (F : HistoryFormula σ) + (M p : ℕ) (hp : p.Prime) (hM : p.Coprime M) + (hF : ∀ s ∈ F.frequencies, s ∣ (M : ℤ)) : ¬p ∣ F.cleared.denominator.natAbs := by + have habs (l : List ℤ) : l.prod.natAbs = (l.map Int.natAbs).prod := by + induction l with + | nil => rfl + | cons a l ih => simp only [List.prod_cons, List.map_cons, Int.natAbs_mul, ih] + apply hp.coprime_iff_not_dvd.mp + rw [F.denominator_eq_frequency_product, habs] + apply Nat.coprime_list_prod_right_iff.mpr + intro n hn + obtain ⟨s, hs, rfl⟩ := List.mem_map.mp hn + exact hM.of_dvd_right (Int.dvd_natCast.mp (hF s hs)) + +theorem reconstructedWordFormula_frequencies_dvd {σ : Type*} (steps : List (HistoryPivotStep σ)) + (stage : ℕ) (word : List σ) (M : ℤ) (hsteps : ∀ step ∈ steps, step.s ∣ M) : + ∀ s ∈ (reconstructedWordFormula steps stage word).frequencies, s ∣ M := by + apply HistoryFormula.frequencies_listProduct_dvd + intro F hF + obtain ⟨i, _, rfl⟩ := List.mem_map.mp hF + exact integerReconstructionFormulas_frequencies_dvd (steps.take stage) M + (fun step hstep => hsteps step (List.mem_of_mem_take hstep)) i + +theorem reconstructed_word_coprimality {σ : Type*} (steps : List (HistoryPivotStep σ)) + (stage : ℕ) (word : List σ) (x : σ → ℤ) (hx : ValidIntegerReconstruction steps x) + (M p : ℕ) (hp : p.Prime) (hM : p.Coprime M) + (hsteps : ∀ step ∈ steps, step.s ∣ (M : ℤ)) : + p.Coprime ((word.map (reconstructIntegers (steps.take stage) x)).prod).natAbs ↔ + ¬p ∣ (MvPolynomial.eval₂Hom (RingHom.id ℤ) x + (reconstructedWordFormula steps stage word).cleared.numerator).natAbs := by + let F := reconstructedWordFormula steps stage word + have hd := F.prime_denominator_unit M p hp hM + (reconstructedWordFormula_frequencies_dvd steps stage word M hsteps) + exact F.cleared.prime_coprime_integer_value x p hp hd _ + (reconstructedWordFormula_value steps stage word x hx) + +theorem zero_reconstructed_word_support {σ : Type*} (steps : List (HistoryPivotStep σ)) + (stage : ℕ) (word : List σ) (coord : σ) + (hzero : zeroHistoryVariable coord (reconstructedWordFormula steps stage word).cleared.numerator = 0) + (x : σ → ℤ) (hx : ValidIntegerReconstruction steps x) + (M p : ℕ) (hp : p.Prime) (hM : p.Coprime M) + (hsteps : ∀ step ∈ steps, step.s ∣ (M : ℤ)) (hcoord : x coord = p) : + ¬p.Coprime ((word.map (reconstructIntegers (steps.take stage) x)).prod).natAbs := by + rw [reconstructed_word_coprimality steps stage word x hx M p hp hM hsteps, not_not] + exact zeroHistoryVariable_identically_bad coord _ hzero x p hcoord + +theorem reconstructed_word_coprimality_removal {A I : Type*} + [Fintype A] [Nonempty A] [Fintype I] {n : ℕ} + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (steps : I → List (HistoryPivotStep (Fin (n + 1)))) (stage : I → ℕ) + (word : I → List (Fin (n + 1))) (coord : I → Fin (n + 1)) + (C : ℕ) (hC : 1 ≤ C) + (hsize : ∀ j step, step ∈ steps j → step.left.length + step.right.length + 4 ≤ C) + (hzero : ∀ j, zeroHistoryVariable (coord j) + (reconstructedWordFormula (steps j) (stage j) (word j)).cleared.numerator ≠ 0) + (μ : Fin (n + 1) → A → ℝ) (hμ : ∀ i a, 0 ≤ μ i a) (hmass : ∀ i, ∑ a, μ i a = 1) + (α V R : ℝ) (β : I → ℝ) (hα : 0 ≤ α) (hβ : ∀ j, 0 ≤ β j) (hV : 0 < V) (hR : 3 ≤ R) + (hmax : ∀ i a, μ i a ≤ α) (hpmax : ∀ j a, μ (coord j) a ≤ β j) + (hlower : ∀ a, V ≤ Real.log (prime a : ℝ)) (hupper : ∀ a, (prime a : ℝ) ≤ R) + (hfreq : ∀ j step, step ∈ steps j → + |(step.v : ℝ)| ≤ R ∧ |(step.w : ℝ)| ≤ R ∧ |(step.s : ℝ)| ≤ R) + (W : (Fin (n + 1) → A) → ℂ) (B : ℝ) (hB : 0 ≤ B) (hW : ∀ x, ‖W x‖ ≤ B) : + ‖(∑ x, (productPrior μ x : ℂ) * + (if ∀ j, ¬prime (x (coord j)) ∣ + (integerTestValue (fun a => (prime a : ℤ)) + (reconstructedWordFormula (steps j) (stage j) (word j)).cleared.numerator x).natAbs + then W x else 0)) - ∑ x, (productPrior μ x : ℂ) * W x‖ ≤ + B * ∑ j, ((word j).length * C ^ (steps j).length + 1 : ℕ) * + (α + Real.log R / V * β j) := by + apply (formula_coprimality_removal prime hpInj hprime + (fun j => reconstructedWordFormula (steps j) (stage j) (word j)) coord hzero + μ hμ hmass α V R β hα hβ hV hR hmax hpmax hlower hupper + (fun j => reconstructedWordFormula_inputsBounded _ _ _ R (by linarith) (hfreq j)) + W B hB hW).trans + apply mul_le_mul_of_nonneg_left _ hB + apply Finset.sum_le_sum + intro j _ + apply mul_le_mul_of_nonneg_right + · exact_mod_cast reconstructedWordFormula_cost (steps j) (stage j) (word j) C hC (hsize j) + · exact add_nonneg hα (mul_nonneg (div_nonneg (Real.log_nonneg (by linarith)) hV.le) (hβ j)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedWordQueries.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedWordQueries.lean new file mode 100644 index 0000000000000000000000000000000000000000..ef2f7557a3a9a1477f03fef452213783011041bc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructedWordQueries.lean @@ -0,0 +1,92 @@ +import OAI.NumberTheory.Ostmann.Construction.HistoryFormulaFourier + +namespace OAI + +/-! # Products queried at the actual intermediate reconstruction stages -/ + +namespace Ostmann + +open scoped Classical + +theorem ValidIntegerReconstruction.take {σ : Type*} {steps : List (HistoryPivotStep σ)} + {x : σ → ℤ} (h : ValidIntegerReconstruction steps x) (n : ℕ) : + ValidIntegerReconstruction (steps.take n) x := by + induction n generalizing steps x with + | zero => trivial + | succ n ih => + cases steps with + | nil => trivial + | cons step rest => exact ⟨h.1, ih h.2⟩ + +noncomputable def reconstructedWordFormula {σ : Type*} (steps : List (HistoryPivotStep σ)) + (stage : ℕ) (word : List σ) : HistoryFormula σ := + .listProduct (word.map (integerReconstructionFormulas (steps.take stage))) + +theorem reconstructedWordFormula_value {σ : Type*} (steps : List (HistoryPivotStep σ)) + (stage : ℕ) (word : List σ) (x : σ → ℤ) (hx : ValidIntegerReconstruction steps x) : + (reconstructedWordFormula steps stage word).value (fun i => (x i : ℚ)) = + ((word.map (reconstructIntegers (steps.take stage) x)).prod : ℤ) := by + simp only [reconstructedWordFormula, HistoryFormula.value_listProduct, List.map_map, + Function.comp_def, integerReconstructionFormulas_value _ _ (hx.take stage)] + induction word with + | nil => simp + | cons i word ih => simp only [List.map_cons, List.prod_cons, Int.cast_mul, ih] + +theorem reconstructedWordFormula_cost {σ : Type*} (steps : List (HistoryPivotStep σ)) + (stage : ℕ) (word : List σ) (C : ℕ) (hC : 1 ≤ C) + (hsize : ∀ step ∈ steps, step.left.length + step.right.length + 4 ≤ C) : + (reconstructedWordFormula steps stage word).cost ≤ word.length * C ^ steps.length + 1 := by + have hc (i : σ) : (integerReconstructionFormulas (steps.take stage) i).cost ≤ C ^ steps.length := by + have h := HistoryFormula.reconstructedFormulas_cost + ((steps.take stage).map fun step => (step.target, step.formula)) C hC + (by + intro a ha + obtain ⟨step, hstep, rfl⟩ := List.mem_map.mp ha + simpa only [step.formula_cost] using hsize step (List.mem_of_mem_take hstep)) i + simp only [List.length_map] at h + exact h.trans (pow_le_pow_right₀ hC (by + simp only [List.length_take] + exact Nat.min_le_right _ _)) + induction word with + | nil => simp [reconstructedWordFormula, HistoryFormula.listProduct, HistoryFormula.cost] + | cons i word ih => + change (integerReconstructionFormulas (steps.take stage) i).cost + + (reconstructedWordFormula steps stage word).cost ≤ _ + simp only [List.length_cons] + nlinarith [hc i] + +theorem HistoryFormula.inputsBounded_listProduct {σ : Type*} (fs : List (HistoryFormula σ)) + (R : ℝ) (hR : 1 ≤ R) (h : ∀ F ∈ fs, F.InputsBounded R) : + (HistoryFormula.listProduct fs).InputsBounded R := by + induction fs with + | nil => simpa only [listProduct, InputsBounded, Int.cast_one, abs_one] using hR + | cons F fs ih => exact ⟨h F (by simp), ih (fun G hG => h G (by simp [hG]))⟩ + +theorem HistoryPivotStep.formula_inputsBounded {σ : Type*} (step : HistoryPivotStep σ) + (R : ℝ) (hR : 1 ≤ R) (hv : |(step.v : ℝ)| ≤ R) + (hw : |(step.w : ℝ)| ≤ R) (hs : |(step.s : ℝ)| ≤ R) : step.formula.InputsBounded R := by + have hp (l : List σ) : (HistoryFormula.listProduct (l.map .prime)).InputsBounded R := by + apply HistoryFormula.inputsBounded_listProduct _ R hR + intro F hF + obtain ⟨i, _, rfl⟩ := List.mem_map.mp hF + trivial + exact ⟨hp _, hp _, hv, hw, hs⟩ + +theorem reconstructedWordFormula_inputsBounded {σ : Type*} (steps : List (HistoryPivotStep σ)) + (stage : ℕ) (word : List σ) (R : ℝ) (hR : 1 ≤ R) + (hsize : ∀ step ∈ steps, + |(step.v : ℝ)| ≤ R ∧ |(step.w : ℝ)| ≤ R ∧ |(step.s : ℝ)| ≤ R) : + (reconstructedWordFormula steps stage word).InputsBounded R := by + apply HistoryFormula.inputsBounded_listProduct _ R hR + intro F hF + obtain ⟨i, _, rfl⟩ := List.mem_map.mp hF + apply HistoryFormula.replayFormulas_inputs + · intro j; trivial + · intro a ha + obtain ⟨step, hstep, rfl⟩ := List.mem_map.mp ha + obtain ⟨hv, hw, hs⟩ := hsize step (List.mem_of_mem_take hstep) + exact step.formula_inputsBounded R hR hv hw hs + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructionFrequencyPeriod.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructionFrequencyPeriod.lean new file mode 100644 index 0000000000000000000000000000000000000000..1225abf93364b8f5dd1b3f82b31f9e0422ad28ab --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructionFrequencyPeriod.lean @@ -0,0 +1,112 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ReconstructionIntegrality + +namespace OAI + +/-! # A common small-frequency period for the constructed reconstruction tests -/ + +namespace Ostmann + +open scoped Classical + +namespace HistoryFormula + +variable {σ τ : Type*} + +theorem frequencies_bind_dvd (F : HistoryFormula σ) (env : σ → HistoryFormula τ) (M : ℤ) + (hF : ∀ d ∈ F.frequencies, d ∣ M) + (henv : ∀ i d, d ∈ (env i).frequencies → d ∣ M) : + ∀ d ∈ (F.bind env).frequencies, d ∣ M := by + induction F with + | prime i => exact henv i + | external z => simp only [bind, frequencies, List.not_mem_nil, false_implies, implies_true] + | product l r hl hr => + intro d hd + rcases List.mem_append.mp hd with hd | hd + · exact hl (fun a ha => hF a (List.mem_append_left _ ha)) d hd + · exact hr (fun a ha => hF a (List.mem_append_right _ ha)) d hd + | solve l r v w s hs hl hr => + intro d hd + rcases List.mem_cons.mp hd with hds | hd + · subst d; exact hF s (by simp [frequencies]) + · rcases List.mem_append.mp hd with hd | hd + · exact hl (fun a ha => hF a (by simp only [frequencies, List.mem_cons, List.mem_append]; exact Or.inr (Or.inl ha))) d hd + · exact hr (fun a ha => hF a (by simp only [frequencies, List.mem_cons, List.mem_append]; exact Or.inr (Or.inr ha))) d hd + +theorem frequencies_listProduct_dvd (fs : List (HistoryFormula σ)) (M : ℤ) + (h : ∀ F ∈ fs, ∀ d ∈ F.frequencies, d ∣ M) : + ∀ d ∈ (listProduct fs).frequencies, d ∣ M := by + induction fs with + | nil => simp only [listProduct, frequencies, List.not_mem_nil, false_implies, implies_true] + | cons F fs ih => + intro d hd + rcases List.mem_append.mp hd with hd | hd + · exact h F (by simp) d hd + · exact ih (fun G hG => h G (by simp [hG])) d hd + +theorem replay_frequencies_dvd (steps : List (σ × HistoryFormula σ)) + (env : σ → HistoryFormula σ) (M : ℤ) + (hsteps : ∀ step ∈ steps, ∀ d ∈ step.2.frequencies, d ∣ M) + (henv : ∀ i d, d ∈ (env i).frequencies → d ∣ M) (i : σ) : + ∀ d ∈ (replayFormulas steps env i).frequencies, d ∣ M := by + induction steps generalizing env with + | nil => exact henv i + | cons step rest ih => + apply ih _ (fun s hs => hsteps s (by simp [hs])) + intro j d hd + by_cases hj : j = step.1 + · subst j + simp only [Function.update_self] at hd + exact frequencies_bind_dvd step.2 env M (hsteps step (by simp)) henv d hd + · simp only [Function.update_of_ne hj] at hd + exact henv j d hd + +end HistoryFormula + +theorem HistoryPivotStep.formula_frequencies_dvd {σ : Type*} + (step : HistoryPivotStep σ) (M : ℤ) (hs : step.s ∣ M) : + ∀ d ∈ step.formula.frequencies, d ∣ M := by + intro d hd + have hprime (l : List σ) : ∀ a ∈ (HistoryFormula.listProduct (l.map .prime)).frequencies, a ∣ M := by + apply HistoryFormula.frequencies_listProduct_dvd + intro F hF + obtain ⟨i, _, rfl⟩ := List.mem_map.mp hF + simp only [HistoryFormula.frequencies, List.not_mem_nil, false_implies, implies_true] + rcases List.mem_cons.mp hd with he | hd + · subst d; exact hs + · rcases List.mem_append.mp hd with hd | hd + · exact hprime step.left d hd + · exact hprime step.right d hd + +theorem integerReconstructionFormulas_frequencies_dvd {σ : Type*} + (steps : List (HistoryPivotStep σ)) (M : ℤ) + (hsteps : ∀ step ∈ steps, step.s ∣ M) (i : σ) : + ∀ d ∈ (integerReconstructionFormulas steps i).frequencies, d ∣ M := by + apply HistoryFormula.replay_frequencies_dvd + · intro step hstep + obtain ⟨a, ha, rfl⟩ := List.mem_map.mp hstep + exact a.formula_frequencies_dvd M (hsteps a ha) + · intro _ d hd + simp only [HistoryFormula.frequencies, List.not_mem_nil] at hd + +theorem integerReconstructionFormulas_period {σ : Type*} + (steps : List (HistoryPivotStep σ)) (M s : ℤ) (C : ℕ) (hC : 1 ≤ C) + (hsteps : ∀ step ∈ steps, step.s ∣ M) + (hsize : ∀ step ∈ steps, step.left.length + step.right.length + 4 ≤ C) + (hs : s ∣ M) (i : σ) : + (integerReconstructionFormulas steps i).cleared.denominator * s ∣ M ^ (C ^ steps.length + 1) := by + have hc : (integerReconstructionFormulas steps i).cost ≤ C ^ steps.length := by + have hb := HistoryFormula.reconstructedFormulas_cost + (steps.map fun step => (step.target, step.formula)) C hC + (by + intro step hstep + obtain ⟨a, ha, rfl⟩ := List.mem_map.mp hstep + simpa only [a.formula_cost] using hsize a ha) i + simpa only [integerReconstructionFormulas, List.length_map] using hb + have hf := (integerReconstructionFormulas steps i).frequency_count_le_cost + apply ((integerReconstructionFormulas steps i).denominator_test_period M s + (integerReconstructionFormulas_frequencies_dvd steps M hsteps i) hs).trans + exact pow_dvd_pow M (Nat.add_le_add_right (hf.trans hc) 1) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructionIntegrality.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructionIntegrality.lean new file mode 100644 index 0000000000000000000000000000000000000000..61c3f42cdb228825b641a7660dccf27dfc3ae7c2 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructionIntegrality.lean @@ -0,0 +1,88 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ReconstructedHistoryTests + +namespace OAI + +/-! # Every original integer-divisibility gate is a cleared polynomial test -/ + +namespace Ostmann + +open scoped Classical + +def HistoryFormula.IntegralAt {σ : Type*} (F : HistoryFormula σ) (x : σ → ℤ) : Prop := + ∃ y : ℤ, F.value (fun i => (x i : ℚ)) = y + +theorem HistoryFormula.integralAt_iff {σ : Type*} (F : HistoryFormula σ) (x : σ → ℤ) : + F.IntegralAt x ↔ F.cleared.denominator ∣ + MvPolynomial.eval₂Hom (RingHom.id ℤ) x F.cleared.numerator := by + constructor + · rintro ⟨y, hy⟩ + exact ⟨y, F.cleared.integer_value_cleared x y hy⟩ + · rintro ⟨y, hy⟩ + refine ⟨y, ?_⟩ + apply (div_eq_iff (Int.cast_ne_zero.mpr F.cleared.denominator_ne_zero)).mpr + have he : (MvPolynomial.eval₂Hom (RingHom.id ℤ) x F.cleared.numerator : ℚ) = + MvPolynomial.eval₂ (Int.castRingHom ℚ) (fun i => (x i : ℚ)) F.cleared.numerator := by + simpa [Int.castRingHom] using + (MvPolynomial.map_eval₂Hom (RingHom.id ℤ) x (Int.castRingHom ℚ) F.cleared.numerator) + rw [← he, hy, Int.cast_mul, mul_comm] + +theorem HistoryPivotStep.valid_iff_integral {σ : Type*} (step : HistoryPivotStep σ) (x : σ → ℤ) : + step.Valid x ↔ step.formula.IntegralAt x := by + constructor + · intro hx + exact ⟨step.numerator x / step.s, step.formula_value_integer x hx⟩ + · rintro ⟨y, hy⟩ + rw [step.formula_value] at hy + have he : (step.numerator x : ℚ) = (y : ℚ) * step.s := + (div_eq_iff (Int.cast_ne_zero.mpr step.s_ne_zero)).mp hy + have hi : step.numerator x = step.s * y := by + apply Int.cast_injective (α := ℚ) + rw [Int.cast_mul, he, mul_comm] + exact ⟨y, hi⟩ + +noncomputable def reconstructionTests {σ : Type*} : + List (HistoryPivotStep σ) → (σ → HistoryFormula σ) → List (HistoryFormula σ) + | [], _ => [] + | step :: rest, env => + (step.formula.bind env) :: + reconstructionTests rest (Function.update env step.target (step.formula.bind env)) + +/-- Inductively, the polynomial gates enforce exactly the original integer +reconstructions. They are not an independently assumed support predicate. -/ +theorem reconstructionTests_iff {σ : Type*} (steps : List (HistoryPivotStep σ)) + (env : σ → HistoryFormula σ) (x₀ x : σ → ℤ) + (henv : ∀ i, (env i).value (fun j => (x₀ j : ℚ)) = x i) : + (∀ F ∈ reconstructionTests steps env, F.IntegralAt x₀) ↔ ValidIntegerReconstruction steps x := by + induction steps generalizing env x with + | nil => simp [reconstructionTests, ValidIntegerReconstruction] + | cons step rest ih => + have hev : (step.formula.bind env).value (fun j => (x₀ j : ℚ)) = + step.formula.value (fun j => (x j : ℚ)) := by + rw [HistoryFormula.value_bind] + congr 1 + funext i + exact henv i + have hhead : (step.formula.bind env).IntegralAt x₀ ↔ step.Valid x := by + rw [step.valid_iff_integral] + simp only [HistoryFormula.IntegralAt, hev] + simp only [reconstructionTests, List.mem_cons, forall_eq_or_imp, ValidIntegerReconstruction] + rw [hhead] + constructor + · rintro ⟨hs, hrest⟩ + refine ⟨hs, (ih _ _ ?_).mp hrest⟩ + intro i + by_cases hi : i = step.target + · subst i + simp only [Function.update_self, HistoryPivotStep.applyInteger, hev, step.formula_value_integer x hs] + · simp only [Function.update_of_ne hi, HistoryPivotStep.applyInteger, henv] + · rintro ⟨hs, hrest⟩ + refine ⟨hs, (ih _ _ ?_).mpr hrest⟩ + intro i + by_cases hi : i = step.target + · subst i + simp only [Function.update_self, HistoryPivotStep.applyInteger, hev, step.formula_value_integer x hs] + · simp only [Function.update_of_ne hi, HistoryPivotStep.applyInteger, henv] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructionTestBounds.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructionTestBounds.lean new file mode 100644 index 0000000000000000000000000000000000000000..47165b44d3b858b433b615d2e78cc4204c3c6c02 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReconstructionTestBounds.lean @@ -0,0 +1,74 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ReconstructionFrequencyPeriod + +namespace OAI + +/-! # Bounds for every intermediate test in the actual substitution order -/ + +namespace Ostmann + +open scoped Classical + +theorem reconstructionTests_cost {σ : Type*} (steps : List (HistoryPivotStep σ)) + (env : σ → HistoryFormula σ) (C B : ℕ) (hC : 1 ≤ C) (hB : 1 ≤ B) + (henv : ∀ i, (env i).cost ≤ B) + (hsteps : ∀ step ∈ steps, step.formula.cost ≤ C) : + ∀ F ∈ reconstructionTests steps env, F.cost ≤ C ^ steps.length * B := by + induction steps generalizing env B with + | nil => simp only [reconstructionTests, List.not_mem_nil, false_implies, implies_true] + | cons step rest ih => + have hhead : (step.formula.bind env).cost ≤ C * B := by + exact (HistoryFormula.cost_bind_le step.formula env B hB henv).trans + (by simpa only [Nat.mul_comm] using Nat.mul_le_mul_left B (hsteps step (by simp))) + have henv' : ∀ i, (Function.update env step.target (step.formula.bind env) i).cost ≤ C * B := by + intro i + by_cases hi : i = step.target + · subst i; simpa only [Function.update_self] using hhead + · simpa only [Function.update_of_ne hi] using + (henv i).trans (by nlinarith) + intro F hF + rcases List.mem_cons.mp hF with rfl | hF + · have hp : 1 ≤ C ^ rest.length := Nat.one_le_pow rest.length C (by omega) + simp only [List.length_cons, pow_succ] + nlinarith + · have hh := ih _ (C * B) (by nlinarith) henv' + (fun s hs => hsteps s (by simp [hs])) F hF + simpa only [List.length_cons, pow_succ, Nat.mul_assoc] using hh + +theorem reconstructionTests_frequencies_dvd {σ : Type*} (steps : List (HistoryPivotStep σ)) + (env : σ → HistoryFormula σ) (M : ℤ) + (henv : ∀ i d, d ∈ (env i).frequencies → d ∣ M) + (hsteps : ∀ step ∈ steps, step.s ∣ M) : + ∀ F ∈ reconstructionTests steps env, ∀ d ∈ F.frequencies, d ∣ M := by + induction steps generalizing env with + | nil => simp only [reconstructionTests, List.not_mem_nil, false_implies, implies_true] + | cons step rest ih => + have hhead := HistoryFormula.frequencies_bind_dvd step.formula env M + (step.formula_frequencies_dvd M (hsteps step (by simp))) henv + have henv' : ∀ i d, d ∈ (Function.update env step.target (step.formula.bind env) i).frequencies → d ∣ M := by + intro i d hd + by_cases hi : i = step.target + · subst i; simp only [Function.update_self] at hd; exact hhead d hd + · simp only [Function.update_of_ne hi] at hd; exact henv i d hd + intro F hF + rcases List.mem_cons.mp hF with rfl | hF + · exact hhead + · exact ih _ henv' (fun s hs => hsteps s (by simp [hs])) F hF + +theorem reconstructionTests_prime_period {σ : Type*} (steps : List (HistoryPivotStep σ)) + (M s : ℤ) (C : ℕ) (hC : 1 ≤ C) + (hsteps : ∀ step ∈ steps, step.s ∣ M) + (hsize : ∀ step ∈ steps, step.left.length + step.right.length + 4 ≤ C) + (hs : s ∣ M) (F : HistoryFormula σ) + (hF : F ∈ reconstructionTests steps HistoryFormula.prime) : + F.cleared.denominator * s ∣ M ^ (C ^ steps.length + 1) := by + have hc : F.cost ≤ C ^ steps.length := by + simpa only [Nat.mul_one] using reconstructionTests_cost steps .prime C 1 hC (by omega) + (fun _ => le_rfl) (fun step hstep => by simpa only [step.formula_cost] using hsize step hstep) F hF + have hf := reconstructionTests_frequencies_dvd steps .prime M + (by intro i d hd; simp only [HistoryFormula.frequencies, List.not_mem_nil] at hd) hsteps F hF + exact (F.denominator_test_period M s hf hs).trans + (pow_dvd_pow M (Nat.add_le_add_right (F.frequency_count_le_cost.trans hc) 1)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveArchimedeanCutoff.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveArchimedeanCutoff.lean new file mode 100644 index 0000000000000000000000000000000000000000..b99bbf97cb0b83ef0feef7b7cd850c896c38a90f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveArchimedeanCutoff.lean @@ -0,0 +1,47 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.RecursiveFrequencySupport + +namespace OAI + +/-! # The original Fourier weight retains its precise bottom cutoff -/ + +namespace Ostmann + +open scoped Classical + +/-- The original level-zero Fourier factor vanishes outside its prescribed +frequency range; each recursive coefficient retains every leaf cutoff. -/ +theorem recursive_archimedean_square_with_leaf_cutoff {State : Type*} + (sys : TransferHistorySystem State) (M : State → ℕ) (c : State → ℤ → ℝ) + (cutoff : State → ℤ → ℤ → ℤ → ℝ) (X Δ C K : ℝ) (ψhat : ℝ → ℂ) + (hc : ∀ σ v, |c σ v| ≤ 1) (hψ : ∀ u, ‖ψhat u‖ ≤ Real.exp K) + (hwindow : ∀ σ v, c σ v ≠ 0 → 0 < M σ ∧ X * Real.exp (Δ - C) ≤ M σ) + (hcut : ∀ σ s v w, |cutoff σ s v w| ≤ 1) + (V : ℕ) (hfreq : ∀ σ v, c σ v ≠ 0 → v.natAbs ≤ V) + (S : Finset ℤ) (n : ℕ) (σ : State) (t : FrequencyTree S n) : + ‖recursiveTransferWeight sys + (fun σ v => archimedeanLeafFactor X (M σ) v (c σ v) ψhat) cutoff n σ + (frequencyTreeMap Subtype.val n t)‖ ^ 2 ≤ + Real.exp (-(2 ^ n : ℕ) * Δ + (2 ^ n : ℕ) * (C + 2 * K)) * + frequencyLeafWeight (singleFrequencyLeaf S V) n t := by + have hsize (τ : State) (v : ℤ) : + ‖archimedeanLeafFactor X (M τ) v (c τ v) ψhat‖ ^ 2 ≤ Real.exp (-Δ + (C + 2 * K)) := by + apply archimedeanLeafFactor_square_exp_le X (M τ) v (c τ v) Δ C K ψhat (hc τ v) hψ + intro hv + obtain ⟨hp, hb⟩ := hwindow τ v hv + exact ⟨by exact_mod_cast hp, hb⟩ + have hleaf (τ : State) (v : ℤ) + (hv : archimedeanLeafFactor X (M τ) v (c τ v) ψhat ≠ 0) : v.natAbs ≤ V := by + apply hfreq τ v + intro hc0 + apply hv + simp only [archimedeanLeafFactor, hc0, mul_zero, Complex.ofReal_zero, zero_mul] + have h := recursiveTransferWeight_square_with_leaf_cutoff sys _ cutoff + (Real.exp (-Δ + (C + 2 * K))) (Real.exp_pos _).le hsize hcut V hleaf S n σ t + apply h.trans_eq + rw [← Real.exp_nat_mul] + congr 2 + ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveFrequencySupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveFrequencySupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..b80e8b8e93562ba2dfd61e64d01a6b52a93d3970 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveFrequencySupport.lean @@ -0,0 +1,85 @@ +import OAI.NumberTheory.Ostmann.Construction.RecursiveTransferWeight +import OAI.NumberTheory.Ostmann.Arithmetic.SingleFrequencyTree + +namespace OAI + +/-! # The original leaf-frequency cutoffs in the recursive squared weights -/ + +namespace Ostmann + +open scoped Classical + +def frequencyTreeMap {A B : Type} (f : A → B) : (n : ℕ) → FrequencyTree A n → FrequencyTree B n + | 0, x => f x + | n + 1, x => (f x.1, frequencyTreeMap f n x.2.1, frequencyTreeMap f n x.2.2) + +theorem frequencyRoot_map {A B : Type} (f : A → B) (n : ℕ) (x : FrequencyTree A n) : + frequencyRoot n (frequencyTreeMap f n x) = f (frequencyRoot n x) := by + cases n <;> rfl + +theorem frequencyLeafWeight_map {A B : Type} (f : A → B) (W : B → ℝ) + (n : ℕ) (x : FrequencyTree A n) : + frequencyLeafWeight W n (frequencyTreeMap f n x) = frequencyLeafWeight (fun a => W (f a)) n x := by + induction n with + | zero => rfl + | succ n ih => exact congrArg₂ (· * ·) (ih x.2.1) (ih x.2.2) + +theorem recursiveTransferWeight_children_nonzero {State : Type*} + (sys : TransferHistorySystem State) (leaf : State → ℤ → ℂ) + (cutoff : State → ℤ → ℤ → ℤ → ℝ) (n : ℕ) (σ : State) + (t : FrequencyTree ℤ (n + 1)) + (ht : recursiveTransferWeight sys leaf cutoff (n + 1) σ t ≠ 0) : + let P := historyPivot sys σ t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + ValidTransferNode sys σ t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) P ∧ + recursiveTransferWeight sys leaf cutoff n (sys.leftState σ P) t.2.1 ≠ 0 ∧ + recursiveTransferWeight sys leaf cutoff n (sys.rightState σ P) t.2.2 ≠ 0 := by + let P := historyPivot sys σ t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + by_cases hP : ValidTransferNode sys σ t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) P + · rw [recursiveTransferWeight_node sys leaf cutoff n σ t P hP] at ht + refine ⟨hP, ?_, ?_⟩ + · intro hz + change recursiveTransferWeight sys leaf cutoff n (sys.leftState σ P) t.2.1 = 0 at hz + exact ht (by rw [hz, mul_zero, zero_mul]) + · intro hz + change recursiveTransferWeight sys leaf cutoff n (sys.rightState σ P) t.2.2 = 0 at hz + exact ht (by rw [hz, star_zero, mul_zero]) + · exact False.elim (ht (by simp only [recursiveTransferWeight, P, hP, ite_false])) + +theorem recursiveTransferWeight_leaf_cutoff {State : Type*} + (sys : TransferHistorySystem State) (leaf : State → ℤ → ℂ) + (cutoff : State → ℤ → ℤ → ℤ → ℝ) (V n : ℕ) + (hleaf : ∀ σ v, leaf σ v ≠ 0 → v.natAbs ≤ V) (σ : State) (t : FrequencyTree ℤ n) + (ht : recursiveTransferWeight sys leaf cutoff n σ t ≠ 0) : + frequencyLeafWeight (fun v : ℤ => if v.natAbs ≤ V then (1 : ℝ) else 0) n t = 1 := by + induction n generalizing σ with + | zero => exact ite_eq_left (hleaf σ t ht) + | succ n ih => + obtain ⟨_, hL, hR⟩ := recursiveTransferWeight_children_nonzero sys leaf cutoff n σ t ht + change frequencyLeafWeight _ n t.2.1 * frequencyLeafWeight _ n t.2.2 = 1 + rw [ih _ _ hL, ih _ _ hR, mul_one] + +/-- The square bound retains the actual leaf-frequency indicator. No +extra leaf frequencies are introduced when support restrictions are dropped. -/ +theorem recursiveTransferWeight_square_with_leaf_cutoff {State : Type*} + (sys : TransferHistorySystem State) (leaf : State → ℤ → ℂ) + (cutoff : State → ℤ → ℤ → ℤ → ℝ) (B : ℝ) (hB : 0 ≤ B) + (hsize : ∀ σ v, ‖leaf σ v‖ ^ 2 ≤ B) + (hcut : ∀ σ s v w, |cutoff σ s v w| ≤ 1) + (V : ℕ) (hleaf : ∀ σ v, leaf σ v ≠ 0 → v.natAbs ≤ V) + (S : Finset ℤ) (n : ℕ) (σ : State) (t : FrequencyTree S n) : + ‖recursiveTransferWeight sys leaf cutoff n σ (frequencyTreeMap Subtype.val n t)‖ ^ 2 ≤ + B ^ (2 ^ n) * frequencyLeafWeight (singleFrequencyLeaf S V) n t := by + by_cases ht : recursiveTransferWeight sys leaf cutoff n σ (frequencyTreeMap Subtype.val n t) = 0 + · simp only [ht, norm_zero, zero_pow (by decide : 2 ≠ 0)] + exact mul_nonneg (pow_nonneg hB _) (frequencyLeafWeight_nonneg _ + (fun _ => by unfold singleFrequencyLeaf; split_ifs <;> norm_num) n t) + · have hl := recursiveTransferWeight_leaf_cutoff sys leaf cutoff V n hleaf σ + (frequencyTreeMap Subtype.val n t) ht + rw [frequencyLeafWeight_map] at hl + change frequencyLeafWeight (singleFrequencyLeaf S V) n t = 1 at hl + rw [hl, mul_one] + exact recursiveTransferWeight_square_le sys leaf cutoff B hB hsize hcut n σ _ + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveLeafExpansion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveLeafExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..e12c46a7d5f1d8d01563f40180e0cb88a009cfe7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveLeafExpansion.lean @@ -0,0 +1,115 @@ +import OAI.NumberTheory.Ostmann.Construction.RecursiveTransferWeight +import OAI.NumberTheory.Ostmann.Construction.HistoryFourierConjugation + +namespace OAI + +/-! # The exact signed leaves and real support factor of a recursive history -/ + +namespace Ostmann + +open scoped BigOperators ComplexConjugate SchwartzMap FourierTransform Classical + +/-- The flag records the conjugations accumulated from right branches. -/ +noncomputable def transferLeafList {State : Type*} (sys : TransferHistorySystem State) : + (n : ℕ) → State → FrequencyTree ℤ n → List ((State × ℤ) × Bool) + | 0, σ, v => [((σ, v), true)] + | n + 1, σ, t => + let P := historyPivot sys σ t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + transferLeafList sys n (sys.leftState σ P) t.2.1 ++ + (transferLeafList sys n (sys.rightState σ P) t.2.2).map (fun z => (z.1, !z.2)) + +theorem transferLeafList_length {State : Type*} (sys : TransferHistorySystem State) + (n : ℕ) (σ : State) (t : FrequencyTree ℤ n) : + (transferLeafList sys n σ t).length = 2 ^ n := by + induction n generalizing σ with + | zero => rfl + | succ n ih => + simp only [transferLeafList, List.length_append, List.length_map, ih] + rw [pow_succ] + omega + +noncomputable def signedLeafValue {State : Type*} (F : State → ℤ → ℂ) + (z : (State × ℤ) × Bool) : ℂ := + if z.2 then F z.1.1 z.1.2 else conj (F z.1.1 z.1.2) + +theorem signedLeafValue_flip {State : Type*} (F : State → ℤ → ℂ) + (z : (State × ℤ) × Bool) : + signedLeafValue F (z.1, !z.2) = conj (signedLeafValue F z) := by + rcases z with ⟨⟨σ, v⟩, b⟩ + cases b <;> simp [signedLeafValue] + +theorem signedLeafProduct_flip {State : Type*} (F : State → ℤ → ℂ) + (l : List ((State × ℤ) × Bool)) : + ((l.map (fun z => (z.1, !z.2))).map (signedLeafValue F)).prod = + conj ((l.map (signedLeafValue F)).prod) := by + induction l with + | nil => simp + | cons z l ih => + simp only [List.map_cons, List.prod_cons, signedLeafValue_flip, ih, map_mul] + +/-- Leaf bins and all intermediate arithmetic/range gates are real. They +remain real under every conjugation in the frequency tree. -/ +noncomputable def recursiveSupportFactor {State : Type*} (sys : TransferHistorySystem State) + (leafCutoff : State → ℤ → ℝ) (cutoff : State → ℤ → ℤ → ℤ → ℝ) : + (n : ℕ) → State → FrequencyTree ℤ n → ℝ + | 0, σ, v => leafCutoff σ v + | n + 1, σ, t => + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let P := historyPivot sys σ t.1 v w + if ValidTransferNode sys σ t.1 v w P then + cutoff σ t.1 v w * recursiveSupportFactor sys leafCutoff cutoff n (sys.leftState σ P) t.2.1 * + recursiveSupportFactor sys leafCutoff cutoff n (sys.rightState σ P) t.2.2 + else 0 + +/-- This equality uses the original recursive weight, including its actual +reconstructed pivots and its validity tests. -/ +theorem recursiveTransferWeight_leaf_expansion {State : Type*} + (sys : TransferHistorySystem State) (F : State → ℤ → ℂ) + (leafCutoff : State → ℤ → ℝ) (cutoff : State → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (σ : State) (t : FrequencyTree ℤ n) : + recursiveTransferWeight sys (fun σ v => (leafCutoff σ v : ℂ) * F σ v) cutoff n σ t = + (recursiveSupportFactor sys leafCutoff cutoff n σ t : ℂ) * + ((transferLeafList sys n σ t).map (signedLeafValue F)).prod := by + induction n generalizing σ with + | zero => simp [recursiveTransferWeight, recursiveSupportFactor, transferLeafList, signedLeafValue] + | succ n ih => + let v := frequencyRoot n t.2.1 + let w := frequencyRoot n t.2.2 + let P := historyPivot sys σ t.1 v w + by_cases hp : ValidTransferNode sys σ t.1 v w P + · rw [recursiveTransferWeight_node sys _ cutoff n σ t P hp] + simp only [recursiveSupportFactor, transferLeafList, v, w, P, hp, ite_true, + List.map_append, List.prod_append, signedLeafProduct_flip, ih, Complex.star_def, map_mul, Complex.conj_ofReal] + push_cast + ring + · simp only [recursiveTransferWeight, recursiveSupportFactor, v, w, P, hp, ite_false, + Complex.ofReal_zero, zero_mul] + +/-- Every leaf conjugation is absorbed into its frequency; the Fourier +profile remains the same fixed Schwartz function throughout the tree. -/ +theorem recursiveFourierWeight_leaf_expansion {State : Type*} + (sys : TransferHistorySystem State) (ψ : 𝓢(ℝ, ℂ)) + (hreal : ∀ x, conj (ψ x) = ψ x) (scale : State → ℝ) + (leafCutoff : State → ℤ → ℝ) (cutoff : State → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (σ : State) (t : FrequencyTree ℤ n) : + recursiveTransferWeight sys + (fun σ v => (leafCutoff σ v : ℂ) * normalizedFourierProfile (𝓕 ψ : 𝓢(ℝ, ℂ)) v (scale σ)) + cutoff n σ t = + (recursiveSupportFactor sys leafCutoff cutoff n σ t : ℂ) * + ((transferLeafList sys n σ t).map (fun z => + normalizedFourierProfile (𝓕 ψ : 𝓢(ℝ, ℂ)) + (if z.2 then (z.1.2 : ℝ) else -(z.1.2 : ℝ)) (scale z.1.1))).prod := by + rw [recursiveTransferWeight_leaf_expansion] + congr 1 + apply congrArg List.prod + apply List.map_congr_left + intro z _ + rcases z with ⟨⟨τ, v⟩, b⟩ + cases b + · exact normalizedFourierProfile_fourier_conj ψ hreal v (scale τ) + · rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveNodeExpansion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveNodeExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..f6dc5632ee6ddc6bb6ef38146fdd006346472ecf --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveNodeExpansion.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.RecursiveLeafExpansion + +namespace OAI + +/-! # The exact preorder list of reconstructed arithmetic tests -/ + +namespace Ostmann + +open scoped Classical + +structure ReconstructedTransferNode (State : Type*) where + state : State + root : ℤ + left : ℤ + right : ℤ + +namespace ReconstructedTransferNode + +noncomputable def pivot {State : Type*} (sys : TransferHistorySystem State) + (node : ReconstructedTransferNode State) : ℕ := + historyPivot sys node.state node.root node.left node.right + +def Valid {State : Type*} (sys : TransferHistorySystem State) + (node : ReconstructedTransferNode State) : Prop := + ValidTransferNode sys node.state node.root node.left node.right (node.pivot sys) + +end ReconstructedTransferNode + +noncomputable def transferNodeList {State : Type*} (sys : TransferHistorySystem State) : + (n : ℕ) → State → FrequencyTree ℤ n → List (ReconstructedTransferNode State) + | 0, _, _ => [] + | n + 1, σ, t => + let node : ReconstructedTransferNode State := + ⟨σ, t.1, frequencyRoot n t.2.1, frequencyRoot n t.2.2⟩ + node :: (transferNodeList sys n (sys.leftState σ (node.pivot sys)) t.2.1 ++ + transferNodeList sys n (sys.rightState σ (node.pivot sys)) t.2.2) + +theorem transferNodeList_length {State : Type*} (sys : TransferHistorySystem State) + (n : ℕ) (σ : State) (t : FrequencyTree ℤ n) : + (transferNodeList sys n σ t).length = 2 ^ n - 1 := by + induction n generalizing σ with + | zero => rfl + | succ n ih => + simp only [transferNodeList, List.length_cons, List.length_append, ih] + have h := Nat.one_le_two_pow (n := n) + rw [pow_succ] + omega + +/-- The pivot witness in the original definition is precisely the integer +reconstruction, so no existential choice changes the child states. -/ +theorem validTransferHistory_reconstructed_iff {State : Type*} + (sys : TransferHistorySystem State) (n : ℕ) (σ : State) (t : FrequencyTree ℤ (n + 1)) : + ValidTransferHistory sys (n + 1) σ t ↔ + let P := historyPivot sys σ t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) + ValidTransferNode sys σ t.1 (frequencyRoot n t.2.1) (frequencyRoot n t.2.2) P ∧ + ValidTransferHistory sys n (sys.leftState σ P) t.2.1 ∧ + ValidTransferHistory sys n (sys.rightState σ P) t.2.2 := by + constructor + · rintro ⟨P, hp, hl, hr⟩ + rw [hp.historyPivot_eq] + exact ⟨hp, hl, hr⟩ + · rintro ⟨hp, hl, hr⟩ + exact ⟨_, hp, hl, hr⟩ + +/-- All arithmetic support conditions in a complete history are the tests +of its explicitly reconstructed preorder node list. -/ +theorem validTransferHistory_nodeList_iff {State : Type*} + (sys : TransferHistorySystem State) (n : ℕ) (σ : State) (t : FrequencyTree ℤ n) : + ValidTransferHistory sys n σ t ↔ ∀ node ∈ transferNodeList sys n σ t, node.Valid sys := by + induction n generalizing σ with + | zero => simp [ValidTransferHistory, transferNodeList] + | succ n ih => + rw [validTransferHistory_reconstructed_iff] + simp only [transferNodeList, List.mem_cons, List.mem_append, or_imp, + forall_and, forall_eq, ← ih] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveSupportExpansion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveSupportExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..07ce52efa8880580dedfe0d81719e2a0ef5dfe8a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RecursiveSupportExpansion.lean @@ -0,0 +1,64 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.RecursiveNodeExpansion + +namespace OAI + +/-! # All original range factors and all arithmetic tests in a flat history -/ + +namespace Ostmann + +open scoped BigOperators Classical + +noncomputable def transferNodeCutoff {State : Type*} + (cutoff : State → ℤ → ℤ → ℤ → ℝ) (node : ReconstructedTransferNode State) : ℝ := + cutoff node.state node.root node.left node.right + +noncomputable def transferLeafCutoff {State : Type*} + (cutoff : State → ℤ → ℝ) (leaf : (State × ℤ) × Bool) : ℝ := + cutoff leaf.1.1 leaf.1.2 + +theorem transferLeafCutoff_flip {State : Type*} (c : State → ℤ → ℝ) + (l : List ((State × ℤ) × Bool)) : + ((l.map (fun z => (z.1, !z.2))).map (transferLeafCutoff c)).prod = + (l.map (transferLeafCutoff c)).prod := by + simp only [List.map_map, Function.comp_def, transferLeafCutoff] + rfl + +/-- The support is exactly the product of original node and leaf cutoffs +on the original arithmetic validity set. -/ +theorem recursiveSupportFactor_product {State : Type*} + (sys : TransferHistorySystem State) (leafCutoff : State → ℤ → ℝ) + (cutoff : State → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (σ : State) (t : FrequencyTree ℤ n) : + recursiveSupportFactor sys leafCutoff cutoff n σ t = + if ValidTransferHistory sys n σ t then + ((transferNodeList sys n σ t).map (transferNodeCutoff cutoff)).prod * + ((transferLeafList sys n σ t).map (transferLeafCutoff leafCutoff)).prod + else 0 := by + induction n generalizing σ with + | zero => simp [recursiveSupportFactor, ValidTransferHistory, transferNodeList, + transferLeafList, transferLeafCutoff] + | succ n ih => + rw [validTransferHistory_reconstructed_iff] + simp only [recursiveSupportFactor, transferNodeList, transferLeafList, + List.map_cons, List.prod_cons, List.map_append, List.prod_append, + transferLeafCutoff_flip, transferNodeCutoff, ReconstructedTransferNode.pivot, ih] + split_ifs <;> simp_all + ring + +/-- The flat statement uses exactly 2^n-1 node tests, whose validity was +proved equivalent to the recursive support, not assumed as a new condition. -/ +theorem recursiveSupportFactor_nodeList {State : Type*} + (sys : TransferHistorySystem State) (leafCutoff : State → ℤ → ℝ) + (cutoff : State → ℤ → ℤ → ℤ → ℝ) + (n : ℕ) (σ : State) (t : FrequencyTree ℤ n) : + recursiveSupportFactor sys leafCutoff cutoff n σ t = + if ∀ node ∈ transferNodeList sys n σ t, node.Valid sys then + ((transferNodeList sys n σ t).map (transferNodeCutoff cutoff)).prod * + ((transferLeafList sys n σ t).map (transferLeafCutoff leafCutoff)).prod + else 0 := by + rw [recursiveSupportFactor_product, validTransferHistory_nodeList_iff] + congr 1 + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReducedCoefficientLift.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReducedCoefficientLift.lean new file mode 100644 index 0000000000000000000000000000000000000000..c6357a68ea5e72b5bd8917b80ad44a53c863f4a8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReducedCoefficientLift.lean @@ -0,0 +1,51 @@ +import Mathlib.Algebra.BigOperators.Ring.Finset +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticResidueReversal + +namespace OAI + +/-! # Using the remaining precision of reconstructed pivots in later coefficients -/ + +namespace Ostmann + +open scoped BigOperators + +/-- An arbitrary representative at the original modulus. Its reduction +is independent of this lift whenever the remaining precision suffices. -/ +def liftResidueRepresentative (Q M : ℕ) (x : ZMod M) : ZMod Q := x.val + +theorem reduce_liftResidueRepresentative (Q M d : ℕ) [NeZero M] + (hdQ : d ∣ Q) (hdM : d ∣ M) (x : ZMod M) : + ZMod.castHom hdQ (ZMod d) (liftResidueRepresentative Q M x) = + ZMod.castHom hdM (ZMod d) x := by + have h := congrArg (ZMod.castHom hdM (ZMod d)) (ZMod.natCast_zmod_val x) + simpa only [liftResidueRepresentative, map_natCast] using h + +theorem reduce_liftResidueRepresentative_int (Q M d : ℕ) [NeZero M] + (hdQ : d ∣ Q) (hdM : d ∣ M) (x : ZMod M) (a : ℤ) (hx : x = a) : + ZMod.castHom hdQ (ZMod d) (liftResidueRepresentative Q M x) = a := by + rw [reduce_liftResidueRepresentative Q M d hdQ hdM x, hx, map_intCast] + +/-- A known nonbulk coefficient can include any specified finite set of +ancestor pivots. Multiplication loses no further frequency precision. -/ +theorem reduce_ancestor_product {I : Type*} [Fintype I] + (Q M d : ℕ) [NeZero M] (hdQ : d ∣ Q) (hdM : d ∣ M) + (C : ℤ) (x : I → ZMod M) (a : I → ℤ) (hx : ∀ i, x i = a i) : + ZMod.castHom hdQ (ZMod d) + ((C : ZMod Q) * ∏ i, liftResidueRepresentative Q M (x i)) = + ((C * ∏ i, a i : ℤ) : ZMod d) := by + rw [map_mul, map_prod, map_intCast] + simp only [Int.cast_mul, Int.cast_prod] + congr 1 + apply Finset.prod_congr rfl + intro i _ + exact reduce_liftResidueRepresentative_int Q M d hdQ hdM (x i) (a i) (hx i) + +/-- After at most k divisions, the remaining R-power still contains each +frequency divisor, so lifted ancestor coefficients can be tested modulo it. -/ +theorem frequency_dvd_remaining_precision (R s k depth : ℕ) + (hs : s ∣ R) (hdepth : depth ≤ k + 1) : s ∣ R ^ (k + 2 - depth) := by + exact hs.trans (dvd_pow_self R (by omega)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReducedFrequencyEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReducedFrequencyEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..a0e29e67c14be03ed1fcb9ab3893dcffd423b09e --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReducedFrequencyEnergy.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.Ostmann.Characters.UnitRamanujanProduct +import OAI.NumberTheory.Ostmann.Preliminaries.AdditiveSieveProbability + +namespace OAI + +/-! # Reduced-frequency energy of a uniform set and its Ramanujan kernel -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +noncomputable def unitFrequencyEnergy {q : ℕ} [NeZero q] {ι : Type*} + (A : Finset ι) (a : ι → ZMod q) : ℝ := + ∑ u : (ZMod q)ˣ, ‖(A.card : ℂ)⁻¹ * ∑ x ∈ A, + ZMod.stdAddChar ((u : ZMod q) * a x)‖ ^ 2 + +theorem unitFrequencyEnergy_nonneg {q : ℕ} [NeZero q] {ι : Type*} + (A : Finset ι) (a : ι → ZMod q) : 0 ≤ unitFrequencyEnergy A a := + Finset.sum_nonneg (fun _ _ => sq_nonneg _) + +theorem unitFrequencyEnergy_kernel {q : ℕ} [NeZero q] {ι : Type*} + (A : Finset ι) (a : ι → ZMod q) : + (unitFrequencyEnergy A a : ℂ) = + (A.card : ℂ)⁻¹ * (A.card : ℂ)⁻¹ * + ∑ x ∈ A, ∑ y ∈ A, unitRamanujanKernel q (a x - a y) := by + have hp (u : (ZMod q)ˣ) : + ((‖(A.card : ℂ)⁻¹ * ∑ x ∈ A, ZMod.stdAddChar ((u : ZMod q) * a x)‖ ^ 2 : ℝ) : ℂ) = + (A.card : ℂ)⁻¹ * (A.card : ℂ)⁻¹ * ∑ x ∈ A, ∑ y ∈ A, + ZMod.stdAddChar ((u : ZMod q) * (a x - a y)) := by + rw [Complex.ofReal_pow, ← Complex.mul_conj'] + simp only [map_mul, map_inv₀, map_natCast, map_sum, stdAddChar_conj] + simp only [Finset.mul_sum, Finset.sum_mul] + conv_lhs => rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro x _ + apply Finset.sum_congr rfl + intro y _ + rw [show (u : ZMod q) * (a x - a y) = + (u : ZMod q) * a x + -((u : ZMod q) * a y) by ring, + AddChar.map_add_eq_mul] + ring + rw [unitFrequencyEnergy, Complex.ofReal_sum] + simp_rw [hp] + rw [← Finset.mul_sum] + congr 1 + simp_rw [Finset.sum_comm (s := Finset.univ) (t := A)] + rfl + +theorem sum_reducedNumerators_eq_units {q : ℕ} [NeZero q] + {R : Type*} [AddCommMonoid R] (f : ℕ → R) : + (∑ h ∈ reducedNumerators q, f h) = ∑ u : (ZMod q)ˣ, f (u : ZMod q).val := by + change (∑ h ∈ reducedResidues q, f h) = _ + rw [← Finset.sum_coe_sort] + exact ((unitReducedResidueEquiv q).sum_comp (fun a => f a.val)).symm + +theorem intervalSetReducedEnergy_eq_unitFrequencyEnergy {M q : ℕ} [NeZero q] + (A : Finset (Fin M)) (J : ℤ) : + intervalSetReducedEnergy A J q = + unitFrequencyEnergy A (fun n => ((J + (n.val : ℤ) : ℤ) : ZMod q)) := by + unfold intervalSetReducedEnergy unitFrequencyEnergy + rw [sum_reducedNumerators_eq_units] + apply Finset.sum_congr rfl + intro u _ + simp only [intervalSetExponentialSum, sieveAdditivePhase_eq_stdAddChar, + ZMod.natCast_zmod_val] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReducedFrequencySum.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReducedFrequencySum.lean new file mode 100644 index 0000000000000000000000000000000000000000..18d73cd7a62fa2e9952ca99757bf29d335971ac6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReducedFrequencySum.lean @@ -0,0 +1,92 @@ +import Mathlib.NumberTheory.Divisors +import OAI.NumberTheory.Ostmann.Arithmetic.LcmFrequencySum + +namespace OAI + +/-! # Multiplicity of the reduced frequency modulus -/ + +namespace Ostmann + +open scoped BigOperators + +def reducedFrequency (g s : ℕ) : ℕ := s / s.gcd g + +theorem reducedFrequency_mul_gcd (g s : ℕ) : reducedFrequency g s * s.gcd g = s := + Nat.div_mul_cancel (Nat.gcd_dvd_left s g) + +theorem reducedFrequency_mem {N g s : ℕ} (hs : s ∈ Finset.Icc 1 N) : + reducedFrequency g s ∈ Finset.Icc 1 N := by + obtain ⟨hs₀, hsN⟩ := Finset.mem_Icc.mp hs + have hg := Nat.gcd_pos_of_pos_left g (show 0 < s from hs₀) + exact Finset.mem_Icc.mpr ⟨Nat.div_pos + (Nat.le_of_dvd hs₀ (Nat.gcd_dvd_left s g)) hg, (Nat.div_le_self _ _).trans hsN⟩ + +/-- A fixed reduced modulus has at most one frequency for each divisor +of the gcd of the two child frequencies. -/ +theorem reducedFrequency_fiber_card_le (N g a : ℕ) (hg : g ≠ 0) : + ((Finset.Icc 1 N).filter fun s => reducedFrequency g s = a).card ≤ g.divisors.card := by + apply Finset.card_le_card_of_injOn (fun s => s.gcd g) + · intro s _ + exact Nat.mem_divisors.mpr ⟨Nat.gcd_dvd_right s g, hg⟩ + · intro s hs t ht heq + change s.gcd g = t.gcd g at heq + have hsa := (Finset.mem_filter.mp hs).2 + have hta := (Finset.mem_filter.mp ht).2 + calc + s = reducedFrequency g s * s.gcd g := (reducedFrequency_mul_gcd g s).symm + _ = reducedFrequency g t * t.gcd g := by rw [hsa, hta, heq] + _ = t := reducedFrequency_mul_gcd g t + +theorem sum_reducedFrequency_le (N g : ℕ) (hg : g ≠ 0) + (F : ℕ → ℝ) (hF : ∀ a ∈ Finset.Icc 1 N, 0 ≤ F a) : + (∑ s ∈ Finset.Icc 1 N, F (reducedFrequency g s)) ≤ + g.divisors.card * ∑ a ∈ Finset.Icc 1 N, F a := by + rw [← Finset.sum_fiberwise_of_maps_to (fun s hs => reducedFrequency_mem (g := g) hs) + (fun s => F (reducedFrequency g s))] + calc + _ ≤ ∑ a ∈ Finset.Icc 1 N, (g.divisors.card : ℝ) * F a := by + apply Finset.sum_le_sum + intro a ha + have heq : (∑ s ∈ (Finset.Icc 1 N).filter (fun s => reducedFrequency g s = a), + F (reducedFrequency g s)) = + (((Finset.Icc 1 N).filter (fun s => reducedFrequency g s = a)).card : ℝ) * F a := by + calc + _ = ∑ _s ∈ (Finset.Icc 1 N).filter (fun s => reducedFrequency g s = a), F a := + Finset.sum_congr rfl fun _ hs => congrArg F (Finset.mem_filter.mp hs).2 + _ = _ := by simp + rw [heq] + exact mul_le_mul_of_nonneg_right (by exact_mod_cast reducedFrequency_fiber_card_le N g a hg) + (hF a ha) + _ = _ := (Finset.mul_sum _ _ _).symm + +/-- After fixing the child frequencies, summing the two parent reduced +moduli costs only the divisor multiplicities and a cubic logarithm. -/ +theorem reducedFrequency_lcm_sum_le (N g h : ℕ) (hg : g ≠ 0) (hh : h ≠ 0) : + (∑ s ∈ Finset.Icc 1 N, ∑ t ∈ Finset.Icc 1 N, + (((reducedFrequency g s).lcm (reducedFrequency h t) : ℕ) : ℝ)⁻¹) ≤ + (g.divisors.card : ℝ) * h.divisors.card * (1 + Real.log N) ^ 3 := by + have hfirst := sum_reducedFrequency_le N g hg + (fun a => ∑ t ∈ Finset.Icc 1 N, ((a.lcm (reducedFrequency h t) : ℕ) : ℝ)⁻¹) + (fun _ _ => Finset.sum_nonneg fun _ _ => by positivity) + calc + _ ≤ (g.divisors.card : ℝ) * + ∑ a ∈ Finset.Icc 1 N, ∑ t ∈ Finset.Icc 1 N, + ((a.lcm (reducedFrequency h t) : ℕ) : ℝ)⁻¹ := hfirst + _ ≤ (g.divisors.card : ℝ) * + ∑ a ∈ Finset.Icc 1 N, (h.divisors.card : ℝ) * + ∑ b ∈ Finset.Icc 1 N, ((a.lcm b : ℕ) : ℝ)⁻¹ := by + apply mul_le_mul_of_nonneg_left _ (Nat.cast_nonneg _) + apply Finset.sum_le_sum + intro a _ + exact sum_reducedFrequency_le N h hh + (fun b => ((a.lcm b : ℕ) : ℝ)⁻¹) (fun _ _ => by positivity) + _ = (g.divisors.card : ℝ) * h.divisors.card * + (∑ a ∈ Finset.Icc 1 N, ∑ b ∈ Finset.Icc 1 N, ((a.lcm b : ℕ) : ℝ)⁻¹) := by + rw [← Finset.mul_sum] + ring + _ ≤ _ := mul_le_mul_of_nonneg_left (reciprocal_lcm_sum_le_log_cube N) + (mul_nonneg (Nat.cast_nonneg _) (Nat.cast_nonneg _)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RepeatedLabels.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RepeatedLabels.lean new file mode 100644 index 0000000000000000000000000000000000000000..949650a15145817a25a41c8e88fdf6b8916c8604 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RepeatedLabels.lean @@ -0,0 +1,65 @@ +import Mathlib + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.RepeatedLabels +open scoped BigOperators + +def multiplicity {ι κ : Type*} [DecidableEq κ] (s : Finset ι) (label : ι → κ) + (b : κ) : ℕ := (s.filter fun i => label i = b).card + +theorem product_by_multiplicity {ι κ M : Type*} [DecidableEq κ] [Fintype κ] + [CommMonoid M] (s : Finset ι) (label : ι → κ) (p : κ → M) : + (∏ i ∈ s, p (label i)) = ∏ b, p b ^ multiplicity s label b := by + rw [← Finset.prod_fiberwise' s label p] + simp only [multiplicity, Finset.prod_const] + +theorem occurrence_product_by_labels {ι κ M : Type*} [DecidableEq κ] [Fintype κ] + [CommMonoid M] (s : Finset ι) (label : ι → κ) (w : ι → M) : + (∏ i ∈ s, w i) = ∏ b, ∏ i ∈ s with label i = b, w i := + (Finset.prod_fiberwise s label w).symm + +theorem representative_identity {ι : Type*} [DecidableEq ι] (s : Finset ι) + {i₀ : ι} (hi₀ : i₀ ∈ s) (b : ℝ) (μ : ι → ℝ) : + ((∏ i ∈ s, μ i) * b ^ s.card) / (b-1) = + (b/(b-1)) * μ i₀ * ∏ i ∈ s.erase i₀, b * μ i := by + rw [← Finset.prod_const, ← Finset.prod_mul_distrib] + rw [← Finset.mul_prod_erase s (fun i => μ i * b) hi₀] + simp_rw [mul_comm (μ _) b] + ring + +theorem representative_domination {ι : Type*} [DecidableEq ι] (s : Finset ι) + {i₀ : ι} (hi₀ : i₀ ∈ s) {b K : ℝ} (hb : 2 ≤ b) (_hK : 0 ≤ K) + (μ : ι → ℝ) (hμ : ∀ i ∈ s, 0 ≤ μ i) + (hbound : ∀ i ∈ s, b * μ i ≤ K) : + ((∏ i ∈ s, μ i) * b ^ s.card) / (b-1) ≤ + 2 * μ i₀ * K ^ (s.card-1) := by + rw [representative_identity s hi₀] + have hb0 : 0 ≤ b := le_trans (by norm_num) hb + have hratio : b / (b-1) ≤ 2 := (div_le_iff₀ (by linarith)).2 (by linarith) + have hratio0 : 0 ≤ b / (b-1) := div_nonneg hb0 (by linarith) + have hprod0 : 0 ≤ ∏ i ∈ s.erase i₀, b * μ i := + Finset.prod_nonneg fun i hi => mul_nonneg hb0 (hμ i (Finset.mem_of_mem_erase hi)) + have hprod : (∏ i ∈ s.erase i₀, b * μ i) ≤ K ^ (s.card-1) := by + calc + _ ≤ ∏ _i ∈ s.erase i₀, K := Finset.prod_le_prod₀ + (fun i hi => mul_nonneg hb0 (hμ i (Finset.mem_of_mem_erase hi))) + (fun i hi => hbound i (Finset.mem_of_mem_erase hi)) + _ = _ := by simp [Finset.card_erase_of_mem hi₀] + exact mul_le_mul + (mul_le_mul_of_nonneg_right hratio (hμ i₀ hi₀)) hprod hprod0 + (mul_nonneg (by norm_num) (hμ i₀ hi₀)) + +theorem representative_sum {κ : Type*} [Fintype κ] [DecidableEq κ] + (S : κ → Finset ℕ) (μ : κ → ℕ → ℝ) + (hμ : ∀ b, ∑ p ∈ S b, μ b p = 1) : + ∑ x ∈ Fintype.piFinset S, ∏ b, μ b (x b) = 1 := by + rw [← Finset.prod_univ_sum] + simp only [hμ, Finset.prod_const_one] + +end Ostmann.Arithmetic.RepeatedLabels + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueHaar.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueHaar.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4ca859107325c10579a4463852a15360b2ead18 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueHaar.lean @@ -0,0 +1,69 @@ +import Mathlib + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.ResidueHaar +open scoped BigOperators + +def average {α : Type*} [Fintype α] (f : α → ℂ) : ℂ := + (Fintype.card α : ℂ)⁻¹ * ∑ x, f x + +theorem average_equiv {α β : Type*} [Fintype α] [Fintype β] + (e : α ≃ β) (f : β → ℂ) : average (fun x => f (e x)) = average f := by + unfold average + rw [Fintype.card_congr e, e.sum_comp] + +theorem average_product {α β : Type*} [Fintype α] [Fintype β] + (f : α → ℂ) (g : β → ℂ) : + average (fun z : α × β => f z.1 * g z.2) = average f * average g := by + simp only [average, Fintype.card_prod, Nat.cast_mul, mul_inv_rev, + Fintype.sum_prod_type, ← Finset.mul_sum, ← Finset.sum_mul] + ring + +def crtUnits {m n : ℕ} (h : m.Coprime n) : + (ZMod (m*n))ˣ ≃* (ZMod m)ˣ × (ZMod n)ˣ := + (Units.mapEquiv (ZMod.chineseRemainder h).toMulEquiv).trans MulEquiv.prodUnits + +theorem crt_average_product {m n : ℕ} [NeZero m] [NeZero n] + (h : m.Coprime n) (f : (ZMod m)ˣ → ℂ) (g : (ZMod n)ˣ → ℂ) : + average (fun z : (ZMod (m*n))ˣ => + f (crtUnits h z).1 * g (crtUnits h z).2) = average f * average g := by + exact (average_equiv (crtUnits h).toEquiv + (fun z => f z.1 * g z.2)).trans (average_product f g) + +def splitEquiv {G : Type*} [Group G] : G × G ≃ G × G where + toFun z := (z.1*z.2,z.1) + invFun z := (z.2,z.2⁻¹*z.1) + left_inv z := by ext <;> simp + right_inv z := by ext <;> simp + +theorem split_average {G : Type*} [Group G] [Fintype G] + (F : G × G → ℂ) : + average (fun z : G × G => F (z.1*z.2,z.1)) = average F := + average_equiv splitEquiv F + +def fixedProductEquiv {G : Type*} [Group G] (t : G) : + {z : G × G // z.1*z.2=t} ≃ G where + toFun z := z.val.1 + invFun x := ⟨(x,x⁻¹*t), by simp⟩ + left_inv z := by + apply Subtype.ext + apply Prod.ext + · rfl + · dsimp + calc + _ = (z.val.1)⁻¹ * (z.val.1*z.val.2) := + congrArg (fun w => (z.val.1)⁻¹*w) z.property.symm + _ = _ := by simp + right_inv _ := rfl + +theorem fixedProduct_card {G : Type*} [Group G] [Finite G] (t : G) : + Nat.card {z : G × G // z.1*z.2=t} = Nat.card G := + Nat.card_congr (fixedProductEquiv t) + +end Ostmann.Arithmetic.ResidueHaar + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueIntervals.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueIntervals.lean new file mode 100644 index 0000000000000000000000000000000000000000..f602b96c0c8742ec9ca2fcdc87eb1c44c31a5368 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueIntervals.lean @@ -0,0 +1,93 @@ +import OAI.NumberTheory.Ostmann.Construction.GiantDiscreteTransport + +namespace OAI + +/-! # Exact residue decompositions of the original giant sums -/ + +namespace Ostmann +open scoped BigOperators Classical + +def reducedResidues (q : ℕ) : Finset ℕ := (Finset.range q).filter (fun a => a.Coprime q) + +theorem reducedResidues_card_le (q : ℕ) : (reducedResidues q).card ≤ q := by + exact (Finset.card_filter_le _ _).trans_eq (Finset.card_range q) + +theorem prime_mod_mem_reducedResidues (q p : ℕ) (hq : 0 < q) (hp : p.Prime) (hqp : q < p) : + p % q ∈ reducedResidues q := by + refine Finset.mem_filter.mpr ⟨Finset.mem_range.mpr (Nat.mod_lt _ hq), ?_⟩ + have hc : p.Coprime q := hp.coprime_iff_not_dvd.mpr (Nat.not_dvd_of_pos_of_lt hq hqp) + rw [Nat.coprime_iff_gcd_eq_one, ← Nat.gcd_rec] + exact hc.symm + +theorem sum_residue_indicator (q : ℕ) (S : Finset ℕ) (hS : ∀ a ∈ S, a < q) + (p : ℕ) (hp : p % q ∈ S) (z : ℂ) : + (∑ a ∈ S, if Nat.ModEq q p a then z else 0) = z := by + rw [Finset.sum_eq_single (p % q)] + · simp only [Nat.ModEq, Nat.mod_mod, ite_true] + · intro a ha hne + have hnot : ¬ Nat.ModEq q p a := by + intro h + have he : p % q = a := by simpa only [Nat.ModEq, Nat.mod_eq_of_lt (hS a ha)] using h + exact hne he.symm + simp only [hnot, ite_false] + · exact fun hn => (hn hp).elim + +theorem complexPrimeInterval_residues (q : ℕ) (hq : 0 < q) (u v : ℝ) + (hlarge : ∀ p ∈ Finset.Ioc ⌊Real.exp u⌋₊ ⌊Real.exp v⌋₊, p.Prime → q < p) + (f : ℝ → ℂ) : + complexPrimeInterval 1 0 u v f = + ∑ a ∈ reducedResidues q, complexPrimeInterval q a u v f := by + unfold complexPrimeInterval + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro p hp + by_cases hprime : p.Prime + · simp only [hprime, true_and, Nat.modEq_one, ite_true] + exact (sum_residue_indicator q (reducedResidues q) + (fun a ha => Finset.mem_range.mp (Finset.mem_filter.mp ha).1) p + (prime_mod_mem_reducedResidues q p hq hprime (hlarge p hp hprime)) _).symm + · simp only [hprime, false_and, ite_false, Finset.sum_const_zero] + +theorem complexIntegerInterval_residues (q : ℕ) (hq : 0 < q) (u v J : ℝ) (f : ℝ → ℂ) : + complexIntegerInterval 1 0 u v J f = + ∑ a ∈ Finset.range q, complexIntegerInterval q a u v J f := by + unfold complexIntegerInterval integerResidueAtom + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro p _ + simp only [Nat.modEq_one, ite_true, apply_ite, Complex.ofReal_zero, mul_zero] + exact (sum_residue_indicator q (Finset.range q) (fun a ha => Finset.mem_range.mp ha) p + (Finset.mem_range.mpr (Nat.mod_lt _ hq)) _).symm + +theorem complexPrimeInterval_finset_sum {A : Type*} (S : Finset A) + (q a : ℕ) (u v : ℝ) (f : A → ℝ → ℂ) : + complexPrimeInterval q a u v (fun y => ∑ i ∈ S, f i y) = + ∑ i ∈ S, complexPrimeInterval q a u v (f i) := by + unfold complexPrimeInterval + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro p _ + split_ifs <;> simp only [Finset.sum_mul, Finset.sum_const_zero] + +theorem reciprocalPrimeInterval_le_exp (q a : ℕ) (u v : ℝ) : + reciprocalPrimeInterval q a (Real.exp u) (Real.exp v) ≤ Real.exp (v - u) := by + calc + _ ≤ ∑ _p ∈ Finset.Ioc ⌊Real.exp u⌋₊ ⌊Real.exp v⌋₊, Real.exp (-u) := by + apply Finset.sum_le_sum + intro p hp + split_ifs + · have hp0 : (0 : ℝ) < p := (Real.exp_pos u).trans (Nat.lt_of_floor_lt (Finset.mem_Ioc.mp hp).1) + have hlog : Real.exp (-Real.log (p : ℝ)) = (p : ℝ)⁻¹ := by + rw [Real.exp_neg, Real.exp_log hp0] + rw [← hlog] + exact Real.exp_le_exp.mpr (neg_le_neg (log_mem_of_mem_exp_interval hp).1.le) + · exact (Real.exp_pos _).le + _ = ((⌊Real.exp v⌋₊ - ⌊Real.exp u⌋₊ : ℕ) : ℝ) * Real.exp (-u) := by simp + _ ≤ Real.exp v * Real.exp (-u) := by + apply mul_le_mul_of_nonneg_right _ (Real.exp_pos _).le + exact (Nat.cast_le.mpr (Nat.sub_le _ _)).trans (Nat.floor_le (Real.exp_pos _).le) + _ = _ := by rw [← Real.exp_add, sub_eq_add_neg] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResiduePopulationCount.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResiduePopulationCount.lean new file mode 100644 index 0000000000000000000000000000000000000000..14e242d7f59c03e0e3ea400fdde0368889185903 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResiduePopulationCount.lean @@ -0,0 +1,62 @@ +import Mathlib.Data.Finset.Max +import Mathlib.Data.ZMod.Basic +import Mathlib.Data.Nat.Dist +import OAI.NumberTheory.Ostmann.Construction.IntegerIntervalDistribution + +namespace OAI + +/-! # Counting bounded populations in their occupied residue classes -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem nat_progression_population_card_le (S : Finset ℕ) (q D : ℕ) (hq : 0 < q) + (hdiam : ∀ a ∈ S, ∀ b ∈ S, Nat.dist a b ≤ D) + (hcongr : ∀ a ∈ S, ∀ b ∈ S, a ≡ b [MOD q]) : + (S.card : ℝ) ≤ (D : ℝ) / q + 2 := by + by_cases hS : S.Nonempty + · let a := S.min' hS + have ha : a ∈ S := Finset.min'_mem _ _ + have hsub : S.erase a ⊆ (Finset.Ioc a (a + D)).filter (fun n => n ≡ a [MOD q]) := by + intro b hb + obtain ⟨hne, hbS⟩ := Finset.mem_erase.mp hb + have hab : a ≤ b := Finset.min'_le S b hbS + have hd := hdiam a ha b hbS + rw [Nat.dist_eq_sub_of_le hab] at hd + exact Finset.mem_filter.mpr ⟨Finset.mem_Ioc.mpr ⟨by omega, by omega⟩, hcongr b hbS a ha⟩ + have hc : ((S.erase a).card : ℝ) ≤ + (((Finset.Ioc a (a + D)).filter (fun n => n ≡ a [MOD q])).card : ℝ) := by + exact_mod_cast Finset.card_le_card hsub + have he := (abs_le.mp (integer_interval_residue_error a (a + D) q a (by omega) hq)).2 + have hcard : (S.card : ℝ) = ((S.erase a).card : ℝ) + 1 := by + exact_mod_cast (Finset.card_erase_add_one ha).symm + rw [Nat.cast_add, add_sub_cancel_left] at he + linarith + · rw [Finset.not_nonempty_iff_eq_empty.mp hS] + simp only [Finset.card_empty, Nat.cast_zero] + positivity + +theorem nat_residue_population_card_le (S : Finset ℕ) (q D : ℕ) (hq : 0 < q) + (hdiam : ∀ a ∈ S, ∀ b ∈ S, Nat.dist a b ≤ D) : + (S.card : ℝ) ≤ ((S.image (fun n : ℕ => (n : ZMod q))).card : ℝ) * ((D : ℝ) / q + 2) := by + let R := S.image (fun n : ℕ => (n : ZMod q)) + have hf (r : ZMod q) : ((S.filter fun n : ℕ => (n : ZMod q) = r).card : ℝ) ≤ (D : ℝ) / q + 2 := by + apply nat_progression_population_card_le _ q D hq + · intro a ha b hb + exact hdiam a (Finset.mem_filter.mp ha).1 b (Finset.mem_filter.mp hb).1 + · intro a ha b hb + exact (ZMod.natCast_eq_natCast_iff a b q).mp + ((Finset.mem_filter.mp ha).2.trans (Finset.mem_filter.mp hb).2.symm) + have heq := Finset.card_eq_sum_card_image (fun n : ℕ => (n : ZMod q)) S + calc + (S.card : ℝ) = ∑ r ∈ R, ((S.filter fun n : ℕ => (n : ZMod q) = r).card : ℝ) := by + exact_mod_cast heq + _ ≤ ∑ _r ∈ R, ((D : ℝ) / q + 2) := Finset.sum_le_sum fun r _ => hf r + _ = _ := by + simp only [Finset.sum_const, nsmul_eq_mul] + rfl + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueProductSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueProductSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..1a7869975b90ef72ed9c9b0d105b105aced2c9c6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueProductSupport.lean @@ -0,0 +1,82 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticProductSupport +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticResidueReversal + +namespace OAI + +/-! # The independent bulk support bound for concrete residue numerators -/ + +namespace Ostmann + +open scoped BigOperators Classical +open Filter + +theorem sequentialSupport_congr {A : Type} (test₁ test₂ : List A → A → Prop) + (h : ∀ past x, test₁ past x ↔ test₂ past x) (past : List A) + (n : ℕ) (x : SplitSamples A n) : + sequentialSupport test₁ past n x = sequentialSupport test₂ past n x := by + induction n generalizing past with + | zero => rfl + | succ n ih => + change (if test₁ past x.1 then sequentialSupport test₁ (x.1 :: past) n x.2 else 0) = + (if test₂ past x.1 then sequentialSupport test₂ (x.1 :: past) n x.2 else 0) + rw [propext (h past x.1)] + split_ifs + · exact ih _ _ + · rfl + +noncomputable def residueProductSupportSum {Q : ℕ} [NeZero Q] + (S : Finset ℤ) (V n : ℕ) + (data : FrequencyTree (S × S) n → (ZMod Q)ˣ → List (ZMod Q)ˣ → + ArithmeticResidueSplit Q × ArithmeticResidueSplit Q) : ℝ := + ∑ t : FrequencyTree (S × S) n, + frequencyLeafWeight (pairedFrequencyLeaf S V) n t * + ((Fintype.card (TreeLeafTuple (ZMod Q)ˣ n) : ℝ)⁻¹ * + ∑ x : TreeLeafTuple (ZMod Q)ˣ n, + sequentialSupport + (fun past y => (data t (treeLeafProduct n x) past).1.support y ∧ + (data t (treeLeafProduct n x) past).2.support y) [] + (2 ^ n - 1) (treeLeafSplitEquiv n (treeLeafProduct n x) ⟨x, rfl⟩)) + +theorem residueProductSupportSum_eq {Q : ℕ} [NeZero Q] + (S : Finset ℤ) (V n : ℕ) + (data : FrequencyTree (S × S) n → (ZMod Q)ˣ → List (ZMod Q)ˣ → + ArithmeticResidueSplit Q × ArithmeticResidueSplit Q) : + residueProductSupportSum S V n data = arithmeticProductSupportSum S V n + (fun t P past => arithmeticResiduePairData (data t P past).1 (data t P past).2) := by + unfold residueProductSupportSum arithmeticProductSupportSum + apply Finset.sum_congr rfl + intro t _ + congr 1 + congr 1 + apply Finset.sum_congr rfl + intro x _ + apply sequentialSupport_congr + intro past y + exact (arithmeticResiduePairData_test _ _ y).symm + +theorem residue_product_support_rate {Q : ℕ} [NeZero Q] + (n : ℕ) (K C ε : ℝ) (hC : 0 ≤ C) (hε : 0 < ε) : + ∀ᶠ m : ℝ in atTop, ∀ N V : ℕ, ∀ Δ : ℝ, ∀ S : Finset ℤ, + (N : ℝ) ≤ Real.exp (C * m) → + (V : ℝ) ≤ Real.exp (Δ + Real.sqrt m) → + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) → + ∀ data : FrequencyTree (S × S) n → (ZMod Q)ˣ → List (ZMod Q)ˣ → + ArithmeticResidueSplit Q × ArithmeticResidueSplit Q, + (∀ t P past, (data t P past).1.frequencies = + (treeNodeFrequencies S n t past.length).1 ∧ + (data t P past).2.frequencies = (treeNodeFrequencies S n t past.length).2) → + Real.exp (-(2 ^ n : ℕ) * Δ + K) * residueProductSupportSum S V n data ≤ + Real.exp ((2 ^ n : ℕ) * Δ + ε * m) := by + filter_upwards [arithmetic_product_support_rate (Q := Q) n K C ε hC hε] with m hm + intro N V Δ S hN hV hS data hmatch + rw [residueProductSupportSum_eq] + apply hm N V Δ S hN hV hS + intro t P past d e h + have hd := arithmeticResiduePairData_frequencies _ _ d e h + rw [(hmatch t P past).1] at hd + rw [(hmatch t P past).2] at hd + exact hd + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueQuotient.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueQuotient.lean new file mode 100644 index 0000000000000000000000000000000000000000..bf6035cf425d4c97211cdcb5e138bb694ad9f92f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ResidueQuotient.lean @@ -0,0 +1,76 @@ +import Mathlib.Data.ZMod.Basic +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticPrecision + +namespace OAI + +/-! # Division by a signed frequency with an explicit loss of precision + +The quotient is an actual function on residue classes. It agrees with +integer division whenever the frequency divides the represented integer. +-/ + +namespace Ostmann + +theorem modEq_divide_signed {s a b : ℤ} (M : ℕ) (hs : s ≠ 0) + (ha : s ∣ a) (hb : s ∣ b) + (h : a ≡ b [ZMOD (s.natAbs * M : ℕ)]) : + a / s ≡ b / s [ZMOD M] := by + apply Int.modEq_iff_dvd.mpr + apply Int.dvd_of_mul_dvd_mul_left hs + rw [mul_sub, Int.mul_ediv_cancel' hb, Int.mul_ediv_cancel' ha] + apply dvd_trans _ h.dvd + have hsabs : s ∣ (s.natAbs : ℤ) := Int.dvd_natCast.mpr (dvd_refl _) + simpa only [Nat.cast_mul] using mul_dvd_mul_right hsabs (M : ℤ) + +noncomputable def residueQuotient (s : ℤ) (M : ℕ) + (x : ZMod (s.natAbs * M)) : ZMod M := + ((x.val : ℤ) / s : ℤ) + +theorem residueQuotient_intCast (s : ℤ) (M : ℕ) [NeZero M] + (hs : s ≠ 0) (a : ℤ) (ha : s ∣ a) : + residueQuotient s M (a : ZMod (s.natAbs * M)) = (a / s : ℤ) := by + have : NeZero (s.natAbs * M) := + ⟨mul_ne_zero (Int.natAbs_ne_zero.mpr hs) (NeZero.ne M)⟩ + have hmod : ((a : ZMod (s.natAbs * M)).val : ℤ) ≡ a + [ZMOD (s.natAbs * M : ℕ)] := by + apply (ZMod.intCast_eq_intCast_iff _ _ _).mp + simp only [Int.cast_natCast, ZMod.natCast_zmod_val] + have hval : s ∣ ((a : ZMod (s.natAbs * M)).val : ℤ) := by + have hsabs : s ∣ (s.natAbs : ℤ) := Int.dvd_natCast.mpr (dvd_refl _) + have hdiv : s ∣ a - ((a : ZMod (s.natAbs * M)).val : ℤ) := + dvd_trans (dvd_mul_of_dvd_left hsabs (M : ℤ)) hmod.dvd + simpa only [sub_sub_cancel] using dvd_sub ha hdiv + exact (ZMod.intCast_eq_intCast_iff _ _ _).mpr + (modEq_divide_signed M hs hval ha hmod) + +noncomputable def frequencyQuotient (R M : ℕ) (s : ℤ) + (hsR : s.natAbs ∣ R) (x : ZMod (R * M)) : ZMod M := + residueQuotient s M + (ZMod.castHom (Nat.mul_dvd_mul hsR (dvd_refl M)) _ x) + +theorem frequencyQuotient_intCast (R M : ℕ) [NeZero M] (s : ℤ) + (hs : s ≠ 0) (hsR : s.natAbs ∣ R) (a : ℤ) (ha : s ∣ a) : + frequencyQuotient R M s hsR (a : ZMod (R * M)) = (a / s : ℤ) := by + rw [frequencyQuotient, map_intCast] + exact residueQuotient_intCast s M hs a ha + +/-- The extra compensation factor is a unit, so it costs no further +precision after the signed frequency has been divided out. -/ +theorem frequencyQuotient_reversal (R M : ℕ) [NeZero M] (s : ℤ) + (hs : s ≠ 0) (hsR : s.natAbs ∣ R) (u p : ℤ) + (U : (ZMod M)ˣ) (hU : (U : ZMod M) = u) : + frequencyQuotient R M s hsR (s * u * p : ZMod (R * M)) * ↑U⁻¹ = p := by + have h := frequencyQuotient_intCast R M s hs hsR (s * u * p) + (dvd_mul_of_dvd_left (dvd_mul_right s u) p) + have hdiv : (s * u * p) / s = u * p := by + rw [Int.mul_assoc, Int.mul_ediv_cancel_left _ hs] + rw [hdiv] at h + simp only [Int.cast_mul] at h + rw [h, ← hU] + calc + (U : ZMod M) * p * ↑U⁻¹ = (p : ZMod M) * ((U : ZMod M) * ↑U⁻¹) := by ring + _ = p := by rw [U.mul_inv, mul_one] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RestoredBulkSignedBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RestoredBulkSignedBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..7caf6e6fcf7a687bc2a3626ca967793db513fda6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RestoredBulkSignedBound.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.RestoredPrimeCellExpansion +import OAI.NumberTheory.Ostmann.Arithmetic.BulkWeightedCellComparison + +namespace OAI + +/-! # Return the signed bulk integral estimate to the original prime atoms -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators + +theorem restored_bulk_prime_bound {J C : Type*} [Fintype J] [Fintype C] + (P : Finset ℕ) (M : ℕ) [NeZero M] (u v : J → C → ℝ) + (hu : ∀ j c, 0 < u j c) (c₀ : C × (ZMod M)ˣ) + (hP : ∀ j, primeCellSupport M (fun c : C × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ P) + (hsep : ∀ j (c d : C × (ZMod M)ˣ), c ≠ d → + ¬Nat.ModEq M c.2.val.val d.2.val.val ∨ v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (D : J → Finset ℕ) + (hD : ∀ j, (∑ p ∈ primeCellSupport M (fun c : C × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ D j, (p : ℝ)⁻¹) ≠ 0) + (K : BulkIntegrand J) (a : (J → (ZMod M)ˣ) → ℂ) + (input : PublishedProgressionInput) (Q : ℕ) (err : (J → C) → (J → (ZMod M)ˣ) → ℝ) + (herror : ∀ c z, + ‖(∫ y, K y ∂Measure.pi (fun j => primeLogCellMeasure M (z j).val.val (u j (c j)) (v j (c j)))) - + ∫ y, K y ∂Measure.pi (fun j => primeGiantMeasure input Q M + (z j).val.val (u j (c j)) (v j (c j)))‖ ≤ err c z) + (B : ℝ) : + let S := fun j => primeCellSupport M (fun c : C × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ p ∈ S j \ D j, (p : ℝ)⁻¹)⁻¹ + let label := fun (x : J → P) j => primeCellLabel M + (fun c : C × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) c₀ (x j) + ‖∑ z, ∫ y, (K.constMul (a z)) y ∂Measure.pi (fun j => bulkCellMixture (Z j) + (fun c => primeGiantMeasure input Q M (z j).val.val (u j c) (v j c)))‖ ≤ B → + ‖∑ x : J → P, + ((∏ j, (if (x j : ℕ) ∈ S j then Z j * (x j : ℝ)⁻¹ else 0) : ℝ) : ℂ) * + (a (fun j => (label x j).2) * K (fun j => Real.log (x j : ℕ)))‖ ≤ + B + (∏ j, Z j) * ∑ c : J → C, ∑ z, ‖a z‖ * err c z := by + dsimp only + intro hmain + let S := fun j => primeCellSupport M (fun c : C × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ p ∈ S j \ D j, (p : ℝ)⁻¹)⁻¹ + have hZ (j : J) : 0 ≤ Z j := by dsimp only [Z]; positivity + let μ := fun (c : J → C) (z : J → (ZMod M)ˣ) j => + primeLogCellMeasure M (z j).val.val (u j (c j)) (v j (c j)) + let ν := fun (c : J → C) (z : J → (ZMod M)ˣ) j => + primeGiantMeasure input Q M (z j).val.val (u j (c j)) (v j (c j)) + let _ : ∀ c z j, IsFiniteMeasure (ν c z j) := fun c z j => + finite_primeGiantMeasure input Q M (z j).val.val _ _ (hu j (c j)) + let _ : ∀ (z : J → (ZMod M)ˣ) j c, + IsFiniteMeasure (primeGiantMeasure input Q M (z j).val.val (u j c) (v j c)) := + fun z j c => finite_primeGiantMeasure input Q M (z j).val.val _ _ (hu j c) + have hm := bulk_residue_mixture_integral Z hZ + (fun z j c => primeGiantMeasure input Q M (z j).val.val (u j c) (v j c)) + (fun z => K.constMul (a z)) + rw [hm] at hmain + have he := restored_bulk_residue_expansion P M u v c₀ hP hsep D hD + (fun _ z => K.constMul (a z)) + exact (congrArg norm he).symm.trans_le + (bulk_weighted_cell_bound K a Z hZ μ ν err herror B hmain) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RestoredHarmonicCells.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RestoredHarmonicCells.lean new file mode 100644 index 0000000000000000000000000000000000000000..8d9160cc47fa5c340bbf0679721de4d6c013ed90 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RestoredHarmonicCells.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Construction.HarmonicBoxMass + +namespace OAI + +/-! # Restoring exceptional prime atoms with the original normalization -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators + +theorem primeSubsetLogMeasure_restored_mass (S D : Finset ℕ) + (hS : (∑ p ∈ S \ D, (p : ℝ)⁻¹) ≠ 0) : + (primeSubsetLogMeasure S (∑ p ∈ S \ D, (p : ℝ)⁻¹)⁻¹).real Set.univ = + 1 + (∑ p ∈ S \ D, (p : ℝ)⁻¹)⁻¹ * ∑ p ∈ S ∩ D, (p : ℝ)⁻¹ := by + rw [primeSubsetLogMeasure_mass S _ (by positivity)] + have hs := Finset.sum_inter_add_sum_sdiff S D (fun p : ℕ => (p : ℝ)⁻¹) + rw [← hs, mul_add, inv_mul_cancel₀ hS, add_comm] + +/-- The modulus-one comparison gives the exact error in replacing all +harmonic prime atoms by the real harmonic masses of the cells. -/ +theorem PublishedProgressionInput.harmonic_cells_mass_error + (P : PublishedProgressionInput) {C : Type*} [Fintype C] + (Q : ℕ) (hQ : 2 ≤ Q) (u v : C → ℝ) + (hu : ∀ c, 1 ≤ u c) (huv : ∀ c, u c ≤ v c) (hshort : ∀ c, v c ≤ u c + 1) + (Z : ℝ) (hZ : 0 ≤ Z) : + |(bulkCellMixture Z (fun c => primeLogCellMeasure 1 0 (u c) (v c))).real Set.univ - + Z * ∑ c, ∫ x in Set.Ioc (u c) (v c), (x : ℝ)⁻¹| ≤ + Z * ∑ c, bulkPrimeErrorFactor P Q (u c) := by + let μ := fun c => primeLogCellMeasure 1 0 (u c) (v c) + let ν := fun c => primeGiantMeasure P Q 1 0 (u c) (v c) + let _ : ∀ c, IsFiniteMeasure (ν c) := fun c => + finite_primeGiantMeasure P Q 1 0 (u c) (v c) (lt_of_lt_of_le zero_lt_one (hu c)) + have h := (bulkConstant (σ := Unit) 1).cellMixture_comparison Z hZ μ ν () + (fun c => bulkPrimeErrorFactor P Q (u c)) (fun c _ => by + rw [bulkConstant_average_one, bulkConstant_average_one, ← Complex.ofReal_sub, + Complex.norm_real, Real.norm_eq_abs] + exact primeLogCell_page_mass_error P hQ (by norm_num) (by omega) (by simp) + (u c) (v c) (hu c) (huv c) (hshort c)) (fun _ => 0) + rw [bulkConstant_average_one, bulkConstant_average_one, ← Complex.ofReal_sub, + Complex.norm_real, Real.norm_eq_abs] at h + rw [bulkCellMixture_mass Z hZ ν] at h + simpa only [ν, primeGiantMeasure_one_mass P Q 0 _ _ (lt_of_lt_of_le zero_lt_one (hu _))] using h + +/-- Small exceptional deletions and the interval error share the same unit +error budget, while the normalization remains that of the deleted prime set. -/ +theorem PublishedProgressionInput.restored_harmonic_cells_le_two + (P : PublishedProgressionInput) {C : Type*} [Fintype C] + (Q : ℕ) (hQ : 2 ≤ Q) (u v : C → ℝ) + (hu : ∀ c, 1 ≤ u c) (huv : ∀ c, u c ≤ v c) (hshort : ∀ c, v c ≤ u c + 1) + (hsep : ∀ c d, c ≠ d → v c ≤ u d ∨ v d ≤ u c) + (D : Finset ℕ) + (hS : (∑ p ∈ primeCellSupport 1 (fun _ => 0) u v \ D, (p : ℝ)⁻¹) ≠ 0) + (herror : + (∑ p ∈ primeCellSupport 1 (fun _ => 0) u v \ D, (p : ℝ)⁻¹)⁻¹ * + ((∑ p ∈ primeCellSupport 1 (fun _ => 0) u v ∩ D, (p : ℝ)⁻¹) + + ∑ c, bulkPrimeErrorFactor P Q (u c)) ≤ 1) : + (∑ p ∈ primeCellSupport 1 (fun _ => 0) u v \ D, (p : ℝ)⁻¹)⁻¹ * + ∑ c, ∫ x in Set.Ioc (u c) (v c), (x : ℝ)⁻¹ ≤ 2 := by + let S := primeCellSupport 1 (fun _ : C => 0) u v + let Z := (∑ p ∈ S \ D, (p : ℝ)⁻¹)⁻¹ + have hz : 0 ≤ Z := by positivity + have he := P.harmonic_cells_mass_error Q hQ u v hu huv hshort Z hz + have hm := primeSubsetLogMeasure_restored_mass S D hS + have hsep' : ∀ c d, c ≠ d → ¬Nat.ModEq 1 (0 : ℕ) 0 ∨ v c ≤ u d ∨ v d ≤ u c := + fun c d hcd => Or.inr (hsep c d hcd) + change (primeSubsetLogMeasure (primeCellSupport 1 (fun _ : C => 0) u v) Z).real Set.univ = + 1 + Z * ∑ p ∈ S ∩ D, (p : ℝ)⁻¹ at hm + rw [primeSubsetLogMeasure_cells 1 (fun _ : C => 0) u v Z hsep'] at hm + rw [hm] at he + have hlow := (abs_le.mp he).1 + change Z * ((∑ p ∈ S ∩ D, (p : ℝ)⁻¹) + ∑ c, bulkPrimeErrorFactor P Q (u c)) ≤ 1 at herror + change Z * ∑ c, ∫ x in Set.Ioc (u c) (v c), (x : ℝ)⁻¹ ≤ 2 + rw [mul_add] at herror + linarith + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RestoredPrimeCellExpansion.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RestoredPrimeCellExpansion.lean new file mode 100644 index 0000000000000000000000000000000000000000..b72605230ee82202de8a15d09523b8ee49b23aaf --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RestoredPrimeCellExpansion.lean @@ -0,0 +1,107 @@ +import OAI.NumberTheory.Ostmann.Construction.OriginalPrimeCellExpansion +import OAI.NumberTheory.Ostmann.Arithmetic.RestoredHarmonicCells +import OAI.NumberTheory.Ostmann.Construction.OriginalBulkResidues + +namespace OAI + +/-! # Keep the deleted-set normalization in the original cell expansion -/ + +namespace Ostmann +open MeasureTheory +open scoped Classical BigOperators + +theorem harmonic_mass_ne_zero_of_sdiff (S D : Finset ℕ) + (h : (∑ p ∈ S \ D, (p : ℝ)⁻¹) ≠ 0) : (∑ p ∈ S, (p : ℝ)⁻¹) ≠ 0 := by + have hp : 0 < ∑ p ∈ S \ D, (p : ℝ)⁻¹ := + lt_of_le_of_ne (Finset.sum_nonneg fun p _ => by positivity) (Ne.symm h) + exact ne_of_gt (hp.trans_le (Finset.sum_le_sum_of_subset_of_nonneg Finset.sdiff_subset + (fun p _ _ => by positivity))) + +/-- Restoring a prime atom multiplies the full-set normalized prior by +exactly the ratio of its harmonic masses, not by a new probability law. -/ +theorem restored_prime_prior_atom (P S D : Finset ℕ) + (h : (∑ p ∈ S \ D, (p : ℝ)⁻¹) ≠ 0) (p : P) : + ((∑ t ∈ S \ D, (t : ℝ)⁻¹)⁻¹ * ∑ t ∈ S, (t : ℝ)⁻¹) * primeSubsetPrior P S p = + if (p : ℕ) ∈ S then (∑ t ∈ S \ D, (t : ℝ)⁻¹)⁻¹ * (p : ℝ)⁻¹ else 0 := by + unfold primeSubsetPrior + by_cases hp : (p : ℕ) ∈ S + · rw [ite_eq_left hp, ite_eq_left hp, div_eq_mul_inv] + have hs := harmonic_mass_ne_zero_of_sdiff S D h + calc + _ = (∑ t ∈ S \ D, (t : ℝ)⁻¹)⁻¹ * (p : ℝ)⁻¹ * + ((∑ t ∈ S, (t : ℝ)⁻¹) * (∑ t ∈ S, (t : ℝ)⁻¹)⁻¹) := by ring + _ = _ := by rw [mul_inv_cancel₀ hs, mul_one] + · simp [hp] + +theorem restored_prime_cell_expansion {J C : Type*} [Fintype J] [Fintype C] + (P : Finset ℕ) (q : J → ℕ) (a : J → C → ℕ) (u v : J → C → ℝ) (c₀ : C) + (hP : ∀ j, primeCellSupport (q j) (a j) (u j) (v j) ⊆ P) + (hsep : ∀ j c d, c ≠ d → + ¬Nat.ModEq (q j) (a j c) (a j d) ∨ v j c ≤ u j d ∨ v j d ≤ u j c) + (D : J → Finset ℕ) + (hD : ∀ j, (∑ p ∈ primeCellSupport (q j) (a j) (u j) (v j) \ D j, (p : ℝ)⁻¹) ≠ 0) + (f : (J → C) → BulkIntegrand J) : + let S := fun j => primeCellSupport (q j) (a j) (u j) (v j) + let Z := fun j => (∑ p ∈ S j \ D j, (p : ℝ)⁻¹)⁻¹ + ((∏ j, Z j : ℝ) : ℂ) * ∑ c : J → C, + ∫ y, f c y ∂Measure.pi (fun j => primeLogCellMeasure (q j) (a j (c j)) (u j (c j)) (v j (c j))) = + ∑ x : J → P, + ((∏ j, (if (x j : ℕ) ∈ S j then Z j * (x j : ℝ)⁻¹ else 0) : ℝ) : ℂ) * + f (fun j => primeCellLabel (q j) (a j) (u j) (v j) c₀ (x j)) (fun j => Real.log (x j : ℕ)) := by + let S := fun j => primeCellSupport (q j) (a j) (u j) (v j) + let T := fun j => ∑ p ∈ S j, (p : ℝ)⁻¹ + let Z := fun j => (∑ p ∈ S j \ D j, (p : ℝ)⁻¹)⁻¹ + let R := ∏ j, Z j * T j + have ht (j : J) : T j ≠ 0 := harmonic_mass_ne_zero_of_sdiff (S j) (D j) (hD j) + have hc : R * (∏ j, (T j)⁻¹) = ∏ j, Z j := by + rw [← Finset.prod_mul_distrib] + apply Finset.prod_congr rfl + intro j _ + rw [mul_assoc, mul_inv_cancel₀ (ht j), mul_one] + have h := congrArg ((R : ℂ) * ·) (original_prime_cell_expansion P q a u v c₀ hP hsep f) + rw [← mul_assoc, ← Complex.ofReal_mul] at h + change ((R * ∏ j, (T j)⁻¹ : ℝ) : ℂ) * _ = _ at h + rw [hc] at h + conv_rhs at h => rw [Finset.mul_sum] + refine h.trans ?_ + apply Finset.sum_congr rfl + intro x _ + rw [← mul_assoc, ← Complex.ofReal_mul, ← Finset.prod_mul_distrib] + congr 2 + apply Finset.prod_congr rfl + intro j _ + exact restored_prime_prior_atom P (S j) (D j) (hD j) (x j) + +/-- Restored atoms retain both their actual residue labels and the original +deleted-set normalizer. -/ +theorem restored_bulk_residue_expansion {J C : Type*} [Fintype J] [Fintype C] + (P : Finset ℕ) (M : ℕ) [NeZero M] (u v : J → C → ℝ) + (c₀ : C × (ZMod M)ˣ) + (hP : ∀ j, primeCellSupport M (fun c : C × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) ⊆ P) + (hsep : ∀ j (c d : C × (ZMod M)ˣ), c ≠ d → + ¬Nat.ModEq M c.2.val.val d.2.val.val ∨ v j c.1 ≤ u j d.1 ∨ v j d.1 ≤ u j c.1) + (D : J → Finset ℕ) + (hD : ∀ j, (∑ p ∈ primeCellSupport M (fun c : C × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) \ D j, (p : ℝ)⁻¹) ≠ 0) + (f : (J → C) → (J → (ZMod M)ˣ) → BulkIntegrand J) : + let S := fun j => primeCellSupport M (fun c : C × (ZMod M)ˣ => c.2.val.val) + (fun c => u j c.1) (fun c => v j c.1) + let Z := fun j => (∑ p ∈ S j \ D j, (p : ℝ)⁻¹)⁻¹ + let label := fun (x : J → P) j => primeCellLabel M + (fun c : C × (ZMod M)ˣ => c.2.val.val) (fun c => u j c.1) (fun c => v j c.1) c₀ (x j) + ((∏ j, Z j : ℝ) : ℂ) * ∑ c : J → C, ∑ z : J → (ZMod M)ˣ, + ∫ y, f c z y ∂Measure.pi (fun j => primeLogCellMeasure M (z j).val.val (u j (c j)) (v j (c j))) = + ∑ x : J → P, + ((∏ j, (if (x j : ℕ) ∈ S j then Z j * (x j : ℝ)⁻¹ else 0) : ℝ) : ℂ) * + f (fun j => (label x j).1) (fun j => (label x j).2) (fun j => Real.log (x j : ℕ)) := by + have h := restored_prime_cell_expansion P (fun _ : J => M) + (fun _ (c : C × (ZMod M)ˣ) => c.2.val.val) + (fun j c => u j c.1) (fun j c => v j c.1) c₀ hP hsep D hD + (fun a => f (fun j => (a j).1) (fun j => (a j).2)) + rw [sum_joint_cells_residues] at h + exact h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReversalCoprimality.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReversalCoprimality.lean new file mode 100644 index 0000000000000000000000000000000000000000..b6a2e8712b02f6c18b375165226c8d6c4f04c243 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ReversalCoprimality.lean @@ -0,0 +1,59 @@ +import Mathlib + +namespace OAI + +namespace Ostmann.Arithmetic + +def reversalNumerator {R : Type*} [CommRing R] (v w Hplus Hminus : R) : R := + v * Hminus - w * Hplus + +theorem reversalNumerator_coprime {R : Type*} [CommRing R] + {v w Hplus Hminus : R} (hH : IsCoprime Hplus Hminus) + (hv : IsCoprime v Hplus) (hw : IsCoprime w Hminus) : + IsCoprime (reversalNumerator v w Hplus Hminus) Hplus ∧ + IsCoprime (reversalNumerator v w Hplus Hminus) Hminus := by + constructor + · simpa only [reversalNumerator, IsCoprime.sub_mul_right_left_iff] using hv.mul_left hH.symm + · simpa only [reversalNumerator, IsCoprime.mul_sub_right_left_iff] using hw.mul_left hH + +theorem integral_reversal_inherited_coprime {R : Type*} [CommRing R] + {v w Hplus Hminus s u p a : R} + (hH : IsCoprime Hplus Hminus) (hv : IsCoprime v Hplus) + (hw : IsCoprime w Hminus) + (heq : reversalNumerator v w Hplus Hminus = s * u * p) + (ha : a ∣ Hplus ∨ a ∣ Hminus) : IsCoprime p a ∧ IsCoprime u a := by + have hN : IsCoprime (reversalNumerator v w Hplus Hminus) a := by + obtain ⟨hplus,hminus⟩ := reversalNumerator_coprime hH hv hw + exact ha.elim (fun h => hplus.of_isCoprime_of_dvd_right h) + (fun h => hminus.of_isCoprime_of_dvd_right h) + rw [heq] at hN + exact ⟨hN.of_mul_left_right, hN.of_mul_left_left.of_mul_left_right⟩ + +theorem integral_reversal_iff {R : Type*} [CommRing R] {s u N : R} + (h : IsCoprime s u) : (∃ p, N = s * u * p) ↔ s ∣ N ∧ u ∣ N := by + constructor + · rintro ⟨p,rfl⟩ + exact ⟨⟨u*p, by ring⟩, ⟨s*p, by ring⟩⟩ + · rintro ⟨hs,hu⟩ + exact h.mul_dvd hs hu + +theorem prime_square_test {b N s u p : ℤ} (hb : Prime b) + (hbs : ¬ b ∣ s) (hbu : b ∣ u) (hbu2 : ¬ b*b ∣ u) + (hN : N = s*u*p) : (¬ b*b ∣ N) ↔ ¬ b ∣ p := by + obtain ⟨u', hu'⟩ := hbu + have hbu' : ¬ b ∣ u' := by + intro h + obtain ⟨z,rfl⟩ := h + apply hbu2 + refine ⟨z, ?_⟩ + rw [hu'] + ring + have hb0 : b ≠ 0 := hb.ne_zero + rw [hN, hu'] + have heq : s * (b*u') * p = b * (s*u'*p) := by ring + rw [heq, mul_dvd_mul_iff_left hb0] + simp only [hb.dvd_mul, hbs, hbu', false_or] + +end Ostmann.Arithmetic + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootCellErrorRates.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootCellErrorRates.lean new file mode 100644 index 0000000000000000000000000000000000000000..043a155b86d261862d584d0abdf0840f3d676c37 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootCellErrorRates.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.ZeroDensity.WeightedProgressionRates +import OAI.NumberTheory.Ostmann.Arithmetic.RootCellPrimeComparison + +namespace OAI + +/-! # The complete root-cell error retains a double-exponential saving -/ + +namespace Ostmann +open Filter +open scoped BigOperators +open MeasureTheory + +theorem weighted_giant_atom_rate (C : ℝ) (d : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ u B : ℝ, + Real.exp ((49 / 1000 : ℝ) * L) ≤ u → + B ≤ Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + B * Real.exp (-u) ≤ Real.exp (-Real.exp ((13 / 1000 : ℝ) * L)) := by + filter_upwards [arithmetic_error_absorption (12 / 1000) (49 / 1000) (13 / 1000) C 1 d + (by norm_num) (by norm_num) (by norm_num) (by norm_num)] with L hL + intro u B hu hB + calc + _ ≤ Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) * Real.exp (-u) := + mul_le_mul_of_nonneg_right hB (Real.exp_pos _).le + _ ≤ Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) * + Real.exp (-Real.exp ((49 / 1000 : ℝ) * L)) := + mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr (neg_le_neg hu)) (Real.exp_pos _).le + _ ≤ _ := by simpa only [one_mul, neg_mul] using hL + +/-- The number of root cells is fixed before X grows. This estimate includes +both the weighted progression error and all retained endpoint-prime atoms. -/ +theorem PublishedProgressionInput.root_cell_error_rate (P : PublishedProgressionInput) + (C : ℝ) (d K : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ Q : ℕ, 2 ≤ Q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ N : ℕ, N ≤ K → ∀ s V B : ℕ → ℝ, + (∀ j < N, Real.exp ((49 / 1000 : ℝ) * L) ≤ s j) → + (∀ j < N, V j ≤ Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + (∀ j < N, B j ≤ Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L))) → + (∑ j ∈ Finset.range N, + (V j * (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ)))) + B j * Real.exp (-(s j)))) ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [P.weighted_giant_budget_rate C d, weighted_giant_atom_rate C d, + constant_mul_double_exp_le (2 * (K : ℝ)) 1 (13 / 1000) (125 / 10000) + (by positivity) (by norm_num) (by norm_num) (by norm_num)] with L hP hA hK + intro Q hQ hlog N hNK s V B hs hV hB + calc + _ ≤ ∑ _j ∈ Finset.range N, 2 * Real.exp (-Real.exp ((13 / 1000 : ℝ) * L)) := by + apply Finset.sum_le_sum + intro j hj + have hjN := Finset.mem_range.mp hj + linarith [hP Q hQ hlog (s j) (V j) (hs j hjN) (hV j hjN), + hA (s j) (B j) (hs j hjN) (hB j hjN)] + _ = 2 * (N : ℝ) * Real.exp (-Real.exp ((13 / 1000 : ℝ) * L)) := by simp; ring + _ ≤ 2 * (K : ℝ) * Real.exp (-Real.exp ((13 / 1000 : ℝ) * L)) := by + gcongr + _ ≤ _ := by simpa only [one_mul, neg_mul] using hK + +/-- The complete smooth root-cell comparison, uniformly for every bounded +multiplier and every polynomial family within the stated numerical budget. -/ +theorem PublishedProgressionInput.root_cell_prime_rate (P : PublishedProgressionInput) + (C : ℝ) (d K k : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ Q q a : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → a.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v : ℝ, Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + ∀ (F : Fin k → ClippedPolynomialFactor) (S : Finset ℝ), S.card + 1 ≤ K → + (∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) → + ∀ (c : (S → Ordering) → ℂ) (B : ℝ), 0 ≤ B → (∀ code, ‖c code‖ ≤ B) → + 2 * B * smoothPolynomialBudget F ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + ∃ (s : ℕ → ℝ) (N : ℕ) (b : ℕ → ℂ), + Monotone s ∧ s 0 = u ∧ s N = v ∧ N ≤ S.card + 1 ∧ (∀ j, ‖b j‖ ≤ B) ∧ + ‖complexPrimeInterval q a u v + (fun y => c (rootCellCode S (Real.exp y)) * smoothPolynomialWeight F (Real.exp y)) - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + b j * smoothPolynomialWeight F (Real.exp y) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [P.root_cell_error_rate C d K, eventually_ge_atTop (0 : ℝ)] with L hL hL0 + intro Q q a hQ hq hqQ ha hlog u v hu huv hshort F S hSK hroots c B hB hc hbudget + have hu1 : 1 ≤ u := (Real.one_le_exp (by positivity)).trans hu + obtain ⟨s, N, b, hs, hs0, hsN, hN, hb, herr⟩ := P.root_cell_prime_comparison + hQ hq hqQ ha u v hu1 huv hshort F S hroots c B hB hc + refine ⟨s, N, b, hs, hs0, hsN, hN, hb, herr.trans ?_⟩ + apply hL Q hQ hlog N (hN.trans hSK) s + (fun j => ‖b j‖ * smoothPolynomialBudget F) + (fun _ => 2 * B * smoothPolynomialBudget F) + · intro j _ + exact hu.trans (by rw [← hs0]; exact hs (Nat.zero_le _)) + · intro j _ + have hbF := mul_le_mul_of_nonneg_right (hb j) (smoothPolynomialBudget_nonneg F) + have hBF : 0 ≤ B * smoothPolynomialBudget F := mul_nonneg hB (smoothPolynomialBudget_nonneg F) + nlinarith + · intro j _ + exact hbudget + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootCellIntegerComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootCellIntegerComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..12658f1cabb904972bd38173d137cebe592dd5c8 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootCellIntegerComparison.lean @@ -0,0 +1,89 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.OpenCellIntegerComparison +import OAI.NumberTheory.Ostmann.Arithmetic.RootCellPrimeComparison + +namespace OAI + +/-! # Root-cell idealization for the original external integer coordinate -/ + +namespace Ostmann +open scoped BigOperators Classical +open MeasureTheory + +theorem root_cell_integer_comparison {q a : ℕ} (hq : 0 < q) + (u v G : ℝ) (huv : u ≤ v) {k : ℕ} (F : Fin k → ClippedPolynomialFactor) + (S : Finset ℝ) (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (c : (S → Ordering) → ℂ) (C : ℝ) (hC : 0 ≤ C) (hc : ∀ code, ‖c code‖ ≤ C) : + ∃ (s : ℕ → ℝ) (N : ℕ) (d : ℕ → ℂ), + Monotone s ∧ s 0 = u ∧ s N = v ∧ N ≤ S.card + 1 ∧ (∀ j, ‖d j‖ ≤ C) ∧ + ‖complexIntegerInterval q a u v G + (fun y => c (rootCellCode S (Real.exp y)) * smoothPolynomialWeight F (Real.exp y)) - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + d j * smoothPolynomialWeight F (Real.exp y) * (integerLogDensity q G y : ℂ)‖ ≤ + 4 * ((S.card + 1 : ℕ) : ℝ) * C * smoothPolynomialBudget F * Real.exp (-G) := by + obtain ⟨s, N, hs, hs0, hsN, hN, hfree⟩ := finite_log_root_mesh S u v huv + let d := fun j => c (rootCellCode S (Real.exp ((s j + s (j + 1)) / 2))) + have hd (j : ℕ) : ‖d j‖ ≤ C := hc _ + refine ⟨s, N, d, hs, hs0, hsN, hN, hd, ?_⟩ + have herr : ‖complexIntegerInterval q a (s 0) (s N) G + (fun y => c (rootCellCode S (Real.exp y)) * smoothPolynomialWeight F (Real.exp y)) - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + d j * smoothPolynomialWeight F (Real.exp y) * (integerLogDensity q G y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, + (‖d j‖ * smoothPolynomialBudget F * (2 * Real.exp (-G)) + + (2 * C * smoothPolynomialBudget F) * Real.exp (-G)) := by + apply piecewise_integer_comparison q a hq G s hs N + _ (fun j y => d j * smoothPolynomialWeight F (Real.exp y)) + (fun j => ‖d j‖ * smoothPolynomialBudget F) (fun _ => 2 * C * smoothPolynomialBudget F) + · intro j hj + exact continuousOn_const.mul + (((continuous_smoothPolynomialWeight F).comp Real.continuous_exp).continuousOn) + · intro j hj r hr M hr0 hrM + rw [discreteVariation_const_mul] + apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) + apply smoothPolynomialWeight_variation_no_roots F (fun k => Real.exp (r k)) + (Real.exp_monotone.comp hr) M + intro i x hx hxin + apply hfree j hj x (hroots i x hx) + refine ⟨?_, ?_⟩ + · simpa only [hr0] using hxin.1 + · have hlast : Real.exp (r (M - 1)) ≤ Real.exp (s (j + 1)) := by + rw [← hrM] + exact Real.exp_le_exp.mpr (hr (Nat.sub_le M 1)) + exact hxin.2.trans_le hlast + · intro j hj + exact mul_nonneg (mul_nonneg (by positivity) hC) (smoothPolynomialBudget_nonneg F) + · intro j hj y hy + calc + _ ≤ ‖c (rootCellCode S (Real.exp y)) * smoothPolynomialWeight F (Real.exp y)‖ + + ‖d j * smoothPolynomialWeight F (Real.exp y)‖ := norm_sub_le _ _ + _ ≤ C * smoothPolynomialBudget F + C * smoothPolynomialBudget F := by + simp only [norm_mul] + exact add_le_add + (mul_le_mul (hc _) (smoothPolynomialWeight_norm F _) (norm_nonneg _) hC) + (mul_le_mul (hd _) (smoothPolynomialWeight_norm F _) (norm_nonneg _) hC) + _ = _ := by ring + · intro j hj y hy + congr 2 + apply rootCellCode_eq_of_root_free S (Real.exp (s j)) (Real.exp (s (j + 1))) + (Real.exp y) (Real.exp ((s j + s (j + 1)) / 2)) (hfree j hj) + · exact ⟨Real.exp_lt_exp.mpr hy.1, Real.exp_lt_exp.mpr hy.2⟩ + · constructor <;> apply Real.exp_lt_exp.mpr <;> linarith [hy.1, hy.2] + rw [hs0, hsN] at herr + apply herr.trans + calc + _ ≤ ∑ _j ∈ Finset.range N, 4 * C * smoothPolynomialBudget F * Real.exp (-G) := by + apply Finset.sum_le_sum + intro j hj + have hb := mul_le_mul_of_nonneg_right (hd j) (smoothPolynomialBudget_nonneg F) + have he := mul_le_mul_of_nonneg_right hb (by positivity : 0 ≤ 2 * Real.exp (-G)) + nlinarith + _ = (N : ℝ) * (4 * C * smoothPolynomialBudget F * Real.exp (-G)) := by simp + _ ≤ ((S.card + 1 : ℕ) : ℝ) * (4 * C * smoothPolynomialBudget F * Real.exp (-G)) := by + apply mul_le_mul_of_nonneg_right (by exact_mod_cast hN) + exact mul_nonneg (mul_nonneg (mul_nonneg (by positivity) hC) + (smoothPolynomialBudget_nonneg F)) (Real.exp_pos _).le + _ = _ := by ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootCellPrimeComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootCellPrimeComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..b4acd14ce85ce11f5ec180870bf797b2c99f236f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootCellPrimeComparison.lean @@ -0,0 +1,80 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.FiniteRootMesh +import OAI.NumberTheory.Ostmann.Arithmetic.OpenCellPrimeComparison +import OAI.NumberTheory.Ostmann.ZeroDensity.RootFreeSmoothWeight + +namespace OAI + +/-! # Weighted prime comparison for the complete finite root-cell multiplier -/ + +namespace Ostmann +open scoped BigOperators Classical +open MeasureTheory + +/-- Root-cell multipliers include the exact sharp arithmetic indicators. +The continuous factors and all endpoint primes are retained. -/ +theorem PublishedProgressionInput.root_cell_prime_comparison (P : PublishedProgressionInput) + {Q q a : ℕ} (hQ : 2 ≤ Q) (hq : 1 ≤ q) (hqQ : q ≤ Q) (ha : a.Coprime q) + (u v : ℝ) (hu : 1 ≤ u) (huv : u ≤ v) (hshort : v ≤ u + 1) + {n : ℕ} (F : Fin n → ClippedPolynomialFactor) + (S : Finset ℝ) (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (c : (S → Ordering) → ℂ) (C : ℝ) (hC : 0 ≤ C) (hc : ∀ code, ‖c code‖ ≤ C) : + ∃ (s : ℕ → ℝ) (N : ℕ) (d : ℕ → ℂ), + Monotone s ∧ s 0 = u ∧ s N = v ∧ N ≤ S.card + 1 ∧ (∀ j, ‖d j‖ ≤ C) ∧ + ‖complexPrimeInterval q a u v + (fun y => c (rootCellCode S (Real.exp y)) * smoothPolynomialWeight F (Real.exp y)) - + ∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + d j * smoothPolynomialWeight F (Real.exp y) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, + (‖d j‖ * smoothPolynomialBudget F * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ)))) + + 2 * C * smoothPolynomialBudget F * Real.exp (-(s j))) := by + obtain ⟨s, N, hs, hs0, hsN, hN, hfree⟩ := finite_log_root_mesh S u v huv + let d := fun j => c (rootCellCode S (Real.exp ((s j + s (j + 1)) / 2))) + have hd (j : ℕ) : ‖d j‖ ≤ C := hc _ + refine ⟨s, N, d, hs, hs0, hsN, hN, hd, ?_⟩ + rw [← hs0, ← hsN] + apply P.piecewise_prime_comparison hQ hq hqQ ha s hs N (by simpa only [hs0] using hu) + (by simpa only [hs0, hsN] using hshort) + _ (fun j y => d j * smoothPolynomialWeight F (Real.exp y)) + (fun j => ‖d j‖ * smoothPolynomialBudget F) + (fun _ => 2 * C * smoothPolynomialBudget F) + · intro j hj + exact continuousOn_const.mul + (((continuous_smoothPolynomialWeight F).comp Real.continuous_exp).continuousOn) + · intro j hj r hr M hr0 hrM + rw [discreteVariation_const_mul] + apply mul_le_mul_of_nonneg_left _ (norm_nonneg _) + apply smoothPolynomialWeight_variation_no_roots F (fun k => Real.exp (r k)) + (Real.exp_monotone.comp hr) M + intro i x hx hxin + apply hfree j hj x (hroots i x hx) + refine ⟨?_, ?_⟩ + · simpa only [hr0] using hxin.1 + · have hlast : Real.exp (r (M - 1)) ≤ Real.exp (s (j + 1)) := by + rw [← hrM] + exact Real.exp_le_exp.mpr (hr (Nat.sub_le M 1)) + exact hxin.2.trans_le hlast + · intro j hj + exact mul_nonneg (mul_nonneg (by positivity) hC) (smoothPolynomialBudget_nonneg F) + · intro j hj y hy + calc + _ ≤ ‖c (rootCellCode S (Real.exp y)) * smoothPolynomialWeight F (Real.exp y)‖ + + ‖d j * smoothPolynomialWeight F (Real.exp y)‖ := norm_sub_le _ _ + _ ≤ C * smoothPolynomialBudget F + C * smoothPolynomialBudget F := by + simp only [norm_mul] + exact add_le_add + (mul_le_mul (hc _) (smoothPolynomialWeight_norm F _) (norm_nonneg _) hC) + (mul_le_mul (hd _) (smoothPolynomialWeight_norm F _) (norm_nonneg _) hC) + _ = _ := by ring + · intro j hj y hy + congr 2 + apply rootCellCode_eq_of_root_free S (Real.exp (s j)) (Real.exp (s (j + 1))) + (Real.exp y) (Real.exp ((s j + s (j + 1)) / 2)) (hfree j hj) + · exact ⟨Real.exp_lt_exp.mpr hy.1, Real.exp_lt_exp.mpr hy.2⟩ + · constructor <;> apply Real.exp_lt_exp.mpr <;> linarith [hy.1, hy.2] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootIntegralRates.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootIntegralRates.lean new file mode 100644 index 0000000000000000000000000000000000000000..3485258565fa533ae06d84d1654a9ccb4377b95f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootIntegralRates.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.RootMeshIntegral +import OAI.NumberTheory.Ostmann.Arithmetic.RootCellErrorRates + +namespace OAI + +/-! # Uniform rates for the whole sharp-gate integral -/ + +namespace Ostmann +open Filter MeasureTheory +open scoped BigOperators + +theorem PublishedProgressionInput.root_integral_prime_rate (P : PublishedProgressionInput) + (C : ℝ) (d K : ℕ) : + ∀ᶠ L : ℝ in atTop, ∀ Q q a : ℕ, 2 ≤ Q → 1 ≤ q → q ≤ Q → a.Coprime q → + Real.log (4 * (Q : ℝ)) ≤ 2 * Real.exp ((12 / 1000 : ℝ) * L) → + ∀ u v : ℝ, Real.exp ((49 / 1000 : ℝ) * L) ≤ u → u ≤ v → v ≤ u + 1 → + ∀ (k : ℕ) (F : Fin k → ClippedPolynomialFactor) (S : Finset ℝ), S.card + 1 ≤ K → + (∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) → + ∀ (w : ℝ → ℂ) (B : ℝ), 0 ≤ B → (∀ x, ‖w x‖ ≤ B) → + (∀ x y, rootCellCode S x = rootCellCode S y → w x = w y) → + 2 * B * smoothPolynomialBudget F ≤ + Real.exp (C * L ^ d + C * L * Real.exp ((12 / 1000 : ℝ) * L)) → + ‖complexPrimeInterval q a u v (fun y => w (Real.exp y) * smoothPolynomialWeight F (Real.exp y)) - + ∫ y in Set.Ioc u v, w (Real.exp y) * smoothPolynomialWeight F (Real.exp y) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + Real.exp (-Real.exp ((125 / 10000 : ℝ) * L)) := by + filter_upwards [P.root_cell_error_rate C d K, eventually_ge_atTop (0 : ℝ)] with L hL hL0 + intro Q q a hQ hq hqQ ha hlog u v hu huv hshort k F S hSK hroots w B hB hw hconst hbudget + obtain ⟨s, N, hs, hs0, hsN, hN, hfree⟩ := finite_log_root_mesh S u v huv + have hu1 : 1 ≤ s 0 := by rw [hs0]; exact (Real.one_le_exp (by positivity)).trans hu + have h := P.common_root_prime_integral S s hs N hfree hQ hq hqQ ha hu1 + (by simpa only [hs0, hsN] using hshort) F hroots w B hB hw hconst + rw [hs0, hsN] at h + apply h.trans + apply hL Q hQ hlog N (hN.trans hSK) s + (fun j => ‖w (Real.exp ((s j + s (j + 1)) / 2))‖ * smoothPolynomialBudget F) + (fun _ => 2 * B * smoothPolynomialBudget F) + · intro j _ + exact hu.trans (by rw [← hs0]; exact hs (Nat.zero_le _)) + · intro j _ + have hbF := mul_le_mul_of_nonneg_right (hw (Real.exp ((s j + s (j + 1)) / 2))) + (smoothPolynomialBudget_nonneg F) + have hBF : 0 ≤ B * smoothPolynomialBudget F := mul_nonneg hB (smoothPolynomialBudget_nonneg F) + nlinarith + · intro j _ + exact hbudget + +theorem root_integral_integer_bound (q a : ℕ) (hq : 0 < q) (u v G : ℝ) (huv : u ≤ v) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) (S : Finset ℝ) + (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (w : ℝ → ℂ) (B : ℝ) (hB : 0 ≤ B) (hw : ∀ x, ‖w x‖ ≤ B) + (hconst : ∀ x y, rootCellCode S x = rootCellCode S y → w x = w y) : + ‖complexIntegerInterval q a u v G (fun y => w (Real.exp y) * smoothPolynomialWeight F (Real.exp y)) - + ∫ y in Set.Ioc u v, w (Real.exp y) * smoothPolynomialWeight F (Real.exp y) * + (integerLogDensity q G y : ℂ)‖ ≤ + 4 * ((S.card + 1 : ℕ) : ℝ) * B * smoothPolynomialBudget F * Real.exp (-G) := by + obtain ⟨s, N, hs, hs0, hsN, hN, hfree⟩ := finite_log_root_mesh S u v huv + have h := common_root_integer_integral S s hs N hfree q a hq G F hroots w B hB hw hconst + rw [hs0, hsN] at h + apply h.trans + calc + _ ≤ ∑ _j ∈ Finset.range N, 4 * B * smoothPolynomialBudget F * Real.exp (-G) := by + apply Finset.sum_le_sum + intro j _ + have hbF := mul_le_mul_of_nonneg_right (hw (Real.exp ((s j + s (j + 1)) / 2))) + (smoothPolynomialBudget_nonneg F) + have he := mul_le_mul_of_nonneg_right hbF (by positivity : 0 ≤ 2 * Real.exp (-G)) + nlinarith + _ = (N : ℝ) * (4 * B * smoothPolynomialBudget F * Real.exp (-G)) := by simp + _ ≤ ((S.card + 1 : ℕ) : ℝ) * (4 * B * smoothPolynomialBudget F * Real.exp (-G)) := by + apply mul_le_mul_of_nonneg_right (by exact_mod_cast hN) + exact mul_nonneg (mul_nonneg (mul_nonneg (by positivity) hB) + (smoothPolynomialBudget_nonneg F)) (Real.exp_pos _).le + _ = _ := by ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootMeshIntegral.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootMeshIntegral.lean new file mode 100644 index 0000000000000000000000000000000000000000..2b7785661aba3488d0ca638d124a3d8d0525abda --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/RootMeshIntegral.lean @@ -0,0 +1,98 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.CommonRootMesh + +namespace OAI + +/-! # Reassembling root cells into the original real integral -/ + +namespace Ostmann +open scoped BigOperators Classical +open MeasureTheory + +theorem rootMeshWeight_integral {k : ℕ} (F : Fin k → ClippedPolynomialFactor) + (w : ℝ → ℂ) (S : Finset ℝ) + (hconst : ∀ x y, rootCellCode S x = rootCellCode S y → w x = w y) + (s : ℕ → ℝ) (hs : Monotone s) (N : ℕ) + (hfree : ∀ j < N, ∀ r ∈ S, r ∉ Set.Ioo (Real.exp (s j)) (Real.exp (s (j + 1)))) + (ρ : ℝ → ℂ) (hρ : ContinuousOn ρ (Set.Icc (s 0) (s N))) : + IntervalIntegrable (fun y => w (Real.exp y) * smoothPolynomialWeight F (Real.exp y) * ρ y) + volume (s 0) (s N) ∧ + (∑ j ∈ Finset.range N, ∫ y in Set.Ioc (s j) (s (j + 1)), + rootMeshWeight F w s j y * ρ y) = + ∫ y in Set.Ioc (s 0) (s N), + w (Real.exp y) * smoothPolynomialWeight F (Real.exp y) * ρ y := by + let f := fun y => w (Real.exp y) * smoothPolynomialWeight F (Real.exp y) * ρ y + have heq (j : ℕ) (hj : j < N) (y : ℝ) (hy : y ∈ Set.Ioo (s j) (s (j + 1))) : + rootMeshWeight F w s j y * ρ y = f y := by + rw [← rootMeshWeight_eq F w S hconst s N hfree j hj y hy] + have hc (j : ℕ) (hj : j < N) : + IntervalIntegrable (fun y => rootMeshWeight F w s j y * ρ y) volume (s j) (s (j + 1)) := by + apply ((rootMeshWeight_continuous F w s j).continuousOn.mul (hρ.mono ?_)).intervalIntegrable_of_Icc + (hs (Nat.le_succ _)) + intro y hy + exact ⟨(hs (Nat.zero_le _)).trans hy.1, hy.2.trans (hs (by omega))⟩ + have hf (j : ℕ) (hj : j < N) : IntervalIntegrable f volume (s j) (s (j + 1)) := by + apply (hc j hj).congr_uIoo + rw [Set.uIoo_of_le (hs (Nat.le_succ _))] + exact heq j hj + refine ⟨IntervalIntegrable.trans_iterate hf, ?_⟩ + have heqI (j : ℕ) (hj : j < N) : + (∫ y in Set.Ioc (s j) (s (j + 1)), rootMeshWeight F w s j y * ρ y) = + ∫ y in (s j)..(s (j + 1)), f y := by + rw [← intervalIntegral.integral_of_le (hs (Nat.le_succ _))] + exact intervalIntegral.integral_congr_Ioo_of_le (hs (Nat.le_succ _)) (heq j hj) + calc + _ = ∑ j ∈ Finset.range N, ∫ y in (s j)..(s (j + 1)), f y := by + apply Finset.sum_congr rfl + intro j hj + exact heqI j (Finset.mem_range.mp hj) + _ = ∫ y in (s 0)..(s N), f y := intervalIntegral.sum_integral_adjacent_intervals hf + _ = _ := intervalIntegral.integral_of_le (hs (Nat.zero_le _)) + +/-- No root-dependent main term survives the partition. The full density +and the sharp real gate remain inside one integral. -/ +theorem PublishedProgressionInput.common_root_prime_integral (P : PublishedProgressionInput) + (S : Finset ℝ) (s : ℕ → ℝ) (hs : Monotone s) (N : ℕ) + (hfree : ∀ j < N, ∀ r ∈ S, r ∉ Set.Ioo (Real.exp (s j)) (Real.exp (s (j + 1)))) + {Q q a : ℕ} (hQ : 2 ≤ Q) (hq : 1 ≤ q) (hqQ : q ≤ Q) (ha : a.Coprime q) + (hu : 1 ≤ s 0) (hshort : s N ≤ s 0 + 1) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) + (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (w : ℝ → ℂ) (C : ℝ) (hC : 0 ≤ C) (hw : ∀ x, ‖w x‖ ≤ C) + (hconst : ∀ x y, rootCellCode S x = rootCellCode S y → w x = w y) : + ‖complexPrimeInterval q a (s 0) (s N) + (fun y => w (Real.exp y) * smoothPolynomialWeight F (Real.exp y)) - + ∫ y in Set.Ioc (s 0) (s N), w (Real.exp y) * smoothPolynomialWeight F (Real.exp y) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, + (‖w (Real.exp ((s j + s (j + 1)) / 2))‖ * smoothPolynomialBudget F * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ)))) + + 2 * C * smoothPolynomialBudget F * Real.exp (-(s j))) := by + have h := P.common_root_mesh_prime_comparison S s hs N hfree hQ hq hqQ ha hu hshort F hroots + w C hC hw hconst + have hρ : ContinuousOn (fun y => (selectedPrimeLogDensity P Q q a y : ℂ)) (Set.Icc (s 0) (s N)) := + Complex.continuous_ofReal.comp_continuousOn (continuousOn_primeLogDensity _ _ _ (by linarith)) + rwa [(rootMeshWeight_integral F w S hconst s hs N hfree _ hρ).2] at h + +theorem common_root_integer_integral + (S : Finset ℝ) (s : ℕ → ℝ) (hs : Monotone s) (N : ℕ) + (hfree : ∀ j < N, ∀ r ∈ S, r ∉ Set.Ioo (Real.exp (s j)) (Real.exp (s (j + 1)))) + (q a : ℕ) (hq : 0 < q) (G : ℝ) {k : ℕ} (F : Fin k → ClippedPolynomialFactor) + (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (w : ℝ → ℂ) (C : ℝ) (hC : 0 ≤ C) (hw : ∀ x, ‖w x‖ ≤ C) + (hconst : ∀ x y, rootCellCode S x = rootCellCode S y → w x = w y) : + ‖complexIntegerInterval q a (s 0) (s N) G + (fun y => w (Real.exp y) * smoothPolynomialWeight F (Real.exp y)) - + ∫ y in Set.Ioc (s 0) (s N), w (Real.exp y) * smoothPolynomialWeight F (Real.exp y) * + (integerLogDensity q G y : ℂ)‖ ≤ + ∑ j ∈ Finset.range N, + (‖w (Real.exp ((s j + s (j + 1)) / 2))‖ * smoothPolynomialBudget F * + (2 * Real.exp (-G)) + 2 * C * smoothPolynomialBudget F * Real.exp (-G)) := by + have h := common_root_mesh_integer_comparison S s hs N hfree q a hq G F hroots w C hC hw hconst + have hρ : ContinuousOn (fun y => (integerLogDensity q G y : ℂ)) (Set.Icc (s 0) (s N)) := + (Complex.continuous_ofReal.comp (continuous_integerLogDensity q G)).continuousOn + rwa [(rootMeshWeight_integral F w S hconst s hs N hfree _ hρ).2] at h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SafeRationalExpressions.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SafeRationalExpressions.lean new file mode 100644 index 0000000000000000000000000000000000000000..1ace2b89ba86a6da286eef25e981b884a103be83 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SafeRationalExpressions.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.HistorySymbolicStep +import OAI.NumberTheory.Ostmann.Arithmetic.MonomialDenominators + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.SafeRationalExpressions +open Characters.RationalHistory + +variable {ι : Type*} + +inductive Denominator (S : Set ℤ) : Expr ι → Prop + | atom (i : ι) : Denominator S (.atom i) + | one : Denominator S (.fixed 1) + | frequency (s : ℤ) (hs : s ∈ S) : Denominator S (.fixed s) + | mul {a b : Expr ι} : Denominator S a → Denominator S b → Denominator S (.mul a b) + +inductive Expression (S : Set ℤ) : Expr ι → Prop + | atom (i : ι) : Expression S (.atom i) + | fixed (c : ℤ) : Expression S (.fixed c) + | add {a b : Expr ι} : Expression S a → Expression S b → Expression S (.add a b) + | sub {a b : Expr ι} : Expression S a → Expression S b → Expression S (.sub a b) + | mul {a b : Expr ι} : Expression S a → Expression S b → Expression S (.mul a b) + | divide {a b : Expr ι} : Expression S a → Denominator S b → Expression S (.divide a b) + +theorem Denominator.expression {S : Set ℤ} {e : Expr ι} (he : Denominator S e) : Expression S e := by + induction he with + | atom i => exact .atom i + | one => exact .fixed 1 + | frequency s hs => exact .fixed s + | mul ha hb ia ib => exact .mul ia ib + +theorem Denominator.product {S : Set ℤ} (es : List (Expr ι)) + (h : ∀ e ∈ es, Denominator S e) : Denominator S (HistorySymbolicStep.product es) := by + induction es with + | nil => exact .one + | cons e es ih => exact .mul (h e (by simp)) (ih (fun z hz => h z (by simp [hz]))) + +theorem Denominator.product_ofFn {S : Set ℤ} {n : ℕ} (f : Fin n → Expr ι) + (h : ∀ i, Denominator S (f i)) : Denominator S (HistorySymbolicStep.product (List.ofFn f)) := by + apply Denominator.product + intro e he + obtain ⟨i,rfl⟩ := List.mem_ofFn.mp he + exact h i + +theorem Denominator.fieldRegular {S : Set ℤ} {e : Expr ι} (he : Denominator S e) + {K : Type*} [Field K] (x : ι → K) : e.FieldRegularAt x := by + induction he with + | atom i | one | frequency s hs => trivial + | mul ha hb ia ib => exact ⟨ia,ib⟩ + +theorem Denominator.fieldEval_ne_zero {S : Set ℤ} {e : Expr ι} + (he : Denominator S e) {K : Type*} [Field K] [DecidableEq ι] + (x : ι → K) (hS : ∀ s ∈ S, (s:K) ≠ 0) + (hx : ∀ i ∈ e.atoms, x i ≠ 0) : e.fieldEval x ≠ 0 := by + induction he with + | atom i => exact hx i (by simp [Expr.atoms]) + | one => simp [Expr.fieldEval] + | frequency s hs => exact hS s hs + | @mul a b ha hb ia ib => + exact mul_ne_zero (ia (fun i hi => hx i (Finset.mem_union_left _ hi))) + (ib (fun i hi => hx i (Finset.mem_union_right _ hi))) + +theorem Expression.fieldRegular {S : Set ℤ} {e : Expr ι} + (he : Expression S e) {K : Type*} [Field K] [DecidableEq ι] + (x : ι → K) (hS : ∀ s ∈ S, (s:K) ≠ 0) + (hx : ∀ i ∈ e.atoms, x i ≠ 0) : e.FieldRegularAt x := by + induction he with + | atom i | fixed c => trivial + | @add a b ha hb ia ib | @sub a b ha hb ia ib | @mul a b ha hb ia ib => + exact ⟨ia (fun i hi => hx i (Finset.mem_union_left _ hi)), + ib (fun i hi => hx i (Finset.mem_union_right _ hi))⟩ + | @divide a b ha hb ia => + exact ⟨ia (fun i hi => hx i (Finset.mem_union_left _ hi)), + hb.fieldRegular x,hb.fieldEval_ne_zero x hS (fun i hi => hx i (Finset.mem_union_right _ hi))⟩ + +theorem Denominator.generated {S : Set ℤ} {e : Expr ι} (he : Denominator S e) : + MonomialDenominators.Generated S e.numerator ∧ + MonomialDenominators.Generated S e.denominator := by + induction he with + | atom i => exact ⟨.var i,.one⟩ + | one => exact ⟨by simpa [Expr.numerator,Expr.fraction] using (MonomialDenominators.Generated.one (S:=S) (ι:=ι)),.one⟩ + | frequency s hs => exact ⟨.constant s hs,.one⟩ + | mul ha hb ia ib => exact ⟨.mul ia.1 ib.1,.mul ia.2 ib.2⟩ + +theorem Expression.denominator_generated {S : Set ℤ} {e : Expr ι} (he : Expression S e) : + MonomialDenominators.Generated S e.denominator := by + induction he with + | atom i | fixed c => exact .one + | add ha hb ia ib | sub ha hb ia ib | mul ha hb ia ib => exact .mul ia ib + | divide ha hb ia => exact .mul ia hb.generated.1 + +end Ostmann.Arithmetic.SafeRationalExpressions + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledHistoryEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledHistoryEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..1deb23a7b9c520d611d86d503973c5af55983d7c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledHistoryEnergy.lean @@ -0,0 +1,87 @@ +import OAI.NumberTheory.Ostmann.Construction.AdaptivePivotSupport +import OAI.NumberTheory.Ostmann.Arithmetic.HarmonicHistorySupport +import OAI.NumberTheory.Ostmann.Arithmetic.RecursiveFrequencySupport + +namespace OAI + +/-! # The squared-history sum with its constructed arithmetic support -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem treeIntegerResidues_prime_sample (P : Finset ℕ) (Q n : ℕ) + (hunit : ∀ p : P, (p : ℕ).Coprime Q) (x : TreeLeafTuple P n) : + treeIntegerResidues Q n + (treeLeafMap (fun p : P => ((p : ℕ) : ℤ)) n x) + (treeLeafMap (fun p : P => ZMod.unitOfCoprime (p : ℕ) (hunit p)) n x) := by + induction n with + | zero => + simpa only [treeIntegerResidues, treeLeafMap, Int.cast_natCast] using + ZMod.coe_unitOfCoprime (n := Q) (Subtype.val (show P from x)) (hunit x) + | succ n ih => exact ⟨ih x.1, ih x.2⟩ + +noncomputable def sampledPrimeHistory (P : Finset ℕ) (Q n : ℕ) + (hunit : ∀ p : P, (p : ℕ).Coprime Q) (x : TreeLeafIndex n → P) + (pivots : Fin (2 ^ n - 1) → ℤ) : SampledPivotHistory n Q where + bulk := treeLeafMap (fun p : P => ((p : ℕ) : ℤ)) n ((treeLeafTupleEquiv P n).symm x) + residue := treeLeafMap (fun p : P => ZMod.unitOfCoprime (p : ℕ) (hunit p)) n + ((treeLeafTupleEquiv P n).symm x) + pivots := pivots + compatible := treeIntegerResidues_prime_sample P Q n hunit _ + +theorem sampledPrimeHistory_residue (P : Finset ℕ) (Q n : ℕ) + (hunit : ∀ p : P, (p : ℕ).Coprime Q) (x : TreeLeafIndex n → P) + (pivots : Fin (2 ^ n - 1) → ℤ) : + (sampledPrimeHistory P Q n hunit x pivots).residue = + (treeLeafTupleEquiv (ZMod Q)ˣ n).symm (fun i => ZMod.unitOfCoprime (x i : ℕ) (hunit (x i))) := by + apply (treeLeafTupleEquiv (ZMod Q)ˣ n).injective + funext i + simp only [sampledPrimeHistory, treeLeafTupleEquiv_map, Equiv.apply_symm_apply] + +/-- No new support probability is assumed: it is computed from the literal +integer reversal equations of each nonzero sampled history. -/ +theorem sampled_history_square_sum_le (P : Finset ℕ) (S : Finset ℤ) (V n k : ℕ) + (R : FrequencyTree S n → ℕ) [∀ t, NeZero (R t ^ (k + 2))] + (D : FrequencyTree S n → PivotDependencyScheme (2 ^ n - 1)) + (hdepth : ∀ t i, (D t).depth i ≤ k) + (hs : ∀ t i, ((D t).frequencies i).root ≠ 0) + (hsR : ∀ t i, ((D t).frequencies i).root.natAbs ∣ R t) + (T : TreeLeafIndex n → Finset ℕ) + (hunit : ∀ t, ∀ p : P, (p : ℕ).Coprime (R t ^ (k + 2))) + (pivots : FrequencyTree S n → (TreeLeafIndex n → P) → Fin (2 ^ n - 1) → ℤ) + (W : FrequencyTree S n → (TreeLeafIndex n → P) → ℂ) + (B : ℝ) (hB : 0 ≤ B) + (hsize : ∀ t x, ‖W t x‖ ^ 2 ≤ B * frequencyLeafWeight (singleFrequencyLeaf S V) n t) + (hvalid : ∀ t x, W t x ≠ 0 → + (sampledPrimeHistory P (R t ^ (k + 2)) n (hunit t) x (pivots t x)).valid (D t)) : + (∑ t, ∑ x, (∏ i, primeSubsetPrior P (T i) (x i)) * ‖W t x‖ ^ 2) ≤ + B * harmonicHistorySupportSum P S V n (fun t => R t ^ (k + 2)) T hunit + (fun t => adaptivePivotData n (R t) k (D t) (hs t) (hsR t)) := by + unfold harmonicHistorySupportSum + rw [Finset.mul_sum] + apply Finset.sum_le_sum + intro t _ + rw [← mul_assoc, Finset.mul_sum] + apply Finset.sum_le_sum + intro x _ + have hμ : 0 ≤ ∏ i, primeSubsetPrior P (T i) (x i) := + Finset.prod_nonneg (fun i _ => primeSubsetPrior_nonneg P (T i) (x i)) + by_cases hw : W t x = 0 + · simp only [hw, norm_zero, zero_pow (by decide : 2 ≠ 0), mul_zero] + exact mul_nonneg (mul_nonneg hB (frequencyLeafWeight_nonneg _ + (fun _ => by unfold singleFrequencyLeaf; split_ifs <;> norm_num) n t)) + (mul_nonneg hμ (singleArithmeticLeafSupport_nonneg n _ _)) + · have hp := adaptivePivotData_actual_support n (R t) k (D t) (hdepth t) (hs t) (hsR t) + (sampledPrimeHistory P (R t ^ (k + 2)) n (hunit t) x (pivots t x)) (hvalid t x hw) + rw [sampledPrimeHistory_residue] at hp + rw [hp, mul_one] + calc + _ ≤ (∏ i, primeSubsetPrior P (T i) (x i)) * + (B * frequencyLeafWeight (singleFrequencyLeaf S V) n t) := + mul_le_mul_of_nonneg_left (hsize t x) hμ + _ = _ := by ring + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledHistoryRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledHistoryRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..ff0e4546c6ca86ba7eb895abc33fd410cc4c4e53 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledHistoryRate.lean @@ -0,0 +1,68 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SampledHistoryEnergy +import OAI.NumberTheory.Ostmann.Arithmetic.HarmonicHistoryRates + +namespace OAI + +/-! # Original-prior squared-history rate from integer reversals -/ + +namespace Ostmann + +open Filter +open scoped BigOperators Classical + +theorem adaptivePivotData_history_frequencies (S : Finset ℤ) (n R k : ℕ) + (t : FrequencyTree S n) (D : PivotDependencyScheme (2 ^ n - 1)) + (hs : ∀ i, (D.frequencies i).root ≠ 0) + (hsR : ∀ i, (D.frequencies i).root.natAbs ∣ R) + (hfreq : ∀ i, D.frequencies i = singleTreeNodeFrequencies S n t i.val) + (total : (ZMod (R ^ (k + 2)))ˣ) (past : List (ZMod (R ^ (k + 2)))ˣ) + (d : ArithmeticSplitData (R ^ (k + 2))) + (hd : adaptivePivotData n R k D hs hsR total past = some d) : + d.hasFrequencies (singleTreeNodeFrequencies S n t past.length) := by + by_cases hj : past.length < 2 ^ n - 1 + · have h := adaptivePivotData_frequencies n R k D hs hsR total past hj d hd + rwa [hfreq] at h + · simp only [adaptivePivotData, hj, dite_false] at hd + cases hd + +/-- This is the squared-history estimate with actual prime sampling and +actual integer integrality/unit conditions. The adaptive-support event is +constructed, and is not an additional hypothesis. -/ +theorem sampled_history_square_rate (n k : ℕ) (K C ε : ℝ) (hC : 0 ≤ C) (hε : 0 < ε) : + ∀ᶠ m : ℝ in atTop, ∀ N V : ℕ, ∀ Δ : ℝ, ∀ P : Finset ℕ, ∀ S : Finset ℤ, + (N : ℝ) ≤ Real.exp (C * m) → + (V : ℝ) ≤ Real.exp (Δ + Real.sqrt m) → + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) → + ∀ R : FrequencyTree S n → ℕ, ∀ [_hQ : ∀ t, NeZero (R t ^ (k + 2))], + ∀ D : FrequencyTree S n → PivotDependencyScheme (2 ^ n - 1), + (∀ t i, (D t).depth i ≤ k) → + ∀ _hs : ∀ t i, ((D t).frequencies i).root ≠ 0, + ∀ _hsR : ∀ t i, ((D t).frequencies i).root.natAbs ∣ R t, + (∀ t i, (D t).frequencies i = singleTreeNodeFrequencies S n t i.val) → + ∀ T : TreeLeafIndex n → Finset ℕ, ∀ h J : TreeLeafIndex n → ℕ, + ∀ hunit : ∀ t, ∀ p : P, (p : ℕ).Coprime (R t ^ (k + 2)), + (∀ t i, R t ^ (k + 2) ≤ 2 ^ h i) → + (∀ i p, p ∈ T i → 2 ^ h i ≤ p ∧ p < 2 ^ (h i + J i)) → + ∀ a C₁ L : ℝ, 0 < a → 1 ≤ L → + (∀ i, a ≤ ∑ p ∈ T i, (p : ℝ)⁻¹) → + (∀ i, (J i : ℝ) ≤ Real.exp (C₁ * L)) → + ∀ pivots : FrequencyTree S n → (TreeLeafIndex n → P) → Fin (2 ^ n - 1) → ℤ, + ∀ W : FrequencyTree S n → (TreeLeafIndex n → P) → ℂ, + (∀ t x, ‖W t x‖ ^ 2 ≤ Real.exp (-(2 ^ n : ℕ) * Δ + K) * + frequencyLeafWeight (singleFrequencyLeaf S V) n t) → + (∀ t x, W t x ≠ 0 → + (sampledPrimeHistory P (R t ^ (k + 2)) n (hunit t) x (pivots t x)).valid (D t)) → + (∑ t, ∑ x, (∏ i, primeSubsetPrior P (T i) (x i)) * ‖W t x‖ ^ 2) ≤ + Real.exp ((C₁ + max (Real.log (3 / a)) 0) * (2 ^ n : ℕ) * L + ε * m) := by + filter_upwards [harmonic_history_support_rate n K C ε hC hε] with m hm + intro N V Δ P S hN hV hS R _hQ D hdepth hs hsR hfreq T h J hunit hsmall hrange + a C₁ L ha hL hmass hJ pivots W hsize hvalid + have hb := sampled_history_square_sum_le P S V n k R D hdepth hs hsR T hunit pivots W + (Real.exp (-(2 ^ n : ℕ) * Δ + K)) (Real.exp_pos _).le hsize hvalid + exact hb.trans (hm N V Δ P S hN hV hS (fun t => R t ^ (k + 2)) T h J hunit hsmall hrange + a C₁ L ha hL hmass hJ (fun t => adaptivePivotData n (R t) k (D t) (hs t) (hsR t)) + (fun t => adaptivePivotData_history_frequencies S n (R t) k t (D t) (hs t) (hsR t) (hfreq t))) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledPrimeCoincidence.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledPrimeCoincidence.lean new file mode 100644 index 0000000000000000000000000000000000000000..40fcf3ea9b17e45fdfa2987f54cb1dec4e5f9edb --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledPrimeCoincidence.lean @@ -0,0 +1,111 @@ +import OAI.NumberTheory.Ostmann.Tree.OmittedCoordinate + +namespace OAI + +/-! # Coincidence bounds when the prime is one of the sampled coordinates + +The omitted-variable condition proves the required independence inside one +joint product prior. No separate independent-prime hypothesis is assumed. +-/ + +namespace Ostmann + +open scoped BigOperators Classical + +private theorem sampled_prime_divisibility_le {A : Type*} [Fintype A] + (prime : A → ℕ) (hinj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (ν : A → ℝ) (β V H : ℝ) (hβ : 0 ≤ β) (hV : 0 < V) + (hν : ∀ a, ν a ≤ β) (hsize : ∀ a, ν a ≠ 0 → V ≤ Real.log (prime a : ℝ)) + (z : ℤ) (hz : z ≠ 0) (hvalue : |(z : ℝ)| ≤ H) : + (∑ a, if prime a ∣ z.natAbs then ν a else 0) ≤ (Real.log H / V) * β := by + let P : Finset ℕ := (Finset.univ.filter fun a => ν a ≠ 0).image prime + let S : Finset A := Finset.univ.filter fun a => prime a ∣ z.natAbs ∧ ν a ≠ 0 + have hc : S.card ≤ (P.filter fun p => p ∣ z.natAbs).card := by + apply Finset.card_le_card_of_injOn prime + · intro a ha + exact Finset.mem_filter.mpr ⟨Finset.mem_image.mpr + ⟨a, Finset.mem_filter.mpr ⟨Finset.mem_univ _, (Finset.mem_filter.mp ha).2.2⟩, rfl⟩, + (Finset.mem_filter.mp ha).2.1⟩ + · exact hinj.injOn + have hc' := int_prime_divisor_card_le P z hz + (fun p hp => by obtain ⟨a, _, rfl⟩ := Finset.mem_image.mp hp; exact hprime a) + V H hV + (fun p hp => by + obtain ⟨a, ha, rfl⟩ := Finset.mem_image.mp hp + exact hsize a (Finset.mem_filter.mp ha).2) hvalue + calc + _ = ∑ a ∈ S, ν a := by + rw [Finset.sum_filter] + apply Finset.sum_congr rfl + intro a _ + by_cases hd : prime a ∣ z.natAbs <;> by_cases hn : ν a = 0 <;> simp [hd, hn] + _ ≤ ∑ _a ∈ S, β := Finset.sum_le_sum fun a _ => hν a + _ = (S.card : ℝ) * β := by simp + _ ≤ ((P.filter fun p => p ∣ z.natAbs).card : ℝ) * β := + mul_le_mul_of_nonneg_right (by exact_mod_cast hc) hβ + _ ≤ _ := mul_le_mul_of_nonneg_right hc' hβ + +theorem sampled_coordinate_prime_coincidence_le {A : Type*} [Fintype A] [Nonempty A] + {n : ℕ} (value : A → ℤ) (hinj : Function.Injective value) + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (F : MvPolynomial (Fin (n + 1)) ℤ) (hF : F ≠ 0) + (i : Fin (n + 1)) (hi : i ∉ F.vars) + (μ : Fin (n + 1) → A → ℝ) (hμ : ∀ j a, 0 ≤ μ j a) + (hmass : ∀ j, ∑ a, μ j a = 1) + (α β V H : ℝ) (hα : 0 ≤ α) (hβ : 0 ≤ β) (hV : 0 < V) (hH : 1 ≤ H) + (hmax : ∀ j a, μ j a ≤ α) (hpmax : ∀ a, μ i a ≤ β) + (hsize : ∀ a, μ i a ≠ 0 → V ≤ Real.log (prime a : ℝ)) + (hvalue : ∀ x, |(integerTestValue value F x : ℝ)| ≤ H) : + (∑ x, productPrior μ x * + if prime (x i) ∣ (integerTestValue value F x).natAbs then 1 else 0) ≤ + (F.totalDegree : ℝ) * α + (Real.log H / V) * β := by + let a₀ : A := Classical.arbitrary A + let z : (Fin n → A) → ℤ := fun x => integerTestValue value F (i.insertNth a₀ x) + let W := productPrior (fun j => μ (i.succAbove j)) + have hz (x : Fin n → A) (a : A) : integerTestValue value F (i.insertNth a x) = z x := + integerTestValue_insertNth_independent value F i hi x a a₀ + have hinner (x : Fin n → A) : + (∑ a, μ i a * if prime a ∣ (z x).natAbs then (1 : ℝ) else 0) ≤ + (if z x = 0 then 1 else 0) + (Real.log H / V) * β := by + by_cases hx : z x = 0 + · simp only [hx, Int.natAbs_zero, dvd_zero, ite_true, mul_one, hmass] + exact le_add_of_nonneg_right (mul_nonneg (div_nonneg (Real.log_nonneg hH) hV.le) hβ) + · simp only [hx, ite_false, zero_add] + have he : (∑ a, μ i a * if prime a ∣ (z x).natAbs then (1 : ℝ) else 0) = + ∑ a, if prime a ∣ (z x).natAbs then μ i a else 0 := by + apply Finset.sum_congr rfl + intro a _ + split_ifs <;> simp + rw [he] + exact sampled_prime_divisibility_le prime hpInj hprime (μ i) β V H hβ hV hpmax hsize + (z x) hx (hvalue (i.insertNth a₀ x)) + have hzero : (∑ x, productPrior μ x * if integerTestValue value F x = 0 then (1 : ℝ) else 0) = + ∑ x, W x * if z x = 0 then 1 else 0 := by + rw [sum_productPrior_insertNth μ i] + simp only [hz, ← Finset.sum_mul, hmass, one_mul, W] + have hbound : (∑ x, productPrior μ x * + if prime (x i) ∣ (integerTestValue value F x).natAbs then 1 else 0) ≤ + (∑ x, W x * if z x = 0 then 1 else 0) + (Real.log H / V) * β := by + rw [sum_productPrior_insertNth μ i] + simp only [Fin.insertNth_apply_same, hz] + calc + _ ≤ ∑ x, W x * ((if z x = 0 then 1 else 0) + (Real.log H / V) * β) := by + apply Finset.sum_le_sum + intro x _ + exact mul_le_mul_of_nonneg_left (hinner x) + (productPrior_nonneg _ (fun j a => hμ (i.succAbove j) a) x) + _ = _ := by + simp only [mul_add, Finset.sum_add_distrib, ← Finset.sum_mul] + rw [show (∑ x, W x) = 1 from productPrior_mass _ (fun j => hmass (i.succAbove j)), one_mul] + rw [← hzero] at hbound + have hroot := weighted_polynomial_roots_le (fun a => (value a : ℚ)) + (Int.cast_injective.comp hinj) α hα (MvPolynomial.map (Int.castRingHom ℚ) F) + (fun hz => hF ((integerPolynomial_rational_zero_iff F).mp hz)) μ hμ hmass hmax + simp only [integerPolynomial_rational_eval, Int.cast_eq_zero, integerPolynomial_rational_degree] at hroot + change (∑ x, productPrior μ x * if integerTestValue value F x = 0 then (1 : ℝ) else 0) ≤ + (F.totalDegree : ℝ) * α at hroot + exact hbound.trans (by linarith [hroot]) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledSpectatorComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledSpectatorComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..87f07ebcd48ef90dfd907898e2a0ecc72b57a58c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledSpectatorComparison.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantSamples +import OAI.NumberTheory.Ostmann.Arithmetic.MovingGiantSpectator +import OAI.NumberTheory.Ostmann.Construction.NormalizedSpectatorComparison + +namespace OAI + +/-! # The good-matching bound for the constructed compensation histories -/ + +namespace Ostmann +open scoped Classical BigOperators ComplexConjugate + +/-- The actual sampled small data produce fixed diagrams, the exact supported +integer coefficient, and the good-matching decay for their uniform residues. -/ +theorem sampled_good_spectator_comparison {q : ℕ} [Fact q.Prime] (hq : 3 ≤ q) + (n m : ℕ) (hm : 0 < m) + (e : Equiv.Perm (TreeLeafIndex (n + 2) × Fin m)) + (hgood : 4 * Fintype.card (arrangementGraph m e).ConnectedComponent ≤ + 3 * Fintype.card (TreeLeafIndex (n + 2))) + (t₁ t₂ : FrequencyTree ℤ (n + 2)) + (small₁ small₂ : TreeLeafTuple ℕ (n + 2)) + (samples₁ samples₂ : MovingGiantSamples (n + 2)) + (hfreq₁ : movingGiantFrequencyUnits q (n + 2) t₁) + (hfreq₂ : movingGiantFrequencyUnits q (n + 2) t₂) + (hsmall₁ : ((treeLeafProduct (n + 2) small₁ : ℕ) : ZMod q) ≠ 0) + (hsmall₂ : ((treeLeafProduct (n + 2) small₂ : ℕ) : ZMod q) ≠ 0) + (hsamples₁ : samples₁.UnitsAt q) (hsamples₂ : samples₂.UnitsAt q) + (D₁ D₂ : (ZMod q)ˣ) (XL₁ XR₁ XL₂ XR₂ : ℕ) + (A₁ B₁ A₂ B₂ : (ZMod q)ˣ) + (hA₁ : (XL₁ : ZMod q) = A₁) (hB₁ : (XR₁ : ZMod q) = B₁) + (hA₂ : (XL₂ : ZMod q) = A₂) (hB₂ : (XR₂ : ZMod q) = B₂) + (S : Finset (ZMod q)) (hlo : (1 / 3 : ℝ) ≤ residueDensity S) + (hhi : residueDensity S ≤ 2 / 3) (hS : S.Nonempty) (hSq : S.card < q) + (β ε : ℝ) (hε : 0 ≤ ε) (hε1 : ε ≤ 1) + (hprincipal : 3 / Real.sqrt (q : ℝ) ≤ ε) (hβ : 2 * β ≤ ε) + (hbias : ∀ (χ : MulChar (ZMod q) ℂ), χ ≠ 1 → ∀ a : ZMod q, + ‖(S.card : ℂ)⁻¹ * ∑ x ∈ S, χ⁻¹ (-a - x)‖ ≤ β) : + let T₁ := buildMovingGiantTree (n + 2) t₁ small₁ samples₁ + let T₂ := buildMovingGiantTree (n + 2) t₂ small₂ samples₂ + ∃ d₁ d₂ : SpectatorDiagram q (n + 2), + (∀ (x₁ x₂ : TreeLeafTuple ℕ (n + 2)) + (y₁ y₂ : TreeLeafTuple (ZMod q)ˣ (n + 2)) (c : ℂ), + TreeNaturalLift (n + 2) x₁ y₁ → TreeNaturalLift (n + 2) x₂ y₂ → + (c ≠ 0 → T₁.Integral XL₁ XR₁ x₁ ∧ T₂.Integral XL₂ XR₂ x₂) → + c * (movingGiantAmplitude (normalizedResidueTransform S) D₁ T₁ XL₁ XR₁ x₁ * + conj (movingGiantAmplitude (normalizedResidueTransform S) D₂ T₂ XL₂ XR₂ x₂)) = + c * (d₁.value (normalizedResidueTransform S) y₁ * + conj (d₂.value (normalizedResidueTransform S) y₂))) ∧ + ‖(Fintype.card (TreeLeafIndex (n + 2) × Fin m → (ZMod q)ˣ) : ℂ)⁻¹ * + (∑ x : TreeLeafIndex (n + 2) × Fin m → (ZMod q)ˣ, + d₁.bulkValue (normalizedResidueTransform S) x * + conj (d₂.bulkValue (normalizedResidueTransform S) (x ∘ e.symm)))‖ ^ 2 ≤ + quartetTreeConstant n * (ε ^ 2 + Real.sqrt (3 / (q : ℝ))) := by + dsimp only + obtain ⟨d₁, d₂, hc₁, _, hvalue⟩ := movingGiant_pair_diagrams + (buildMovingGiantTree (n + 2) t₁ small₁ samples₁) + (buildMovingGiantTree (n + 2) t₂ small₂ samples₂) + (buildMovingGiantTree_units t₁ small₁ samples₁ hfreq₁ hsmall₁ hsamples₁) + (buildMovingGiantTree_units t₂ small₂ samples₂ hfreq₂ hsmall₂ hsamples₂) + D₁ D₂ XL₁ XR₁ XL₂ XR₂ A₁ B₁ A₂ B₂ hA₁ hB₁ hA₂ hB₂ + refine ⟨d₁, d₂, hvalue (normalizedResidueTransform S), ?_⟩ + let c := treeLeafTupleEquiv Bool n (transferConjugations n false) + apply normalized_spectator_bulk_comparison hq n m hm e hgood S hlo hhi hS hSq β ε + hε hε1 hprincipal hβ hbias d₁ d₂ c (fun j => !(c j)) + intro j + rw [hc₁] + simpa only [Bool.not_not] using transferConjugations_quartet n false j + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledTupleAmplitude.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledTupleAmplitude.lean new file mode 100644 index 0000000000000000000000000000000000000000..8dba5f68f98b6547601542474db2a4e682db2cb7 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SampledTupleAmplitude.lean @@ -0,0 +1,56 @@ +import OAI.NumberTheory.Ostmann.Construction.TupleFrequencyCutoff +import OAI.NumberTheory.Ostmann.Construction.RepeatedTuplePoisson + +namespace OAI + +/-! # The finite graph amplitude of an injective prime sample -/ + +namespace Ostmann + +open scoped BigOperators FourierTransform SchwartzMap Classical + +theorem prime_character_isPrimitive (p : ℕ) (hp : p.Prime) + (χ : DirichletCharacter ℂ p) (hχ : χ ≠ 1) : χ.IsPrimitive := by + let : NeZero p := ⟨hp.ne_zero⟩ + rcases (Nat.dvd_prime hp).mp χ.conductor_dvd_level with h | h + · exact False.elim (hχ (DirichletCharacter.eq_one_iff_conductor_eq_one.mpr h)) + · exact h + +noncomputable def sampledTupleAmplitude {I : Type*} [Fintype I] + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (χ : I → ∀ p : ℕ, DirichletCharacter ℂ p) (t : ∀ p : ℕ, ZMod p) + (ψ : 𝓢(ℝ, ℂ)) (X : ℝ) (N : ℕ) (x : I → P) : ℂ := + let : ∀ i, NeZero (x i : ℕ) := fun i => ⟨(hP _ (x i).property).ne_zero⟩ + ∑ v ∈ tupleFrequencies (fun i => (x i : ℕ)) N, + (Real.sqrt (X / (∏ i, (x i : ℕ))) : ℂ) * + 𝓕 ψ ((v : ℝ) * X / (∏ i, (x i : ℕ))) * + tupleGraphPhase (fun i => (x i : ℕ)) (fun i => χ i (x i)) (fun i => t (x i)) v + +theorem sampledTupleAmplitude_eq {I : Type*} [Fintype I] [Nonempty I] + (P : Finset ℕ) (hP : ∀ p ∈ P, p.Prime) + (χ : I → ∀ p : ℕ, DirichletCharacter ℂ p) + (hχ : ∀ i p, p ∈ P → χ i p ≠ 1) (t : ∀ p : ℕ, ZMod p) + (ψ : 𝓢(ℝ, ℂ)) (X H : ℝ) (hX : 0 < X) (N : ℕ) + (hsupp : ∀ u : ℝ, H < |u| → 𝓕 ψ u = 0) + (x : I → P) (hx : Function.Injective x) + (hcut : H * (∏ i, (x i : ℕ)) ≤ N * X) : + characterTupleSum (fun i => (x i : ℕ)) χ t ψ X / (Real.sqrt X : ℂ) = + sampledTupleAmplitude P hP χ t ψ X N x := by + let : ∀ i, NeZero (x i : ℕ) := fun i => ⟨(hP _ (x i).property).ne_zero⟩ + let : NeZero (∏ i, (x i : ℕ)) := ⟨Finset.prod_ne_zero_iff.mpr + (fun i _ => (hP _ (x i).property).ne_zero)⟩ + have hc : Pairwise (fun i j => (x i : ℕ).Coprime (x j : ℕ)) := by + intro i j hij + apply (hP _ (x i).property).coprime_iff_not_dvd.mpr + intro hd + have he : (x i : ℕ) = (x j : ℕ) := + ((Nat.dvd_prime (hP _ (x j).property)).mp hd).resolve_left (hP _ (x i).property).ne_one + exact hij (hx (Subtype.ext he)) + exact tuple_character_poisson_finite (fun i => (x i : ℕ)) + (fun i => (hP _ (x i).property).two_le) hc (fun i => χ i (x i)) + (fun i => prime_character_isPrimitive _ (hP _ (x i).property) _ (hχ i _ (x i).property)) + (fun i => t (x i)) ψ X H hX N hcut hsupp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ScaleBudget.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ScaleBudget.lean new file mode 100644 index 0000000000000000000000000000000000000000..2baa9c5f0cc60a9176dbedb59fe59cafd02b6bb5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ScaleBudget.lean @@ -0,0 +1,95 @@ +import Mathlib + +namespace OAI + +noncomputable section +namespace Ostmann.Arithmetic.ScaleBudget +open Filter Asymptotics +open scoped Topology + +structure Row where + a₀ : ℝ + a₁ : ℝ + μ : ℝ + δ : ℝ + δ' : ℝ + θ : ℝ + target : ℝ + μ_pos : 0 < μ + μ_lt_δ : μ < δ + δ_lt_δ' : δ < δ' + δ'_lt_θ : δ' < θ + zero_gap : 3*θ < a₀ + range : a₀ < a₁ + target_pos : 0 < target + target_lt_δ : target < δ + +def giant : Row where + a₀ := 49/1000 + a₁ := 95/100 + μ := 12/1000 + δ := 14/1000 + δ' := 15/1000 + θ := 16/1000 + target := 13/1000 + μ_pos := by norm_num + μ_lt_δ := by norm_num + δ_lt_δ' := by norm_num + δ'_lt_θ := by norm_num + zero_gap := by norm_num + range := by norm_num + target_pos := by norm_num + target_lt_δ := by norm_num + +def bulk : Row where + a₀ := 39/10000 + a₁ := 7/1000 + μ := 11/10000 + δ := 115/100000 + δ' := 12/10000 + θ := 125/100000 + target := 11/10000 + μ_pos := by norm_num + μ_lt_δ := by norm_num + δ_lt_δ' := by norm_num + δ'_lt_θ := by norm_num + zero_gap := by norm_num + range := by norm_num + target_pos := by norm_num + target_lt_δ := by norm_num + +theorem bulk_spectator_gap : (1:ℝ)/1000 < bulk.μ := by norm_num [bulk] +theorem giant_conclusion_gap : (12:ℝ)/1000 < giant.δ' := by norm_num [giant] + +theorem eventually_poly_exp_le (C : ℝ) (n : ℕ) {a b K : ℝ} + (hab : a < b) (hK : 0 < K) : + ∀ᶠ L : ℝ in atTop, C * L^n * Real.exp (a*L) ≤ K * Real.exp (b*L) := by + have h : (fun L : ℝ => C * (Real.exp (a*L) * L^n)) =o[atTop] + (fun L : ℝ => Real.exp (b*L)) := by + have h₀ := isLittleO_exp_mul_rpow_of_lt (n:ℝ) hab + simp only [Real.rpow_natCast] at h₀ + exact h₀.const_mul_left C + filter_upwards [h.bound hK] with L hL + calc + C*L^n*Real.exp (a*L) = C*(Real.exp (a*L)*L^n) := by ring + _ ≤ ‖C*(Real.exp (a*L)*L^n)‖ := le_abs_self _ + _ ≤ K*Real.exp (b*L) := by simpa only [Real.norm_eq_abs, + Real.abs_exp] using hL + +theorem eventually_double_exp_error (C : ℝ) (n : ℕ) {a b d c : ℝ} + (hab : a < b) (hdb : d < b) (hc : 0 < c) : + ∀ᶠ L : ℝ in atTop, + Real.exp (-c*Real.exp (b*L)+C*L^n*Real.exp (a*L)) ≤ + Real.exp (-Real.exp (d*L)) := by + have hhalf : 0 < c/2 := by linarith + filter_upwards [eventually_poly_exp_le C n hab hhalf, + eventually_poly_exp_le 1 0 hdb hhalf] with L h₁ h₂ + apply Real.exp_le_exp.mpr + simp only [pow_zero, mul_one, one_mul] at h₂ + linarith + +end Ostmann.Arithmetic.ScaleBudget + +end + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/ScaledPoisson.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ScaledPoisson.lean new file mode 100644 index 0000000000000000000000000000000000000000..839007ef5951d8351bd2e88743164969bedfe8a5 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/ScaledPoisson.lean @@ -0,0 +1,75 @@ +import Mathlib.MeasureTheory.Measure.Haar.NormedSpace +import OAI.NumberTheory.Ostmann.Characters.TranslatedCharacterPoisson + +namespace OAI + +/-! # The original scale in the quadratic-character Poisson formula -/ + +namespace Ostmann + +open scoped BigOperators FourierTransform SchwartzMap +open MeasureTheory + +theorem fourier_comp_positive_mul (f : ℝ → ℂ) {a : ℝ} (ha : 0 < a) (ξ : ℝ) : + 𝓕 (fun x => f (a * x)) ξ = (a : ℂ)⁻¹ * 𝓕 f (ξ / a) := by + rw [Real.fourier_real_eq_integral_exp_smul, Real.fourier_real_eq_integral_exp_smul] + let g : ℝ → ℂ := fun y => Complex.exp (((-2 * Real.pi * y * (ξ / a) : ℝ) : ℂ) * Complex.I) • f y + have hi : (∫ x : ℝ, Complex.exp (((-2 * Real.pi * x * ξ : ℝ) : ℂ) * Complex.I) • f (a * x)) = + ∫ x : ℝ, g (a * x) := by + apply integral_congr_ae + filter_upwards [] with x + dsimp [g] + have he : (-2 * Real.pi * (a * x) * (ξ / a) : ℝ) = -2 * Real.pi * x * ξ := by + field_simp + rw [he] + rw [hi, Measure.integral_comp_mul_left] + simp only [abs_of_pos (inv_pos.mpr ha), Complex.real_smul, Complex.ofReal_inv] + rfl + +noncomputable def positiveDilate (f : 𝓢(ℝ, ℂ)) (a : ℝ) (ha : 0 < a) : 𝓢(ℝ, ℂ) := + SchwartzMap.compCLM ℂ (g := fun x : ℝ => a * x) (by fun_prop) + ⟨1, a⁻¹, fun x => by + simp only [pow_one, norm_mul, Real.norm_eq_abs, abs_of_pos ha] + rw [mul_add, ← mul_assoc, inv_mul_cancel₀ ha.ne', one_mul] + simpa only [mul_one] using le_add_of_nonneg_left (a := |x|) (inv_nonneg.mpr ha.le)⟩ f + +theorem positiveDilate_apply (f : 𝓢(ℝ, ℂ)) (a : ℝ) (ha : 0 < a) (x : ℝ) : + positiveDilate f a ha x = f (a * x) := rfl + +theorem positiveDilate_fourier (f : 𝓢(ℝ, ℂ)) (a : ℝ) (ha : 0 < a) (ξ : ℝ) : + 𝓕 (positiveDilate f a ha) ξ = (a : ℂ)⁻¹ * 𝓕 f (ξ / a) := by + change 𝓕 (fun x : ℝ => f (a * x)) ξ = (a : ℂ)⁻¹ * 𝓕 (f : ℝ → ℂ) (ξ / a) + exact fourier_comp_positive_mul f ha ξ + +theorem scaled_quadratic_character_poisson {d M : ℕ} [NeZero d] [NeZero M] + (h : d.Coprime M) (f : ZMod d → ℂ) (χ : DirichletCharacter ℂ M) + (hχ : χ.IsPrimitive) (hq : χ.IsQuadratic) (t : ZMod M) (ψ : 𝓢(ℝ, ℂ)) + (X : ℝ) (hX : 0 < X) : + (∑' n : ℤ, f (n : ZMod d) * χ ((n : ZMod M) - t) * ψ ((n : ℝ) / X)) = + (X : ℂ) / M * gaussSum χ ZMod.stdAddChar * ∑' n : ℤ, + 𝓕 ψ ((n : ℝ) * X / (d * M : ℕ)) * + additiveFourier f (-((M : ZMod d)⁻¹ * (n : ZMod d))) * + ZMod.stdAddChar (t * ((d : ZMod M)⁻¹ * (n : ZMod M))) * + χ (d : ZMod M) * χ (n : ZMod M) := by + have hd : (0 : ℝ) < d := by exact_mod_cast NeZero.pos d + have hM : (0 : ℝ) < M := by exact_mod_cast NeZero.pos M + have ha : 0 < (d * M : ℕ) / X := div_pos (by rw [Nat.cast_mul]; exact mul_pos hd hM) hX + have hp := quadratic_character_poisson h f χ hχ hq t + (positiveDilate ψ ((d * M : ℕ) / X) ha) + have harg (n : ℤ) : ((d * M : ℕ) : ℝ) / X * ((n : ℝ) / (d * M : ℕ)) = n / X := by + field_simp + simp_rw [positiveDilate_apply, harg, positiveDilate_fourier] at hp + have hfreq (n : ℤ) : (n : ℝ) / ((d * M : ℕ) / X) = (n : ℝ) * X / (d * M : ℕ) := by rw [div_div_eq_mul_div] + simp_rw [hfreq] at hp + rw [hp] + simp_rw [← tsum_mul_left] + apply tsum_congr + intro n + have hdC : (d : ℂ) ≠ 0 := by exact_mod_cast NeZero.ne d + have hMC : (M : ℂ) ≠ 0 := by exact_mod_cast NeZero.ne M + push_cast + field_simp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SequentialActualSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SequentialActualSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..b417f39fc3e898dfb2eb980206d84b4866c47393 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SequentialActualSupport.lean @@ -0,0 +1,45 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SplitSampleLists +import OAI.NumberTheory.Ostmann.Arithmetic.SingleHistorySupport + +namespace OAI + +/-! # Passing all actual preorder node tests retains the whole support weight -/ + +namespace Ostmann + +open scoped Classical + +theorem sequentialSupport_eq_one_of_prefix {A : Type} [One A] + (test : List A → A → Prop) (past : List A) (n : ℕ) (x : SplitSamples A n) + (htest : ∀ j < n, test (((splitSampleList n x).take j).reverse ++ past) + ((splitSampleList n x).getD j 1)) : sequentialSupport test past n x = 1 := by + induction n generalizing past with + | zero => rfl + | succ n ih => + have h0 : test past x.1 := by simpa [splitSampleList] using htest 0 (by omega) + change (if test past x.1 then sequentialSupport test (x.1 :: past) n x.2 else 0) = 1 + rw [ite_eq_left h0] + apply ih + intro j hj + have ht := htest (j + 1) (by omega) + simpa only [splitSampleList, List.take_succ_cons, List.reverse_cons, + List.getD_cons_succ, List.append_assoc, List.singleton_append] using ht + +/-- The support is evaluated on the original leaf tuple. Its tests are +checked at the actual parent/child product splits, in their true order. -/ +theorem singleArithmeticLeafSupport_eq_one_of_actual_tests {Q : ℕ} [NeZero Q] + (n : ℕ) (data : (ZMod Q)ˣ → List (ZMod Q)ˣ → Option (ArithmeticSplitData Q)) + (x : TreeLeafTuple (ZMod Q)ˣ n) + (htest : ∀ j < 2 ^ n - 1, + singleArithmeticSplitTest + (data (treeLeafProduct n x) (((actualSplitValues n x).take j).reverse)) + ((actualSplitValues n x).getD j 1)) : + singleArithmeticLeafSupport n data x = 1 := by + unfold singleArithmeticLeafSupport + apply sequentialSupport_eq_one_of_prefix + intro j hj + simpa only [List.append_nil, splitSampleList_treeLeafSplit] using htest j hj + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SequentialProductSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SequentialProductSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..8ec6e750456e34fa16575b31935ec773d8b6b4d6 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SequentialProductSupport.lean @@ -0,0 +1,70 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SequentialSupport + +namespace OAI + +/-! # Distinct frequency bounds at successive exposed splits -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem sequentialSupport_average_le_product {A : Type} [Fintype A] [Nonempty A] + (test : List A → A → Prop) (ρ : ℕ → ℝ) (hρ : ∀ i, 0 ≤ ρ i) + (htest : ∀ past, (Fintype.card A : ℝ)⁻¹ * + (∑ x : A, if test past x then (1 : ℝ) else 0) ≤ ρ past.length) + (past : List A) (n : ℕ) : + (Fintype.card A : ℝ)⁻¹ ^ n * + (∑ x : SplitSamples A n, sequentialSupport test past n x) ≤ + ∏ i ∈ Finset.range n, ρ (past.length + i) := by + induction n generalizing past with + | zero => simp [sequentialSupport, SplitSamples] + | succ n ih => + let B := ∏ i ∈ Finset.range n, ρ (past.length + 1 + i) + have hB : 0 ≤ B := Finset.prod_nonneg fun i _ => hρ _ + have htail (a : A) : (Fintype.card A : ℝ)⁻¹ ^ n * + (∑ x : SplitSamples A n, sequentialSupport test (a :: past) n x) ≤ B := by + simpa only [List.length_cons, B] using ih (a :: past) + change (Fintype.card A : ℝ)⁻¹ ^ (n + 1) * + (∑ x : A × SplitSamples A n, + if test past x.1 then sequentialSupport test (x.1 :: past) n x.2 else 0) ≤ _ + rw [Fintype.sum_prod_type, pow_succ] + have heq : (∑ a : A, ∑ x : SplitSamples A n, + if test past a then sequentialSupport test (a :: past) n x else 0) = + ∑ a : A, (if test past a then (1 : ℝ) else 0) * + (∑ x : SplitSamples A n, sequentialSupport test (a :: past) n x) := by + apply Finset.sum_congr rfl + intro a _ + by_cases ha : test past a <;> simp [ha] + rw [heq] + calc + _ = (Fintype.card A : ℝ)⁻¹ * + ∑ a : A, (if test past a then (1 : ℝ) else 0) * + ((Fintype.card A : ℝ)⁻¹ ^ n * + (∑ x : SplitSamples A n, sequentialSupport test (a :: past) n x)) := by + rw [Finset.mul_sum, Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + ring + _ ≤ (Fintype.card A : ℝ)⁻¹ * + ∑ a : A, (if test past a then (1 : ℝ) else 0) * B := by + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (Nat.cast_nonneg _)) + exact Finset.sum_le_sum fun a _ => + mul_le_mul_of_nonneg_left (htail a) (by split_ifs <;> norm_num) + _ = ((Fintype.card A : ℝ)⁻¹ * + ∑ a : A, if test past a then (1 : ℝ) else 0) * B := by + rw [← Finset.sum_mul, mul_assoc] + _ ≤ ρ past.length * B := mul_le_mul_of_nonneg_right (htest past) hB + _ = _ := by + rw [Finset.prod_range_succ'] + simp only [Nat.add_zero] + rw [mul_comm (ρ past.length)] + dsimp [B] + congr 1 + apply Finset.prod_congr rfl + intro i _ + congr 1 + omega + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SequentialSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SequentialSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..fa96d512a3e8326498c7c79c0ad2b746f6b30af1 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SequentialSupport.lean @@ -0,0 +1,89 @@ +import Mathlib.Algebra.Order.BigOperators.Ring.Finset +import Mathlib.Data.Fintype.Prod +import Mathlib.Algebra.BigOperators.Fin +import Mathlib.Basic.Real.Basic + +namespace OAI + +/-! # Multiplying support bounds under the original independent prior + +The test at a split can depend on the entire already exposed prefix. This +records the order of exposure, so future validity never changes its law. +-/ + +namespace Ostmann + +open scoped BigOperators Classical + +@[implicit_reducible] def SplitSamples (A : Type) : ℕ → Type _ + | 0 => Unit + | n + 1 => A × SplitSamples A n + +instance splitSamplesFintype (A : Type) [Fintype A] (n : ℕ) : Fintype (SplitSamples A n) := by + induction n with + | zero => exact inferInstanceAs (Fintype Unit) + | succ n ih => exact @instFintypeProd _ _ _ ih + +noncomputable def sequentialSupport {A : Type} (test : List A → A → Prop) + (past : List A) : (n : ℕ) → SplitSamples A n → ℝ + | 0, _ => 1 + | n + 1, x => if test past x.1 then sequentialSupport test (x.1 :: past) n x.2 else 0 + +theorem sequentialSupport_nonneg {A : Type} (test : List A → A → Prop) + (past : List A) (n : ℕ) (x : SplitSamples A n) : + 0 ≤ sequentialSupport test past n x := by + induction n generalizing past with + | zero => exact zero_le_one + | succ n ih => + change 0 ≤ if test past x.1 then sequentialSupport test (x.1 :: past) n x.2 else 0 + split_ifs + · exact ih _ _ + · exact le_rfl + +/-- Prefix-adapted tests multiply their bounds without conditioning on +the complete support event. -/ +theorem sequentialSupport_average_le {A : Type} [Fintype A] [Nonempty A] + (test : List A → A → Prop) (ρ : ℝ) (hρ : 0 ≤ ρ) + (htest : ∀ past, (Fintype.card A : ℝ)⁻¹ * + (∑ x : A, if test past x then (1 : ℝ) else 0) ≤ ρ) + (past : List A) (n : ℕ) : + (Fintype.card A : ℝ)⁻¹ ^ n * + (∑ x : SplitSamples A n, sequentialSupport test past n x) ≤ ρ ^ n := by + induction n generalizing past with + | zero => simp [sequentialSupport, SplitSamples] + | succ n ih => + change (Fintype.card A : ℝ)⁻¹ ^ (n + 1) * + (∑ x : A × SplitSamples A n, + if test past x.1 then sequentialSupport test (x.1 :: past) n x.2 else 0) ≤ _ + rw [Fintype.sum_prod_type, pow_succ] + have heq : (∑ a : A, ∑ x : SplitSamples A n, + if test past a then sequentialSupport test (a :: past) n x else 0) = + ∑ a : A, (if test past a then (1 : ℝ) else 0) * + (∑ x : SplitSamples A n, sequentialSupport test (a :: past) n x) := by + apply Finset.sum_congr rfl + intro a _ + by_cases ha : test past a <;> simp [ha] + rw [heq] + calc + _ = (Fintype.card A : ℝ)⁻¹ * + ∑ a : A, (if test past a then (1 : ℝ) else 0) * + ((Fintype.card A : ℝ)⁻¹ ^ n * + (∑ x : SplitSamples A n, sequentialSupport test (a :: past) n x)) := by + rw [Finset.mul_sum, Finset.mul_sum] + apply Finset.sum_congr rfl + intro a _ + ring + _ ≤ (Fintype.card A : ℝ)⁻¹ * + ∑ a : A, (if test past a then (1 : ℝ) else 0) * ρ ^ n := by + apply mul_le_mul_of_nonneg_left _ (inv_nonneg.mpr (Nat.cast_nonneg _)) + exact Finset.sum_le_sum fun a _ => + mul_le_mul_of_nonneg_left (ih (a :: past)) (by split_ifs <;> norm_num) + _ = ((Fintype.card A : ℝ)⁻¹ * + ∑ a : A, if test past a then (1 : ℝ) else 0) * ρ ^ n := by + rw [← Finset.sum_mul, mul_assoc] + _ ≤ ρ * ρ ^ n := mul_le_mul_of_nonneg_right (htest past) (pow_nonneg hρ n) + _ = ρ ^ (n + 1) := (pow_succ' ρ n).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedRightJacobiBasic.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedRightJacobiBasic.lean new file mode 100644 index 0000000000000000000000000000000000000000..af7d5a9643b5018638115974ccaa808f4a6b0224 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedRightJacobiBasic.lean @@ -0,0 +1,70 @@ +import Mathlib + +namespace OAI + +namespace Ostmann.Arithmetic + +def signedRightJacobi (n : ℤ) (m : ℕ) : ℤ := if Odd m then jacobiSym n m else 0 + +theorem signedRightJacobi_mod (n : ℤ) (m : ℕ) : + signedRightJacobi n m = signedRightJacobi n (m % (4 * n.natAbs)) := by + have hodd : Odd (m % (4 * n.natAbs)) ↔ Odd m := by + rw [Nat.odd_iff, Nat.odd_iff, Nat.mod_mod_of_dvd] + exact dvd_mul_of_dvd_left (by norm_num : 2 ∣ 4) n.natAbs + by_cases hm : Odd m + · simp only [signedRightJacobi, hm, hodd.mpr hm, ite_eq_left] + exact jacobiSym.mod_right n hm + · simp [signedRightJacobi, hm, hodd] + +theorem signedRightJacobi_periodic (n : ℤ) : + Function.Periodic (signedRightJacobi n) (4 * n.natAbs) := by + intro m + rw [signedRightJacobi_mod n (m + 4 * n.natAbs), Nat.add_mod_right, ← signedRightJacobi_mod] + +@[simp] theorem signedRightJacobi_one (n : ℤ) : signedRightJacobi n 1 = 1 := by + simp [signedRightJacobi] + +@[simp] theorem signedRightJacobi_zero (n : ℤ) : signedRightJacobi n 0 = 0 := by + simp [signedRightJacobi] + +theorem signedRightJacobi_mul (n : ℤ) (a b : ℕ) : + signedRightJacobi n (a * b) = signedRightJacobi n a * signedRightJacobi n b := by + by_cases ha : Odd a + · by_cases hb : Odd b + · simp only [signedRightJacobi, ha, hb, ha.mul hb, ite_eq_left] + exact jacobiSym.mul_right' n (by rintro rfl; simp at ha) (by rintro rfl; simp at hb) + · have hab : ¬ Odd (a * b) := by simpa [Nat.odd_mul, ha] using hb + simp [signedRightJacobi, hab, hb] + · have hab : ¬ Odd (a * b) := by simp [Nat.odd_mul, ha] + simp [signedRightJacobi, hab, ha] + +theorem signedRightJacobi_zero_of_not_coprime (n : ℤ) (m : ℕ) + (hc : ¬ Nat.Coprime m (4 * n.natAbs)) : signedRightJacobi n m = 0 := by + by_cases hm : Odd m + · simp only [signedRightJacobi, ite_eq_left hm] + have hm4 : Nat.Coprime m 4 := by + simpa using (Nat.coprime_two_right.mpr hm).pow_right 2 + have hmn : ¬ Nat.Coprime n.natAbs m := fun h => + hc (Nat.coprime_mul_iff_right.mpr ⟨hm4, h.symm⟩) + apply jacobiSym.eq_zero_iff.mpr + refine ⟨by rintro rfl; simp at hm, ?_⟩ + simpa only [Int.gcd_def, Int.natAbs_natCast, Nat.coprime_iff_gcd_eq_one] using hmn + · simp only [signedRightJacobi, ite_eq_right hm] + +theorem signedRightJacobi_trichotomy (n : ℤ) (m : ℕ) : + signedRightJacobi n m = 0 ∨ signedRightJacobi n m = 1 ∨ signedRightJacobi n m = -1 := by + unfold signedRightJacobi + split + · exact jacobiSym.trichotomy n m + · exact Or.inl rfl + +def signedRightJacobiResidue (n : ℤ) (a : ZMod (4 * n.natAbs)) : ℤ := + signedRightJacobi n a.val + +@[simp] theorem signedRightJacobiResidue_natCast (n : ℤ) (a : ℕ) : + signedRightJacobiResidue n (a : ZMod (4 * n.natAbs)) = signedRightJacobi n a := by + rw [signedRightJacobiResidue, ZMod.val_natCast, ← signedRightJacobi_mod] + +end Ostmann.Arithmetic + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedRightJacobiCharacter.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedRightJacobiCharacter.lean new file mode 100644 index 0000000000000000000000000000000000000000..0440d80cda02bed2f286395366b8a3071b4c6998 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedRightJacobiCharacter.lean @@ -0,0 +1,57 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SignedRightJacobiBasic + +namespace OAI + +namespace Ostmann.Arithmetic + +noncomputable def signedRightJacobiCharacterInt (n : ℤ) (hn : n ≠ 0) : + DirichletCharacter ℤ (4 * n.natAbs) := by + let : NeZero (4 * n.natAbs) := ⟨mul_ne_zero (by norm_num) (Int.natAbs_ne_zero.mpr hn)⟩ + exact { + toFun := signedRightJacobiResidue n + map_one' := by + simpa only [Nat.cast_one, signedRightJacobi_one] using signedRightJacobiResidue_natCast n 1 + map_mul' := by + intro a b + simp only [signedRightJacobiResidue, ZMod.val_mul, ← signedRightJacobi_mod, signedRightJacobi_mul] + map_nonunit' := by + intro a ha + apply signedRightJacobi_zero_of_not_coprime + intro hc + apply ha + simpa only [ZMod.natCast_zmod_val] using (ZMod.isUnit_iff_coprime a.val (4 * n.natAbs)).mpr hc } + +@[simp] theorem signedRightJacobiCharacterInt_natCast (n : ℤ) (hn : n ≠ 0) (a : ℕ) : + signedRightJacobiCharacterInt n hn (a : ZMod (4 * n.natAbs)) = signedRightJacobi n a := + signedRightJacobiResidue_natCast n a + +noncomputable def signedRightJacobiCharacter (n : ℤ) (hn : n ≠ 0) : + DirichletCharacter ℂ (4 * n.natAbs) := + (signedRightJacobiCharacterInt n hn).ringHomComp (Int.castRingHom ℂ) + +@[simp] theorem signedRightJacobiCharacter_natCast (n : ℤ) (hn : n ≠ 0) (a : ℕ) : + signedRightJacobiCharacter n hn (a : ZMod (4 * n.natAbs)) = (signedRightJacobi n a : ℂ) := by + simp only [signedRightJacobiCharacter, MulChar.ringHomComp_apply, + signedRightJacobiCharacterInt_natCast] + rfl + +theorem signedRightJacobiCharacter_natCast_of_odd (n : ℤ) (hn : n ≠ 0) + {a : ℕ} (ha : Odd a) : + signedRightJacobiCharacter n hn (a : ZMod (4 * n.natAbs)) = (jacobiSym n a : ℂ) := by + simp only [signedRightJacobiCharacter_natCast, signedRightJacobi, ite_eq_left ha] + +theorem signedRightJacobiCharacter_isQuadratic (n : ℤ) (hn : n ≠ 0) : + (signedRightJacobiCharacter n hn).IsQuadratic := by + let : NeZero (4 * n.natAbs) := ⟨mul_ne_zero (by norm_num) (Int.natAbs_ne_zero.mpr hn)⟩ + intro a + obtain ⟨a, rfl⟩ := ZMod.natCast_zmod_surjective a + rw [signedRightJacobiCharacter_natCast] + rcases signedRightJacobi_trichotomy n a with h | h | h <;> simp [h] + +@[simp] theorem signedRightJacobiCharacter_inv (n : ℤ) (hn : n ≠ 0) : + (signedRightJacobiCharacter n hn)⁻¹ = signedRightJacobiCharacter n hn := + (signedRightJacobiCharacter_isQuadratic n hn).inv + +end Ostmann.Arithmetic + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedRightJacobiNonsquare.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedRightJacobiNonsquare.lean new file mode 100644 index 0000000000000000000000000000000000000000..676d9428454f84942096e499d6840f790cb3575c --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedRightJacobiNonsquare.lean @@ -0,0 +1,75 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SignedRightJacobiCharacter +import OAI.NumberTheory.Ostmann.QuadraticCenter.RightJacobiNonsquare + +namespace OAI + +namespace Ostmann.Arithmetic + +theorem signedRightJacobi_negative_witness {N : ℕ} (hN : 0 < N) : + (4 * N - 1).Coprime (4 * N) ∧ + signedRightJacobi (-(N : ℤ)) (4 * N - 1) = -1 := by + let m := 4 * N - 1 + have hm : 3 ≤ m := by dsimp [m]; omega + have hsucc : m + 1 = 4 * N := by dsimp [m]; omega + have hm4 : m % 4 = 3 := by omega + have hodd : Odd m := Nat.odd_iff.mpr (Nat.odd_of_mod_four_eq_three hm4) + have hcop : m.Coprime (4 * N) := by + rw [← hsucc] + simp + refine ⟨hcop, ?_⟩ + change signedRightJacobi (-(N : ℤ)) m = -1 + have hcong : Nat.ModEq m (4 * N) 1 := by + change (4 * N) % m = 1 % m + rw [← hsucc, Nat.add_mod] + simp + have hjmul : jacobiSym ((4 * N : ℕ) : ℤ) m = 1 := by + rw [Ostmann.QuadraticSieve.jacobi_nat_modEq hcong] + simp + have htwo : (2 : ℤ).gcd (m : ℤ) = 1 := by + change ((2 : ℕ) : ℤ).gcd (m : ℤ) = 1 + rw [Int.gcd_natCast_natCast] + exact (Nat.coprime_two_left.mpr hodd).gcd_eq_one + have hjfour : jacobiSym 4 m = 1 := by + simpa using jacobiSym.sq_one' htwo + have hjN : jacobiSym (N : ℤ) m = 1 := by + simpa only [Nat.cast_mul, Nat.cast_ofNat, jacobiSym.mul_left, hjfour, one_mul] using hjmul + simp only [signedRightJacobi, ite_eq_left hodd, jacobiSym.neg _ hodd, + ZMod.χ₄_nat_three_mod_four hm4, hjN, mul_one] + +theorem exists_signedRightJacobi_nonresidue (n : ℤ) (hn : n ≠ 0) (hns : ¬ IsSquare n) : + ∃ a : ℕ, a.Coprime (4 * n.natAbs) ∧ signedRightJacobi n a = -1 := by + have hN : 0 < n.natAbs := Nat.pos_of_ne_zero (Int.natAbs_ne_zero.mpr hn) + by_cases hneg : n < 0 + · have heq : n = -(n.natAbs : ℤ) := by + rw [Int.natCast_natAbs, abs_of_neg hneg, neg_neg] + obtain ⟨hcop, hval⟩ := signedRightJacobi_negative_witness hN + exact ⟨4 * n.natAbs - 1, hcop, by simpa only [← heq] using hval⟩ + · have heq : n = (n.natAbs : ℤ) := Int.eq_natAbs_of_nonneg (le_of_not_gt hneg) + have hNns : ¬ IsSquare n.natAbs := by + intro hs + apply hns + rw [heq] + exact Int.isSquare_natCast_iff.mpr hs + obtain ⟨a, hac, ha⟩ := Ostmann.QuadraticCenter.exists_nonsquare_right_nonresidue hN hNns + refine ⟨a, hac, ?_⟩ + rw [heq] + exact ha + +theorem signedRightJacobiCharacter_ne_one (n : ℤ) (hn : n ≠ 0) (hns : ¬ IsSquare n) : + signedRightJacobiCharacter n hn ≠ 1 := by + obtain ⟨a, hac, ha⟩ := exists_signedRightJacobi_nonresidue n hn hns + intro h + have he := congrArg (fun χ : DirichletCharacter ℂ (4 * n.natAbs) => + χ (a : ZMod (4 * n.natAbs))) h + rw [signedRightJacobiCharacter_natCast, ha, + MulChar.one_apply ((ZMod.isUnit_iff_coprime a (4 * n.natAbs)).mpr hac)] at he + norm_num at he + +theorem signedRightJacobiCharacter_prime (n : ℤ) (hn : n ≠ 0) {p : ℕ} + (hp : p.Prime) (hp2 : p ≠ 2) : + signedRightJacobiCharacter n hn (p : ZMod (4 * n.natAbs)) = (jacobiSym n p : ℂ) := + signedRightJacobiCharacter_natCast_of_odd n hn (hp.odd_of_ne_two hp2) + +end Ostmann.Arithmetic + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedSplitSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedSplitSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..d3ea079904bb44d958463a0fda033f97eecdee98 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SignedSplitSupport.lean @@ -0,0 +1,78 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.JointSplitProbability + +namespace OAI + +/-! # Signed frequencies in the actual split-support equations -/ + +namespace Ostmann + +open scoped BigOperators Classical + +def frequencySignUnit (q : ℕ) (v : ℤ) : (ZMod q)ˣ := if 0 ≤ v then 1 else -1 + +theorem intCast_frequencySign (q : ℕ) (v : ℤ) : + (v : ZMod q) = (v.natAbs : ZMod q) * frequencySignUnit q v := by + by_cases hv : 0 ≤ v + · have he := congrArg (Int.castRingHom (ZMod q)) (Int.eq_natAbs_of_nonneg hv) + simpa only [frequencySignUnit, hv, ↓reduceIte, Units.val_one, mul_one, + Int.coe_castRingHom, Int.cast_natCast] using he + · have he := congrArg (Int.castRingHom (ZMod q)) + (Int.eq_neg_natAbs_of_nonpos (le_of_not_ge hv)) + simpa only [frequencySignUnit, hv, ↓reduceIte, Units.val_neg, Units.val_one, + Int.coe_castRingHom, Int.cast_neg, Int.cast_natCast, mul_neg, mul_one] using he + +theorem signed_coefficient_equation_iff {q : ℕ} (v w : ℤ) (x y : (ZMod q)ˣ) : + (v : ZMod q) * x = (w : ZMod q) * y ↔ + (v.natAbs : ZMod q) * (frequencySignUnit q v * x : (ZMod q)ˣ) = + (w.natAbs : ZMod q) * (frequencySignUnit q w * y : (ZMod q)ˣ) := by + rw [intCast_frequencySign q v, intCast_frequencySign q w] + simp only [Units.val_mul, mul_assoc] + +theorem common_reduced_modulus {s v w : ℕ} (h : v.gcd s = w.gcd s) : + reducedFrequency (v.gcd w) s = s / v.gcd s := by + have hg : (v.gcd w).gcd s = v.gcd s := by + rw [Nat.gcd_assoc, ← h, ← Nat.gcd_assoc, Nat.gcd_self] + simp only [reducedFrequency, Nat.gcd_comm s, hg] + +/-- Both signs are absorbed into fixed units, and impossible gcd patterns +contribute zero. Thus no soluble-pattern hypothesis is needed. -/ +theorem signed_joint_split_probability_le {s t Q : ℕ} [NeZero s] [NeZero t] [NeZero Q] + (hs : s ∣ Q) (ht : t ∣ Q) (v w v' w' : ℤ) + (A B P : (ZMod s)ˣ) (A' B' P' : (ZMod t)ˣ) : + (Fintype.card (ZMod Q)ˣ : ℝ)⁻¹ * (∑ x : (ZMod Q)ˣ, + if (v : ZMod s) * (A * (P / ZMod.unitsMap hs x) : (ZMod s)ˣ) = + (w : ZMod s) * (B * ZMod.unitsMap hs x : (ZMod s)ˣ) ∧ + (v' : ZMod t) * (A' * (P' / ZMod.unitsMap ht x) : (ZMod t)ˣ) = + (w' : ZMod t) * (B' * ZMod.unitsMap ht x : (ZMod t)ˣ) + then (1 : ℝ) else 0) ≤ + 2 * (((reducedFrequency (v.natAbs.gcd w.natAbs) s).lcm + (reducedFrequency (v'.natAbs.gcd w'.natAbs) t)).divisors.card : ℝ) ^ 2 / + (reducedFrequency (v.natAbs.gcd w.natAbs) s).lcm + (reducedFrequency (v'.natAbs.gcd w'.natAbs) t) := by + simp_rw [signed_coefficient_equation_iff, ← mul_assoc] + by_cases h : v.natAbs.gcd s = w.natAbs.gcd s + · by_cases h' : v'.natAbs.gcd t = w'.natAbs.gcd t + · rw [common_reduced_modulus h, common_reduced_modulus h'] + exact joint_split_probability_le hs ht v.natAbs w.natAbs v'.natAbs w'.natAbs h h' + (frequencySignUnit s v * A) (frequencySignUnit s w * B) P + (frequencySignUnit t v' * A') (frequencySignUnit t w' * B') P' + · have hz (x : (ZMod Q)ˣ) : ¬((v'.natAbs : ZMod t) * + ((frequencySignUnit t v' * A') * (P' / ZMod.unitsMap ht x) : (ZMod t)ˣ) = + (w'.natAbs : ZMod t) * + ((frequencySignUnit t w' * B') * ZMod.unitsMap ht x : (ZMod t)ˣ)) := by + intro he + exact h' (unit_coefficient_gcd_eq _ _ _ _ he) + simp only [hz, and_false, ↓reduceIte, Finset.sum_const_zero, mul_zero] + positivity + · have hz (x : (ZMod Q)ˣ) : ¬((v.natAbs : ZMod s) * + ((frequencySignUnit s v * A) * (P / ZMod.unitsMap hs x) : (ZMod s)ˣ) = + (w.natAbs : ZMod s) * + ((frequencySignUnit s w * B) * ZMod.unitsMap hs x : (ZMod s)ˣ)) := by + intro he + exact h (unit_coefficient_gcd_eq _ _ _ _ he) + simp only [hz, false_and, ↓reduceIte, Finset.sum_const_zero, mul_zero] + positivity + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SimultaneousSquares.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SimultaneousSquares.lean new file mode 100644 index 0000000000000000000000000000000000000000..5df309ace1669b4e90d8128324b15a90c5e44edc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SimultaneousSquares.lean @@ -0,0 +1,97 @@ +import OAI.NumberTheory.Ostmann.Tree.UniformGroupReduction + +namespace OAI + +/-! # The two simultaneous square congruences at a history split -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem unitsMap_eq_iff_modEq {q Q : ℕ} [NeZero Q] (h : q ∣ Q) + (x y : (ZMod Q)ˣ) : + ZMod.unitsMap h x = ZMod.unitsMap h y ↔ + Nat.ModEq q (x : ZMod Q).val (y : ZMod Q).val := by + rw [← Units.val_inj] + change ZMod.castHom h (ZMod q) (x : ZMod Q) = + ZMod.castHom h (ZMod q) (y : ZMod Q) ↔ _ + nth_rw 1 [← ZMod.natCast_zmod_val (x : ZMod Q), ← ZMod.natCast_zmod_val (y : ZMod Q)] + simp only [map_natCast, ZMod.natCast_eq_natCast_iff] + +theorem lcm_units_ext {a b : ℕ} [NeZero (a.lcm b)] (x y : (ZMod (a.lcm b))ˣ) + (ha : ZMod.unitsMap (Nat.dvd_lcm_left a b) x = ZMod.unitsMap (Nat.dvd_lcm_left a b) y) + (hb : ZMod.unitsMap (Nat.dvd_lcm_right a b) x = ZMod.unitsMap (Nat.dvd_lcm_right a b) y) : + x = y := by + have hma := (unitsMap_eq_iff_modEq (Nat.dvd_lcm_left a b) x y).mp ha + have hmb := (unitsMap_eq_iff_modEq (Nat.dvd_lcm_right a b) x y).mp hb + have hm := Nat.mod_lcm hma hmb + apply Units.ext + simpa only [ZMod.natCast_zmod_val] using + (ZMod.natCast_eq_natCast_iff (x : ZMod (a.lcm b)).val + (y : ZMod (a.lcm b)).val (a.lcm b)).mpr hm + +theorem simultaneous_square_probability_le {a b : ℕ} [NeZero a] [NeZero b] + [NeZero (a.lcm b)] (A : (ZMod a)ˣ) (B : (ZMod b)ˣ) : + (Fintype.card (ZMod (a.lcm b))ˣ : ℝ)⁻¹ * + (∑ x : (ZMod (a.lcm b))ˣ, + if (ZMod.unitsMap (Nat.dvd_lcm_left a b) x) ^ 2 = A ∧ + (ZMod.unitsMap (Nat.dvd_lcm_right a b) x) ^ 2 = B then (1 : ℝ) else 0) ≤ + 2 * ((a.lcm b).divisors.card : ℝ) ^ 2 / (a.lcm b) := by + let P := fun x : (ZMod (a.lcm b))ˣ => + (ZMod.unitsMap (Nat.dvd_lcm_left a b) x) ^ 2 = A ∧ + (ZMod.unitsMap (Nat.dvd_lcm_right a b) x) ^ 2 = B + by_cases hex : ∃ r, P r + · obtain ⟨r, hr⟩ := hex + have heq (x : (ZMod (a.lcm b))ˣ) : P x ↔ x ^ 2 = r ^ 2 := by + constructor + · intro hx + apply lcm_units_ext + · simp only [map_pow] + exact hx.1.trans hr.1.symm + · simp only [map_pow] + exact hx.2.trans hr.2.symm + · intro hx + constructor + · have ht := congrArg (ZMod.unitsMap (Nat.dvd_lcm_left a b)) hx + rw [map_pow, map_pow] at ht + exact ht.trans hr.1 + · have ht := congrArg (ZMod.unitsMap (Nat.dvd_lcm_right a b)) hx + rw [map_pow, map_pow] at ht + exact ht.trans hr.2 + change (Fintype.card (ZMod (a.lcm b))ˣ : ℝ)⁻¹ * (∑ x, if P x then 1 else 0) ≤ _ + simp_rw [heq] + have hs : (∑ x : (ZMod (a.lcm b))ˣ, if x ^ 2 = r ^ 2 then (1 : ℝ) else 0) = + (Nat.card {x : (ZMod (a.lcm b))ˣ // x ^ 2 = r ^ 2} : ℝ) := by + rw [Nat.card_eq_fintype_card, Fintype.card_subtype] + simp only [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one] + rw [hs, mul_comm, ← div_eq_mul_inv] + exact unit_square_probability_le (a.lcm b) (r ^ 2) + · have hn : ∀ x, ¬P x := by simpa only [not_exists] using hex + change (Fintype.card (ZMod (a.lcm b))ˣ : ℝ)⁻¹ * (∑ x, if P x then 1 else 0) ≤ _ + simp only [hn, ↓reduceIte, Finset.sum_const_zero, mul_zero] + positivity + +/-- The support probability under the original larger Haar modulus, before +conditioning on any history tests. -/ +theorem reduced_simultaneous_square_probability_le {a b Q : ℕ} + [NeZero a] [NeZero b] [NeZero Q] + (ha : a ∣ Q) (hb : b ∣ Q) (A : (ZMod a)ˣ) (B : (ZMod b)ˣ) : + (Fintype.card (ZMod Q)ˣ : ℝ)⁻¹ * + (∑ x : (ZMod Q)ˣ, + if (ZMod.unitsMap ha x) ^ 2 = A ∧ (ZMod.unitsMap hb x) ^ 2 = B then (1 : ℝ) else 0) ≤ + 2 * ((a.lcm b).divisors.card : ℝ) ^ 2 / (a.lcm b) := by + let _ : NeZero (a.lcm b) := ⟨Nat.lcm_ne_zero (NeZero.ne a) (NeZero.ne b)⟩ + have hL : a.lcm b ∣ Q := Nat.lcm_dvd ha hb + have hleft (x : (ZMod Q)ˣ) : ZMod.unitsMap (Nat.dvd_lcm_left a b) (ZMod.unitsMap hL x) = + ZMod.unitsMap ha x := DFunLike.congr_fun (ZMod.unitsMap_comp (Nat.dvd_lcm_left a b) hL) x + have hright (x : (ZMod Q)ˣ) : ZMod.unitsMap (Nat.dvd_lcm_right a b) (ZMod.unitsMap hL x) = + ZMod.unitsMap hb x := DFunLike.congr_fun (ZMod.unitsMap_comp (Nat.dvd_lcm_right a b) hL) x + have heq := unit_reduction_average hL (fun x => + if (ZMod.unitsMap (Nat.dvd_lcm_left a b) x) ^ 2 = A ∧ + (ZMod.unitsMap (Nat.dvd_lcm_right a b) x) ^ 2 = B then (1 : ℝ) else 0) + simp only [hleft, hright] at heq + exact heq.trans_le (simultaneous_square_probability_le A B) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleFrequencyModulus.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleFrequencyModulus.lean new file mode 100644 index 0000000000000000000000000000000000000000..00dd3fe3ee3273f82ff74b8a191f853ee8fc1b8a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleFrequencyModulus.lean @@ -0,0 +1,133 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SingleFrequencyTree + +namespace OAI + +/-! # The modulus attached to one fixed frequency history -/ + +namespace Ostmann + +open scoped BigOperators Classical + +/-- The product includes every internal frequency and every leaf frequency, +with multiplicity, exactly as in the residue-precision argument. -/ +def historyFrequencyProduct (S : Finset ℤ) : (n : ℕ) → FrequencyTree S n → ℕ + | 0, s => (show S from s).val.natAbs + | n + 1, t => (t.1 : ℤ).natAbs * historyFrequencyProduct S n t.2.1 * + historyFrequencyProduct S n t.2.2 + +def historyFrequencyModulus (S : Finset ℤ) (n k : ℕ) (t : FrequencyTree S n) : ℕ := + historyFrequencyProduct S n t ^ (k + 2) + +theorem historyFrequencyProduct_pos (S : Finset ℤ) (hS : ∀ s ∈ S, s ≠ 0) + (n : ℕ) (t : FrequencyTree S n) : 0 < historyFrequencyProduct S n t := by + induction n with + | zero => exact Int.natAbs_pos.mpr (hS _ t.property) + | succ n ih => + exact Nat.mul_pos + (Nat.mul_pos (Int.natAbs_pos.mpr (hS _ t.1.property)) (ih _)) (ih _) + +theorem historyFrequencyModulus_pos (S : Finset ℤ) (hS : ∀ s ∈ S, s ≠ 0) + (n k : ℕ) (t : FrequencyTree S n) : 0 < historyFrequencyModulus S n k t := + pow_pos (historyFrequencyProduct_pos S hS n t) _ + +theorem historyFrequencyProduct_le (S : Finset ℤ) (N : ℕ) + (hS : ∀ s ∈ S, s.natAbs ≤ N) (n : ℕ) (t : FrequencyTree S n) : + historyFrequencyProduct S n t ≤ N ^ (2 ^ (n + 1) - 1) := by + induction n with + | zero => simpa [historyFrequencyProduct] using hS _ t.property + | succ n ih => + have he : 2 ^ (n + 1 + 1) - 1 = 1 + (2 ^ (n + 1) - 1) + (2 ^ (n + 1) - 1) := by + have hp : 1 ≤ 2 ^ (n + 1) := Nat.one_le_two_pow + rw [pow_succ] + omega + calc + _ ≤ N * N ^ (2 ^ (n + 1) - 1) * N ^ (2 ^ (n + 1) - 1) := + Nat.mul_le_mul (Nat.mul_le_mul (hS _ t.1.property) (ih _)) (ih _) + _ = _ := by rw [he]; simp only [pow_add, pow_one] + +theorem historyFrequencyModulus_le (S : Finset ℤ) (N : ℕ) + (hS : ∀ s ∈ S, s.natAbs ≤ N) (n k : ℕ) (t : FrequencyTree S n) : + historyFrequencyModulus S n k t ≤ N ^ ((2 ^ (n + 1) - 1) * (k + 2)) := by + simpa only [historyFrequencyModulus, pow_mul] using + Nat.pow_le_pow_left (historyFrequencyProduct_le S N hS n t) (k + 2) + +theorem history_root_dvd_frequencyProduct (S : Finset ℤ) (n : ℕ) (t : FrequencyTree S n) : + ((frequencyRoot n t : S) : ℤ).natAbs ∣ historyFrequencyProduct S n t := by + cases n with + | zero => + change t.val.natAbs ∣ t.val.natAbs + exact dvd_rfl + | succ n => + change (t.1 : ℤ).natAbs ∣ (t.1 : ℤ).natAbs * _ * _ + exact dvd_mul_of_dvd_left (dvd_mul_right (t.1 : ℤ).natAbs _) _ + +theorem singleFrequencySplitList_root_mem (S : Finset ℤ) (n : ℕ) (t : FrequencyTree S n) + (f : NodeFrequencies) (hf : f ∈ singleFrequencySplitList S n t) : f.root ∈ S := by + induction n with + | zero => simp [singleFrequencySplitList] at hf + | succ n ih => + simp only [singleFrequencySplitList, List.mem_cons, List.mem_append] at hf + rcases hf with rfl | hf | hf + · exact t.1.property + · exact ih _ hf + · exact ih _ hf + +theorem singleTreeNodeFrequencies_root_mem (S : Finset ℤ) (n : ℕ) (t : FrequencyTree S n) + (j : ℕ) (hj : j < 2 ^ n - 1) : (singleTreeNodeFrequencies S n t j).root ∈ S := by + apply singleFrequencySplitList_root_mem S n t + have hj' : j < (singleFrequencySplitList S n t).length := by + simpa only [singleFrequencySplitList_length] using hj + rw [singleTreeNodeFrequencies, List.getD_eq_getElem _ _ hj'] + exact List.getElem_mem hj' + +theorem history_node_dvd_frequencyProduct (S : Finset ℤ) (n : ℕ) (t : FrequencyTree S n) + (f : NodeFrequencies) (hf : f ∈ singleFrequencySplitList S n t) : + f.root.natAbs ∣ historyFrequencyProduct S n t := by + induction n with + | zero => simp [singleFrequencySplitList] at hf + | succ n ih => + simp only [singleFrequencySplitList, List.mem_cons, List.mem_append] at hf + rcases hf with rfl | hf | hf + · exact dvd_mul_of_dvd_left (dvd_mul_right _ _) _ + · exact dvd_mul_of_dvd_left (dvd_mul_of_dvd_right (ih _ hf) _) _ + · exact dvd_mul_of_dvd_right (ih _ hf) _ + +theorem history_node_dvd_frequencyModulus (S : Finset ℤ) (n k : ℕ) (t : FrequencyTree S n) + (f : NodeFrequencies) (hf : f ∈ singleFrequencySplitList S n t) : + f.root.natAbs ∣ historyFrequencyModulus S n k t := + (history_node_dvd_frequencyProduct S n t f hf).trans (dvd_pow_self _ (by omega)) + +/-- All actual primes exceed the frequency range. Consequently they are +units for the full history modulus, including its precision exponent. -/ +theorem prime_coprime_historyFrequencyModulus (S : Finset ℤ) (N p : ℕ) + (hp : p.Prime) (hpN : N < p) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) (n k : ℕ) (t : FrequencyTree S n) : + p.Coprime (historyFrequencyModulus S n k t) := by + have hfreq (s : S) : p.Coprime (s : ℤ).natAbs := by + apply hp.coprime_iff_not_dvd.mpr + intro hd + have hpos : 0 < (s : ℤ).natAbs := Int.natAbs_pos.mpr (hS _ s.property).1 + have hle := Nat.le_of_dvd hpos hd + have hbound := (hS _ s.property).2 + omega + have hprod : p.Coprime (historyFrequencyProduct S n t) := by + induction n with + | zero => exact hfreq t + | succ n ih => exact (hfreq t.1).mul_right (ih t.2.1) |>.mul_right (ih t.2.2) + exact hprod.pow_right (k + 2) + +theorem historyFrequencyModulus_le_exp (S : Finset ℤ) (N n k : ℕ) (C m : ℝ) + (hS : ∀ s ∈ S, s.natAbs ≤ N) (hN : (N : ℝ) ≤ Real.exp (C * m)) + (t : FrequencyTree S n) : + (historyFrequencyModulus S n k t : ℝ) ≤ + Real.exp (((2 ^ (n + 1) - 1) * (k + 2) : ℕ) * (C * m)) := by + calc + _ ≤ (N : ℝ) ^ ((2 ^ (n + 1) - 1) * (k + 2)) := by + exact_mod_cast historyFrequencyModulus_le S N hS n k t + _ ≤ Real.exp (C * m) ^ ((2 ^ (n + 1) - 1) * (k + 2)) := + pow_le_pow_left₀ (Nat.cast_nonneg _) hN _ + _ = _ := (Real.exp_nat_mul _ _).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleFrequencyTree.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleFrequencyTree.lean new file mode 100644 index 0000000000000000000000000000000000000000..11c004854a182b92503b34a0f69325ad7400ca69 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleFrequencyTree.lean @@ -0,0 +1,159 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.FrequencyTreeNodes + +namespace OAI + +/-! # The frequency budget for one squared history + +Unlike a pair of histories, this sum has exactly one frequency at each leaf. +This is needed before the level-zero square-weight cancellation. +-/ + +namespace Ostmann + +open scoped BigOperators Classical + +noncomputable def singleFrequencyKernel (S : Finset ℤ) (D : ℝ) + (root left right : S) : ℝ := + 2 * D ^ 2 / reducedFrequency ((left : ℤ).natAbs.gcd (right : ℤ).natAbs) (root : ℤ).natAbs + +noncomputable def singleFrequencyLeaf (S : Finset ℤ) (V : ℕ) (x : S) : ℝ := + if (x : ℤ).natAbs ≤ V then 1 else 0 + +theorem signed_reducedFrequency_sum_le (S : Finset ℤ) (N g : ℕ) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) (hg : g ≠ 0) : + (∑ s ∈ S, ((reducedFrequency g s.natAbs : ℕ) : ℝ)⁻¹) ≤ + 2 * (g.divisors.card : ℝ) * (1 + Real.log N) := by + have hh : (∑ a ∈ Finset.Icc 1 N, (a : ℝ)⁻¹) ≤ 1 + Real.log N := by + simpa only [harmonic_eq_sum_Icc, Rat.cast_sum, Rat.cast_inv, Rat.cast_natCast] using harmonic_le_one_add_log N + calc + _ ≤ 2 * ∑ a ∈ Finset.Icc 1 N, ((reducedFrequency g a : ℕ) : ℝ)⁻¹ := + sum_signed_magnitudes_le S N hS _ (fun _ _ => by positivity) + _ ≤ 2 * ((g.divisors.card : ℝ) * ∑ a ∈ Finset.Icc 1 N, (a : ℝ)⁻¹) := + mul_le_mul_of_nonneg_left (sum_reducedFrequency_le N g hg + (fun a => (a : ℝ)⁻¹) (fun _ _ => by positivity)) (by norm_num) + _ ≤ _ := by + have := mul_le_mul_of_nonneg_left hh (show 0 ≤ (g.divisors.card : ℝ) by positivity) + nlinarith + +theorem singleFrequencyKernel_sum_le (S : Finset ℤ) (N : ℕ) (D : ℝ) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) + (hdiv : ∀ v ∈ S, ∀ w ∈ S, ((v.natAbs.gcd w.natAbs).divisors.card : ℝ) ≤ D) + (left right : S) : + (∑ root : S, singleFrequencyKernel S D root left right) ≤ + 4 * D ^ 3 * (1 + Real.log N) := by + let g := (left : ℤ).natAbs.gcd (right : ℤ).natAbs + have hg : g ≠ 0 := Nat.ne_of_gt (Nat.gcd_pos_of_pos_left _ + (Int.natAbs_pos.mpr (hS _ left.property).1)) + have hb := signed_reducedFrequency_sum_le S N g hS hg + have hd : (g.divisors.card : ℝ) ≤ D := hdiv _ left.property _ right.property + calc + _ = 2 * D ^ 2 * (∑ s ∈ S, ((reducedFrequency g s.natAbs : ℕ) : ℝ)⁻¹) := by + unfold singleFrequencyKernel + simp only [div_eq_mul_inv, ← Finset.mul_sum] + rw [Finset.sum_coe_sort S (fun s : ℤ => ((reducedFrequency g s.natAbs : ℕ) : ℝ)⁻¹)] + _ ≤ 2 * D ^ 2 * (2 * (g.divisors.card : ℝ) * (1 + Real.log N)) := + mul_le_mul_of_nonneg_left hb (by positivity) + _ ≤ 2 * D ^ 2 * (2 * D * (1 + Real.log N)) := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_left hd (by norm_num)) + (by have := Real.log_natCast_nonneg N; positivity) + _ = _ := by ring + +theorem singleFrequencyLeaf_sum_le (S : Finset ℤ) (V : ℕ) + (hS : ∀ s ∈ S, s ≠ 0) : + (∑ x : S, singleFrequencyLeaf S V x) ≤ 2 * V := by + let T := S.filter fun s => s.natAbs ≤ V + have hT : ∀ s ∈ T, s ≠ 0 ∧ s.natAbs ≤ V := by + intro s hs + exact ⟨hS s (Finset.mem_filter.mp hs).1, (Finset.mem_filter.mp hs).2⟩ + have hb := sum_signed_magnitudes_le T V hT (fun _ => (1 : ℝ)) (by intros; norm_num) + unfold singleFrequencyLeaf + rw [Finset.sum_coe_sort S (fun s : ℤ => if s.natAbs ≤ V then (1 : ℝ) else 0)] + simpa [← Finset.sum_filter, T] using hb + +theorem single_frequency_tree_sum_le (S : Finset ℤ) (N V n : ℕ) (D : ℝ) + (hD : 0 ≤ D) (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) + (hdiv : ∀ v ∈ S, ∀ w ∈ S, ((v.natAbs.gcd w.natAbs).divisors.card : ℝ) ≤ D) : + (∑ x : FrequencyTree S n, + frequencyTreeWeight (singleFrequencyKernel S D) (singleFrequencyLeaf S V) n x) ≤ + (4 * D ^ 3 * (1 + Real.log N)) ^ (2 ^ n - 1) * (2 * (V : ℝ)) ^ (2 ^ n) := by + have hC : 0 ≤ 4 * D ^ 3 * (1 + Real.log N) := by + have := Real.log_natCast_nonneg N + positivity + apply (frequencyTree_sum_le (singleFrequencyKernel S D) (singleFrequencyLeaf S V) + _ (by intros; unfold singleFrequencyKernel; positivity) + (by intros; unfold singleFrequencyLeaf; split_ifs <;> norm_num) hC + (singleFrequencyKernel_sum_le S N D hS hdiv) n).trans + exact mul_le_mul_of_nonneg_left + (pow_le_pow_left₀ (Finset.sum_nonneg fun x _ => by + unfold singleFrequencyLeaf; split_ifs <;> norm_num) + (singleFrequencyLeaf_sum_le S V (fun s hs => (hS s hs).1)) _) (pow_nonneg hC _) + +def singleFrequencySplitList (S : Finset ℤ) : (n : ℕ) → + FrequencyTree S n → List NodeFrequencies + | 0, _ => [] + | n + 1, x => ⟨x.1, (frequencyRoot n x.2.1 : S), (frequencyRoot n x.2.2 : S)⟩ :: + (singleFrequencySplitList S n x.2.1 ++ singleFrequencySplitList S n x.2.2) + +theorem singleFrequencySplitList_length (S : Finset ℤ) (n : ℕ) (x : FrequencyTree S n) : + (singleFrequencySplitList S n x).length = 2 ^ n - 1 := by + induction n with + | zero => rfl + | succ n ih => + simp only [singleFrequencySplitList, List.length_cons, List.length_append, ih] + have hp : 1 ≤ 2 ^ n := Nat.one_le_two_pow + rw [pow_succ] + omega + +noncomputable def singleFrequencySupportBound (D : ℝ) (f : NodeFrequencies) : ℝ := + 2 * D ^ 2 / f.reducedModulus + +theorem singleFrequencyTreeWeight_eq (S : Finset ℤ) (D : ℝ) (W : S → ℝ) + (n : ℕ) (x : FrequencyTree S n) : + frequencyTreeWeight (singleFrequencyKernel S D) W n x = + ((singleFrequencySplitList S n x).map (singleFrequencySupportBound D)).prod * + frequencyLeafWeight W n x := by + induction n with + | zero => simp [frequencyTreeWeight, singleFrequencySplitList, frequencyLeafWeight] + | succ n ih => + simp only [frequencyTreeWeight, singleFrequencySplitList, frequencyLeafWeight, + List.map_cons, List.map_append, List.prod_cons, List.prod_append, ih, + singleFrequencySupportBound, singleFrequencyKernel, NodeFrequencies.reducedModulus] + ring + +def singleTreeNodeFrequencies (S : Finset ℤ) (n : ℕ) (x : FrequencyTree S n) + (j : ℕ) : NodeFrequencies := + (singleFrequencySplitList S n x).getD j emptyNodeFrequencies + +theorem singleFrequencySplitList_modulus_mem (S : Finset ℤ) (N : ℕ) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) (n : ℕ) (x : FrequencyTree S n) + (f : NodeFrequencies) (hf : f ∈ singleFrequencySplitList S n x) : + f.reducedModulus ∈ Finset.Icc 1 N := by + induction n with + | zero => simp [singleFrequencySplitList] at hf + | succ n ih => + simp only [singleFrequencySplitList, List.mem_cons, List.mem_append] at hf + rcases hf with rfl | hf | hf + · exact reducedFrequency_mem (Finset.mem_Icc.mpr + ⟨Int.natAbs_pos.mpr (hS _ x.1.property).1, (hS _ x.1.property).2⟩) + · exact ih _ hf + · exact ih _ hf + +theorem singleTreeNodeFrequencies_divisor_bound (S : Finset ℤ) (N : ℕ) (D : ℝ) + (hD : 0 ≤ D) (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) + (n : ℕ) (x : FrequencyTree S n) (j : ℕ) : + (((singleTreeNodeFrequencies S n x j).reducedModulus).divisors.card : ℝ) ≤ D := by + by_cases hj : j < (singleFrequencySplitList S n x).length + · have hmem : singleTreeNodeFrequencies S n x j ∈ singleFrequencySplitList S n x := by + rw [singleTreeNodeFrequencies, List.getD_eq_getElem _ _ hj] + exact List.getElem_mem hj + obtain ⟨hpos, hle⟩ := Finset.mem_Icc.mp (singleFrequencySplitList_modulus_mem S N hS n x _ hmem) + apply hdiv _ (Nat.ne_of_gt hpos) + exact hle.trans (by nlinarith) + · rw [singleTreeNodeFrequencies, List.getD_eq_default _ _ (by omega)] + simpa [emptyNodeFrequencies, NodeFrequencies.reducedModulus, reducedFrequency] using hD + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleHistoryRates.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleHistoryRates.lean new file mode 100644 index 0000000000000000000000000000000000000000..7c417bb90688fad97e6949e6b2b7d90471060be0 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleHistoryRates.lean @@ -0,0 +1,128 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.HarmonicHistorySupport +import OAI.NumberTheory.Ostmann.Arithmetic.FrequencyBudgetRates +import OAI.NumberTheory.Ostmann.Arithmetic.LeafFrequencyBudget + +namespace OAI + +/-! # Cancellation of the single-history leaf frequency cost -/ + +namespace Ostmann + +open Filter + +/-- Unlike the two-history comparison, this cancels every leading copy +of Delta against the squared level-zero weight. -/ +theorem single_leaf_frequency_cancellation (r V : ℕ) (Δ m K : ℝ) + (hV : (V : ℝ) ≤ Real.exp (Δ + Real.sqrt m)) : + (2 * (V : ℝ)) ^ r * Real.exp (-(r : ℝ) * Δ + K) ≤ + Real.exp ((r : ℝ) * Real.sqrt m + r * Real.log 2 + K) := by + calc + _ ≤ (2 * Real.exp (Δ + Real.sqrt m)) ^ r * Real.exp (-(r : ℝ) * Δ + K) := + mul_le_mul_of_nonneg_right (pow_le_pow_left₀ (by positivity) (by linarith) _) (Real.exp_pos _).le + _ = _ := by + nth_rw 1 [show (2 : ℝ) = Real.exp (Real.log 2) by rw [Real.exp_log (by norm_num)]] + rw [← Real.exp_add, ← Real.exp_nat_mul, ← Real.exp_add] + congr 1 + ring + +theorem single_leaf_frequency_budget_sublinear (r : ℕ) (K ε : ℝ) (hε : 0 < ε) : + ∃ M : ℝ, ∀ m : ℝ, M ≤ m → ∀ Δ : ℝ, ∀ V : ℕ, + (V : ℝ) ≤ Real.exp (Δ + Real.sqrt m) → + (2 * (V : ℝ)) ^ r * Real.exp (-(r : ℝ) * Δ + K) ≤ Real.exp (ε * m) := by + obtain ⟨M, hM⟩ := sqrt_cost_sublinear r (r * Real.log 2 + K) ε (by positivity) hε + refine ⟨M, fun m hm Δ V hV => (single_leaf_frequency_cancellation r V Δ m K hV).trans ?_⟩ + apply Real.exp_le_exp.mpr + linarith [hM m hm] + +theorem single_frequency_budget_subexponential (C ε : ℝ) (hC : 0 ≤ C) (hε : 0 < ε) : + ∀ᶠ m : ℝ in atTop, ∃ D : ℝ, 1 ≤ D ∧ + (∀ n : ℕ, n ≠ 0 → (n : ℝ) ≤ Real.exp (2 * C * m) → (n.divisors.card : ℝ) ≤ D) ∧ + (∀ N : ℕ, (N : ℝ) ≤ Real.exp (C * m) → + 4 * D ^ 3 * (1 + Real.log N) ≤ Real.exp (ε * m)) := by + filter_upwards [frequency_budget_subexponential C ε hC hε, + eventually_ge_atTop (0 : ℝ)] with m hm hm0 + obtain ⟨D, hD, hdiv, hcost⟩ := hm + have hD1 : 1 ≤ D := by + have h1 := hdiv 1 (by norm_num) (by simpa using Real.one_le_exp (mul_nonneg (by positivity) hm0)) + simpa using h1 + refine ⟨D, hD1, hdiv, fun N hN => ?_⟩ + have hL : 1 ≤ 1 + Real.log N := by linarith [Real.log_natCast_nonneg N] + have hpD : D ^ 3 ≤ D ^ 4 := pow_le_pow_right₀ hD1 (by norm_num) + have hpL : 1 + Real.log N ≤ (1 + Real.log N) ^ 3 := by + simpa using pow_le_pow_right₀ hL (show 1 ≤ 3 by norm_num) + apply le_trans _ (hcost N hN) + calc + _ ≤ 8 * D ^ 3 * (1 + Real.log N) := by + apply mul_le_mul_of_nonneg_right _ (by linarith) + exact mul_le_mul_of_nonneg_right (by norm_num) (pow_nonneg hD 3) + _ ≤ 8 * D ^ 4 * (1 + Real.log N) ^ 3 := by gcongr + +/-- A single divisor bound works for every history and every permissible +frequency range. The numerical estimate is independent of its residue modulus. -/ +theorem single_history_budget_parameters (n : ℕ) (K C ε : ℝ) + (hC : 0 ≤ C) (hε : 0 < ε) : + ∀ᶠ m : ℝ in atTop, ∃ D : ℝ, 0 ≤ D ∧ + (∀ q : ℕ, q ≠ 0 → (q : ℝ) ≤ Real.exp (2 * C * m) → (q.divisors.card : ℝ) ≤ D) ∧ + (∀ N V : ℕ, ∀ Δ : ℝ, (N : ℝ) ≤ Real.exp (C * m) → + (V : ℝ) ≤ Real.exp (Δ + Real.sqrt m) → + Real.exp (-(2 ^ n : ℕ) * Δ + K) * + ((4 * D ^ 3 * (1 + Real.log N)) ^ (2 ^ n - 1) * (2 * (V : ℝ)) ^ (2 ^ n)) ≤ + Real.exp (ε * m)) := by + let r : ℕ := 2 ^ n + let δ : ℝ := ε / (2 * r) + have hr : (0 : ℝ) < r := by exact_mod_cast Nat.two_pow_pos n + have hδ : 0 < δ := div_pos hε (by positivity) + have hδr : δ * r = ε / 2 := by dsimp [δ]; field_simp + obtain ⟨M, hM⟩ := single_leaf_frequency_budget_sublinear r K (ε / 2) (by positivity) + filter_upwards [single_frequency_budget_subexponential C δ hC hδ, + eventually_ge_atTop M, eventually_ge_atTop (0 : ℝ)] with m hrate hm hm0 + obtain ⟨D, hD, hdiv, hcost⟩ := hrate + have hD0 : 0 ≤ D := le_trans (by norm_num) hD + refine ⟨D, hD0, hdiv, fun N V Δ hN hV => ?_⟩ + have hnode : (4 * D ^ 3 * (1 + Real.log N)) ^ (r - 1) ≤ Real.exp ((ε / 2) * m) := by + calc + _ ≤ Real.exp (δ * m) ^ (r - 1) := pow_le_pow_left₀ (by + have := Real.log_natCast_nonneg N + positivity) (hcost N hN) _ + _ = Real.exp ((r - 1 : ℕ) * (δ * m)) := (Real.exp_nat_mul _ _).symm + _ ≤ _ := by + apply Real.exp_le_exp.mpr + have hcount : ((r - 1 : ℕ) : ℝ) ≤ r := by exact_mod_cast Nat.sub_le r 1 + have hh := mul_le_mul_of_nonneg_right hcount (mul_nonneg hδ.le hm0) + nlinarith [hδr] + have hleaf := hM m hm Δ V hV + calc + _ = (4 * D ^ 3 * (1 + Real.log N)) ^ (r - 1) * + ((2 * (V : ℝ)) ^ r * Real.exp (-(r : ℝ) * Δ + K)) := by ring + _ ≤ Real.exp ((ε / 2) * m) * Real.exp ((ε / 2) * m) := + mul_le_mul hnode hleaf (by positivity) (Real.exp_pos _).le + _ = _ := by rw [← Real.exp_add]; congr 1; ring + +/-- The one-history arithmetic sum, including its square-weight factor, +is subexponential. This bound is uniform in the choice of residue modulus. -/ +theorem single_arithmetic_support_rate {Q : ℕ} [NeZero Q] + (n : ℕ) (K C ε : ℝ) (hC : 0 ≤ C) (hε : 0 < ε) : + ∀ᶠ m : ℝ in atTop, ∀ N V : ℕ, ∀ Δ : ℝ, ∀ S : Finset ℤ, + (N : ℝ) ≤ Real.exp (C * m) → + (V : ℝ) ≤ Real.exp (Δ + Real.sqrt m) → + (∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) → + ∀ data : FrequencyTree S n → (ZMod Q)ˣ → List (ZMod Q)ˣ → Option (ArithmeticSplitData Q), + (∀ t P past d, data t P past = some d → + d.hasFrequencies (singleTreeNodeFrequencies S n t past.length)) → + Real.exp (-(2 ^ n : ℕ) * Δ + K) * singleArithmeticSupportSum S V n data ≤ Real.exp (ε * m) := by + filter_upwards [single_history_budget_parameters n K C ε hC hε] with m hm + obtain ⟨D, hD, hdiv, hbudget⟩ := hm + intro N V Δ S hN hV hS data hmatch + have hdivN (q : ℕ) (hq : q ≠ 0) (hqN : q ≤ N ^ 2) : (q.divisors.card : ℝ) ≤ D := by + apply hdiv q hq + calc + (q : ℝ) ≤ (N : ℝ) ^ 2 := by exact_mod_cast hqN + _ ≤ Real.exp (C * m) ^ 2 := pow_le_pow_left₀ (Nat.cast_nonneg _) hN 2 + _ = Real.exp (2 * C * m) := by rw [← Real.exp_nat_mul]; congr 1; ring + exact (mul_le_mul_of_nonneg_left + (single_arithmetic_support_sum_le S N V n D hD hS hdivN data hmatch) + (Real.exp_pos _).le).trans (hbudget N V Δ hN hV) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleHistorySupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleHistorySupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..6300e1c308382791e1bc0bea57ee9be6d67f5910 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SingleHistorySupport.lean @@ -0,0 +1,151 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SingleFrequencyTree +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticHistorySupportSum +import OAI.NumberTheory.Ostmann.Characters.TreeProductDisintegration + +namespace OAI + +/-! # Exact one-history arithmetic support under independent uniform leaves -/ + +namespace Ostmann + +open scoped BigOperators Classical + +def diagonalSplitData {Q : ℕ} (d : Option (ArithmeticSplitData Q)) : + Option (ArithmeticSplitData Q × ArithmeticSplitData Q) := d.map fun e => (e, e) + +def singleArithmeticSplitTest {Q : ℕ} (d : Option (ArithmeticSplitData Q)) + (x : (ZMod Q)ˣ) : Prop := match d with + | none => False + | some e => e.test x + +theorem diagonalSplitData_test {Q : ℕ} (d : Option (ArithmeticSplitData Q)) + (x : (ZMod Q)ˣ) : + arithmeticPairSplitTest (diagonalSplitData d) x ↔ singleArithmeticSplitTest d x := by + cases d <;> simp [diagonalSplitData, arithmeticPairSplitTest, singleArithmeticSplitTest] + +noncomputable def singleArithmeticLeafSupport {Q : ℕ} [NeZero Q] + (n : ℕ) (data : (ZMod Q)ˣ → List (ZMod Q)ˣ → Option (ArithmeticSplitData Q)) + (x : TreeLeafTuple (ZMod Q)ˣ n) : ℝ := + sequentialSupport (fun past y => singleArithmeticSplitTest (data (treeLeafProduct n x) past) y) + [] (2 ^ n - 1) (treeLeafSplitEquiv n (treeLeafProduct n x) ⟨x, rfl⟩) + +theorem singleArithmeticLeafSupport_nonneg {Q : ℕ} [NeZero Q] + (n : ℕ) (data : (ZMod Q)ˣ → List (ZMod Q)ˣ → Option (ArithmeticSplitData Q)) + (x : TreeLeafTuple (ZMod Q)ˣ n) : 0 ≤ singleArithmeticLeafSupport n data x := + sequentialSupport_nonneg _ _ _ _ + +/-- The already proved joint root bound, applied twice to the same test, +loses no additional frequency choices or support conditions. -/ +theorem single_arithmetic_leaf_support_le {Q : ℕ} [NeZero Q] + (data : List (ZMod Q)ˣ → Option (ArithmeticSplitData Q)) + (frequencies : ℕ → NodeFrequencies) (D : ℝ) (hD : 0 ≤ D) + (hmatch : ∀ past d, data past = some d → d.hasFrequencies (frequencies past.length)) + (hdiv : ∀ j, ((frequencies j).reducedModulus.divisors.card : ℝ) ≤ D) + (n : ℕ) (P : (ZMod Q)ˣ) : + (Fintype.card (TreeLeafFiber (ZMod Q)ˣ n P) : ℝ)⁻¹ * + (∑ x : TreeLeafFiber (ZMod Q)ˣ n P, + sequentialSupport (fun past y => singleArithmeticSplitTest (data past) y) [] + (2 ^ n - 1) (treeLeafSplitEquiv n P x)) ≤ + ∏ j ∈ Finset.range (2 ^ n - 1), singleFrequencySupportBound D (frequencies j) := by + have hm : ∀ past d e, diagonalSplitData (data past) = some (d, e) → + d.hasFrequencies (frequencies past.length) ∧ + e.hasFrequencies (frequencies past.length) := by + intro past d e he + cases hd : data past with + | none => simp [diagonalSplitData, hd] at he + | some f => + have heq : (f, f) = (d, e) := by simpa [diagonalSplitData, hd] using he + have hf := hmatch past f hd + cases heq + exact ⟨hf, hf⟩ + have hb := arithmetic_leaf_support_fixed_frequencies + (fun past => diagonalSplitData (data past)) (fun j => (frequencies j, frequencies j)) D hD hm + (fun j => by simpa only [Nat.lcm_self] using hdiv j) n P + simpa only [diagonalSplitData_test, pairFrequencySupportBound, Nat.lcm_self, + singleFrequencySupportBound] using hb + +/-- Pointwise in the frequency history and independent of the size of Q. +This permits the modulus to be chosen separately for each history. -/ +theorem single_arithmetic_leaf_average_le {Q : ℕ} [NeZero Q] + (S : Finset ℤ) (N n : ℕ) (D : ℝ) (hD : 0 ≤ D) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) + (t : FrequencyTree S n) + (data : (ZMod Q)ˣ → List (ZMod Q)ˣ → Option (ArithmeticSplitData Q)) + (hmatch : ∀ P past d, data P past = some d → + d.hasFrequencies (singleTreeNodeFrequencies S n t past.length)) : + (Fintype.card (TreeLeafTuple (ZMod Q)ˣ n) : ℝ)⁻¹ * + (∑ x : TreeLeafTuple (ZMod Q)ˣ n, singleArithmeticLeafSupport n data x) ≤ + ((singleFrequencySplitList S n t).map (singleFrequencySupportBound D)).prod := by + have hprod : (∏ j ∈ Finset.range (2 ^ n - 1), + singleFrequencySupportBound D (singleTreeNodeFrequencies S n t j)) = + ((singleFrequencySplitList S n t).map (singleFrequencySupportBound D)).prod := by + rw [← singleFrequencySplitList_length S n t] + exact prod_range_list_getD _ _ _ + unfold singleArithmeticLeafSupport + rw [treeLeaf_average_by_product (G := (ZMod Q)ˣ) n + (fun P x => sequentialSupport (fun past y => singleArithmeticSplitTest (data P past) y) + [] (2 ^ n - 1) (treeLeafSplitEquiv n P x))] + calc + _ ≤ (Fintype.card (ZMod Q)ˣ : ℝ)⁻¹ * ∑ _P : (ZMod Q)ˣ, + ((singleFrequencySplitList S n t).map (singleFrequencySupportBound D)).prod := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact Finset.sum_le_sum fun P _ => + (single_arithmetic_leaf_support_le (data P) (singleTreeNodeFrequencies S n t) D hD + (hmatch P) (singleTreeNodeFrequencies_divisor_bound S N D hD hS hdiv n t) n P).trans_eq hprod + _ = _ := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + rw [← mul_assoc, inv_mul_cancel₀ (by exact_mod_cast Fintype.card_ne_zero), one_mul] + +noncomputable def singleArithmeticSupportSum {Q : ℕ} [NeZero Q] + (S : Finset ℤ) (V n : ℕ) + (data : FrequencyTree S n → (ZMod Q)ˣ → List (ZMod Q)ˣ → Option (ArithmeticSplitData Q)) : ℝ := + ∑ t : FrequencyTree S n, frequencyLeafWeight (singleFrequencyLeaf S V) n t * + ((Fintype.card (TreeLeafTuple (ZMod Q)ˣ n) : ℝ)⁻¹ * + ∑ x : TreeLeafTuple (ZMod Q)ˣ n, singleArithmeticLeafSupport n (data t) x) + +/-- The exponent is `2^n`, the number of leaves of one history. Thus its +initial squared weight cancels the entire leading leaf-frequency cost. -/ +theorem single_arithmetic_support_sum_le {Q : ℕ} [NeZero Q] + (S : Finset ℤ) (N V n : ℕ) (D : ℝ) (hD : 0 ≤ D) + (hS : ∀ s ∈ S, s ≠ 0 ∧ s.natAbs ≤ N) + (hdiv : ∀ q : ℕ, q ≠ 0 → q ≤ N ^ 2 → (q.divisors.card : ℝ) ≤ D) + (data : FrequencyTree S n → (ZMod Q)ˣ → List (ZMod Q)ˣ → Option (ArithmeticSplitData Q)) + (hmatch : ∀ t P past d, data t P past = some d → + d.hasFrequencies (singleTreeNodeFrequencies S n t past.length)) : + singleArithmeticSupportSum S V n data ≤ + (4 * D ^ 3 * (1 + Real.log N)) ^ (2 ^ n - 1) * (2 * (V : ℝ)) ^ (2 ^ n) := by + have hlocal (t : FrequencyTree S n) (P : (ZMod Q)ˣ) := + single_arithmetic_leaf_support_le (data t P) (singleTreeNodeFrequencies S n t) D hD + (hmatch t P) (singleTreeNodeFrequencies_divisor_bound S N D hD hS hdiv n t) n P + have hprod (t : FrequencyTree S n) : + (∏ j ∈ Finset.range (2 ^ n - 1), + singleFrequencySupportBound D (singleTreeNodeFrequencies S n t j)) = + ((singleFrequencySplitList S n t).map (singleFrequencySupportBound D)).prod := by + rw [← singleFrequencySplitList_length S n t] + exact prod_range_list_getD _ _ _ + apply le_trans _ (single_frequency_tree_sum_le S N V n D hD hS + (gcd_frequency_divisor_bound S N D hS hdiv)) + unfold singleArithmeticSupportSum + apply Finset.sum_le_sum + intro t _ + rw [singleFrequencyTreeWeight_eq] + apply le_trans _ (le_of_eq (mul_comm _ _)) + apply mul_le_mul_of_nonneg_left _ (frequencyLeafWeight_nonneg _ + (fun _ => by unfold singleFrequencyLeaf; split_ifs <;> norm_num) n t) + unfold singleArithmeticLeafSupport + rw [treeLeaf_average_by_product (G := (ZMod Q)ˣ) n + (fun P x => sequentialSupport (fun past y => singleArithmeticSplitTest (data t P past) y) + [] (2 ^ n - 1) (treeLeafSplitEquiv n P x))] + calc + _ ≤ (Fintype.card (ZMod Q)ˣ : ℝ)⁻¹ * ∑ _P : (ZMod Q)ˣ, + ((singleFrequencySplitList S n t).map (singleFrequencySupportBound D)).prod := by + apply mul_le_mul_of_nonneg_left _ (by positivity) + exact Finset.sum_le_sum fun P _ => (hlocal t P).trans_eq (hprod t) + _ = _ := by + simp only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + rw [← mul_assoc, inv_mul_cancel₀ (by exact_mod_cast Fintype.card_ne_zero), one_mul] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothCellRate.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothCellRate.lean new file mode 100644 index 0000000000000000000000000000000000000000..5aba740b0bbd0d4f5ec52870938e784ac4e17c8a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothCellRate.lean @@ -0,0 +1,117 @@ +import OAI.NumberTheory.Ostmann.Construction.SmoothCellDeletion +import OAI.NumberTheory.Ostmann.Construction.SmoothLogCellProfile +import OAI.NumberTheory.Ostmann.Construction.OneSidedDecayBudget + +namespace OAI + +/-! # Uniform normalization after the two prescribed nongiant deletions -/ + +namespace Ostmann +open Filter +open scoped Classical BigOperators + +/-- Removing either Page-exceptional prime costs less than half the cell +mass. The bound is uniform over the chosen centres and over the deleted set. -/ +theorem PublishedProgressionInput.deletedSmoothCell_normalizer_rate + (P : PublishedProgressionInput) (C b : ℝ) (hb : 0 < b) + (φ : ℝ → ℝ) (hφ : ∀ x, 0 ≤ φ x) (hφone : ∀ x, φ x ≤ 1) + (hout : ∀ x, 1 ≤ |x| → φ x = 0) + (hcentral : ∀ x, |x| ≤ 1 / 2 → b ≤ φ x) : + ∀ᶠ L : ℝ in atTop, ∀ (G : ℝ) (E : Finset ℕ), + 2 ≤ G → Real.exp ((39 / 10000 : ℝ) * L) ≤ G - 1 / 2 → + G ≤ Real.exp (C * L) → E.card ≤ 2 → + Real.exp (-(C + 1 / 5) * L) ≤ + smoothGiantMass (smoothGiantPrimeRange G \ E) φ G ∧ + smoothGiantLogNormalizer (smoothGiantPrimeRange G \ E) φ G ≤ (C + 1 / 5) * L ∧ + (∑ p : smoothGiantPrimeRange G, + deletedSmoothCellPrior (smoothGiantPrimeRange G) E φ G p) = 1 := by + let K : ℝ := |C| + |Real.log 4| + 3 + have hK : 0 ≤ K := by dsimp only [K]; positivity + filter_upwards [P.smoothGiant_normalizer_rate C b hb φ hφ hcentral, + eventual_polynomial_log_budget K 1 (39 / 10000) 1 1 hK (by norm_num) + (by norm_num) (by norm_num), + eventually_ge_atTop (1 : ℝ), eventually_ge_atTop (10 * Real.log 2)] + with L hbase hpoly hL hL2 + intro G E hG hlo hhi hE + obtain ⟨hmass, _, _⟩ := hbase G hG hlo hhi + have hpoly' : K * (1 + L) ≤ Real.exp ((39 / 10000 : ℝ) * L) := by + simpa only [pow_one, one_mul] using hpoly L (by linarith) (by linarith) + have hlin : (C + 1 / 10) * L + 1 + Real.log 4 ≤ K * (1 + L) := by + have hC := le_abs_self C + have hlog := le_abs_self (Real.log 4) + have hC0 := abs_nonneg C + have hlog0 := abs_nonneg (Real.log 4) + dsimp only [K] + nlinarith + have hexponent : 1 - G ≤ -(C + 1 / 10) * L - Real.log 4 := by linarith + have hsmall : 2 * Real.exp (1 - G) ≤ Real.exp (-(C + 1 / 10) * L) / 2 := by + calc + _ ≤ 2 * Real.exp (-(C + 1 / 10) * L - Real.log 4) := + mul_le_mul_of_nonneg_left (Real.exp_le_exp.mpr hexponent) (by norm_num) + _ = _ := by rw [Real.exp_sub, Real.exp_log (by norm_num : (0 : ℝ) < 4)]; ring + have hdelete := smoothCell_deletion_loss (smoothGiantPrimeRange G) E φ G hφone hout + have hE' : (E.card : ℝ) * Real.exp (1 - G) ≤ 2 * Real.exp (1 - G) := + mul_le_mul_of_nonneg_right (by exact_mod_cast hE) (Real.exp_nonneg _) + have hhalf : Real.exp (-(C + 1 / 10) * L) / 2 ≤ + smoothGiantMass (smoothGiantPrimeRange G \ E) φ G := by linarith + have htenth : Real.exp (-L / 10) ≤ (1 / 2 : ℝ) := by + calc + _ ≤ Real.exp (-Real.log 2) := Real.exp_le_exp.mpr (by linarith) + _ = _ := by rw [Real.exp_neg, Real.exp_log (by norm_num : (0 : ℝ) < 2)]; norm_num + have hmass' : Real.exp (-(C + 1 / 5) * L) ≤ + smoothGiantMass (smoothGiantPrimeRange G \ E) φ G := by + apply le_trans _ hhalf + calc + _ = Real.exp (-(C + 1 / 10) * L) * Real.exp (-L / 10) := by + rw [← Real.exp_add]; congr 1; ring + _ ≤ Real.exp (-(C + 1 / 10) * L) * (1 / 2) := + mul_le_mul_of_nonneg_left htenth (Real.exp_nonneg _) + _ = _ := by ring + have hpos := lt_of_lt_of_le (Real.exp_pos _) hmass' + refine ⟨hmass', ?_, deletedSmoothCellPrior_mass _ E φ G hpos⟩ + have hlog := Real.log_le_log (Real.exp_pos _) hmass' + rw [Real.log_exp] at hlog + unfold smoothGiantLogNormalizer + linarith + +theorem PublishedProgressionInput.logCellProfile_deleted_rate + (P : PublishedProgressionInput) (C : ℝ) : + ∀ᶠ L : ℝ in atTop, ∀ (G : ℝ) (E : Finset ℕ), + 2 ≤ G → Real.exp ((39 / 10000 : ℝ) * L) ≤ G - 1 / 2 → + G ≤ Real.exp (C * L) → E.card ≤ 2 → + Real.exp (-(C + 1 / 5) * L) ≤ + smoothGiantMass (smoothGiantPrimeRange G \ E) logCellProfile G ∧ + smoothGiantLogNormalizer (smoothGiantPrimeRange G \ E) logCellProfile G ≤ (C + 1 / 5) * L ∧ + (∑ p : smoothGiantPrimeRange G, + deletedSmoothCellPrior (smoothGiantPrimeRange G) E logCellProfile G p) = 1 := + P.deletedSmoothCell_normalizer_rate C logCellCentralLower logCellCentralLower_pos + logCellProfile logCellProfile_nonneg logCellProfile_le_one logCellProfile_zero_outside + logCellProfile_central + +/-- All role centres share one threshold. Both the repeated-sample loss +and the maximum atom are computed from the actual deleted smooth prior. -/ +theorem PublishedProgressionInput.logCellProfile_deleted_atom_rate + (P : PublishedProgressionInput) (C : ℝ) : + ∀ᶠ L : ℝ in atTop, ∀ (G : ℝ) (E : Finset ℕ), + 2 ≤ G → Real.exp ((39 / 10000 : ℝ) * L) ≤ G - 1 / 2 → + G ≤ Real.exp (C * L) → E.card ≤ 2 → + (∑ p : smoothGiantPrimeRange G, + deletedSmoothCellPrior (smoothGiantPrimeRange G) E logCellProfile G p) = 1 ∧ + ∀ p : smoothGiantPrimeRange G, + (p : ℝ) * deletedSmoothCellPrior (smoothGiantPrimeRange G) E logCellProfile G p ≤ + Real.exp ((C + 1 / 5) * L) ∧ + deletedSmoothCellPrior (smoothGiantPrimeRange G) E logCellProfile G p ≤ + Real.exp ((C + 1 / 5) * L - (G - 1)) := by + filter_upwards [P.logCellProfile_deleted_rate C] with L hL + intro G E hG hlo hhi hE + obtain ⟨_, hn, hm⟩ := hL G E hG hlo hhi hE + refine ⟨hm, fun p => ⟨?_, ?_⟩⟩ + · exact (prime_mul_deletedSmoothCellPrior_le _ E + (fun p hp => (Finset.mem_filter.mp hp).2) logCellProfile G logCellProfile_le_one p).trans + (Real.exp_le_exp.mpr hn) + · exact deletedSmoothCellPrior_le_exp _ E (fun p hp => (Finset.mem_filter.mp hp).2) + logCellProfile G ((C + 1 / 5) * L) logCellProfile_le_one logCellProfile_zero_outside hn p + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothGatedPrimeRoots.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothGatedPrimeRoots.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7b0f7a0cb5fb9730ea666767e44822cd871e036 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothGatedPrimeRoots.lean @@ -0,0 +1,76 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SmoothPrimeAllRoots + +namespace OAI + +/-! # Prime comparison with the original sharp support gates retained -/ + +namespace Ostmann +open scoped Classical BigOperators +open MeasureTheory + +/-- A sharp gate can change at every included polynomial root. Its exact values +at the roots are retained in the prime sum; endpoint atoms are part of the error. -/ +theorem PublishedProgressionInput.gated_smooth_prime_all_roots (P : PublishedProgressionInput) + {Q q a : ℕ} (hQ : 2 ≤ Q) (hq : 1 ≤ q) (hqQ : q ≤ Q) (ha : a.Coprime q) + (u v : ℝ) (hu : 1 ≤ u) (huv : u ≤ v) (hshort : v ≤ u + 1) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) (S : Finset ℝ) + (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (w : ℝ → ℂ) (C : ℝ) (hC : 0 ≤ C) (hw : ∀ x, ‖w x‖ ≤ C) + (hconst : ∀ x y, rootCellCode S x = rootCellCode S y → w x = w y) : + ‖complexPrimeInterval q a u v (fun y => w (Real.exp y) * smoothPolynomialWeight F (Real.exp y)) - + ∫ y in Set.Ioc u v, w (Real.exp y) * smoothPolynomialWeight F (Real.exp y) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + (S.card + 1 : ℕ) * (C * smoothPolynomialBudget F) * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt u) + + Real.exp (-P.kappa * u / Real.log (4 * (Q : ℝ))) + 2 * Real.exp (-u)) := by + obtain ⟨s, N, hs, hs0, hsN, hN, hfree⟩ := finite_log_root_mesh S u v huv + have h := P.common_root_prime_integral S s hs N hfree hQ hq hqQ ha + (by simpa only [hs0] using hu) (by simpa only [hs0, hsN] using hshort) + F hroots w C hC hw hconst + simp only [hs0, hsN] at h + have hlog : 0 ≤ Real.log (4 * (Q : ℝ)) := by + apply Real.log_nonneg + have hQr : (2 : ℝ) ≤ Q := by exact_mod_cast hQ + linarith + have hB := smoothPolynomialBudget_nonneg F + let E := 18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt u) + + Real.exp (-P.kappa * u / Real.log (4 * (Q : ℝ))) + 2 * Real.exp (-u) + have hPC := P.errorConstant_nonneg + have hE : 0 ≤ E := by dsimp only [E]; positivity + apply h.trans + calc + _ ≤ ∑ _j ∈ Finset.range N, (C * smoothPolynomialBudget F) * E := by + apply Finset.sum_le_sum + intro j _ + have hj : u ≤ s j := by rw [← hs0]; exact hs (Nat.zero_le _) + have ht : Real.exp (-P.decay * Real.sqrt (s j)) ≤ Real.exp (-P.decay * Real.sqrt u) := + Real.exp_le_exp.mpr (mul_le_mul_of_nonpos_left (Real.sqrt_le_sqrt hj) (by linarith [P.decay_pos])) + have hp : Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ))) ≤ + Real.exp (-P.kappa * u / Real.log (4 * (Q : ℝ))) := + Real.exp_le_exp.mpr (div_le_div_of_nonneg_right + (mul_le_mul_of_nonpos_left hj (by linarith [P.kappa_pos])) hlog) + have ha' : Real.exp (-(s j)) ≤ Real.exp (-u) := Real.exp_le_exp.mpr (neg_le_neg hj) + have he := add_le_add (add_le_add + (mul_le_mul_of_nonneg_left ht (show 0 ≤ 18 * P.errorConstant from mul_nonneg (by norm_num) hPC)) hp) + (mul_le_mul_of_nonneg_left ha' (by norm_num : (0 : ℝ) ≤ 2)) + have hA : 0 ≤ 18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ))) := by positivity + calc + _ ≤ C * smoothPolynomialBudget F * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ)))) + + 2 * C * smoothPolynomialBudget F * Real.exp (-(s j)) := by + exact add_le_add + (mul_le_mul_of_nonneg_right (mul_le_mul_of_nonneg_right (hw _) hB) hA) le_rfl + _ = (C * smoothPolynomialBudget F) * + ((18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt (s j)) + + Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ)))) + 2 * Real.exp (-(s j))) := by ring + _ ≤ _ := mul_le_mul_of_nonneg_left he (mul_nonneg hC hB) + _ = (N : ℝ) * (C * smoothPolynomialBudget F) * E := by simp; ring + _ ≤ (S.card + 1 : ℕ) * (C * smoothPolynomialBudget F) * E := by + exact mul_le_mul_of_nonneg_right + (mul_le_mul_of_nonneg_right (by exact_mod_cast hN) (mul_nonneg hC hB)) hE + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothPolynomialWeight.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothPolynomialWeight.lean new file mode 100644 index 0000000000000000000000000000000000000000..105ccd4a9892afa6bba4fe87403457bd7afe1e06 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothPolynomialWeight.lean @@ -0,0 +1,125 @@ +import OAI.NumberTheory.Ostmann.Characters.PolynomialCellVariation +import OAI.NumberTheory.Ostmann.ZeroDensity.ReciprocalProgressionVariation + +namespace OAI + +/-! # Finite products of the smooth factors appearing in a history + +Profiles are clipped to their prescribed argument ranges. This leaves their +values unchanged on the retained range and requires no continuity of the sharp +range indicator; those indicators are separate functions of the root cell. +-/ + +namespace Ostmann + +open scoped BigOperators + +structure ClippedPolynomialFactor where + polynomial : Polynomial ℝ + profile : ℝ → ℂ + lo : ℝ + hi : ℝ + bound : ℝ + lip : ℝ + lo_le_hi : lo ≤ hi + bound_nonneg : 0 ≤ bound + lip_nonneg : 0 ≤ lip + norm_le : ∀ x ∈ Set.Icc lo hi, ‖profile x‖ ≤ bound + lipschitz : ∀ x ∈ Set.Icc lo hi, ∀ y ∈ Set.Icc lo hi, + ‖profile x - profile y‖ ≤ lip * |x - y| + +noncomputable def ClippedPolynomialFactor.value (f : ClippedPolynomialFactor) (x : ℝ) : ℂ := + f.profile (clipRealInterval f.lo f.hi (f.polynomial.eval x)) + +theorem ClippedPolynomialFactor.value_of_mem (f : ClippedPolynomialFactor) (x : ℝ) + (hx : f.polynomial.eval x ∈ Set.Icc f.lo f.hi) : + f.value x = f.profile (f.polynomial.eval x) := by + simp only [value, clipRealInterval, min_eq_right hx.2, max_eq_right hx.1] + +theorem ClippedPolynomialFactor.norm_value (f : ClippedPolynomialFactor) (x : ℝ) : + ‖f.value x‖ ≤ f.bound := + f.norm_le _ (clipRealInterval_bounds f.lo f.hi _ f.lo_le_hi) + +theorem ClippedPolynomialFactor.variation (f : ClippedPolynomialFactor) + (S : Finset ℝ) (hroots : ∀ r, r ∈ f.polynomial.derivative.roots → r ∈ S) + (u : ℕ → ℝ) (hu : Monotone u) (N : ℕ) + (hcode : rootCellCode S (u 0) = rootCellCode S (u (N - 1))) : + discreteVariation (fun j => f.value (u j)) N ≤ f.bound + f.lip * (f.hi - f.lo) := by + let v : ℕ → ℝ := fun j => clipRealInterval f.lo f.hi (f.polynomial.eval (u j)) + have hr (j : ℕ) (_hj : j ≤ N - 1) : v j ∈ Set.Icc f.lo f.hi := + clipRealInterval_bounds f.lo f.hi _ f.lo_le_hi + have hu' (j : ℕ) (hj : j ≤ N - 1) : u j ∈ Set.Icc (u 0) (u (N - 1)) := + ⟨hu (Nat.zero_le _), hu hj⟩ + change discreteVariation (fun j => f.profile (v j)) N ≤ _ + rcases polynomial_monotoneOn_of_root_cell f.polynomial S hroots hcode with hm | hm + · apply discreteVariation_comp_monotoneOn f.profile v f.lo f.hi f.bound f.lip N + f.lip_nonneg f.norm_le f.lipschitz hr + intro j hj + exact clipRealInterval_monotone f.lo f.hi + (hm (hu' j hj.le) (hu' (j + 1) (by omega)) (hu (by omega))) + · apply discreteVariation_comp_antitoneOn f.profile v f.lo f.hi f.bound f.lip N + f.lip_nonneg f.norm_le f.lipschitz hr + intro j hj + exact clipRealInterval_monotone f.lo f.hi + (hm (hu' j hj.le) (hu' (j + 1) (by omega)) (hu (by omega))) + +noncomputable def smoothPolynomialWeight {n : ℕ} (F : Fin n → ClippedPolynomialFactor) + (x : ℝ) : ℂ := ∏ i, (F i).value x + +noncomputable def smoothPolynomialBudget {n : ℕ} (F : Fin n → ClippedPolynomialFactor) : ℝ := + ∏ i, (2 * (F i).bound + (F i).lip * ((F i).hi - (F i).lo)) + +theorem smoothPolynomialBudget_nonneg {n : ℕ} (F : Fin n → ClippedPolynomialFactor) : + 0 ≤ smoothPolynomialBudget F := by + apply Finset.prod_nonneg + intro i _ + exact add_nonneg (mul_nonneg (by norm_num) (F i).bound_nonneg) + (mul_nonneg (F i).lip_nonneg (sub_nonneg.mpr (F i).lo_le_hi)) + +theorem smoothPolynomialWeight_norm {n : ℕ} (F : Fin n → ClippedPolynomialFactor) (x : ℝ) : + ‖smoothPolynomialWeight F x‖ ≤ smoothPolynomialBudget F := by + rw [smoothPolynomialWeight, norm_prod] + apply Finset.prod_le_prod₀ (fun _ _ => norm_nonneg _) + intro i _ + apply ((F i).norm_value x).trans + have h := mul_nonneg (F i).lip_nonneg (sub_nonneg.mpr (F i).lo_le_hi) + linarith [(F i).bound_nonneg] + +theorem smoothPolynomialWeight_variation {n : ℕ} (F : Fin n → ClippedPolynomialFactor) + (S : Finset ℝ) (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (u : ℕ → ℝ) (hu : Monotone u) (N : ℕ) + (hcode : rootCellCode S (u 0) = rootCellCode S (u (N - 1))) : + discreteVariation (fun j => smoothPolynomialWeight F (u j)) N ≤ smoothPolynomialBudget F := by + have hV (i : Fin n) : 0 ≤ (F i).bound + (F i).lip * ((F i).hi - (F i).lo) := + add_nonneg (F i).bound_nonneg + (mul_nonneg (F i).lip_nonneg (sub_nonneg.mpr (F i).lo_le_hi)) + have ht := discreteVariation_prod n (fun i j => (F i).value (u j)) + (fun i => (F i).bound) (fun i => (F i).bound + (F i).lip * ((F i).hi - (F i).lo)) N + (fun i => (F i).bound_nonneg) hV (fun i j => (F i).norm_value (u j)) + (fun i => (F i).variation S (hroots i) u hu N hcode) + change discreteVariation (fun j => ∏ i, (F i).value (u j)) N ≤ _ + apply ht.trans_eq + apply Finset.prod_congr rfl + intro i _ + ring + +/-- This is the weight used after the long-prime prior is extended to integers. -/ +theorem smoothPolynomial_reciprocal_variation {n : ℕ} (F : Fin n → ClippedPolynomialFactor) + (S : Finset ℝ) (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (b d : ℝ) (hb : 0 < b) (hd : 0 ≤ d) (N : ℕ) + (hcode : rootCellCode S b = rootCellCode S (b + d * ((N - 1 : ℕ) : ℝ))) : + discreteVariation (fun j => Complex.ofReal ((b + d * j)⁻¹) * + smoothPolynomialWeight F (b + d * j)) N ≤ 2 * b⁻¹ * smoothPolynomialBudget F := by + have hu : Monotone (fun j : ℕ => b + d * j) := by + intro i j hij + have hijR : (i : ℝ) ≤ (j : ℝ) := by exact_mod_cast hij + exact add_le_add le_rfl (mul_le_mul_of_nonneg_left hijR hd) + have hc : rootCellCode S (b + d * (0 : ℕ)) = rootCellCode S (b + d * (N - 1 : ℕ)) := by + simpa only [Nat.cast_zero, mul_zero, add_zero] using hcode + exact reciprocal_progression_product_variation b d hb hd _ N + (smoothPolynomialBudget F) (smoothPolynomialBudget F) le_rfl + (fun j => smoothPolynomialWeight_norm F _) (smoothPolynomialWeight_variation F S hroots _ hu N hc) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothPrimeAllRoots.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothPrimeAllRoots.lean new file mode 100644 index 0000000000000000000000000000000000000000..d9e3e7e5a667319407271a0073f6cf577332c5fc --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothPrimeAllRoots.lean @@ -0,0 +1,66 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.RootMeshIntegral + +namespace OAI + +/-! # Recombined prime comparison across all derivative roots -/ + +namespace Ostmann +open scoped Classical BigOperators +open MeasureTheory + +/-- The root partition is internal to the proof. Both sides retain the entire +original interval, including its endpoint primes. -/ +theorem PublishedProgressionInput.smooth_prime_all_roots (P : PublishedProgressionInput) + {Q q a : ℕ} (hQ : 2 ≤ Q) (hq : 1 ≤ q) (hqQ : q ≤ Q) (ha : a.Coprime q) + (u v : ℝ) (hu : 1 ≤ u) (huv : u ≤ v) (hshort : v ≤ u + 1) + {k : ℕ} (F : Fin k → ClippedPolynomialFactor) (S : Finset ℝ) + (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) : + ‖complexPrimeInterval q a u v (fun y => smoothPolynomialWeight F (Real.exp y)) - + ∫ y in Set.Ioc u v, smoothPolynomialWeight F (Real.exp y) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + (S.card + 1 : ℕ) * smoothPolynomialBudget F * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt u) + + Real.exp (-P.kappa * u / Real.log (4 * (Q : ℝ))) + 2 * Real.exp (-u)) := by + obtain ⟨s, N, hs, hs0, hsN, hN, hfree⟩ := finite_log_root_mesh S u v huv + have h := P.common_root_prime_integral S s hs N hfree hQ hq hqQ ha + (by simpa only [hs0] using hu) (by simpa only [hs0, hsN] using hshort) + F hroots (fun _ => 1) 1 (by norm_num) (by intro; simp) (by intros; rfl) + simp only [one_mul, norm_one, hs0, hsN] at h + have hlog : 0 ≤ Real.log (4 * (Q : ℝ)) := by + apply Real.log_nonneg + have hQr : (2 : ℝ) ≤ Q := by exact_mod_cast hQ + linarith + have hB : 0 ≤ smoothPolynomialBudget F := smoothPolynomialBudget_nonneg F + let E := 18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt u) + + Real.exp (-P.kappa * u / Real.log (4 * (Q : ℝ))) + 2 * Real.exp (-u) + have hC := P.errorConstant_nonneg + have hE : 0 ≤ E := by + dsimp only [E] + positivity + apply h.trans + calc + _ ≤ ∑ _j ∈ Finset.range N, smoothPolynomialBudget F * E := by + apply Finset.sum_le_sum + intro j _ + have hj : u ≤ s j := by rw [← hs0]; exact hs (Nat.zero_le _) + have ht : Real.exp (-P.decay * Real.sqrt (s j)) ≤ Real.exp (-P.decay * Real.sqrt u) := + Real.exp_le_exp.mpr (mul_le_mul_of_nonpos_left (Real.sqrt_le_sqrt hj) (by linarith [P.decay_pos])) + have hp : Real.exp (-P.kappa * s j / Real.log (4 * (Q : ℝ))) ≤ + Real.exp (-P.kappa * u / Real.log (4 * (Q : ℝ))) := + Real.exp_le_exp.mpr (div_le_div_of_nonneg_right + (mul_le_mul_of_nonpos_left hj (by linarith [P.kappa_pos])) hlog) + have ha' : Real.exp (-(s j)) ≤ Real.exp (-u) := Real.exp_le_exp.mpr (neg_le_neg hj) + have he := add_le_add + (mul_le_mul_of_nonneg_left ht (show 0 ≤ 18 * P.errorConstant from mul_nonneg (by norm_num) hC)) hp + have he' := mul_le_mul_of_nonneg_left he hB + have he'' := mul_le_mul_of_nonneg_left ha' (show 0 ≤ 2 * smoothPolynomialBudget F from mul_nonneg (by norm_num) hB) + dsimp only [E] + nlinarith + _ = (N : ℝ) * smoothPolynomialBudget F * E := by simp; ring + _ ≤ (S.card + 1 : ℕ) * smoothPolynomialBudget F * E := by + apply mul_le_mul_of_nonneg_right _ hE + exact mul_le_mul_of_nonneg_right (by exact_mod_cast hN) hB + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothPrimeComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothPrimeComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..4a6e194a7b479c504fb2273b5e78b220ddf968ff --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SmoothPrimeComparison.lean @@ -0,0 +1,59 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ContinuousPrimeComparison +import OAI.NumberTheory.Ostmann.Arithmetic.SmoothPolynomialWeight + +namespace OAI + +/-! # Prime comparison for the actual clipped polynomial factors -/ + +namespace Ostmann +open MeasureTheory +open scoped BigOperators + +theorem ClippedPolynomialFactor.continuous_value (f : ClippedPolynomialFactor) : + Continuous f.value := by + have hp : LipschitzOnWith ⟨f.lip, f.lip_nonneg⟩ f.profile (Set.Icc f.lo f.hi) := by + apply LipschitzOnWith.of_dist_le_mul + intro x hx y hy + change dist (f.profile x) (f.profile y) ≤ f.lip * dist x y + simpa only [dist_eq_norm, Real.norm_eq_abs] using f.lipschitz x hx y hy + have hc : Continuous (fun x => clipRealInterval f.lo f.hi (f.polynomial.eval x)) := + continuous_const.max (continuous_const.min f.polynomial.continuous) + apply continuousOn_univ.mp + exact hp.continuousOn.comp hc.continuousOn + (fun x _ => clipRealInterval_bounds f.lo f.hi _ f.lo_le_hi) + +theorem continuous_smoothPolynomialWeight {n : ℕ} (F : Fin n → ClippedPolynomialFactor) : + Continuous (smoothPolynomialWeight F) := + continuous_finsetProd _ (fun i _ => (F i).continuous_value) + +/-- On one genuine polynomial root cell, the full smooth weight admits +prime-to-Page comparison with its explicit product variation budget. -/ +theorem PublishedProgressionInput.smooth_prime_comparison (P : PublishedProgressionInput) + {Q q a : ℕ} (hQ : 2 ≤ Q) (hq : 1 ≤ q) (hqQ : q ≤ Q) (ha : a.Coprime q) + (u v : ℝ) (hu : 1 ≤ u) (huv : u ≤ v) (hshort : v ≤ u + 1) + {n : ℕ} (F : Fin n → ClippedPolynomialFactor) + (S : Finset ℝ) (hroots : ∀ i r, r ∈ (F i).polynomial.derivative.roots → r ∈ S) + (hcode : rootCellCode S (Real.exp u) = rootCellCode S (Real.exp v)) : + ‖complexPrimeInterval q a u v (fun y => smoothPolynomialWeight F (Real.exp y)) - + ∫ y in Set.Ioc u v, smoothPolynomialWeight F (Real.exp y) * + (selectedPrimeLogDensity P Q q a y : ℂ)‖ ≤ + smoothPolynomialBudget F * + (18 * P.errorConstant * Real.exp (-P.decay * Real.sqrt u) + + Real.exp (-P.kappa * u / Real.log (4 * (Q : ℝ)))) := by + apply P.continuous_prime_comparison hQ hq hqQ ha u v hu huv hshort _ + ((continuous_smoothPolynomialWeight F).comp Real.continuous_exp).continuousOn + intro s hs N hs0 hsN + apply smoothPolynomialWeight_variation F S hroots (fun j => Real.exp (s j)) + (Real.exp_monotone.comp hs) N + have hlo : Real.exp u ≤ Real.exp (s (N - 1)) := by + rw [← hs0] + exact Real.exp_le_exp.mpr (hs (Nat.zero_le _)) + have hhi : Real.exp (s (N - 1)) ≤ Real.exp v := by + rw [← hsN] + exact Real.exp_le_exp.mpr (hs (Nat.sub_le _ _)) + rw [hs0] + exact (rootCellCode_convex S hlo hhi hcode).symm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SplitPrefixProducts.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SplitPrefixProducts.lean new file mode 100644 index 0000000000000000000000000000000000000000..733091fbd75b9de39658e7fa5ad29ba0b87225d4 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SplitPrefixProducts.lean @@ -0,0 +1,126 @@ +import OAI.NumberTheory.Ostmann.Characters.TreeLeafProducts + +namespace OAI + +/-! # Computing every current parent product from previously exposed splits -/ + +namespace Ostmann + +/-- Pending subtrees are visited in preorder. Depth-zero branches require +no split coordinate, so they are never stored in the frontier. -/ +def pendingSplitBranch {G : Type*} (n : ℕ) (P : G) (rest : List (ℕ × G)) : List (ℕ × G) := + match n with + | 0 => rest + | n + 1 => (n + 1, P) :: rest + +def splitFrontierStep {G : Type*} [Div G] (frontier : List (ℕ × G)) (x : G) : List (ℕ × G) := + match frontier with + | [] => [] + | (0, _) :: rest => rest + | (n + 1, P) :: rest => pendingSplitBranch n x (pendingSplitBranch n (P / x) rest) + +def currentSplitParent {G : Type*} [One G] (frontier : List (ℕ × G)) : G := + match frontier with + | [] => 1 + | (_, P) :: _ => P + +def splitPrefixParent {G : Type*} [Div G] [One G] (n : ℕ) (P : G) (past : List G) : G := + currentSplitParent (past.foldr (fun x frontier => splitFrontierStep frontier x) + (pendingSplitBranch n P [])) + +def actualSplitValues {G : Type*} [CommMonoid G] : (n : ℕ) → TreeLeafTuple G n → List G + | 0, _ => [] + | n + 1, x => treeLeafProduct n x.1 :: (actualSplitValues n x.1 ++ actualSplitValues n x.2) + +def actualParentSplits {G : Type*} [CommMonoid G] : (n : ℕ) → TreeLeafTuple G n → List (G × G) + | 0, _ => [] + | n + 1, x => (treeLeafProduct (n + 1) x, treeLeafProduct n x.1) :: + (actualParentSplits n x.1 ++ actualParentSplits n x.2) + +def splitFrontierTrace {G : Type*} [Div G] [One G] (frontier : List (ℕ × G)) : List G → List (G × G) + | [] => [] + | x :: xs => (currentSplitParent frontier, x) :: + splitFrontierTrace (splitFrontierStep frontier x) xs + +theorem splitFrontierTrace_append {G : Type*} [Div G] [One G] + (frontier : List (ℕ × G)) (xs ys : List G) : + splitFrontierTrace frontier (xs ++ ys) = splitFrontierTrace frontier xs ++ + splitFrontierTrace (xs.foldl splitFrontierStep frontier) ys := by + induction xs generalizing frontier with + | nil => rfl + | cons x xs ih => simp only [List.cons_append, splitFrontierTrace, List.foldl_cons, ih] + +theorem splitFrontier_after_actual {G : Type*} [CommGroup G] + (n : ℕ) (x : TreeLeafTuple G n) (rest : List (ℕ × G)) : + (actualSplitValues n x).foldl splitFrontierStep + (pendingSplitBranch n (treeLeafProduct n x) rest) = rest := by + induction n generalizing rest with + | zero => rfl + | succ n ih => + change (actualSplitValues n x.1 ++ actualSplitValues n x.2).foldl splitFrontierStep + (pendingSplitBranch n (treeLeafProduct n x.1) + (pendingSplitBranch n ((treeLeafProduct n x.1 * treeLeafProduct n x.2) / + treeLeafProduct n x.1) rest)) = rest + rw [mul_div_cancel_left, List.foldl_append, ih, ih] + +theorem splitFrontierTrace_actual {G : Type*} [CommGroup G] + (n : ℕ) (x : TreeLeafTuple G n) (rest : List (ℕ × G)) : + splitFrontierTrace (pendingSplitBranch n (treeLeafProduct n x) rest) + (actualSplitValues n x) = actualParentSplits n x := by + induction n generalizing rest with + | zero => rfl + | succ n ih => + change (treeLeafProduct n x.1 * treeLeafProduct n x.2, treeLeafProduct n x.1) :: + splitFrontierTrace (pendingSplitBranch n (treeLeafProduct n x.1) + (pendingSplitBranch n ((treeLeafProduct n x.1 * treeLeafProduct n x.2) / + treeLeafProduct n x.1) rest)) (actualSplitValues n x.1 ++ actualSplitValues n x.2) = + (treeLeafProduct n x.1 * treeLeafProduct n x.2, treeLeafProduct n x.1) :: + (actualParentSplits n x.1 ++ actualParentSplits n x.2) + rw [mul_div_cancel_left, splitFrontierTrace_append, splitFrontier_after_actual, ih, ih] + +/-- The stored prefix uses the same reverse chronological convention as +`sequentialSupport`: the most recently exposed split is the head. -/ +theorem splitPrefixParent_eq_foldl {G : Type*} [Div G] [One G] + (n : ℕ) (P : G) (past : List G) : + splitPrefixParent n P past = currentSplitParent + (past.reverse.foldl splitFrontierStep (pendingSplitBranch n P [])) := by + rw [splitPrefixParent, List.foldr_eq_foldl_reverse] + +theorem actualSplitValues_length {G : Type*} [CommGroup G] + (n : ℕ) (x : TreeLeafTuple G n) : (actualSplitValues n x).length = 2 ^ n - 1 := by + induction n with + | zero => rfl + | succ n ih => + simp only [actualSplitValues, List.length_cons, List.length_append, ih] + have h := Nat.one_le_two_pow (n := n) + rw [pow_succ] + omega + +theorem splitFrontierTrace_getD {G : Type*} [Div G] [One G] + (frontier : List (ℕ × G)) (xs : List G) (j : ℕ) (hj : j < xs.length) : + (splitFrontierTrace frontier xs).getD j (1, 1) = + (currentSplitParent ((xs.take j).foldl splitFrontierStep frontier), xs.getD j 1) := by + induction xs generalizing frontier j with + | nil => simp at hj + | cons x xs ih => + cases j with + | zero => rfl + | succ j => + simpa only [splitFrontierTrace, List.getD_cons_succ, List.take_succ_cons, List.foldl_cons] using + ih (splitFrontierStep frontier x) j (by simpa using hj) + +/-- The actual parent product at a node is a function of the initial total +and the preceding split coordinates alone, with the same prefix convention +as the arithmetic support estimator. -/ +theorem actualParentSplits_from_prefix {G : Type*} [CommGroup G] + (n : ℕ) (x : TreeLeafTuple G n) (j : ℕ) (hj : j < 2 ^ n - 1) : + (actualParentSplits n x).getD j (1, 1) = + (splitPrefixParent n (treeLeafProduct n x) ((actualSplitValues n x).take j).reverse, + (actualSplitValues n x).getD j 1) := by + rw [← splitFrontierTrace_actual n x []] + rw [splitFrontierTrace_getD _ _ j (by simpa only [actualSplitValues_length] using hj)] + rw [splitPrefixParent_eq_foldl, List.reverse_reverse] + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SplitSampleLists.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SplitSampleLists.lean new file mode 100644 index 0000000000000000000000000000000000000000..7b2381a70650b824a0b36cfee42d440d97611b5a --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SplitSampleLists.lean @@ -0,0 +1,77 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.SplitPrefixProducts +import OAI.NumberTheory.Ostmann.Characters.TreeSplitCoordinates + +namespace OAI + +/-! # The checked split-coordinate equivalence records actual product splits -/ + +namespace Ostmann + +@[implicit_reducible] def splitSampleList {G : Type} : (n : ℕ) → SplitSamples G n → List G + | 0, _ => [] + | n + 1, x => x.1 :: splitSampleList n x.2 + +theorem splitSampleList_cast_symm {G A : Type} (m n : ℕ) (h : m = n) + (e : SplitSamples G m ≃ A) (he : (SplitSamples G n ≃ A) = (SplitSamples G m ≃ A)) (x : A) : + splitSampleList n ((he.mpr e).symm x) = splitSampleList m (e.symm x) := by + cases h + rfl + +theorem splitSampleList_cast_apply {G A : Type} (m n : ℕ) (h : m = n) + (e : A ≃ SplitSamples G m) (he : (A ≃ SplitSamples G n) = (A ≃ SplitSamples G m)) (x : A) : + splitSampleList n ((he.mpr e) x) = splitSampleList m (e x) := by + cases h + rfl + +theorem splitSampleList_append {G : Type} (m n : ℕ) + (x : SplitSamples G m) (y : SplitSamples G n) : + splitSampleList (m + n) ((splitSamplesAppendEquiv G m n).symm (x, y)) = + splitSampleList m x ++ splitSampleList n y := by + induction m with + | zero => + simp only [splitSamplesAppendEquiv] + rw [splitSampleList_cast_symm n (0 + n) (Nat.zero_add n).symm] + rfl + | succ m ih => + simp only [splitSamplesAppendEquiv] + rw [splitSampleList_cast_symm (m + n + 1) (m + 1 + n) (by omega)] + change x.1 :: splitSampleList (m + n) ((splitSamplesAppendEquiv G m n).symm (x.2, y)) = + (x.1 :: splitSampleList m x.2) ++ splitSampleList n y + rw [ih] + rfl + +theorem splitSampleList_treeLeafSplit {G : Type} [CommGroup G] + (n : ℕ) (P : G) (x : TreeLeafFiber G n P) : + splitSampleList (2 ^ n - 1) (treeLeafSplitEquiv n P x) = actualSplitValues n x.1 := by + induction n generalizing P with + | zero => rfl + | succ n ih => + have hn : 1 ≤ 2 ^ n := Nat.one_le_two_pow + have he : (2 ^ n - 1) + (2 ^ n - 1) + 1 = 2 ^ (n + 1) - 1 := by + rw [pow_succ] + omega + simp only [treeLeafSplitEquiv] + rw [splitSampleList_cast_apply _ _ he] + change treeLeafProduct n x.1.1 :: + splitSampleList ((2 ^ n - 1) + (2 ^ n - 1)) + ((splitSamplesAppendEquiv G (2 ^ n - 1) (2 ^ n - 1)).symm + (treeLeafSplitEquiv n (treeLeafProduct n x.1.1) ⟨x.1.1, rfl⟩, + treeLeafSplitEquiv n (P / treeLeafProduct n x.1.1) ⟨x.1.2, _⟩)) = _ + rw [splitSampleList_append, ih, ih] + rfl + +/-- Each parent recorded by the actual split-coordinate equivalence is +computed from the preceding coordinates, including in right subtrees. -/ +theorem split_coordinate_parent {G : Type} [CommGroup G] + (n : ℕ) (P : G) (x : TreeLeafFiber G n P) (j : ℕ) (hj : j < 2 ^ n - 1) : + (actualParentSplits n x.1).getD j (1, 1) = + (splitPrefixParent n P + ((splitSampleList (2 ^ n - 1) (treeLeafSplitEquiv n P x)).take j).reverse, + (splitSampleList (2 ^ n - 1) (treeLeafSplitEquiv n P x)).getD j 1) := by + rw [splitSampleList_treeLeafSplit] + have h := actualParentSplits_from_prefix n x.1 j hj + simpa only [x.property] using h + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SplitSquareSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SplitSquareSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..e70c8b27d41daaac76d5fe82c29cf36bd58dc097 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SplitSquareSupport.lean @@ -0,0 +1,121 @@ +import Mathlib.Data.Nat.ModEq +import Mathlib.Tactic.Group +import OAI.NumberTheory.Ostmann.Arithmetic.SimultaneousSquares +import OAI.NumberTheory.Ostmann.Arithmetic.ReducedFrequencySum + +namespace OAI + +/-! # From the actual split relation to its reduced square equation -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem split_relation_gcd_eq {s v w x y : ℕ} + (hx : x.Coprime s) (hy : y.Coprime s) + (h : Nat.ModEq s (v * x) (w * y)) : v.gcd s = w.gcd s := by + simpa only [hx.gcd_mul_right_cancel, hy.gcd_mul_right_cancel] using h.gcd_eq + +theorem split_relation_common_gcd {s v w x y : ℕ} + (hx : x.Coprime s) (hy : y.Coprime s) + (h : Nat.ModEq s (v * x) (w * y)) : (v.gcd w).gcd s = v.gcd s := by + rw [Nat.gcd_assoc, ← split_relation_gcd_eq hx hy h, ← Nat.gcd_assoc, Nat.gcd_self] + +theorem split_relation_divide_gcd {s v w x y : ℕ} (hs : s ≠ 0) + (hgcd : v.gcd s = w.gcd s) : + Nat.ModEq s (v * x) (w * y) ↔ + Nat.ModEq (s / v.gcd s) ((v / v.gcd s) * x) ((w / v.gcd s) * y) := by + have hd : v.gcd s ≠ 0 := Nat.gcd_ne_zero_right hs + have hdv : v.gcd s ∣ v := Nat.gcd_dvd_left v s + have hdw : v.gcd s ∣ w := hgcd ▸ Nat.gcd_dvd_left w s + have hds : v.gcd s ∣ s := Nat.gcd_dvd_right v s + simpa only [← Nat.mul_assoc, Nat.mul_div_cancel' hds, + Nat.mul_div_cancel' hdv, Nat.mul_div_cancel' hdw] using + (Nat.ModEq.mul_left_cancel_iff' (a := (v / v.gcd s) * x) + (b := (w / v.gcd s) * y) (m := s / v.gcd s) hd) + +theorem reduced_split_coefficients_coprime {s v w : ℕ} (hs : s ≠ 0) + (hgcd : v.gcd s = w.gcd s) : + (v / v.gcd s).Coprime (s / v.gcd s) ∧ + (w / v.gcd s).Coprime (s / v.gcd s) := by + have hv := Nat.coprime_div_gcd_div_gcd (Nat.gcd_pos_of_pos_right v (Nat.pos_of_ne_zero hs)) + have hw := Nat.coprime_div_gcd_div_gcd (Nat.gcd_pos_of_pos_right w (Nat.pos_of_ne_zero hs)) + exact ⟨hv, hgcd ▸ hw⟩ + +theorem unit_coefficient_equation_iff {s : ℕ} [NeZero s] + (v w : ℕ) (x y : (ZMod s)ˣ) : + (v : ZMod s) * x = (w : ZMod s) * y ↔ + Nat.ModEq s (v * (x : ZMod s).val) (w * (y : ZMod s).val) := by + simpa only [Nat.cast_mul, ZMod.natCast_zmod_val] using + ZMod.natCast_eq_natCast_iff (v * (x : ZMod s).val) (w * (y : ZMod s).val) s + +theorem unit_coefficient_gcd_eq {s : ℕ} [NeZero s] + (v w : ℕ) (x y : (ZMod s)ˣ) + (h : (v : ZMod s) * x = (w : ZMod s) * y) : v.gcd s = w.gcd s := + split_relation_gcd_eq (ZMod.val_coe_unit_coprime x) (ZMod.val_coe_unit_coprime y) + ((unit_coefficient_equation_iff v w x y).mp h) + +theorem unit_coefficient_reduce {s : ℕ} [NeZero s] + (v w : ℕ) (hgcd : v.gcd s = w.gcd s) (x y : (ZMod s)ˣ) : + (v : ZMod s) * x = (w : ZMod s) * y ↔ + (v / v.gcd s : ZMod (s / v.gcd s)) * + ZMod.unitsMap (Nat.div_dvd_of_dvd (Nat.gcd_dvd_right v s)) x = + (w / v.gcd s : ZMod (s / v.gcd s)) * + ZMod.unitsMap (Nat.div_dvd_of_dvd (Nat.gcd_dvd_right v s)) y := by + rw [unit_coefficient_equation_iff, + split_relation_divide_gcd (NeZero.ne s) hgcd] + have hcast (u : (ZMod s)ˣ) : + (ZMod.unitsMap (Nat.div_dvd_of_dvd (Nat.gcd_dvd_right v s)) u : + ZMod (s / v.gcd s)) = ((u : ZMod s).val : ZMod (s / v.gcd s)) := by + change ZMod.castHom (Nat.div_dvd_of_dvd (Nat.gcd_dvd_right v s)) _ (u : ZMod s) = _ + nth_rw 1 [← ZMod.natCast_zmod_val (u : ZMod s)] + exact map_natCast _ _ + rw [hcast, hcast] + exact (ZMod.natCast_eq_natCast_iff _ _ _).symm.trans (by simp only [Nat.cast_mul]) + +/-- The parent product is already exposed. The child product remains the +uniform variable, and the split relation specifies its square. -/ +theorem split_relation_iff_square {G : Type*} [CommGroup G] + (A B P x : G) : A * (P / x) = B * x ↔ x ^ 2 = A * P / B := by + constructor + · intro h + have hm := congrArg (fun y => y * x / B) h + calc + x ^ 2 = B * x * x / B := by rw [mul_assoc, mul_div_cancel_left, pow_two] + _ = A * (P / x) * x / B := hm.symm + _ = A * P / B := by rw [mul_assoc A, div_mul_cancel] + · intro h + have hm := congrArg (fun y => B * y / x) h + calc + A * (P / x) = B * (A * P / B) / x := by + rw [mul_div_cancel, mul_div_assoc] + _ = B * x ^ 2 / x := hm.symm + _ = B * x := by rw [pow_two, ← mul_assoc, mul_div_cancel_right] + +noncomputable def splitSquareTarget {s : ℕ} [NeZero s] + (v w : ℕ) (hgcd : v.gcd s = w.gcd s) (A B P : (ZMod s)ˣ) : + (ZMod (s / v.gcd s))ˣ := + let f := ZMod.unitsMap (Nat.div_dvd_of_dvd (Nat.gcd_dvd_right v s)) + let h := reduced_split_coefficients_coprime (NeZero.ne s) hgcd + (ZMod.unitOfCoprime (v / v.gcd s) h.1 * f A) * f P / + (ZMod.unitOfCoprime (w / v.gcd s) h.2 * f B) + +theorem unit_split_iff_square {s : ℕ} [NeZero s] + (v w : ℕ) (hgcd : v.gcd s = w.gcd s) (A B P x : (ZMod s)ˣ) : + (v : ZMod s) * (A * (P / x) : (ZMod s)ˣ) = + (w : ZMod s) * (B * x : (ZMod s)ˣ) ↔ + (ZMod.unitsMap (Nat.div_dvd_of_dvd (Nat.gcd_dvd_right v s)) x) ^ 2 = + splitSquareTarget v w hgcd A B P := by + let f := ZMod.unitsMap (Nat.div_dvd_of_dvd (Nat.gcd_dvd_right v s)) + let h := reduced_split_coefficients_coprime (NeZero.ne s) hgcd + have heq := split_relation_iff_square + (ZMod.unitOfCoprime (v / v.gcd s) h.1 * f A) + (ZMod.unitOfCoprime (w / v.gcd s) h.2 * f B) (f P) (f x) + rw [← Units.val_inj] at heq + apply (unit_coefficient_reduce v w hgcd (A * (P / x)) (B * x)).trans + simpa only [f, splitSquareTarget, map_mul, map_div, Units.val_mul, + Units.val_div_eq_div_val, ZMod.coe_unitOfCoprime, mul_assoc] using heq + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SquareCongruence.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SquareCongruence.lean new file mode 100644 index 0000000000000000000000000000000000000000..13ec3f0270ceb5da91876a694ebed261e3428048 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SquareCongruence.lean @@ -0,0 +1,82 @@ +import Mathlib.RingTheory.ZMod.UnitsCyclic +import OAI.NumberTheory.Ostmann.Arithmetic.CRTResidueAverage + +namespace OAI + +/-! # Square congruences in the frequency support -/ + +namespace Ostmann + +open scoped BigOperators Classical + +def squareFiberEquivOne {G : Type*} [CommGroup G] (r : G) : + {x : G // x ^ 2 = r ^ 2} ≃ {x : G // x ^ 2 = 1} where + toFun x := ⟨x / r, by rw [div_pow, x.property, div_self']⟩ + invFun x := ⟨x * r, by rw [mul_pow, x.property, one_mul]⟩ + left_inv x := by ext; exact div_mul_cancel x.val r + right_inv x := by ext; exact mul_div_cancel_right x.val r + +theorem cyclic_square_fiber_card_le {G : Type*} [CommGroup G] [Fintype G] + [IsCyclic G] (a : G) : Nat.card {x : G // x ^ 2 = a} ≤ 2 := by + classical + rw [Nat.card_eq_fintype_card] + by_cases h : ∃ r : G, r ^ 2 = a + · obtain ⟨r, rfl⟩ := h + rw [Fintype.card_congr (squareFiberEquivOne r)] + simpa only [Fintype.card_subtype] using (IsCyclic.card_pow_eq_one_le (α := G) (by decide : 0 < 2)) + · have hi : IsEmpty {x : G // x ^ 2 = a} := ⟨fun x => h ⟨x, x.property⟩⟩ + rw [Fintype.card_of_isEmpty] + omega + +/-- The odd-prime-power part of the manuscript's square-root bound follows +from Mathlib's proved cyclicity of the unit group. -/ +theorem odd_prime_power_square_fiber_card_le (p n : ℕ) [Fact p.Prime] + (hp2 : p ≠ 2) (a : (ZMod (p ^ n))ˣ) : + Nat.card {x : (ZMod (p ^ n))ˣ // x ^ 2 = a} ≤ 2 := by + let _ : NeZero (p ^ n) := ⟨pow_ne_zero _ (Fact.out : p.Prime).ne_zero⟩ + let _ : IsCyclic (ZMod (p ^ n))ˣ := + ZMod.isCyclic_units_of_prime_pow p Fact.out hp2 n + exact cyclic_square_fiber_card_le a + +noncomputable def crtSquareFiberEquiv {I : Type*} [Fintype I] + (q : I → ℕ) (hc : Pairwise (fun i j => (q i).Coprime (q j))) + (a : (ZMod (∏ i, q i))ˣ) : + {x : (ZMod (∏ i, q i))ˣ // x ^ 2 = a} ≃ + ∀ i, {x : (ZMod (q i))ˣ // x ^ 2 = crtUnitEquiv q hc a i} := + ((crtUnitEquiv q hc).toEquiv.subtypeEquiv (by + intro x + constructor + · intro hx i + simpa only [map_pow, Pi.pow_apply, MulEquiv.toEquiv_eq_coe, MulEquiv.coe_toEquiv] using + congrArg (fun y => crtUnitEquiv q hc y i) hx + · intro hx + apply (crtUnitEquiv q hc).injective + funext i + simpa only [map_pow, Pi.pow_apply, MulEquiv.toEquiv_eq_coe, MulEquiv.coe_toEquiv] + using hx i)).trans Equiv.subtypePiEquivPi + +theorem crt_square_fiber_card {I : Type*} [Fintype I] + (q : I → ℕ) [∀ i, NeZero (q i)] [NeZero (∏ i, q i)] + (hc : Pairwise (fun i j => (q i).Coprime (q j))) (a : (ZMod (∏ i, q i))ˣ) : + Nat.card {x : (ZMod (∏ i, q i))ˣ // x ^ 2 = a} = + ∏ i, Nat.card {x : (ZMod (q i))ˣ // x ^ 2 = crtUnitEquiv q hc a i} := by + rw [Nat.card_congr (crtSquareFiberEquiv q hc a)] + simp only [Nat.card_eq_fintype_card, Fintype.card_pi] + +/-- Exact CRT factorization gives the full odd-prime-power square bound. -/ +theorem odd_prime_powers_square_fiber_card_le {I : Type*} [Fintype I] + (p n : I → ℕ) [∀ i, Fact (p i).Prime] [∀ i, NeZero (p i ^ n i)] + [NeZero (∏ i, p i ^ n i)] + (hp2 : ∀ i, p i ≠ 2) + (hc : Pairwise (fun i j => (p i ^ n i).Coprime (p j ^ n j))) + (a : (ZMod (∏ i, p i ^ n i))ˣ) : + Nat.card {x : (ZMod (∏ i, p i ^ n i))ˣ // x ^ 2 = a} ≤ 2 ^ Fintype.card I := by + rw [crt_square_fiber_card (fun i => p i ^ n i) hc a] + calc + _ ≤ ∏ _i : I, 2 := Finset.prod_le_prod fun i _ => + odd_prime_power_square_fiber_card_le (p i) (n i) (hp2 i) _ + _ = _ := by simp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SquareLiftExclusions.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SquareLiftExclusions.lean new file mode 100644 index 0000000000000000000000000000000000000000..e7711f7ac3fd8b6c6a6000f6d920b8ec4e514211 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SquareLiftExclusions.lean @@ -0,0 +1,111 @@ +import Mathlib.Analysis.Complex.Basic +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticLifts + +namespace OAI + +/-! # Dropping the prime-square exclusions in a two-history expansion -/ + +namespace Ostmann + +open scoped BigOperators + +/-- Uniform pairs over the fixed giant residues modulo `p`. -/ +abbrev SquareLiftPairs (p : ℕ) (x₀ y₀ : ZMod p) := + {x : ZMod (p ^ 2) // squareReduction p x = x₀} × + {y : ZMod (p ^ 2) // squareReduction p y = y₀} + +private def zeroLiftEquiv {p : ℕ} (a : (ZMod (p ^ 2))ˣ) + (b : ZMod (p ^ 2)) (x₀ y₀ : ZMod p) : + {v : SquareLiftPairs p x₀ y₀ // (a : ZMod (p ^ 2)) * v.1.1 + b * v.2.1 = 0} ≃ + {xy : ZMod (p ^ 2) × ZMod (p ^ 2) // + squareReduction p xy.1 = x₀ ∧ squareReduction p xy.2 = y₀ ∧ + (a : ZMod (p ^ 2)) * xy.1 + b * xy.2 = 0} where + toFun v := ⟨(v.1.1, v.1.2), v.1.1.property, v.1.2.property, v.property⟩ + invFun v := ⟨(⟨v.1.1, v.property.1⟩, ⟨v.1.2, v.property.2.1⟩), v.property.2.2⟩ + left_inv _ := rfl + right_inv _ := rfl + +theorem card_zeroLift {p : ℕ} [Fact p.Prime] + (a : (ZMod (p ^ 2))ˣ) (b : ZMod (p ^ 2)) (x₀ y₀ : ZMod p) + (hbase : squareReduction p a * x₀ + squareReduction p b * y₀ = 0) : + Fintype.card {v : SquareLiftPairs p x₀ y₀ // + (a : ZMod (p ^ 2)) * v.1.1 + b * v.2.1 = 0} = p := by + rw [Fintype.card_congr (zeroLiftEquiv a b x₀ y₀), + Fintype.card_congr (liftedLineEquiv (squareReduction p) a b x₀ y₀ hbase), + card_squareReduction_fiber] + +/-- All forbidden prime-square zeros, one for each occurrence of the prime. -/ +noncomputable def squareLiftBad {I : Type*} [Fintype I] {p : ℕ} [Fact p.Prime] + (a : I → (ZMod (p ^ 2))ˣ) (b : I → ZMod (p ^ 2)) (x₀ y₀ : ZMod p) : + Finset (SquareLiftPairs p x₀ y₀) := by + classical + exact Finset.univ.filter fun v => ∃ i, (a i : ZMod (p ^ 2)) * v.1.1 + b i * v.2.1 = 0 + +theorem card_squareLiftBad_le {I : Type*} [Fintype I] {p : ℕ} [Fact p.Prime] + (a : I → (ZMod (p ^ 2))ˣ) (b : I → ZMod (p ^ 2)) (x₀ y₀ : ZMod p) + (hbase : ∀ i, squareReduction p (a i) * x₀ + squareReduction p (b i) * y₀ = 0) : + (squareLiftBad a b x₀ y₀).card ≤ Fintype.card I * p := by + classical + have heq : squareLiftBad a b x₀ y₀ = Finset.univ.biUnion + (fun i => Finset.univ.filter fun v : SquareLiftPairs p x₀ y₀ => + (a i : ZMod (p ^ 2)) * v.1.1 + b i * v.2.1 = 0) := by + ext v + simp [squareLiftBad] + rw [heq] + refine (Finset.card_biUnion_le).trans_eq ?_ + have hc (i : I) : (Finset.univ.filter fun v : SquareLiftPairs p x₀ y₀ => + (a i : ZMod (p ^ 2)) * v.1.1 + b i * v.2.1 = 0).card = p := by + simpa only [Fintype.card_subtype] using card_zeroLift (a i) (b i) x₀ y₀ (hbase i) + simp only [hc, Finset.sum_const, Finset.card_univ, smul_eq_mul] + +/-- A bounded integrand loses at most `B * (# occurrences) / p` when all +prime-square exclusions are imposed. No independence of the exclusions is used. -/ +theorem square_lift_removed_mass_le {I : Type*} [Fintype I] {p : ℕ} [Fact p.Prime] + (a : I → (ZMod (p ^ 2))ˣ) (b : I → ZMod (p ^ 2)) (x₀ y₀ : ZMod p) + (hbase : ∀ i, squareReduction p (a i) * x₀ + squareReduction p (b i) * y₀ = 0) + (F : SquareLiftPairs p x₀ y₀ → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hF : ∀ v, ‖F v‖ ≤ B) : + ‖∑ v ∈ squareLiftBad a b x₀ y₀, F v‖ / (p : ℝ) ^ 2 ≤ + B * (Fintype.card I : ℝ) / p := by + classical + have hcard : ((squareLiftBad a b x₀ y₀).card : ℝ) ≤ (Fintype.card I : ℝ) * p := + by exact_mod_cast card_squareLiftBad_le a b x₀ y₀ hbase + have hsum : ‖∑ v ∈ squareLiftBad a b x₀ y₀, F v‖ ≤ B * (Fintype.card I : ℝ) * p := by + calc + _ ≤ ∑ v ∈ squareLiftBad a b x₀ y₀, ‖F v‖ := norm_sum_le _ _ + _ ≤ ∑ _v ∈ squareLiftBad a b x₀ y₀, B := Finset.sum_le_sum fun v _ => hF v + _ = B * ((squareLiftBad a b x₀ y₀).card : ℝ) := by simp [mul_comm] + _ ≤ _ := by nlinarith + have hp : (0 : ℝ) < p := by exact_mod_cast (Fact.out : p.Prime).pos + calc + _ ≤ (B * (Fintype.card I : ℝ) * p) / (p : ℝ) ^ 2 := + div_le_div_of_nonneg_right hsum (sq_nonneg _) + _ = _ := by field_simp + +/-- The form used in both giant environments: the second giant has a nonzero +residue, and every occurrence has a nonzero row. This supplies the unit +coefficient needed for the lift count rather than assuming it separately. -/ +theorem square_lift_nonzero_rows_removed_mass_le {I : Type*} [Fintype I] + {p : ℕ} [Fact p.Prime] (a b : I → ZMod (p ^ 2)) (x₀ y₀ : ZMod p) + (hy : y₀ ≠ 0) + (hrow : ∀ i, squareReduction p (a i) ≠ 0 ∨ squareReduction p (b i) ≠ 0) + (hbase : ∀ i, squareReduction p (a i) * x₀ + squareReduction p (b i) * y₀ = 0) + (F : SquareLiftPairs p x₀ y₀ → ℂ) (B : ℝ) (hB : 0 ≤ B) + (hF : ∀ v, ‖F v‖ ≤ B) : + ‖∑ v ∈ Finset.univ.filter (fun v : SquareLiftPairs p x₀ y₀ => + ∃ i, a i * v.1.1 + b i * v.2.1 = 0), F v‖ / (p : ℝ) ^ 2 ≤ + B * (Fintype.card I : ℝ) / p := by + classical + let u : I → (ZMod (p ^ 2))ˣ := fun i => + (square_line_first_isUnit (a i) (b i) x₀ y₀ hy (hrow i) (hbase i)).unit + have hu (i : I) : (u i : ZMod (p ^ 2)) = a i := IsUnit.unit_spec _ + have hb : ∀ i, squareReduction p (u i) * x₀ + squareReduction p (b i) * y₀ = 0 := by + intro i + rw [hu] + exact hbase i + simpa only [squareLiftBad, hu] using + square_lift_removed_mass_le u b x₀ y₀ hb F B hB hF + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SquareRootProbability.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SquareRootProbability.lean new file mode 100644 index 0000000000000000000000000000000000000000..efcc7cdfa3a20cfb0561a9f6420527766f58be71 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SquareRootProbability.lean @@ -0,0 +1,68 @@ +import Mathlib.NumberTheory.ArithmeticFunction.Misc +import Mathlib.Tactic.FieldSimp +import OAI.NumberTheory.Ostmann.Arithmetic.UnitSquareRoots + +namespace OAI + +/-! # The divisor loss in the square-congruence probability -/ + +namespace Ostmann + +open scoped BigOperators Classical + +theorem two_pow_primeFactors_card_le_divisors_card (q : ℕ) (hq : q ≠ 0) : + 2 ^ q.primeFactors.card ≤ q.divisors.card := by + rw [Nat.card_divisors hq] + calc + _ = ∏ _p ∈ q.primeFactors, 2 := by simp + _ ≤ _ := by + apply Finset.prod_le_prod + intro p hp + have hmem : p ∈ q.factorization.support := by + simpa only [Nat.support_factorization] using hp + have hf := Finsupp.mem_support_iff.mp hmem + omega + +theorem le_divisors_card_mul_totient (q : ℕ) (hq : q ≠ 0) : + q ≤ q.divisors.card * q.totient := by + calc + _ = ∑ d ∈ q.divisors, d.totient := (Nat.sum_totient q).symm + _ ≤ ∑ _d ∈ q.divisors, q.totient := Finset.sum_le_sum fun d hd => + Nat.le_of_dvd (Nat.totient_pos.mpr (Nat.pos_of_ne_zero hq)) + (Nat.totient_dvd_of_dvd (Nat.dvd_of_mem_divisors hd)) + _ = _ := by simp + +/-- The loss from unit sampling and the possible power of two is bounded +by two divisor factors, leaving the essential reciprocal-modulus decay. -/ +theorem square_root_density_factor_le (q : ℕ) [NeZero q] : + (2 : ℝ) ^ (q.primeFactors.card + 1) / q.totient ≤ + 2 * (q.divisors.card : ℝ) ^ 2 / q := by + have hq : (0 : ℝ) < q := by exact_mod_cast NeZero.pos q + have hφ : (0 : ℝ) < q.totient := by + exact_mod_cast Nat.totient_pos.mpr (NeZero.pos q) + have hω : (2 : ℝ) ^ q.primeFactors.card ≤ q.divisors.card := by + exact_mod_cast two_pow_primeFactors_card_le_divisors_card q (NeZero.ne q) + have hd : (q : ℝ) ≤ q.divisors.card * (q.totient : ℝ) := by + exact_mod_cast le_divisors_card_mul_totient q (NeZero.ne q) + apply (div_le_div_iff₀ hφ hq).mpr + calc + _ ≤ (2 * (q.divisors.card : ℝ)) * q := by + rw [pow_succ] + exact mul_le_mul_of_nonneg_right (by nlinarith) hq.le + _ ≤ (2 * (q.divisors.card : ℝ)) * (q.divisors.card * (q.totient : ℝ)) := + mul_le_mul_of_nonneg_left hd (by positivity) + _ = _ := by ring + +/-- A Haar unit satisfies a prescribed square congruence with probability +at most `2*tau(q)^2/q`. This applies also to inconsistent congruences. -/ +theorem unit_square_probability_le (q : ℕ) [NeZero q] (a : (ZMod q)ˣ) : + (Nat.card {x : (ZMod q)ˣ // x ^ 2 = a} : ℝ) / Fintype.card (ZMod q)ˣ ≤ + 2 * (q.divisors.card : ℝ) ^ 2 / q := by + rw [ZMod.card_units_eq_totient] + apply le_trans _ (square_root_density_factor_le q) + apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _) + exact_mod_cast unit_square_fiber_card_le q a + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SupportedHistoryCancellation.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SupportedHistoryCancellation.lean new file mode 100644 index 0000000000000000000000000000000000000000..d4fa7f90ac0b121d32caa2746402d6c1c5a33998 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SupportedHistoryCancellation.lean @@ -0,0 +1,71 @@ +import OAI.NumberTheory.Ostmann.Construction.HistoryResidueGate +import OAI.NumberTheory.Ostmann.Characters.PolynomialRangeGuards +import OAI.NumberTheory.Ostmann.Arithmetic.HarmonicPeriodicBound + +namespace OAI + +/-! # One-sided cancellation with the literal history support conditions -/ + +namespace Ostmann + +open scoped BigOperators Classical + +noncomputable def supportedHistoryAmplitude {σ I : Type*} [Fintype I] {n : ℕ} + (N : I → MvPolynomial σ ℤ) (d : I → ℤ) (s : I → ℕ) (a : σ → ℤ) (i : σ) + (F : Fin n → ClippedPolynomialFactor) (x : ℤ) : ℂ := + (if ∀ j, smallDivisionTest + (MvPolynomial.eval₂ (RingHom.id ℤ) (Function.update a i x) (N j)) (d j) (s j) then 1 else 0) * + ((if ∀ j, (F j).polynomial.eval (x : ℝ) ∈ Set.Icc (F j).lo (F j).hi then 1 else 0) * + ∏ j, (F j).profile ((F j).polynomial.eval (x : ℝ))) + +theorem supportedHistoryAmplitude_eq {σ I : Type*} [Fintype I] {n : ℕ} + (N : I → MvPolynomial σ ℤ) (d : I → ℤ) (s : I → ℕ) (a : σ → ℤ) (i : σ) + (F : Fin n → ClippedPolynomialFactor) (M : ℕ) [NeZero M] + (hd : ∀ j, d j ≠ 0) (hdiv : ∀ j, d j * s j ∣ (M : ℤ)) (x : ℤ) : + supportedHistoryAmplitude N d s a i F x = + clearedHistoryResidueGate N d s a i M (x : ZMod M) * + polynomialAmplitude F (polynomialRangeBounds F) (polynomialRangeKeep n) (x : ℝ) := by + rw [clearedHistoryResidueGate_exact N d s a i M hd hdiv x, polynomialAmplitude_range] + rfl + +/-- All residue gates and sharp smooth-argument ranges are the actual tests +on the sampled integers. No hypothesis asserting their regularity is needed. -/ +theorem harmonic_supported_history_bound {σ I : Type*} [Fintype I] {n : ℕ} + (P Q : Finset ℕ) (hprime : ∀ q ∈ Q, q.Prime) + (χ : ∀ q : Q, DirichletCharacter ℂ (q : ℕ)) (hnonprincipal : ∀ q, χ q ≠ 1) + (a M K : ℕ) [NeZero M] (ha : 0 < a) (hM : ∀ q : Q, M.Coprime (q : ℕ)) + (hlow : ∀ p ∈ P, a ≤ p) (hhigh : ∀ p ∈ P, p < a + K * M) + (b : ℝ) (hb : 0 < b) (hbQ : ∀ q ∈ Q, b ≤ (q : ℝ)) + (hPmass : 0 < ∑ p ∈ P, (p : ℝ)⁻¹) (hQmass : 0 < ∑ q ∈ Q, (q : ℝ)⁻¹) + (N : Q → I → MvPolynomial σ ℤ) (d : Q → I → ℤ) (s : Q → I → ℕ) + (fixed : Q → σ → ℤ) (coord : σ) + (hd : ∀ q j, d q j ≠ 0) (hdiv : ∀ q j, d q j * s q j ∣ (M : ℤ)) + (F : Q → Fin n → ClippedPolynomialFactor) (B : ℝ) (D Bq : ℕ) + (hB : 0 ≤ B) (hbudget : ∀ q, smoothPolynomialBudget (F q) ≤ B) + (hdegree : ∀ q, (∑ j, (F q j).polynomial.natDegree) ≤ D) + (hBq : ∀ q : Q, (q : ℕ) ≤ Bq) + (U : P → ℂ) (V : Q → ℂ) (hU : ∀ p, ‖U p‖ ≤ 1) (hV : ∀ q, ‖V q‖ ≤ 1) : + ‖∑ p : P, (primeSubsetPrior P P p : ℂ) * + (U p * ∑ q : Q, (primeSubsetPrior Q Q q : ℂ) * V q * + (χ q ((p : ℕ) : ZMod (q : ℕ)) * + supportedHistoryAmplitude (N q) (d q) (s q) (fixed q) coord (F q) (p : ℕ)))‖ ^ 2 ≤ + (∑ p ∈ P, (p : ℝ)⁻¹)⁻¹ * + (((∑ q ∈ Q, (q : ℝ)⁻¹)⁻¹ * b⁻¹) * (((K * M : ℕ) : ℝ) / a * B ^ 2) + + (M : ℝ) * ((3 ^ (2 * (3 * D)) : ℕ) * (2 * (a : ℝ)⁻¹ * B ^ 2)) * (Bq : ℝ) ^ 2) := by + have he (q : Q) (p : P) : supportedHistoryAmplitude (N q) (d q) (s q) (fixed q) coord (F q) (p : ℕ) = + clearedHistoryResidueGate (N q) (d q) (s q) (fixed q) coord M ((p : ℕ) : ZMod M) * + polynomialAmplitude (F q) (polynomialRangeBounds (F q)) (polynomialRangeKeep n) (p : ℝ) := by + simpa only [Int.cast_natCast] using supportedHistoryAmplitude_eq + (N q) (d q) (s q) (fixed q) coord (F q) M (hd q) (hdiv q) (p : ℕ) + simp_rw [he] + apply harmonic_periodic_polynomial_one_sided_bound P Q hprime χ hnonprincipal a M K ha hM + (fun q => clearedHistoryResidueGate (N q) (d q) (s q) (fixed q) coord M) + (fun q => clearedHistoryResidueGate_norm (N q) (d q) (s q) (fixed q) coord M) + hlow hhigh b hb hbQ hPmass hQmass F (fun q => polynomialRangeBounds (F q)) + (fun _ => polynomialRangeKeep n) B (3 * D) Bq hB hbudget _ hBq U V hU hV + intro q + exact (polynomialRange_complexity (F q)).trans (Nat.mul_le_mul_left 3 (hdegree q)) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SupportedMatchedHistoryEnergy.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SupportedMatchedHistoryEnergy.lean new file mode 100644 index 0000000000000000000000000000000000000000..058ab534ce639261bd2e290e61768532c48464ea --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SupportedMatchedHistoryEnergy.lean @@ -0,0 +1,54 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.MatchedHistoryEnergy +import OAI.NumberTheory.Ostmann.Construction.ConstituentUniqueRootEnergy + +namespace OAI + +/-! # Matched history energy using only its nonzero support -/ + +namespace Ostmann +open scoped BigOperators Classical ComplexConjugate + +theorem permuted_root_energy_on_support {A R : Type*} [Fintype A] [Fintype R] + (e : Equiv.Perm A) (μ : A → ℝ) (F : R → A → ℂ) (A₀ : ℝ) + (hA₀ : 0 ≤ A₀) (hμ : ∀ a, 0 ≤ μ a) (hbound : ∀ s a, F s a ≠ 0 → μ a ≤ A₀) : + ‖∑ s, ∑ a, ((μ a * μ (e a) : ℝ) : ℂ) * F s a * conj (F s (e a))‖ ≤ + A₀ * ∑ s, ∑ a, μ a * ‖F s a‖ ^ 2 := by + have hs (s : R) := matched_diagonal_energy e μ μ (F s) (F s) (fun _ => 1) A₀ + hA₀ hμ hμ (fun _ => by simp) (fun a ha he => ⟨hbound s a ha, hbound s (e a) he⟩) + simp only [mul_one] at hs + calc + _ ≤ ∑ s, ‖∑ a, ((μ a * μ (e a) : ℝ) : ℂ) * F s a * conj (F s (e a))‖ := norm_sum_le _ _ + _ ≤ ∑ s, A₀ / 2 * ((∑ a, μ a * ‖F s a‖ ^ 2) + ∑ a, μ a * ‖F s a‖ ^ 2) := + Finset.sum_le_sum fun s _ => hs s + _ = _ := by rw [← Finset.mul_sum, Finset.sum_add_distrib]; ring + +/-- Root equality is retained in the diagonal. Uniqueness removes the entire +frequency-history multiplicity from its square-energy estimate. -/ +theorem permuted_history_energy_on_support {A D R : Type*} + [Fintype A] [Fintype D] [Fintype R] + (e : Equiv.Perm A) (μ : A → ℝ) (root : D → R) (F : D → A → ℂ) (A₀ : ℝ) + (hA₀ : 0 ≤ A₀) (hμ : ∀ a, 0 ≤ μ a) (hbound : ∀ a d, F d a ≠ 0 → μ a ≤ A₀) + (hunique : ∀ a d d', F d a ≠ 0 → F d' a ≠ 0 → root d = root d' → d = d') : + ‖∑ d, ∑ d', if root d = root d' then + ∑ a, ((μ a * μ (e a) : ℝ) : ℂ) * (F d a * conj (F d' (e a))) else 0‖ ≤ + A₀ * ∑ d, ∑ a, μ a * ‖F d a‖ ^ 2 := by + rw [← rootFibreSum_weighted_pair root root (fun a => μ a * μ (e a)) F + (fun d a => F d (e a))] + have h := permuted_root_energy_on_support e μ (fun s a => rootFibreSum root s (fun d => F d a)) + A₀ hA₀ hμ (by + intro s a ha + by_contra hn + have hz (d : D) : F d a = 0 := by + by_contra hd + exact hn (hbound a d hd) + exact ha (by simp [rootFibreSum, hz])) + simp only [mul_assoc] at h + apply h.trans_eq + congr 1 + rw [Finset.sum_comm] + simp_rw [← Finset.mul_sum, rootFibreSum_energy_of_unique root _ (hunique _), Finset.mul_sum] + exact Finset.sum_comm + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SupportedPolynomialCharacterSum.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SupportedPolynomialCharacterSum.lean new file mode 100644 index 0000000000000000000000000000000000000000..853f3675d551706edfcc2f24fd2e41bc62bc2f53 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SupportedPolynomialCharacterSum.lean @@ -0,0 +1,61 @@ +import OAI.NumberTheory.Ostmann.Characters.PolynomialCharacterSum +import OAI.NumberTheory.Ostmann.Characters.PolynomialCellSupports + +namespace OAI + +/-! # The weighted character bound with its actual polynomial support -/ + +namespace Ostmann + +open scoped BigOperators ComplexConjugate Classical + +noncomputable def historyWeightRootCuts {n t : ℕ} (F : Fin n → ClippedPolynomialFactor) + (H : Fin t → Polynomial ℝ) : Finset ℝ := + polynomialRootCuts (Sum.elim (fun i => (F i).polynomial.derivative) H) + +theorem historyWeightRootCuts_factor {n t : ℕ} (F : Fin n → ClippedPolynomialFactor) + (H : Fin t → Polynomial ℝ) (i : Fin n) (x : ℝ) + (hx : x ∈ (F i).polynomial.derivative.roots) : x ∈ historyWeightRootCuts F H := by + apply Finset.mem_biUnion.mpr + exact ⟨Sum.inl i, Finset.mem_univ _, by simpa only [Sum.elim_inl, Multiset.mem_toFinset] using hx⟩ + +theorem historyWeightRootCuts_support {n t : ℕ} (F : Fin n → ClippedPolynomialFactor) + (H : Fin t → Polynomial ℝ) (i : Fin t) (x : ℝ) (hx : x ∈ (H i).roots) : + x ∈ historyWeightRootCuts F H := by + apply Finset.mem_biUnion.mpr + exact ⟨Sum.inr i, Finset.mem_univ _, by simpa only [Sum.elim_inr, Multiset.mem_toFinset] using hx⟩ + +theorem historyWeightRootCuts_card {n t : ℕ} (F : Fin n → ClippedPolynomialFactor) + (H : Fin t → Polynomial ℝ) : + (historyWeightRootCuts F H).card ≤ + (∑ i, (F i).polynomial.derivative.natDegree) + ∑ i, (H i).natDegree := by + simpa only [historyWeightRootCuts, Fintype.sum_sum_type, Sum.elim_inl, Sum.elim_inr] using + polynomialRootCuts_card (Sum.elim (fun i => (F i).polynomial.derivative) H) + +theorem supported_polynomial_character_progression {q r : ℕ} [NeZero q] [NeZero r] + (hqr : q.Coprime r) (χ : DirichletCharacter ℂ q) (ψ : DirichletCharacter ℂ r) + (hχ : χ ≠ 1) (a M N : ℕ) (ha : 0 < a) (hM : M.Coprime (q * r)) + {n t : ℕ} (F : Fin n → ClippedPolynomialFactor) (H : Fin t → Polynomial ℝ) + (keep : (Fin t → Bool) → Bool) : + ‖∑ j ∈ Finset.range N, + (if keep (polynomialSupportCode H ((a + M * j : ℕ) : ℝ)) = true then (1 : ℂ) else 0) * + (Complex.ofReal (((a + M * j : ℕ) : ℝ)⁻¹) * + smoothPolynomialWeight F ((a + M * j : ℕ) : ℝ)) * + (χ ((a + M * j : ℕ) : ZMod q) * conj (ψ ((a + M * j : ℕ) : ZMod r)))‖ ≤ + (3 ^ ((∑ i, (F i).polynomial.derivative.natDegree) + ∑ i, (H i).natDegree) : ℕ) * + (2 * (a : ℝ)⁻¹ * smoothPolynomialBudget F) * (q * r) := by + let S := historyWeightRootCuts F H + have hb := polynomial_weighted_character_progression hqr χ ψ hχ a M N ha hM F S + (historyWeightRootCuts_factor F H) (polynomialRootCellFlag H S keep) + (polynomialRootCellFlag_norm H S keep) + simp_rw [polynomialRootCellFlag_value H S (historyWeightRootCuts_support F H) keep] at hb + apply hb.trans + apply mul_le_mul_of_nonneg_right _ (by positivity) + apply mul_le_mul_of_nonneg_right _ (by + have hV := smoothPolynomialBudget_nonneg F + positivity) + exact_mod_cast Nat.pow_le_pow_right (by norm_num : 0 < (3 : ℕ)) (historyWeightRootCuts_card F H) + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SymbolicLineComparison.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SymbolicLineComparison.lean new file mode 100644 index 0000000000000000000000000000000000000000..11fdee8db045867ec43e661f6598ed76c03aee7f --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SymbolicLineComparison.lean @@ -0,0 +1,149 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.ArithmeticCoincidences +import OAI.NumberTheory.Ostmann.Arithmetic.WeightedFlagComparison + +namespace OAI + +/-! # Signed replacement of accidental arithmetic flags + +After denominators are cleared in §8, coefficient and minor tests are integer +polynomials. Under independent representative priors, replacing their congruence +flags by their rational polynomial-identity flags has the following quantitative +error. The polynomial root and prime-divisor estimates are proved inputs here. +-/ + +namespace Ostmann + +open scoped BigOperators + +/-- Use one fixed decision procedure in statements and proofs. -/ +noncomputable def arithmeticTestFlag (P : Prop) : Bool := by + classical + exact decide P + +@[simp] theorem arithmeticTestFlag_of_true {P : Prop} (h : P) : arithmeticTestFlag P = true := by + simp [arithmeticTestFlag, h] + +@[simp] theorem arithmeticTestFlag_of_false {P : Prop} (h : ¬P) : arithmeticTestFlag P = false := by + simp [arithmeticTestFlag, h] + +@[simp] theorem arithmeticTestFlag_eq_true_iff (P : Prop) : + arithmeticTestFlag P = true ↔ P := by + classical + by_cases h : P <;> simp [h] + +@[simp] theorem arithmeticTestFlag_eq_false_iff (P : Prop) : + arithmeticTestFlag P = false ↔ ¬P := by + classical + by_cases h : P <;> simp [h] + +/-- The actual divisibility flags agree with the symbolic identity flags away +from the accidental zeros of nonzero polynomials. -/ +theorem polynomial_flags_agree {X I : Type*} {n : ℕ} + (F : I → MvPolynomial (Fin n) ℚ) (value : X → Fin n → ℚ) + (N : I → X → ℕ) + (hzero : ∀ i x, N i x = 0 ↔ MvPolynomial.eval (value x) (F i) = 0) + (x : X) (p : ℕ) (hgood : ∀ i, ¬(F i ≠ 0 ∧ p ∣ N i x)) : + (fun i => arithmeticTestFlag (p ∣ N i x)) = (fun i => arithmeticTestFlag (F i = 0)) := by + classical + funext i + by_cases hi : F i = 0 + · have hn : N i x = 0 := (hzero i x).mpr (by simp [hi]) + simp [hn, hi] + · have hn : ¬p ∣ N i x := fun h => hgood i ⟨hi, h⟩ + simp [hi, hn] + +private theorem weighted_prime_event_sum {X : Type*} [Fintype X] + (P : Finset ℕ) (w : X → ℝ) (ν : ℕ → ℝ) (event : X → ℕ → Prop) + [∀ x p, Decidable (event x p)] : + (∑ xp : X × {p // p ∈ P}, (w xp.1 * ν xp.2) * + if event xp.1 xp.2 then (1 : ℝ) else 0) = + ∑ x, w x * ∑ p ∈ P, if event x p then ν p else 0 := by + rw [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro x _ + rw [← Finset.sum_coe_sort P, Finset.mul_sum] + apply Finset.sum_congr rfl + intro p _ + by_cases h : event x p <;> simp [h] + +private theorem polynomial_event_bound {A : Type*} [Fintype A] {n : ℕ} + (value : A → ℚ) (hinj : Function.Injective value) + (F : MvPolynomial (Fin n) ℚ) + (μ : Fin n → A → ℝ) (hμ : ∀ i a, 0 ≤ μ i a) + (hmass : ∀ i, ∑ a, μ i a = 1) + (α : ℝ) (hα : 0 ≤ α) (hmax : ∀ i a, μ i a ≤ α) + (P : Finset ℕ) (ν : ℕ → ℝ) (hνmass : ∑ p ∈ P, ν p = 1) + (N : (Fin n → A) → ℕ) + (hzero : ∀ x, N x = 0 ↔ MvPolynomial.eval (fun j => value (x j)) F = 0) + (β K : ℝ) (hβ : 0 ≤ β) (hK : 0 ≤ K) (hνmax : ∀ p ∈ P, ν p ≤ β) + (hcard : ∀ x, N x ≠ 0 → ((P.filter fun p => p ∣ N x).card : ℝ) ≤ K) : + (∑ xp : (Fin n → A) × {p // p ∈ P}, (productPrior μ xp.1 * ν xp.2) * + if F ≠ 0 ∧ (xp.2 : ℕ) ∣ N xp.1 then (1 : ℝ) else 0) ≤ + (F.totalDegree : ℝ) * α + K * β := by + classical + rw [weighted_prime_event_sum P (productPrior μ) ν (fun x p => F ≠ 0 ∧ p ∣ N x)] + by_cases hi : F = 0 + · simp only [hi, ne_eq, not_true_eq_false, false_and, ite_false, + Finset.sum_const_zero, mul_zero] + positivity + · simp only [ne_eq, hi, not_false_eq_true, true_and] + exact polynomial_prime_coincidence_le value hinj F hi μ hμ hmass + α hα hmax P ν hνmass N hzero β K hβ hK hνmax hcard + +/-- Signed comparison for any bounded amplitude depending on the coefficient +and minor flags, with the smooth and spectator variables left untouched. -/ +theorem polynomial_symbolic_comparison_le {A I : Type*} [Fintype A] [Fintype I] + {n : ℕ} (value : A → ℚ) (hinj : Function.Injective value) + (F : I → MvPolynomial (Fin n) ℚ) + (μ : Fin n → A → ℝ) (hμ : ∀ i a, 0 ≤ μ i a) + (hmass : ∀ i, ∑ a, μ i a = 1) + (α : ℝ) (hα : 0 ≤ α) (hmax : ∀ i a, μ i a ≤ α) + (P : Finset ℕ) (ν : ℕ → ℝ) (hν : ∀ p ∈ P, 0 ≤ ν p) + (hνmass : ∑ p ∈ P, ν p = 1) + (N : I → (Fin n → A) → ℕ) + (hzero : ∀ i x, N i x = 0 ↔ MvPolynomial.eval (fun j => value (x j)) (F i) = 0) + (β K : ℝ) (hβ : 0 ≤ β) (hK : 0 ≤ K) (hνmax : ∀ p ∈ P, ν p ≤ β) + (hcard : ∀ i x, N i x ≠ 0 → ((P.filter fun p => p ∣ N i x).card : ℝ) ≤ K) + (Ψ : (Fin n → A) → ℕ → (I → Bool) → ℂ) + (B : ℝ) (hB : 0 ≤ B) (hΨ : ∀ x p v, ‖Ψ x p v‖ ≤ B) : + ‖∑ x, ∑ p ∈ P, ((productPrior μ x * ν p : ℝ) : ℂ) * + (Ψ x p (fun i => arithmeticTestFlag (p ∣ N i x)) - Ψ x p (fun i => arithmeticTestFlag (F i = 0)))‖ ≤ + 2 * B * ∑ i, (((F i).totalDegree : ℝ) * α + K * β) := by + classical + let X := (Fin n → A) × {p // p ∈ P} + let w : X → ℝ := fun xp => productPrior μ xp.1 * ν xp.2 + let bad : I → X → Prop := fun i xp => F i ≠ 0 ∧ (xp.2 : ℕ) ∣ N i xp.1 + have hw : ∀ xp, 0 ≤ w xp := fun xp => mul_nonneg + (productPrior_nonneg μ hμ xp.1) (hν xp.2 xp.2.property) + have hprob (i : I) : (∑ xp : X, w xp * if bad i xp then 1 else 0) ≤ + ((F i).totalDegree : ℝ) * α + K * β := + polynomial_event_bound value hinj (F i) μ hμ hmass α hα hmax P ν hνmass + (N i) (hzero i) β K hβ hK hνmax (hcard i) + have heq (xp : X) (hgood : ∀ i, ¬bad i xp) : + (fun i => arithmeticTestFlag ((xp.2 : ℕ) ∣ N i xp.1)) = (fun i => arithmeticTestFlag (F i = 0)) := + @polynomial_flags_agree (Fin n → A) I n F + (fun (x : Fin n → A) j => value (x j)) N hzero xp.1 xp.2 hgood + have hbnd (xp : X) (v : I → Bool) : ‖Ψ xp.1 xp.2 v‖ ≤ B := hΨ xp.1 xp.2 v + have h := @weighted_flag_comparison_le X I inferInstance inferInstance w hw + (fun xp i => arithmeticTestFlag ((xp.2 : ℕ) ∣ N i xp.1)) + (fun _ i => arithmeticTestFlag (F i = 0)) bad + (fun _ _ => inferInstance) heq (fun xp => Ψ xp.1 xp.2) B hB hbnd + have hbound := h.trans (mul_le_mul_of_nonneg_left + (Finset.sum_le_sum fun i _ => hprob i) (by positivity : 0 ≤ 2 * B)) + let term : (Fin n → A) → ℕ → ℂ := fun x p => + ((productPrior μ x * ν p : ℝ) : ℂ) * + (Ψ x p (fun i => arithmeticTestFlag (p ∣ N i x)) - + Ψ x p (fun i => arithmeticTestFlag (F i = 0))) + change ‖∑ xp : X, term xp.1 xp.2‖ ≤ _ at hbound + have hsum : (∑ xp : X, term xp.1 xp.2) = ∑ x, ∑ p ∈ P, term x p := by + change (∑ xp : (Fin n → A) × {p // p ∈ P}, term xp.1 xp.2) = _ + rw [Fintype.sum_prod_type] + apply Finset.sum_congr rfl + intro x _ + exact (Finset.sum_subtype P (fun _ => Iff.rfl) (term x)).symm + rw [hsum] at hbound + exact hbound + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/SymmetrizedPairBound.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SymmetrizedPairBound.lean new file mode 100644 index 0000000000000000000000000000000000000000..3f8fe25567179b7bc88159f814ecf1ec8ab143b9 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/SymmetrizedPairBound.lean @@ -0,0 +1,99 @@ +import OAI.NumberTheory.Ostmann.Arithmetic.BulkSymmetrization +import OAI.NumberTheory.Ostmann.Tree.BadArrangementFraction + +namespace OAI + +/-! # Pair-correlation control of the symmetrized amplitude -/ + +namespace Ostmann + +open scoped BigOperators Classical + +noncomputable def finiteFamilyAverage {J X : Type*} [Fintype J] + (A : J → X → ℂ) (x : X) : ℂ := + (Fintype.card J : ℂ)⁻¹ * ∑ j, A j x + +theorem finiteFamilyAverage_norm_sq {J X : Type*} [Fintype J] + (A : J → X → ℂ) (x : X) : + ‖finiteFamilyAverage A x‖ ^ 2 = + ((Fintype.card J : ℝ)⁻¹) ^ 2 * + (∑ i : J, ∑ j : J, A i x * star (A j x)).re := by + have hs : (∑ i : J, ∑ j : J, A i x * star (A j x)) = + (∑ i, A i x) * star (∑ j, A j x) := by + rw [star_sum, Finset.sum_mul_sum] + rw [hs, Complex.star_def, Complex.mul_conj', ← Complex.ofReal_pow, Complex.ofReal_re] + unfold finiteFamilyAverage + rw [norm_mul, norm_inv, Complex.norm_natCast, mul_pow] + +theorem finiteFamilyAverage_energy_le {J X : Type*} [Fintype J] [Fintype X] + (μ : X → ℝ) (A : J → X → ℂ) : + (∑ x, μ x * ‖finiteFamilyAverage A x‖ ^ 2) ≤ + ((Fintype.card J : ℝ)⁻¹) ^ 2 * + ∑ i : J, ∑ j : J, ‖∑ x, (μ x : ℂ) * (A i x * star (A j x))‖ := by + simp_rw [finiteFamilyAverage_norm_sq A] + have hs : + (∑ x, μ x * (∑ i : J, ∑ j : J, A i x * star (A j x)).re) = + ∑ i : J, ∑ j : J, (∑ x, (μ x : ℂ) * (A i x * star (A j x))).re := by + simp only [Complex.re_sum, Complex.mul_re, Complex.ofReal_re, Complex.ofReal_im, + zero_mul, sub_zero, Finset.mul_sum] + rw [Finset.sum_comm] + apply Finset.sum_congr rfl + intro i _ + rw [Finset.sum_comm] + calc + _ = ((Fintype.card J : ℝ)⁻¹) ^ 2 * + ∑ x, μ x * (∑ i : J, ∑ j : J, A i x * star (A j x)).re := by + rw [Finset.mul_sum] + apply Finset.sum_congr rfl + intro x _ + ring + _ = _ := congrArg (fun z => ((Fintype.card J : ℝ)⁻¹) ^ 2 * z) hs + _ ≤ _ := mul_le_mul_of_nonneg_left + (Finset.sum_le_sum fun i _ => Finset.sum_le_sum fun j _ => Complex.re_le_norm _) + (sq_nonneg _) + +theorem sum_relative_function {J : Type*} [Group J] [Fintype J] + (f : J → ℝ) (i : J) : (∑ j, f (i⁻¹ * j)) = ∑ j, f j := + (Equiv.mulLeft i⁻¹).bijective.sum_comp f + +/-- Bad pairs are counted by a single relative permutation. No invariance +of individual amplitudes or support conditions is required. -/ +theorem finiteFamilyAverage_good_bad_bound {J X : Type*} [Group J] [Fintype J] + [Fintype X] (μ : X → ℝ) (A : J → X → ℂ) + (bad : J → Prop) (B E : ℝ) (hE : 0 ≤ E) + (hpair : ∀ i j, ‖∑ x, (μ x : ℂ) * (A i x * star (A j x))‖ ≤ + if bad (i⁻¹ * j) then B else E) : + (∑ x, μ x * ‖finiteFamilyAverage A x‖ ^ 2) ≤ + (Fintype.card {j : J // bad j} : ℝ) / Fintype.card J * B + E := by + have hc : (Fintype.card J : ℝ) ≠ 0 := by exact_mod_cast Fintype.card_ne_zero + have hc0 : 0 < (Fintype.card J : ℝ) := by exact_mod_cast Fintype.card_pos + have hsum : (∑ j : J, if bad j then B else E) ≤ + (Fintype.card {j : J // bad j} : ℝ) * B + (Fintype.card J : ℝ) * E := by + calc + _ ≤ ∑ j : J, ((if bad j then B else 0) + E) := by + apply Finset.sum_le_sum + intro j _ + split_ifs <;> linarith + _ = _ := by + rw [Finset.sum_add_distrib] + simp only [← Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, + Finset.card_univ, Fintype.card_subtype] + apply (finiteFamilyAverage_energy_le μ A).trans + calc + _ ≤ ((Fintype.card J : ℝ)⁻¹) ^ 2 * + ∑ i : J, ∑ j : J, if bad (i⁻¹ * j) then B else E := by + apply mul_le_mul_of_nonneg_left _ (sq_nonneg _) + exact Finset.sum_le_sum fun i _ => Finset.sum_le_sum fun j _ => hpair i j + _ = ((Fintype.card J : ℝ)⁻¹) ^ 2 * + ((Fintype.card J : ℝ) * ∑ j : J, if bad j then B else E) := by + simp only [sum_relative_function (fun j => if bad j then B else E), + Finset.sum_const, Finset.card_univ, nsmul_eq_mul] + _ ≤ ((Fintype.card J : ℝ)⁻¹) ^ 2 * + ((Fintype.card J : ℝ) * + ((Fintype.card {j : J // bad j} : ℝ) * B + (Fintype.card J : ℝ) * E)) := by + gcongr + _ = _ := by field_simp + +end Ostmann + +end OAI diff --git a/lean/OAI/NumberTheory/Ostmann/Arithmetic/TopPrimePairSupport.lean b/lean/OAI/NumberTheory/Ostmann/Arithmetic/TopPrimePairSupport.lean new file mode 100644 index 0000000000000000000000000000000000000000..989f6abc6cceda060cff631b713266efc5f31381 --- /dev/null +++ b/lean/OAI/NumberTheory/Ostmann/Arithmetic/TopPrimePairSupport.lean @@ -0,0 +1,60 @@ +import OAI.NumberTheory.Ostmann.Construction.TopPrimeSupport +import OAI.NumberTheory.Ostmann.Construction.PrimeWordCoefficient + +namespace OAI + +/-! # Top collisions and external integers in the supported history pair -/ + +namespace Ostmann + +open scoped BigOperators ComplexConjugate Classical SchwartzMap + +theorem top_prime_coefficient_pair_bound + {A J : Type*} [Fintype A] [Nonempty A] [Fintype J] {m n : ℕ} + (prime : A → ℕ) (hpInj : Function.Injective prime) (hprime : ∀ a, (prime a).Prime) + (checks : J → TopPrimeCondition (Fin (m + 1))) + (C C' : WordPrimeDecoration (Fin (m + 1)) n) + (U U' D D' : WordRangeDecoration (ExpandedScheduledVariable (Fin (m + 1)) n) n) + (template template' : WordTransferTemplate (ExpandedScheduledVariable (Fin (m + 1)) n) n) + (t t' : FrequencyTree ℤ n) (ht : NonzeroInternalFrequencies n t) (ht' : NonzeroInternalFrequencies n t') + (p p' : WordFourierParameters n) + (μ : Fin (m + 1) → A → ℝ) (hμ : ∀ i a, 0 ≤ μ i a) (hmass : ∀ i, ∑ a, μ i a = 1) + (α V R : ℝ) (hα : 0 ≤ α) (hV : 0 < V) (hR : 3 ≤ R) + (hmax : ∀ i a, μ i a ≤ α) + (hlower : ∀ a, V ≤ Real.log (prime a : ℝ)) (hupper : ∀ a, (prime a : ℝ) ≤ R) + (hbound : ∀ j, (checks j).Bounded R) + (G : (Fin (m + 1) → ℕ) → ℂ) (hG : ∀ x, ‖G x‖ ≤ 1) + (δ : ℝ) (hδ : 0 ≤ δ) + (hcancel : ‖∑ x, (productPrior μ x : ℂ) * + (G (fun i => prime (x i)) * + (p.primeUnitRangedCoefficient C U D template t ht (fun i => prime (x i)) * + conj (p'.primeUnitRangedCoefficient C' U' D' template' t' ht' (fun i => prime (x i)))))‖ ≤ δ) : + ‖∑ x, (productPrior μ x : ℂ) * + (if ∀ j, (checks j).Holds (fun i => prime (x i)) then + G (fun i => prime (x i)) * + (p.primeUnitRangedCoefficient C U D template t ht (fun i => prime (x i)) * + conj (p'.primeUnitRangedCoefficient C' U' D' template' t' ht' (fun i => prime (x i)))) + else 0)‖ ≤ + δ + ((SchwartzMap.seminorm ℝ 0 0 p.profile) ^ (2 ^ n) * + (SchwartzMap.seminorm ℝ 0 0 p'.profile) ^ (2 ^ n)) * + (Fintype.card J : ℝ) * (α + Real.log R / V * α) := by + let B := (SchwartzMap.seminorm ℝ 0 0 p.profile) ^ (2 ^ n) * + (SchwartzMap.seminorm ℝ 0 0 p'.profile) ^ (2 ^ n) + have hp0 : 0 ≤ (SchwartzMap.seminorm ℝ 0 0 p.profile) ^ (2 ^ n) := + pow_nonneg ((norm_nonneg (p.profile 0)).trans (p.profile.norm_le_seminorm ℝ 0)) _ + have hp'0 : 0 ≤ (SchwartzMap.seminorm ℝ 0 0 p'.profile) ^ (2 ^ n) := + pow_nonneg ((norm_nonneg (p'.profile 0)).trans (p'.profile.norm_le_seminorm ℝ 0)) _ + apply top_prime_support_bound prime hpInj hprime checks μ hμ hmass α V R + hα hV hR hmax hlower hupper hbound _ B δ (mul_nonneg hp0 hp'0) hδ _ hcancel + intro x + rw [norm_mul, norm_mul, Complex.norm_conj] + have hprod := mul_le_mul + (p.primeUnitRangedCoefficient_norm C U D template t ht (fun i => prime (x i))) + (p'.primeUnitRangedCoefficient_norm C' U' D' template' t' ht' (fun i => prime (x i))) + (norm_nonneg _) hp0 + exact (mul_le_mul (hG _) hprod (mul_nonneg (norm_nonneg _) (norm_nonneg _)) + (by norm_num)).trans_eq (one_mul B) + +end Ostmann + +end OAI